11package com.threegap.bitnagil.presentation.emotion
22
3+ import androidx.activity.compose.BackHandler
34import androidx.compose.foundation.Image
45import androidx.compose.foundation.background
56import androidx.compose.foundation.layout.Arrangement
@@ -11,22 +12,32 @@ import androidx.compose.foundation.layout.padding
1112import androidx.compose.foundation.lazy.grid.GridCells
1213import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
1314import androidx.compose.foundation.lazy.grid.items
15+ import androidx.compose.foundation.rememberScrollState
16+ import androidx.compose.foundation.verticalScroll
1417import androidx.compose.material3.Text
1518import androidx.compose.runtime.Composable
1619import androidx.compose.runtime.collectAsState
1720import androidx.compose.runtime.getValue
1821import androidx.compose.ui.Alignment
1922import androidx.compose.ui.Modifier
23+ import androidx.compose.ui.graphics.Color
2024import androidx.compose.ui.res.painterResource
2125import androidx.compose.ui.text.style.TextAlign
26+ import androidx.compose.ui.text.style.TextDecoration
2227import androidx.compose.ui.tooling.preview.Preview
2328import androidx.compose.ui.unit.dp
2429import androidx.hilt.navigation.compose.hiltViewModel
2530import com.threegap.bitnagil.designsystem.BitnagilTheme
31+ import com.threegap.bitnagil.designsystem.component.atom.BitnagilSelectButton
32+ import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButton
33+ import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButtonColor
34+ import com.threegap.bitnagil.designsystem.component.block.BitnagilProgressTopBar
2635import com.threegap.bitnagil.designsystem.component.block.BitnagilTopBar
2736import com.threegap.bitnagil.designsystem.modifier.clickableWithoutRipple
2837import com.threegap.bitnagil.presentation.common.flow.collectAsEffect
2938import com.threegap.bitnagil.presentation.emotion.model.Emotion
39+ import com.threegap.bitnagil.presentation.emotion.model.EmotionRecommendRoutineUiModel
40+ import com.threegap.bitnagil.presentation.emotion.model.EmotionScreenStep
3041import com.threegap.bitnagil.presentation.emotion.model.mvi.EmotionSideEffect
3142import com.threegap.bitnagil.presentation.emotion.model.mvi.EmotionState
3243
@@ -37,17 +48,30 @@ fun EmotionScreenContainer(
3748) {
3849 val state by viewModel.stateFlow.collectAsState()
3950
51+ BackHandler {
52+ viewModel.moveToPrev()
53+ }
54+
4055 viewModel.sideEffectFlow.collectAsEffect { sideEffect ->
4156 when (sideEffect) {
4257 EmotionSideEffect .NavigateToBack -> navigateToBack()
4358 }
4459 }
4560
46- EmotionScreen (
47- state = state,
48- onClickPreviousButton = navigateToBack,
49- onClickEmotion = viewModel::selectEmotion,
50- )
61+ when (state.step) {
62+ EmotionScreenStep .Emotion -> EmotionScreen (
63+ state = state,
64+ onClickPreviousButton = navigateToBack,
65+ onClickEmotion = viewModel::selectEmotion,
66+ )
67+ EmotionScreenStep .RecommendRoutines -> EmotionRecommendRoutineScreen (
68+ state = state,
69+ onClickPreviousButton = viewModel::moveToPrev,
70+ onClickRoutine = viewModel::selectRecommendRoutine,
71+ onClickRegisterRecommendRoutines = viewModel::registerRecommendRoutines,
72+ onClickSkip = navigateToBack
73+ )
74+ }
5175}
5276
5377@Composable
@@ -111,17 +135,127 @@ private fun EmotionScreen(
111135 }
112136}
113137
138+ @Composable
139+ private fun EmotionRecommendRoutineScreen (
140+ state : EmotionState ,
141+ onClickPreviousButton : () -> Unit ,
142+ onClickRoutine : (String ) -> Unit ,
143+ onClickRegisterRecommendRoutines : () -> Unit ,
144+ onClickSkip : () -> Unit ,
145+ ) {
146+ Column (
147+ modifier = Modifier
148+ .fillMaxSize()
149+ .background(color = BitnagilTheme .colors.coolGray99),
150+ ) {
151+ BitnagilProgressTopBar (
152+ onBackClick = onClickPreviousButton,
153+ progress = 1f ,
154+ )
155+
156+ Column (
157+ modifier = Modifier
158+ .weight(1f )
159+ .padding(start = 16 .dp, end = 16 .dp, bottom = 20 .dp, top = 32 .dp),
160+ ) {
161+ Text (
162+ text = " 오늘 감정에 따른\n 루틴을 추천드릴께요!" ,
163+ color = BitnagilTheme .colors.navy500,
164+ style = BitnagilTheme .typography.title2Bold,
165+ )
166+
167+
168+ Spacer (modifier = Modifier .height(10 .dp))
169+
170+ Text (
171+ text = " 오늘 당신의 감정 상태에 맞춰 구성된 맞춤 루틴이에요.\n 원하는 루틴을 선택해서 가볍게 시작해보세요." ,
172+ color = BitnagilTheme .colors.coolGray50,
173+ style = BitnagilTheme .typography.body2Medium,
174+ )
175+
176+
177+ Spacer (modifier = Modifier .height(28 .dp))
178+
179+ val scrollState = rememberScrollState()
180+ Column (
181+ modifier = Modifier
182+ .weight(1f )
183+ .verticalScroll(state = scrollState),
184+ ) {
185+ for (recommendRoutine in state.recommendRoutines) {
186+ BitnagilSelectButton (
187+ title = recommendRoutine.name,
188+ description = recommendRoutine.description,
189+ onClick = { onClickRoutine(recommendRoutine.id) },
190+ selected = recommendRoutine.selected,
191+ modifier = Modifier .padding(bottom = 12 .dp),
192+ )
193+ }
194+ }
195+
196+ Spacer (modifier = Modifier .height(12 .dp))
197+
198+ BitnagilTextButton (
199+ text = " 변경하기" ,
200+ onClick = onClickRegisterRecommendRoutines,
201+ enabled = state.registerRecommendRoutinesButtonEnabled,
202+ )
203+
204+ Spacer (modifier = Modifier .height(10 .dp))
205+
206+ BitnagilTextButton (
207+ text = " 건너뛰기" ,
208+ onClick = onClickSkip,
209+ colors = BitnagilTextButtonColor .skip().copy(
210+ defaultBackgroundColor = Color .Transparent ,
211+ pressedBackgroundColor = Color .Transparent ,
212+ disabledBackgroundColor = Color .Transparent ,
213+ ),
214+ textStyle = BitnagilTheme .typography.body2Regular,
215+ textDecoration = TextDecoration .Underline ,
216+ )
217+ }
218+ }
219+ }
220+
114221@Preview
115222@Composable
116- fun MyPageScreenPreview () {
223+ private fun EmotionScreenPreview () {
117224 BitnagilTheme {
118225 EmotionScreen (
119226 state = EmotionState (
120227 emotions = Emotion .entries,
121228 isLoading = false ,
229+ step = EmotionScreenStep .Emotion ,
122230 ),
123231 onClickEmotion = { _ -> },
124232 onClickPreviousButton = {},
125233 )
126234 }
127235}
236+
237+ @Preview
238+ @Composable
239+ private fun EmotionRecommendRoutineScreenPreview () {
240+ BitnagilTheme {
241+ EmotionRecommendRoutineScreen (
242+ state = EmotionState (
243+ emotions = Emotion .entries,
244+ isLoading = false ,
245+ step = EmotionScreenStep .RecommendRoutines ,
246+ recommendRoutines = listOf (
247+ EmotionRecommendRoutineUiModel (
248+ id = " 1" ,
249+ name = " 루틴 이름" ,
250+ description = " 루틴 설명" ,
251+ selected = true ,
252+ )
253+ )
254+ ),
255+ onClickPreviousButton = {},
256+ onClickRoutine = {},
257+ onClickRegisterRecommendRoutines = {},
258+ onClickSkip = {},
259+ )
260+ }
261+ }
0 commit comments