Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/src/main/java/com/apptive/japkor/data/api/MatchingService.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.apptive.japkor.data.api

import com.apptive.japkor.data.model.AiSummaryResponse
import com.apptive.japkor.data.model.MalePendingMatchingResponse
import com.apptive.japkor.data.model.MatchingResponse
import retrofit2.Call
import retrofit2.http.GET
Expand All @@ -14,6 +15,15 @@ interface MatchingService {
@GET("members/matchings/female")
fun getFemaleMatchings(): Call<List<MatchingResponse>>

@GET("members/matchings/male/pendingMatching")
fun getMalePendingMatchings(): Call<List<MalePendingMatchingResponse>>

@POST("members/matchings/{matchingId}/select")
fun femaleSelectMatching(@Path("matchingId") matchingId: Long): Call<Void>

@POST("members/matchings/{matchingId}/accept")
fun maleAcceptMatching(@Path("matchingId") matchingId: Long): Call<Void>

@POST("members/matchings/{matchingId}/reject")
fun maleRejectMatching(@Path("matchingId") matchingId: Long): Call<Void>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.apptive.japkor.data.model

import com.google.gson.annotations.SerializedName

data class MalePendingMatchingResponse(
val matchingId: Long,
val femaleMemberId: Long,
val femaleName: String,
val femaleEmail: String,
val height: Int?,
val weight: Int?,
val residenceArea: String?,
val aiSummary: String?,
val status: String,
val createdAt: String,
val thumbnailImageUrl: String?,
@SerializedName(value = "profileImageUrls", alternate = ["profileImageUrl"])
val profileImageUrls: List<String>?
)
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ fun MainRouteScreen(
}
}

LaunchedEffect(gender) {
viewModel.fetchMatchingsForGender(gender)
}

