Skip to content

Commit 7a222c8

Browse files
committed
[REFACTOR/#402] SplashUiState ๊ตฌํ˜„
1 parent b629ed5 commit 7a222c8

2 files changed

Lines changed: 30 additions & 11 deletions

File tree

โ€Žfeature/splash/src/main/java/com/terning/feature/splash/SplashRoute.ktโ€Ž

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import com.terning.core.designsystem.theme.TerningMain
2929
import com.terning.core.designsystem.theme.TerningPointTheme
3030
import com.terning.core.designsystem.theme.White
3131
import com.terning.core.designsystem.type.DeeplinkType
32-
import com.terning.domain.update.entity.UpdateState
32+
import com.terning.feature.splash.SplashUiState
3333
import com.terning.feature.splash.component.TerningMajorUpdateDialog
3434
import com.terning.feature.splash.component.TerningPatchUpdateDialog
3535
import kotlinx.coroutines.launch
@@ -104,34 +104,34 @@ internal fun SplashRoute(
104104
}
105105

106106
SplashScreen(
107-
updateState = updateState,
107+
splashUiState = updateState.toUi(),
108108
onUpdateButtonClick = context::launchPlayStore,
109109
onUpdateSkipButtonClick = viewModel::checkIfAccessTokenAvailable
110110
)
111111
}
112112

113113
@Composable
114114
private fun SplashScreen(
115-
updateState: UpdateState,
115+
splashUiState: SplashUiState,
116116
onUpdateButtonClick: () -> Unit,
117117
onUpdateSkipButtonClick: () -> Unit,
118118
) {
119-
when (updateState) {
120-
is UpdateState.MajorUpdateAvailable -> {
119+
when (splashUiState) {
120+
is SplashUiState.MajorUpdateAvailable -> {
121121
AnimatedVisibility(visible = true) {
122122
TerningMajorUpdateDialog(
123-
titleText = updateState.title,
124-
bodyText = updateState.content,
123+
titleText = splashUiState.title,
124+
bodyText = splashUiState.content,
125125
onUpdateButtonClick = onUpdateButtonClick,
126126
)
127127
}
128128
}
129129

130-
is UpdateState.PatchUpdateAvailable -> {
130+
is SplashUiState.PatchUpdateAvailable -> {
131131
AnimatedVisibility(visible = true) {
132132
TerningPatchUpdateDialog(
133-
titleText = updateState.title,
134-
bodyText = updateState.content,
133+
titleText = splashUiState.title,
134+
bodyText = splashUiState.content,
135135
onDismissButtonClick = onUpdateSkipButtonClick,
136136
onUpdateButtonClick = onUpdateButtonClick,
137137
)
@@ -161,7 +161,7 @@ private fun SplashScreen(
161161
private fun SplashScreenPreview() {
162162
TerningPointTheme {
163163
SplashScreen(
164-
updateState = UpdateState.NoUpdateAvailable,
164+
splashUiState = SplashUiState.NoUpdateAvailable,
165165
onUpdateButtonClick = {},
166166
onUpdateSkipButtonClick = {},
167167
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.terning.feature.splash
2+
3+
import androidx.compose.runtime.Immutable
4+
import com.terning.domain.update.entity.UpdateState
5+
6+
@Immutable
7+
sealed class SplashUiState {
8+
data object InitialState : SplashUiState()
9+
data object NoUpdateAvailable : SplashUiState()
10+
data class MajorUpdateAvailable(val title: String, val content: String) : SplashUiState()
11+
data class PatchUpdateAvailable(val title: String, val content: String) : SplashUiState()
12+
}
13+
14+
fun UpdateState.toUi(): SplashUiState = when (this) {
15+
UpdateState.InitialState -> SplashUiState.InitialState
16+
UpdateState.NoUpdateAvailable -> SplashUiState.NoUpdateAvailable
17+
is UpdateState.MajorUpdateAvailable -> SplashUiState.MajorUpdateAvailable(title, content)
18+
is UpdateState.PatchUpdateAvailable -> SplashUiState.PatchUpdateAvailable(title, content)
19+
}

0 commit comments

Comments
ย (0)