Skip to content

Commit fc14574

Browse files
committed
[NDGL-105] feature: 앱 첫 진입시 UserGuideModal 추가
1 parent 95f1dd5 commit fc14574

6 files changed

Lines changed: 29 additions & 7 deletions

File tree

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ android {
1515
}
1616

1717
manifestPlaceholders["MAPS_API_KEY"] = localProperties.getProperty("MAPS_API_KEY", "")
18+
buildConfigField("String", "NDGL_TERMS_URL", "\"${localProperties.getProperty("NDGL_TERMS_URL", "")}\"")
1819
}
1920

2021
buildFeatures {

app/src/main/java/com/yapp/ndgl/MainActivity.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import androidx.compose.runtime.mutableStateOf
1010
import androidx.compose.runtime.saveable.rememberSaveable
1111
import androidx.compose.runtime.setValue
1212
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
13+
import com.yapp.ndgl.core.ui.designsystem.UserGuideModal
1314
import com.yapp.ndgl.core.ui.theme.NDGLTheme
15+
import com.yapp.ndgl.core.ui.util.launchBrowser
1416
import com.yapp.ndgl.feature.splash.SplashRoute
1517
import com.yapp.ndgl.navigation.AppScreen
1618
import com.yapp.ndgl.ui.NDGLApp
@@ -25,14 +27,18 @@ class MainActivity : ComponentActivity() {
2527
setContent {
2628
NDGLTheme {
2729
var currentScreen by rememberSaveable { mutableStateOf(AppScreen.Splash) }
30+
var showUserGuideModal by rememberSaveable { mutableStateOf(false) }
2831

2932
AnimatedContent(
3033
targetState = currentScreen,
3134
) { screen ->
3235
when (screen) {
3336
AppScreen.Splash -> {
3437
SplashRoute(
35-
navigateToHome = { currentScreen = AppScreen.Main },
38+
navigateToHome = { isFirstUser ->
39+
showUserGuideModal = isFirstUser
40+
currentScreen = AppScreen.Main
41+
},
3642
)
3743
}
3844

@@ -41,6 +47,17 @@ class MainActivity : ComponentActivity() {
4147
}
4248
}
4349
}
50+
51+
if (showUserGuideModal) {
52+
UserGuideModal(
53+
onConfirmClick = {
54+
showUserGuideModal = false
55+
},
56+
onTermsClick = {
57+
launchBrowser(BuildConfig.NDGL_TERMS_URL)
58+
},
59+
)
60+
}
4461
}
4562
}
4663
}

data/auth/src/main/java/com/yapp/ndgl/data/auth/repository/AuthRepository.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,25 @@ class AuthRepository @Inject constructor(
2121
private val api: AuthApi,
2222
private val localAuthDataSource: LocalAuthDataSource,
2323
) {
24-
suspend fun initSession() {
24+
suspend fun initSession(): Boolean {
2525
val uuid = localAuthDataSource.getUuid()
26+
var isFirstUser = false
2627
val response = if (uuid.isNotEmpty()) {
2728
suspendRunCatching {
2829
login(uuid)
2930
}.getOrElse {
3031
localAuthDataSource.clearSession()
32+
isFirstUser = true
3133
createUser()
3234
}
3335
} else {
36+
isFirstUser = true
3437
createUser()
3538
}
3639

3740
localAuthDataSource.setAccessToken(response.accessToken)
3841
localAuthDataSource.setUuid(response.uuid)
42+
return isFirstUser
3943
}
4044

4145
private suspend fun createUser(): AuthResponse {

feature/splash/src/main/java/com/yapp/ndgl/feature/splash/SplashContract.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ import com.yapp.ndgl.core.base.UiState
66
class SplashState : UiState
77

88
sealed interface SplashSideEffect : UiSideEffect {
9-
data object NavigateToHome : SplashSideEffect
9+
data class NavigateToHome(val isFirstUser: Boolean) : SplashSideEffect
1010
}

feature/splash/src/main/java/com/yapp/ndgl/feature/splash/SplashScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import com.yapp.ndgl.core.ui.theme.NDGLTheme
2525
@Composable
2626
fun SplashRoute(
2727
viewmodel: SplashViewModel = hiltViewModel(),
28-
navigateToHome: () -> Unit,
28+
navigateToHome: (Boolean) -> Unit,
2929
) {
3030
val context = LocalContext.current
3131
val activity = context as? ComponentActivity
@@ -53,7 +53,7 @@ fun SplashRoute(
5353
viewmodel.collectSideEffect { sideEffect ->
5454
when (sideEffect) {
5555
is SplashSideEffect.NavigateToHome -> {
56-
navigateToHome()
56+
navigateToHome(sideEffect.isFirstUser)
5757
}
5858
}
5959
}

feature/splash/src/main/java/com/yapp/ndgl/feature/splash/SplashViewModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class SplashViewModel @Inject constructor(
2222
private fun initSession() = viewModelScope.launch {
2323
suspendRunCatching {
2424
authRepository.initSession()
25-
}.onSuccess {
26-
postSideEffect(SplashSideEffect.NavigateToHome)
25+
}.onSuccess { isFirstUser ->
26+
postSideEffect(SplashSideEffect.NavigateToHome(isFirstUser = isFirstUser))
2727
}.onFailure {
2828
// FIXME: 에러 뷰
2929
}

0 commit comments

Comments
 (0)