Skip to content

Commit ea90e62

Browse files
authored
Merge pull request #62 from YAPP-Github/feature/#58-reset_onboarding_and_recommend_routine_in_emotion
[Feature/#58] 온보딩 수정 및 감정구슬 선택 후 추천 루틴 표시 부분 구현
2 parents 1a6e9f5 + 240447e commit ea90e62

File tree

21 files changed

+421
-46
lines changed

21 files changed

+421
-46
lines changed

app/src/main/java/com/threegap/bitnagil/MainNavHost.kt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import com.threegap.bitnagil.presentation.emotion.EmotionScreenContainer
1111
import com.threegap.bitnagil.presentation.intro.IntroScreenContainer
1212
import com.threegap.bitnagil.presentation.login.LoginScreenContainer
1313
import com.threegap.bitnagil.presentation.onboarding.OnBoardingScreenContainer
14+
import com.threegap.bitnagil.presentation.onboarding.OnBoardingViewModel
15+
import com.threegap.bitnagil.presentation.onboarding.model.navarg.OnBoardingScreenArg
1416
import com.threegap.bitnagil.presentation.setting.SettingScreenContainer
1517
import com.threegap.bitnagil.presentation.splash.SplashScreenContainer
1618
import com.threegap.bitnagil.presentation.terms.TermsAgreementScreenContainer
@@ -80,7 +82,7 @@ fun MainNavHost(
8082
)
8183
},
8284
navigateToOnBoarding = {
83-
navigator.navController.navigate(Route.OnBoarding)
85+
navigator.navController.navigate(Route.OnBoarding())
8486
},
8587
navigateToBack = { navigator.navController.popBackStack() },
8688
)
@@ -92,7 +94,7 @@ fun MainNavHost(
9294
navigator.navController.navigate(Route.Setting)
9395
},
9496
navigateToOnBoarding = {
95-
navigator.navController.navigate(Route.OnBoarding)
97+
navigator.navController.navigate(Route.OnBoarding(isNew = false))
9698
},
9799
navigateToNotice = {
98100
},
@@ -150,8 +152,20 @@ fun MainNavHost(
150152
)
151153
}
152154

