From 741a5ae16f3c9d4e8045042aefb385076cf077a1 Mon Sep 17 00:00:00 2001 From: soopeach Date: Sun, 12 Jan 2025 16:09:42 +0900 Subject: [PATCH 1/2] =?UTF-8?q?:lipstick:=20=EC=9B=8C=ED=82=A4=20=EB=84=A4?= =?UTF-8?q?=EA=B1=B0=ED=8B=B0=EB=B8=8C=20=EB=B2=84=ED=8A=BC=20=EB=94=94?= =?UTF-8?q?=EC=9E=90=EC=9D=B8=20=EC=9D=BC=EB=B6=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/button/WalkieNegativeButton.kt | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/presentation/src/main/java/com/whyranoid/presentation/component/button/WalkieNegativeButton.kt b/presentation/src/main/java/com/whyranoid/presentation/component/button/WalkieNegativeButton.kt index 943d97ff..69fe46d8 100644 --- a/presentation/src/main/java/com/whyranoid/presentation/component/button/WalkieNegativeButton.kt +++ b/presentation/src/main/java/com/whyranoid/presentation/component/button/WalkieNegativeButton.kt @@ -1,11 +1,10 @@ package com.whyranoid.presentation.component.button -import androidx.compose.foundation.border import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults -import androidx.compose.material.OutlinedButton import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @@ -17,22 +16,20 @@ import androidx.compose.ui.unit.sp @Composable fun WalkieNegativeButton( + modifier: Modifier = Modifier, text: String, + isEnabled: Boolean = true, onClicked: () -> Unit = {} ) { - OutlinedButton( - modifier = Modifier + Button( + modifier = modifier .fillMaxWidth() .height(50.dp) - .clip(shape = RoundedCornerShape(15.dp)) - .border( - width = 1.dp, - color = Color(0xFFFB8947), - shape = RoundedCornerShape(15.dp) - ), - colors = ButtonDefaults.outlinedButtonColors( - backgroundColor = Color.White, - contentColor = Color(0xFFFB8947) + .clip(shape = RoundedCornerShape(15.dp)), + enabled = isEnabled, + colors = ButtonDefaults.buttonColors( + backgroundColor = if (isEnabled) Color(0xFFBDBDBD) else Color(0xFFBDBDBD), + contentColor = Color.White ), onClick = { onClicked() }) { Text( From 43a0b26e391c2cb1d8dfd1fd4dc144adb989d2d0 Mon Sep 17 00:00:00 2001 From: soopeach Date: Sun, 12 Jan 2025 16:21:02 +0900 Subject: [PATCH 2/2] =?UTF-8?q?:sparkles:=20=EB=8B=AC=EB=A6=AC=EA=B8=B0=20?= =?UTF-8?q?=EC=A2=85=EB=A3=8C=20=ED=9B=84=20=EC=99=84=EB=A3=8C=EA=B0=80=20?= =?UTF-8?q?=EB=90=9C=20=EC=B1=8C=EB=A6=B0=EC=A7=80=EB=A1=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/whyranoid/walkie/KoinModules.kt | 2 + .../challenge/ChallengeCompleteScreen.kt | 86 ++++++++++--------- .../screens/running/RunningScreen.kt | 27 ++++-- .../challenge/ChallengeCompleteViewModel.kt | 36 +++++++- 4 files changed, 101 insertions(+), 50 deletions(-) diff --git a/app/src/main/java/com/whyranoid/walkie/KoinModules.kt b/app/src/main/java/com/whyranoid/walkie/KoinModules.kt index 7ac00cb7..e0e2e766 100644 --- a/app/src/main/java/com/whyranoid/walkie/KoinModules.kt +++ b/app/src/main/java/com/whyranoid/walkie/KoinModules.kt @@ -102,6 +102,7 @@ import com.whyranoid.presentation.viewmodel.SplashViewModel import com.whyranoid.presentation.viewmodel.TotalBadgeViewModel import com.whyranoid.presentation.viewmodel.UserPageViewModel import com.whyranoid.presentation.viewmodel.UserPostsViewModel +import com.whyranoid.presentation.viewmodel.challenge.ChallengeCompleteViewModel import com.whyranoid.presentation.viewmodel.challenge.ChallengeDetailViewModel import com.whyranoid.presentation.viewmodel.challenge.ChallengeExitViewModel import com.whyranoid.presentation.viewmodel.challenge.ChallengeMainViewModel @@ -123,6 +124,7 @@ val viewModelModule = viewModel { ChallengeMainViewModel(get(), get(), get(), get(), get()) } viewModel { ChallengeDetailViewModel(get(), get(), get()) } viewModel { ChallengeExitViewModel(get(), get()) } + viewModel { ChallengeCompleteViewModel(get()) } viewModel { UserPageViewModel( get(), diff --git a/presentation/src/main/java/com/whyranoid/presentation/screens/challenge/ChallengeCompleteScreen.kt b/presentation/src/main/java/com/whyranoid/presentation/screens/challenge/ChallengeCompleteScreen.kt index 1c45c539..69abe1d3 100644 --- a/presentation/src/main/java/com/whyranoid/presentation/screens/challenge/ChallengeCompleteScreen.kt +++ b/presentation/src/main/java/com/whyranoid/presentation/screens/challenge/ChallengeCompleteScreen.kt @@ -7,25 +7,27 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.text.SpanStyle -import androidx.compose.ui.text.buildAnnotatedString -import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp import androidx.navigation.NavController import coil.compose.AsyncImage -import com.whyranoid.domain.util.BLANK +import com.whyranoid.domain.util.EMPTY import com.whyranoid.presentation.component.button.WalkieNegativeButton import com.whyranoid.presentation.component.button.WalkiePositiveButton -import com.whyranoid.presentation.theme.WalkieColor import com.whyranoid.presentation.theme.WalkieTypography +import com.whyranoid.presentation.viewmodel.challenge.ChallengeCompleteViewModel +import org.koin.androidx.compose.koinViewModel +import org.orbitmvi.orbit.compose.collectAsState @Composable fun ChallengeCompleteScreen( @@ -33,6 +35,13 @@ fun ChallengeCompleteScreen( challengeId: Long, ) { + val viewModel = koinViewModel() + val state by viewModel.collectAsState() + + LaunchedEffect(challengeId) { + viewModel.getChallengeDetail(challengeId) + } + Column( modifier = Modifier .fillMaxWidth() @@ -48,55 +57,49 @@ fun ChallengeCompleteScreen( horizontalAlignment = Alignment.CenterHorizontally, ) { Text( - modifier = Modifier.padding(top = 20.dp), + modifier = Modifier.padding(top = 126.dp), text = "챌린지 성공!", style = WalkieTypography.Title ) - Text( - modifier = Modifier.padding(top = 24.dp), - text = "햄버거 세트 불태우기", - style = WalkieTypography.SubTitle - ) + Spacer(modifier = Modifier.height(56.dp)) AsyncImage( - model = "https://picsum.photos/250/250 ", contentDescription = "", + model = state.challenge.getDataOrNull()?.badge?.imageUrl + ?: "https://picsum.photos/250/250 ", contentDescription = "", modifier = Modifier - .padding(top = 35.dp) - .size(180.dp), + // .size(180.dp) + , contentScale = ContentScale.Crop ) + Spacer(modifier = Modifier.height(20.dp)) + Text( - buildAnnotatedString { - withStyle( - style = SpanStyle( - fontSize = WalkieTypography.Title.fontSize, - fontWeight = WalkieTypography.Title.fontWeight, - fontFamily = WalkieTypography.Title.fontFamily, - color = WalkieColor.Primary - ) - ) { - append("햄버거 세트 뱃지") - } - append(String.BLANK) - withStyle( - style = SpanStyle( - fontSize = WalkieTypography.Title.fontSize, - fontWeight = WalkieTypography.Title.fontWeight, - fontFamily = WalkieTypography.Title.fontFamily, - ) - ) { - append("획득") - } - }, - modifier = Modifier.padding(top = 24.dp), + modifier = Modifier.fillMaxWidth(), + text = state.challenge.getDataOrNull()?.name ?: String.EMPTY, + style = WalkieTypography.Title, + textAlign = androidx.compose.ui.text.style.TextAlign.Center ) + Spacer(modifier = Modifier.height(8.dp)) + Text( - modifier = Modifier.padding(top = 11.dp), + modifier = Modifier.fillMaxWidth(), + text = "뱃지 획득!", + style = WalkieTypography.Title, + textAlign = androidx.compose.ui.text.style.TextAlign.Center + ) + + Spacer(modifier = Modifier.height(10.dp)) + + Text( + modifier = Modifier.fillMaxWidth(), text = "마이페이지에서 확인해보세요", - style = WalkieTypography.Caption.copy(color = Color(0xFF989898)) + style = WalkieTypography.Body1.copy( + color = Color(0xFF989898), + textAlign = androidx.compose.ui.text.style.TextAlign.Center + ) ) } @@ -111,17 +114,18 @@ fun ChallengeCompleteScreen( Row( modifier = Modifier .padding(top = 20.dp) + .padding(horizontal = 20.dp) ) { Box(modifier = Modifier.weight(.5f)) { WalkieNegativeButton(text = "아니오") { - + navController.popBackStack() } } Spacer(modifier = Modifier.size(10.dp)) Box(modifier = Modifier.weight(.5f)) { - WalkiePositiveButton(text = "예") { + WalkiePositiveButton(text = "네 좋아요") { } } diff --git a/presentation/src/main/java/com/whyranoid/presentation/screens/running/RunningScreen.kt b/presentation/src/main/java/com/whyranoid/presentation/screens/running/RunningScreen.kt index 83bbad0c..59fd458a 100644 --- a/presentation/src/main/java/com/whyranoid/presentation/screens/running/RunningScreen.kt +++ b/presentation/src/main/java/com/whyranoid/presentation/screens/running/RunningScreen.kt @@ -81,6 +81,7 @@ import com.whyranoid.presentation.model.running.SavingState import com.whyranoid.presentation.model.running.TrackingMode import com.whyranoid.presentation.reusable.CircleProgressWithText import com.whyranoid.presentation.reusable.GalleryGrid +import com.whyranoid.presentation.screens.Screen import com.whyranoid.presentation.theme.WalkieColor import com.whyranoid.presentation.theme.WalkieTypography import com.whyranoid.presentation.util.dpToPx @@ -105,11 +106,18 @@ fun RunningScreen( val viewModel = koinViewModel() val state by viewModel.collectAsState() - viewModel.collectSideEffect { - when (it) { - is RunningScreenSideEffect.CompleteChallenge -> { it - // todo: navigation elements - println("완료한 것 "+ it) + viewModel.collectSideEffect { event -> + when (event) { + is RunningScreenSideEffect.CompleteChallenge -> { + event.completedChallenges.forEach { completedChallenge -> + navController.navigate( + Screen.ChallengeCompleteScreen.route + .replace( + "{challengeId}", + completedChallenge.challengeId.toString() + ) + ) + } } } } @@ -388,9 +396,12 @@ fun RunningMapScreen( ) Text("이미지", style = WalkieTypography.SubTitle) - Text("초기화", style = WalkieTypography.Body1_Normal, modifier = Modifier.clickable { - onRemoveImage() - }) + Text( + "초기화", + style = WalkieTypography.Body1_Normal, + modifier = Modifier.clickable { + onRemoveImage() + }) // Icon( diff --git a/presentation/src/main/java/com/whyranoid/presentation/viewmodel/challenge/ChallengeCompleteViewModel.kt b/presentation/src/main/java/com/whyranoid/presentation/viewmodel/challenge/ChallengeCompleteViewModel.kt index 7aa7f2b8..715d2eec 100644 --- a/presentation/src/main/java/com/whyranoid/presentation/viewmodel/challenge/ChallengeCompleteViewModel.kt +++ b/presentation/src/main/java/com/whyranoid/presentation/viewmodel/challenge/ChallengeCompleteViewModel.kt @@ -1,4 +1,38 @@ package com.whyranoid.presentation.viewmodel.challenge -class ChallengeCompleteViewModel { +import androidx.lifecycle.ViewModel +import com.whyranoid.domain.model.challenge.Challenge +import com.whyranoid.domain.usecase.GetChallengeDetailUseCase +import com.whyranoid.presentation.model.UiState +import org.orbitmvi.orbit.ContainerHost +import org.orbitmvi.orbit.syntax.simple.intent +import org.orbitmvi.orbit.syntax.simple.reduce +import org.orbitmvi.orbit.viewmodel.container + +sealed class ChallengeCompleteSideEffect { + +} + +data class ChallengeCompleteState( + val challenge: UiState = UiState.Idle, +) + +class ChallengeCompleteViewModel( + private val getChallengeDetailUseCase: GetChallengeDetailUseCase +) : ViewModel(), ContainerHost { + + override val container = + container(ChallengeCompleteState()) + + fun getChallengeDetail(challengeId: Long) = intent { + reduce { + state.copy(challenge = UiState.Loading) + } + + val challenge = getChallengeDetailUseCase(challengeId) + + reduce { + state.copy(challenge = UiState.Success(challenge)) + } + } } \ No newline at end of file