LaunchedEffect(matchings.size) {
if (matchings.isNotEmpty() && pagerState.currentPage >= matchings.size) {
pagerState.scrollToPage(0)
Expand Down Expand Up @@ -239,6 +243,8 @@ fun MainRouteScreen(
onShowDetails = { viewModel.showDetails(it) },
onNoMatch = { viewModel.noMatchSelected() },
onConfirm = { viewModel.selectMatching(it) },
onAccept = { viewModel.acceptMatching(it) },
onReject = { viewModel.rejectMatching(it) },
modifier = Modifier.fillMaxSize()
)
}
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/com/apptive/japkor/ui/main/home/HomeMatching.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.apptive.japkor.ui.main.home

data class HomeMatching(
val matchingId: Long,
val memberId: Long,
val name: String,
val email: String,
val height: Int?,
val weight: Int?,
val residenceArea: String?,
val matchingOrder: Int?,
val status: String
)
171 changes: 118 additions & 53 deletions app/src/main/java/com/apptive/japkor/ui/main/home/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.lerp
import com.apptive.japkor.R
import com.apptive.japkor.data.model.MatchingResponse
import com.apptive.japkor.ui.components.CustomText
import com.apptive.japkor.ui.components.CustomTextType
import com.apptive.japkor.ui.theme.CustomColor
Expand All @@ -45,13 +44,17 @@ fun HomeScreen(
uiState: HomeUiState,
pagerState: PagerState,
canSelectMatching: Boolean,
onShowDetails: (MatchingResponse) -> Unit,
onShowDetails: (HomeMatching) -> Unit,
onNoMatch: () -> Unit,
onConfirm: (Long) -> Unit,
onAccept: (Long) -> Unit,
onReject: (Long) -> Unit,
modifier: Modifier = Modifier
) {
val matchings = uiState.matchings
val selectedMatching = uiState.selectedMatching
val counterpartLabel = if (canSelectMatching) "남성" else "여성"
val matchingTitle = "매칭된 $counterpartLabel"

Box(
modifier = modifier
Expand All @@ -65,6 +68,16 @@ fun HomeScreen(
if (canSelectMatching) {
onConfirm(selectedMatching.matchingId)
}
},
onAccept = {
if (!canSelectMatching) {
onAccept(selectedMatching.matchingId)
}
},
onReject = {
if (!canSelectMatching) {
onReject(selectedMatching.matchingId)
}
}
)
}
Expand All @@ -82,7 +95,9 @@ fun HomeScreen(
matchings = matchings,
pagerState = pagerState,
onShowDetails = onShowDetails,
onNoMatch = onNoMatch
onNoMatch = onNoMatch,
title = matchingTitle,
showNoMatchButton = canSelectMatching
)
}
}
Expand Down Expand Up @@ -184,10 +199,12 @@ private fun WaitingContent(
@Composable
@OptIn(ExperimentalFoundationApi::class)
private fun MatchingCarouselContent(
matchings: List<MatchingResponse>,
matchings: List<HomeMatching>,
pagerState: PagerState,
onShowDetails: (MatchingResponse) -> Unit,
onNoMatch: () -> Unit
onShowDetails: (HomeMatching) -> Unit,
onNoMatch: () -> Unit,
title: String,
showNoMatchButton: Boolean
) {
val currentMatching = matchings.getOrNull(pagerState.currentPage)

Expand All @@ -198,7 +215,7 @@ private fun MatchingCarouselContent(
horizontalAlignment = Alignment.CenterHorizontally
) {
CustomText(
text = "매칭된 남성",
text = title,
type = CustomTextType.title,
color = CustomColor.black
)
Expand Down Expand Up @@ -254,29 +271,31 @@ private fun MatchingCarouselContent(
color = Color.White
)
}
Spacer(modifier = Modifier.height(12.dp))
Button(
onClick = onNoMatch,
modifier = Modifier
.fillMaxWidth()
.height(50.dp),
colors = ButtonDefaults.buttonColors(
containerColor = CustomColor.gray100
),
shape = RoundedCornerShape(16.dp)
) {
CustomText(
text = "마음에 드는 상대가 없어요",
type = CustomTextType.body,
color = CustomColor.black
)
if (showNoMatchButton) {
Spacer(modifier = Modifier.height(12.dp))
Button(
onClick = onNoMatch,
modifier = Modifier
.fillMaxWidth()
.height(50.dp),
colors = ButtonDefaults.buttonColors(
containerColor = CustomColor.gray100
),
shape = RoundedCornerShape(16.dp)
) {
CustomText(
text = "마음에 드는 상대가 없어요",
type = CustomTextType.body,
color = CustomColor.black
)
}
}
}
}

@Composable
private fun MatchingCard(
matching: MatchingResponse,
matching: HomeMatching,
modifier: Modifier = Modifier
) {
Card(
Expand Down Expand Up @@ -306,7 +325,7 @@ private fun MatchingCard(
}
Spacer(modifier = Modifier.height(24.dp))
CustomText(
text = matching.maleName,
text = matching.name,
type = CustomTextType.headline,
color = CustomColor.black,
textAlign = TextAlign.Center
Expand Down Expand Up @@ -343,9 +362,11 @@ private fun PagerIndicator(total: Int, current: Int) {

@Composable
private fun MatchingDetailContent(
matching: MatchingResponse,
matching: HomeMatching,
canSelectMatching: Boolean,
onConfirm: () -> Unit
onConfirm: () -> Unit,
onAccept: () -> Unit,
onReject: () -> Unit
) {
Column(
modifier = Modifier
Expand All @@ -361,32 +382,71 @@ private fun MatchingDetailContent(
ProfileHeader(matching = matching)
}
item {
DetailCard(matching = matching)
DetailCard(
matching = matching,
counterpartLabel = if (canSelectMatching) "남성" else "여성"
)
}
}
Button(
onClick = onConfirm,
enabled = canSelectMatching,
modifier = Modifier
.fillMaxWidth()
.height(50.dp),
colors = ButtonDefaults.buttonColors(
containerColor = CustomColor.primary600,
disabledContainerColor = CustomColor.primary300
),
shape = RoundedCornerShape(16.dp)
) {
CustomText(
text = "마음에 들어요 매칭해주세요",
type = CustomTextType.body,
color = Color.White
)
if (canSelectMatching) {
Button(
onClick = onConfirm,
modifier = Modifier
.fillMaxWidth()
.height(50.dp),
colors = ButtonDefaults.buttonColors(
containerColor = CustomColor.primary600,
disabledContainerColor = CustomColor.primary300
),
shape = RoundedCornerShape(16.dp)
) {
CustomText(
text = "마음에 들어요 매칭해주세요",
type = CustomTextType.body,
color = Color.White
)
}
} else {
Button(
onClick = onAccept,
modifier = Modifier
.fillMaxWidth()
.height(50.dp),
colors = ButtonDefaults.buttonColors(
containerColor = CustomColor.primary600,
disabledContainerColor = CustomColor.primary300
),
shape = RoundedCornerShape(16.dp)
) {
CustomText(
text = "수락할래요",
type = CustomTextType.body,
color = Color.White
)
}
Spacer(modifier = Modifier.height(12.dp))
Button(
onClick = onReject,
modifier = Modifier
.fillMaxWidth()
.height(50.dp),
colors = ButtonDefaults.buttonColors(
containerColor = CustomColor.gray100
),
shape = RoundedCornerShape(16.dp)
) {
CustomText(
text = "거절할래요",
type = CustomTextType.body,
color = CustomColor.black
)
}
}
}
}

@Composable
private fun ProfileHeader(matching: MatchingResponse) {
private fun ProfileHeader(matching: HomeMatching) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
Expand All @@ -407,12 +467,12 @@ private fun ProfileHeader(matching: MatchingResponse) {
Spacer(modifier = Modifier.width(16.dp))
Column {
CustomText(
text = matching.maleName,
text = matching.name,
type = CustomTextType.headline,
color = CustomColor.black
)
CustomText(
text = matching.maleEmail,
text = matching.email,
type = CustomTextType.body,
color = CustomColor.gray400
)
Expand All @@ -421,7 +481,10 @@ private fun ProfileHeader(matching: MatchingResponse) {
}

@Composable
private fun DetailCard(matching: MatchingResponse) {
private fun DetailCard(
matching: HomeMatching,
counterpartLabel: String
) {
Card(
modifier = Modifier.fillMaxWidth(),
shape = RoundedCornerShape(20.dp),
Expand All @@ -439,13 +502,15 @@ private fun DetailCard(matching: MatchingResponse) {
color = CustomColor.black
)
DetailItem(label = "매칭 ID", value = matching.matchingId.toString())
DetailItem(label = "남성 회원 ID", value = matching.maleMemberId.toString())
DetailItem(label = "이름", value = matching.maleName)
DetailItem(label = "이메일", value = matching.maleEmail)
DetailItem(label = "${counterpartLabel} 회원 ID", value = matching.memberId.toString())
DetailItem(label = "이름", value = matching.name)
DetailItem(label = "이메일", value = matching.email)
DetailItem(label = "키", value = formatHeight(matching.height))
DetailItem(label = "몸무게", value = formatWeight(matching.weight))
DetailItem(label = "거주지역", value = formatText(matching.residenceArea))
DetailItem(label = "매칭 순서", value = matching.matchingOrder.toString())
matching.matchingOrder?.let {
DetailItem(label = "매칭 순서", value = it.toString())
}
DetailItem(label = "상태", value = matching.status)
}
}
Expand Down
Loading
Loading