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
20 changes: 17 additions & 3 deletions app/src/main/java/com/threegap/bitnagil/MainNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import com.threegap.bitnagil.presentation.emotion.EmotionScreenContainer
import com.threegap.bitnagil.presentation.intro.IntroScreenContainer
import com.threegap.bitnagil.presentation.login.LoginScreenContainer
import com.threegap.bitnagil.presentation.onboarding.OnBoardingScreenContainer
import com.threegap.bitnagil.presentation.onboarding.OnBoardingViewModel
import com.threegap.bitnagil.presentation.onboarding.model.navarg.OnBoardingScreenArg
import com.threegap.bitnagil.presentation.setting.SettingScreenContainer
import com.threegap.bitnagil.presentation.splash.SplashScreenContainer
import com.threegap.bitnagil.presentation.terms.TermsAgreementScreenContainer
Expand Down Expand Up @@ -80,7 +82,7 @@ fun MainNavHost(
)
},
navigateToOnBoarding = {
navigator.navController.navigate(Route.OnBoarding)
navigator.navController.navigate(Route.OnBoarding())
},
navigateToBack = { navigator.navController.popBackStack() },
)
Expand All @@ -92,7 +94,7 @@ fun MainNavHost(
navigator.navController.navigate(Route.Setting)
},
navigateToOnBoarding = {
navigator.navController.navigate(Route.OnBoarding)
navigator.navController.navigate(Route.OnBoarding(isNew = false))
},
navigateToNotice = {
},
Expand Down Expand Up @@ -150,8 +152,20 @@ fun MainNavHost(
)
}