153-
composable<Route.OnBoarding> {
155+
composable<Route.OnBoarding> { navBackStackEntry ->
156+
val arg = navBackStackEntry.toRoute<Route.OnBoarding>()
157+
val onBoardingScreenArg = if (arg.isNew) {
158+
OnBoardingScreenArg.NEW
159+
} else {
160+
OnBoardingScreenArg.RESET
161+
}
162+
163+
val viewModel = hiltViewModel<OnBoardingViewModel, OnBoardingViewModel.Factory> { factory ->
164+
factory.create(onBoardingScreenArg)
165+
}
166+
154167
OnBoardingScreenContainer(
168+
onBoardingViewModel = viewModel,
155169
navigateToHome = {
156170
navigator.navController.navigate(Route.Home) {
157171
popUpTo(navigator.navController.graph.startDestinationId) {

app/src/main/java/com/threegap/bitnagil/Route.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ sealed interface Route {
2929
data object Setting : Route
3030

3131
@Serializable
32-
data object OnBoarding : Route
32+
data class OnBoarding(
33+
val isNew: Boolean = true,
34+
) : Route
3335

3436
@Serializable
3537
data class WriteRoutine(

core/designsystem/src/main/java/com/threegap/bitnagil/designsystem/component/atom/BitnagilSelectButton.kt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import com.threegap.bitnagil.designsystem.BitnagilTheme
3030
@Composable
3131
fun BitnagilSelectButton(
3232
title: String,
33-
onClick: () -> Unit,
33+
onClick: (() -> Unit)?,
3434
modifier: Modifier = Modifier,
3535
description: String? = null,
3636
selected: Boolean = false,
@@ -57,11 +57,17 @@ fun BitnagilSelectButton(
5757
.fillMaxWidth()
5858
.clip(shape)
5959
.background(backgroundColor)
60-
.clickable(
61-
interactionSource = interactionSource,
62-
indication = null,
63-
onClick = onClick,
64-
)
60+
.let {
61+
if (onClick != null) {
62+
it.clickable(
63+
interactionSource = interactionSource,
64+
indication = null,
65+
onClick = onClick,
66+
)
67+
} else {
68+
it
69+
}
70+
}
6571
.padding(horizontal = 20.dp, vertical = 16.dp)
6672
.semantics {
6773
role = Role.Button

data/src/main/java/com/threegap/bitnagil/data/emotion/model/dto/EmotionRecommendedRoutineDto.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.threegap.bitnagil.data.emotion.model.dto
22

3+
import com.threegap.bitnagil.domain.emotion.model.EmotionRecommendRoutine
34
import kotlinx.serialization.SerialName
45
import kotlinx.serialization.Serializable
56

@@ -13,4 +14,12 @@ data class EmotionRecommendedRoutineDto(
1314
val recommendedRoutineDescription: String,
1415
@SerialName("recommendedSubRoutineSearchResult")
1516
val recommendedSubRoutineSearchResult: List<EmotionRecommendedSubRoutineDto>,
16-
)
17+
) {
18+
fun toEmotionRecommendRoutine(): EmotionRecommendRoutine {
19+
return EmotionRecommendRoutine(
20+
routineId = recommendedRoutineId.toString(),
21+
routineName = recommendedRoutineName,
22+
routineDescription = recommendedRoutineDescription,
23+
)
24+
}
25+
}

data/src/main/java/com/threegap/bitnagil/data/emotion/repositoryImpl/EmotionRepositoryImpl.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.threegap.bitnagil.data.emotion.repositoryImpl
33
import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
44
import com.threegap.bitnagil.data.emotion.model.response.toDomain
55
import com.threegap.bitnagil.domain.emotion.model.Emotion
6+
import com.threegap.bitnagil.domain.emotion.model.EmotionRecommendRoutine
67
import com.threegap.bitnagil.domain.emotion.model.MyEmotion
78
import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository
89
import javax.inject.Inject
@@ -26,7 +27,7 @@ class EmotionRepositoryImpl @Inject constructor(
2627
}
2728
}
2829

29-
override suspend fun registerEmotion(emotion: Emotion): Result<Unit> {
30+
override suspend fun registerEmotion(emotion: Emotion): Result<List<EmotionRecommendRoutine>> {
3031
val selectedEmotion = when (emotion) {
3132
Emotion.CALM -> "CALM"
3233
Emotion.VITALITY -> "VITALITY"
@@ -36,7 +37,12 @@ class EmotionRepositoryImpl @Inject constructor(
3637
Emotion.FATIGUE -> "FATIGUE"
3738
}
3839

39-
return emotionDataSource.registerEmotion(selectedEmotion).map { _ -> }
40+
return emotionDataSource.registerEmotion(selectedEmotion).map {
41+
it.recommendedRoutines.map {
42+
emotionRecommendedRoutineDto ->
43+
emotionRecommendedRoutineDto.toEmotionRecommendRoutine()
44+
}
45+
}
4046
}
4147

4248
override suspend fun getMyEmotionMarble(currentDate: String): Result<MyEmotion> =

data/src/main/java/com/threegap/bitnagil/data/onboarding/model/dto/OnBoardingItemDto.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,25 @@ data class OnBoardingItemDto(
3535
)
3636

3737
val RealOutingZeroPerWeek = OnBoardingItemDto(
38-
id = "ZERO_PER_WEEK",
38+
id = "NEVER",
3939
title = "밖에 나가지 않고 집에서만 지냈어요",
4040
description = null,
4141
)
4242

4343
val RealOutingOneToTwoPerWeek = OnBoardingItemDto(
44-
id = "ONE_TO_TWO_PER_WEEK",
44+
id = "SHORT",
4545
title = "잠깐 외출했어요",
4646
description = null,
4747
)
4848

4949
val RealOutingThreeToFourPerWeek = OnBoardingItemDto(
50-
id = "THREE_TO_FOUR_PER_WEEK",
50+
id = "SOMETIMES",
5151
title = "가끔 나가요",
5252
description = null,
5353
)
5454

5555
val RealOutingMoreThanFivePerWeek = OnBoardingItemDto(
56-
id = "MORE_THAN_FIVE_PER_WEEK",
56+
id = "OFTEN",
5757
title = "자주 외출해요",
5858
description = null,
5959
)
@@ -83,19 +83,19 @@ data class OnBoardingItemDto(
8383
)
8484

8585
val TargetOutingOneToTwoPerWeek = OnBoardingItemDto(
86-
id = "ONE_TO_TWO_PER_WEEK",
86+
id = "ONE_PER_WEEK",
8787
title = "시작이 더 중요해요",
8888
description = "일주일에 1회",
8989
)
9090

9191
val TargetOutingThreeToFourPerWeek = OnBoardingItemDto(
92-
id = "THREE_TO_FOUR_PER_WEEK",
92+
id = "TWO_TO_THREE_PER_WEEK",
9393
title = "너무 무리하지 않아도 괜찮아요",
9494
description = "일주일에 2~3회",
9595
)
9696

9797
val TargetOutingMoreThenFivePerWeek = OnBoardingItemDto(
98-
id = "MORE_THAN_FIVE_PER_WEEK",
98+
id = "MORE_THAN_FOUR_PER_WEEK",
9999
title = "이 정도면 충분히 활력 있는 한 주가 될거에요",
100100
description = "일주일에 4회 이상",
101101
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.threegap.bitnagil.domain.emotion.model
2+
3+
data class EmotionRecommendRoutine(
4+
val routineId: String,
5+
val routineName: String,
6+
val routineDescription: String,
7+
)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package com.threegap.bitnagil.domain.emotion.repository
22

33
import com.threegap.bitnagil.domain.emotion.model.Emotion
4+
import com.threegap.bitnagil.domain.emotion.model.EmotionRecommendRoutine
45
import com.threegap.bitnagil.domain.emotion.model.MyEmotion
56

67
interface EmotionRepository {
78
suspend fun getEmotions(): Result<List<Emotion>>
8-
suspend fun registerEmotion(emotion: Emotion): Result<Unit>
9+
suspend fun registerEmotion(emotion: Emotion): Result<List<EmotionRecommendRoutine>>
910
suspend fun getMyEmotionMarble(currentDate: String): Result<MyEmotion>
1011
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package com.threegap.bitnagil.domain.emotion.usecase
22

33
import com.threegap.bitnagil.domain.emotion.model.Emotion
4+
import com.threegap.bitnagil.domain.emotion.model.EmotionRecommendRoutine
45
import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository
56
import javax.inject.Inject
67

78
class RegisterEmotionUseCase @Inject constructor(
89
private val emotionRepository: EmotionRepository,
910
) {
10-
suspend operator fun invoke(emotion: Emotion): Result<Unit> {
11+
suspend operator fun invoke(emotion: Emotion): Result<List<EmotionRecommendRoutine>> {
1112
return emotionRepository.registerEmotion(emotion)
1213
}
1314
}

0 commit comments

Comments
 (0)