Skip to content

Commit

Permalink
Merge pull request #75 from YAPP-Github/feature/sksowk156/PC-000
Browse files Browse the repository at this point in the history
[PC-000] preview 데이터 초기화, ui 갱신
  • Loading branch information
tgyuuAn authored Feb 16, 2025
2 parents 8461120 + c038729 commit 70d639d
Show file tree
Hide file tree
Showing 19 changed files with 127 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class MatchingRepositoryImpl @Inject constructor(
override suspend fun reportUser(userId: Int, reason: String): Result<Unit> =
matchingDataSource.reportUser(userId = userId, reason = reason)

override suspend fun refuseMatch(): Result<Unit> =
matchingDataSource.refuseMatch()

override suspend fun blockUser(userId: Int): Result<Unit> = matchingDataSource.blockUser(userId)

override suspend fun blockContacts(phoneNumbers: List<String>): Result<Unit> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class FakeMatchingDataSource : MatchingDataSource {
override suspend fun getOpponentProfileImage(): Result<GetOpponentProfileImageResponse> =
Result.success(opponentProfileImageData ?: GetOpponentProfileImageResponse(null))

override suspend fun refuseMatch(): Result<Unit> {
TODO("Not yet implemented")
}

override suspend fun reportUser(userId: Int, reason: String): Result<Unit> =
Result.success(Unit)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.puzzle.domain.model.profile.Contact
import com.puzzle.domain.model.profile.OpponentProfile

interface MatchingRepository {
suspend fun refuseMatch(): Result<Unit>
suspend fun reportUser(userId: Int, reason: String): Result<Unit>
suspend fun getOpponentContacts(): Result<List<Contact>>
suspend fun blockUser(userId: Int): Result<Unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class SpyMatchingRepository : MatchingRepository {
return Result.success(Unit)
}

override suspend fun refuseMatch(): Result<Unit> {
TODO("Not yet implemented")
}

override suspend fun reportUser(userId: Int, reason: String): Result<Unit> {
TODO("Not yet implemented")
}
Expand Down
3 changes: 3 additions & 0 deletions core/network/src/main/java/com/puzzle/network/api/PieceApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ interface PieceApi {
@PUT("/api/profiles/valuePicks")
suspend fun updateMyValuePicks(@Body updateMyValuePickRequests: UpdateMyValuePickRequests): Result<ApiResponse<GetMyValuePicksResponse>>

@PUT("/api/matches/refuse")
suspend fun refuseMatch(): Result<ApiResponse<Unit>>

@PUT("/api/profiles/basic")
suspend fun updateMyProfileBasic(@Body updateMyProfileBasicRequest: UpdateMyProfileBasicRequest): Result<ApiResponse<GetMyProfileBasicResponse>>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.puzzle.network.model.matching.GetOpponentValuePicksResponse
import com.puzzle.network.model.matching.GetOpponentValueTalksResponse

interface MatchingDataSource {
suspend fun refuseMatch(): Result<Unit>
suspend fun reportUser(userId: Int, reason: String): Result<Unit>
suspend fun blockUser(userId: Int): Result<Unit>
suspend fun blockContacts(phoneNumbers: List<String>): Result<Unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import javax.inject.Singleton
class MatchingDataSourceImpl @Inject constructor(
private val pieceApi: PieceApi
) : MatchingDataSource {
override suspend fun refuseMatch(): Result<Unit> =
pieceApi.refuseMatch().unwrapData()

override suspend fun reportUser(userId: Int, reason: String): Result<Unit> =
pieceApi.reportUser(ReportUserRequest(userId = userId, reason = reason)).unwrapData()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ internal fun MatchingDetailRoute(
)
)
},
onDeclineClick = { },
onAcceptClick = { },
onShowPicturesClick = { },
onDeclineClick = {
viewModel.onIntent(MatchingDetailIntent.OnDeclineClick)
},
onAcceptClick = {
viewModel.onIntent(MatchingDetailIntent.OnAcceptClick)
},
)
}

Expand All @@ -107,7 +110,6 @@ private fun MatchingDetailScreen(
onNextPageClick: () -> Unit,
onMoreClick: () -> Unit,
onDeclineClick: () -> Unit,
onShowPicturesClick: () -> Unit,
onAcceptClick: () -> Unit,
modifier: Modifier = Modifier,
) {
Expand All @@ -134,7 +136,10 @@ private fun MatchingDetailScreen(
leftButtonText = "뒤로",
rightButtonText = "매칭 수락하기",
onLeftButtonClick = { showDialog = false },
onRightButtonClick = {},
onRightButtonClick = {
showDialog = false
onAcceptClick()
},
)
},
onDismissRequest = { showDialog = false },
Expand All @@ -160,7 +165,10 @@ private fun MatchingDetailScreen(
leftButtonText = "뒤로",
rightButtonText = "매칭 거절하기",
onLeftButtonClick = { showDialog = false },
onRightButtonClick = {},
onRightButtonClick = {
showDialog = false
onDeclineClick()
},
)
},
onDismissRequest = { showDialog = false },
Expand Down Expand Up @@ -204,7 +212,10 @@ private fun MatchingDetailScreen(
MatchingDetailContent(
state = state,
onMoreClick = onMoreClick,
onDeclineClick = onDeclineClick,
onDeclineClick = {
dialogType = DialogType.DECLINE_MATCHING
showDialog = true
},
modifier = Modifier
.fillMaxSize()
.padding(top = topBarHeight, bottom = bottomBarHeight),
Expand Down Expand Up @@ -236,12 +247,10 @@ private fun MatchingDetailScreen(
onShowPicturesClick = {
dialogType = DialogType.PROFILE_IMAGE_DETAIL
showDialog = true
onShowPicturesClick()
},
onAcceptClick = {
dialogType = DialogType.ACCEPT_MATCHING
showDialog = true
onAcceptClick()
},
modifier = Modifier
.fillMaxWidth()
Expand Down Expand Up @@ -408,7 +417,6 @@ private fun MatchingDetailScreenPreview() {
{},
{},
{},
{},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,23 @@ class MatchingDetailViewModel @AssistedInject constructor(
MatchingDetailIntent.OnBlockClick -> onBlockClick()
MatchingDetailIntent.OnReportClick -> onReportClick()
MatchingDetailIntent.OnAcceptClick -> acceptMatching()
MatchingDetailIntent.OnDeclineClick -> declineMatching()
}
}

private fun declineMatching() = viewModelScope.launch {
matchingRepository.refuseMatch()
.onSuccess {
navigationHelper.navigate(
NavigationEvent.NavigateTo(
route = MatchingGraphDest.MatchingRoute,
popUpTo = true,
)
)
}
.onFailure { errorHelper.sendError(it) }
}

private fun setNextPage() {
setState {
copy(currentPage = MatchingDetailState.MatchingDetailPage.getNextPage(currentPage))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ sealed class MatchingDetailIntent {
data object OnReportClick : MatchingDetailIntent()
data object OnBlockClick : MatchingDetailIntent()
data object OnAcceptClick : MatchingDetailIntent()
data object OnDeclineClick : MatchingDetailIntent()
data class OnMoreClick(val content: @Composable () -> Unit) : MatchingDetailIntent()
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,8 @@ internal fun MatchingRoute(
MatchingScreen(
state = state,
onButtonClick = { viewModel.onIntent(MatchingIntent.OnButtonClick) },
onMatchingDetailClick = {
viewModel.onIntent(
MatchingIntent.Navigate(
NavigationEvent.NavigateTo(MatchingGraphDest.MatchingDetailRoute)
)
)
},
onMatchingDetailClick = { viewModel.onIntent(MatchingIntent.OnMatchingDetailClick) },
onCheckMyProfileClick = {},
onEditProfileClick = {
viewModel.onIntent(MatchingIntent.OnEditProfileClick)
}
Expand All @@ -65,30 +60,31 @@ internal fun MatchingScreen(
state: MatchingState,
onButtonClick: () -> Unit,
onMatchingDetailClick: () -> Unit,
onCheckMyProfileClick: () -> Unit,
onEditProfileClick: () -> Unit,
) {
when (state.userRole) {
UserRole.PENDING -> MatchingPendingScreen(
isNotificationEnabled = state.isNotificationEnabled,
isImageRejected = state.isImageRejected,
isDescriptionRejected = state.isDescriptionRejected,
onCheckMyProfileClick = {},
onCheckMyProfileClick = onCheckMyProfileClick,
onEditProfileClick = onEditProfileClick,
)

UserRole.USER -> {
if (state.matchInfo == null) {
MatchingWaitingScreen(
isNotificationEnabled = state.isNotificationEnabled,
onCheckMyProfileClick = {},
onCheckMyProfileClick = onCheckMyProfileClick,
remainTime = state.formattedRemainWaitingTime,
)
} else {
when (state.matchInfo.matchStatus) {
MatchStatus.UNKNOWN -> MatchingLoadingScreen(isNotificationEnabled = state.isNotificationEnabled)
MatchStatus.BLOCKED -> MatchingWaitingScreen(
isNotificationEnabled = state.isNotificationEnabled,
onCheckMyProfileClick = {},
onCheckMyProfileClick = onCheckMyProfileClick,
remainTime = state.formattedRemainWaitingTime
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,16 @@ class MatchingViewModel @AssistedInject constructor(
private fun processIntent(intent: MatchingIntent) {
when (intent) {
MatchingIntent.OnButtonClick -> processOnButtonClick()
is MatchingIntent.Navigate -> navigationHelper.navigate(intent.navigationEvent)
is MatchingIntent.OnMatchingDetailClick -> navigationHelper.navigate(
NavigationEvent.NavigateTo(
MatchingGraphDest.MatchingDetailRoute
)
)

MatchingIntent.OnEditProfileClick -> moveToProfileRegisterScreen()
MatchingIntent.OnCheckMyProfileClick -> navigationHelper.navigate(
NavigationEvent.NavigateTo(MatchingGraphDest.ProfilePreviewRoute)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.puzzle.matching.graph.main.contract

import com.puzzle.navigation.NavigationEvent

sealed class MatchingIntent {
data object OnButtonClick : MatchingIntent()
data class Navigate(val navigationEvent: NavigationEvent) : MatchingIntent()
data object OnCheckMyProfileClick : MatchingIntent()
data object OnMatchingDetailClick : MatchingIntent()
data object OnEditProfileClick : MatchingIntent()
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import com.puzzle.designsystem.component.PieceLoading
import com.puzzle.designsystem.component.PieceRoundingOutlinedButton
import com.puzzle.designsystem.component.PieceSubCloseTopBar
import com.puzzle.designsystem.foundation.PieceTheme
import com.puzzle.domain.model.profile.OpponentProfile
import com.puzzle.domain.model.profile.MyProfileBasic
import com.puzzle.matching.graph.preview.contract.ProfilePreviewIntent
import com.puzzle.matching.graph.preview.contract.ProfilePreviewSideEffect
import com.puzzle.matching.graph.preview.contract.ProfilePreviewState
Expand Down Expand Up @@ -84,7 +84,7 @@ private fun ProfilePreviewScreen(

if (showDialog) {
PieceImageDialog(
imageUri = state.profile?.imageUrl,
imageUri = state.myProfileBasic?.imageUrl,
buttonLabel = "매칭 수락하기",
onDismissRequest = { showDialog = false },
isApproveButtonShow = false,
Expand Down Expand Up @@ -166,7 +166,7 @@ private fun ProfilePreviewContent(
modifier: Modifier = Modifier,
) {
Box(modifier = modifier.fillMaxSize()) {
state.profile?.let { profile ->
if (state.myProfileBasic != null && state.myValuePicks.isNotEmpty() && state.myValueTalks.isNotEmpty()) {
AnimatedContent(
targetState = currentPage,
transitionSpec = {
Expand All @@ -177,33 +177,35 @@ private fun ProfilePreviewContent(
when (it) {
ProfilePreviewState.Page.BasicInfoPage ->
BasicInfoPage(
nickName = profile.nickname,
selfDescription = profile.description,
birthYear = profile.birthYear,
age = profile.age,
height = profile.height,
weight = profile.weight,
location = profile.location,
job = profile.job,
smokingStatus = profile.smokingStatus,
nickName = state.myProfileBasic.nickname,
selfDescription = state.myProfileBasic.description,
birthYear = state.myProfileBasic.birthdate,
age = state.myProfileBasic.age,
height = state.myProfileBasic.height,
weight = state.myProfileBasic.weight,
location = state.myProfileBasic.location,
job = state.myProfileBasic.job,
smokingStatus = state.myProfileBasic.smokingStatus,
)

ProfilePreviewState.Page.ValueTalkPage ->
ValueTalkPage(
nickName = profile.nickname,
selfDescription = profile.description,
talkCards = profile.valueTalks,
nickName = state.myProfileBasic.nickname,
selfDescription = state.myProfileBasic.description,
talkCards = state.myValueTalks,
)

ProfilePreviewState.Page.ValuePickPage ->
ValuePickPage(
nickName = profile.nickname,
selfDescription = profile.description,
pickCards = profile.valuePicks,
nickName = state.myProfileBasic.nickname,
selfDescription = state.myProfileBasic.description,
pickCards = state.myValuePicks,
)
}
}
} ?: PieceLoading()
} else {
PieceLoading()
}
}
}

Expand Down Expand Up @@ -295,20 +297,22 @@ private fun ProfilePreviewScreenPreview() {
PieceTheme {
ProfilePreviewScreen(
state = ProfilePreviewState(
profile = OpponentProfile(
myProfileBasic = MyProfileBasic(
description = "음악과 요리를 좋아하는",
nickname = "수줍은 수달",
birthYear = "00",
age = 25,
height = 254,
weight = 72,
job = "개발자",
location = "서울특별시",
smokingStatus = "비흡연",
valueTalks = emptyList(),
valuePicks = emptyList(),
imageUrl = "",
)
birthdate = "20000101",
snsActivityLevel = "TODO()",
contacts = emptyList(),
),
myValuePicks = emptyList(),
myValueTalks = emptyList(),
),
onCloseClick = {},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,23 @@ class ProfilePreviewViewModel @AssistedInject constructor(
private fun initProfilePreview() = viewModelScope.launch {
val profileBasicJob = launch {
profileRepository.retrieveMyProfileBasic()
.onSuccess { }
.onSuccess {
setState { copy(myProfileBasic = it) }
}
.onFailure { errorHelper.sendError(it) }
}
val valueTalksJob = launch {
profileRepository.retrieveMyValuePicks()
.onSuccess { }
profileRepository.retrieveMyValueTalks()
.onSuccess {
setState { copy(myValueTalks = it) }
}
.onFailure { errorHelper.sendError(it) }
}
val valuePicksJob = launch {
profileRepository.retrieveMyValueTalks()
.onSuccess { }
profileRepository.retrieveMyValuePicks()
.onSuccess {
setState { copy(myValuePicks = it) }
}
.onFailure { errorHelper.sendError(it) }
}

Expand Down
Loading

0 comments on commit 70d639d

Please sign in to comment.