composable<Route.OnBoarding> {
composable<Route.OnBoarding> { navBackStackEntry ->
val arg = navBackStackEntry.toRoute<Route.OnBoarding>()
val onBoardingScreenArg = if (arg.isNew) {
OnBoardingScreenArg.NEW
} else {
OnBoardingScreenArg.RESET
}

val viewModel = hiltViewModel<OnBoardingViewModel, OnBoardingViewModel.Factory> { factory ->
factory.create(onBoardingScreenArg)
}

OnBoardingScreenContainer(
onBoardingViewModel = viewModel,
navigateToHome = {
navigator.navController.navigate(Route.Home) {
popUpTo(navigator.navController.graph.startDestinationId) {
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/threegap/bitnagil/Route.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ sealed interface Route {
data object Setting : Route

@Serializable
data object OnBoarding : Route
data class OnBoarding(
val isNew: Boolean = true,
) : Route

@Serializable
data class WriteRoutine(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import com.threegap.bitnagil.designsystem.BitnagilTheme
@Composable
fun BitnagilSelectButton(
title: String,
onClick: () -> Unit,
onClick: (() -> Unit)?,
modifier: Modifier = Modifier,
description: String? = null,
selected: Boolean = false,
Expand All @@ -57,11 +57,17 @@ fun BitnagilSelectButton(
.fillMaxWidth()
.clip(shape)
.background(backgroundColor)
.clickable(
interactionSource = interactionSource,
indication = null,
onClick = onClick,
)
.let {
if (onClick != null) {
it.clickable(
interactionSource = interactionSource,
indication = null,
onClick = onClick,
)
} else {
it
}
}
.padding(horizontal = 20.dp, vertical = 16.dp)
.semantics {
role = Role.Button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.threegap.bitnagil.data.emotion.model.dto

import com.threegap.bitnagil.domain.emotion.model.EmotionRecommendRoutine
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand All @@ -13,4 +14,12 @@ data class EmotionRecommendedRoutineDto(
val recommendedRoutineDescription: String,
@SerialName("recommendedSubRoutineSearchResult")
val recommendedSubRoutineSearchResult: List<EmotionRecommendedSubRoutineDto>,
)
) {
fun toEmotionRecommendRoutine(): EmotionRecommendRoutine {
return EmotionRecommendRoutine(
routineId = recommendedRoutineId.toString(),
routineName = recommendedRoutineName,
routineDescription = recommendedRoutineDescription,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.threegap.bitnagil.data.emotion.repositoryImpl
import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
import com.threegap.bitnagil.data.emotion.model.response.toDomain
import com.threegap.bitnagil.domain.emotion.model.Emotion
import com.threegap.bitnagil.domain.emotion.model.EmotionRecommendRoutine
import com.threegap.bitnagil.domain.emotion.model.MyEmotion
import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository
import javax.inject.Inject
Expand All @@ -26,7 +27,7 @@ class EmotionRepositoryImpl @Inject constructor(
}
}

override suspend fun registerEmotion(emotion: Emotion): Result<Unit> {
override suspend fun registerEmotion(emotion: Emotion): Result<List<EmotionRecommendRoutine>> {
val selectedEmotion = when (emotion) {
Emotion.CALM -> "CALM"
Emotion.VITALITY -> "VITALITY"
Expand All @@ -36,7 +37,12 @@ class EmotionRepositoryImpl @Inject constructor(
Emotion.FATIGUE -> "FATIGUE"
}

return emotionDataSource.registerEmotion(selectedEmotion).map { _ -> }
return emotionDataSource.registerEmotion(selectedEmotion).map {
it.recommendedRoutines.map {
emotionRecommendedRoutineDto ->
emotionRecommendedRoutineDto.toEmotionRecommendRoutine()
}
}
}

override suspend fun getMyEmotionMarble(currentDate: String): Result<MyEmotion> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,25 @@ data class OnBoardingItemDto(
)

val RealOutingZeroPerWeek = OnBoardingItemDto(
id = "ZERO_PER_WEEK",
id = "NEVER",
title = "밖에 나가지 않고 집에서만 지냈어요",
description = null,
)

val RealOutingOneToTwoPerWeek = OnBoardingItemDto(
id = "ONE_TO_TWO_PER_WEEK",
id = "SHORT",
title = "잠깐 외출했어요",
description = null,
)

val RealOutingThreeToFourPerWeek = OnBoardingItemDto(
id = "THREE_TO_FOUR_PER_WEEK",
id = "SOMETIMES",
title = "가끔 나가요",
description = null,
)

val RealOutingMoreThanFivePerWeek = OnBoardingItemDto(
id = "MORE_THAN_FIVE_PER_WEEK",
id = "OFTEN",
title = "자주 외출해요",
description = null,
)
Expand Down Expand Up @@ -83,19 +83,19 @@ data class OnBoardingItemDto(
)

val TargetOutingOneToTwoPerWeek = OnBoardingItemDto(
id = "ONE_TO_TWO_PER_WEEK",
id = "ONE_PER_WEEK",
title = "시작이 더 중요해요",
description = "일주일에 1회",
)

val TargetOutingThreeToFourPerWeek = OnBoardingItemDto(
id = "THREE_TO_FOUR_PER_WEEK",
id = "TWO_TO_THREE_PER_WEEK",
title = "너무 무리하지 않아도 괜찮아요",
description = "일주일에 2~3회",
)

val TargetOutingMoreThenFivePerWeek = OnBoardingItemDto(
id = "MORE_THAN_FIVE_PER_WEEK",
id = "MORE_THAN_FOUR_PER_WEEK",
title = "이 정도면 충분히 활력 있는 한 주가 될거에요",
description = "일주일에 4회 이상",
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.threegap.bitnagil.domain.emotion.model

data class EmotionRecommendRoutine(
val routineId: String,
val routineName: String,
val routineDescription: String,
)
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.threegap.bitnagil.domain.emotion.repository

import com.threegap.bitnagil.domain.emotion.model.Emotion
import com.threegap.bitnagil.domain.emotion.model.EmotionRecommendRoutine
import com.threegap.bitnagil.domain.emotion.model.MyEmotion

interface EmotionRepository {
suspend fun getEmotions(): Result<List<Emotion>>
suspend fun registerEmotion(emotion: Emotion): Result<Unit>
suspend fun registerEmotion(emotion: Emotion): Result<List<EmotionRecommendRoutine>>
suspend fun getMyEmotionMarble(currentDate: String): Result<MyEmotion>
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.threegap.bitnagil.domain.emotion.usecase

import com.threegap.bitnagil.domain.emotion.model.Emotion
import com.threegap.bitnagil.domain.emotion.model.EmotionRecommendRoutine
import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository
import javax.inject.Inject

class RegisterEmotionUseCase @Inject constructor(
private val emotionRepository: EmotionRepository,
) {
suspend operator fun invoke(emotion: Emotion): Result<Unit> {
suspend operator fun invoke(emotion: Emotion): Result<List<EmotionRecommendRoutine>> {
return emotionRepository.registerEmotion(emotion)
}
}
Loading