Skip to content

Commit 3720fca

Browse files
committed
[BOOK-260] feat: 스플래시 화면 네트워크 연결 에러 대응
1 parent c38f9d4 commit 3720fca

File tree

6 files changed

+22
-6
lines changed

6 files changed

+22
-6
lines changed

core/common/src/main/kotlin/com/ninecraft/booket/core/common/constants/ErrorDialogSpec.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ package com.ninecraft.booket.core.common.constants
22

33
data class ErrorDialogSpec(
44
val message: String,
5-
val buttonLabel: String,
5+
val buttonLabelResId: Int,
66
val action: () -> Unit,
77
)

core/common/src/main/kotlin/com/ninecraft/booket/core/common/utils/HandleException.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.ninecraft.booket.core.common.utils
22

3+
import androidx.annotation.StringRes
4+
import com.ninecraft.booket.core.common.R
35
import com.ninecraft.booket.core.common.constants.ErrorDialogSpec
46
import com.ninecraft.booket.core.common.constants.ErrorScope
57
import com.ninecraft.booket.core.common.event.ErrorEvent
@@ -46,11 +48,13 @@ fun handleException(
4648
fun postErrorDialog(
4749
errorScope: ErrorScope,
4850
exception: Throwable,
51+
@StringRes buttonLabelResId: Int = R.string.confirm,
4952
action: () -> Unit = {},
5053
) {
5154
val spec = buildDialog(
5255
scope = errorScope,
5356
exception = exception,
57+
buttonLabelResId = buttonLabelResId,
5458
action = action,
5559
)
5660

@@ -60,6 +64,7 @@ fun postErrorDialog(
6064
private fun buildDialog(
6165
scope: ErrorScope,
6266
exception: Throwable,
67+
@StringRes buttonLabelResId: Int,
6368
action: () -> Unit,
6469
): ErrorDialogSpec {
6570
val message = when {
@@ -92,7 +97,7 @@ private fun buildDialog(
9297
}
9398
}
9499

95-
return ErrorDialogSpec(message = message, buttonLabel = "확인", action = action)
100+
return ErrorDialogSpec(message = message, buttonLabelResId = buttonLabelResId, action = action)
96101
}
97102

98103
@Suppress("TooGenericExceptionCaught")

core/common/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
<string name="book_status_completed">독서 완료</string>
66
<string name="record_sort_page_ascending">페이지순</string>
77
<string name="record_sort_recent_register">최신 등록순</string>
8+
<string name="confirm">확인</string>
89
</resources>

core/ui/src/main/kotlin/com/ninecraft/booket/core/ui/ReedScaffold.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ fun ReedScaffold(
2222
content: @Composable (PaddingValues) -> Unit,
2323
) {
2424
Scaffold(
25+
modifier = modifier.keyboardHide(),
2526
topBar = topBar,
2627
bottomBar = bottomBar,
2728
snackbarHost = snackbarHost,
2829
floatingActionButton = floatingActionButton,
2930
containerColor = containerColor,
3031
contentWindowInsets = contentWindowInsets,
31-
modifier = modifier.keyboardHide(),
3232
) { innerPadding ->
3333
content(innerPadding)
3434
}

feature/main/src/main/kotlin/com/ninecraft/booket/feature/main/MainActivity.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import androidx.compose.runtime.mutableStateOf
1111
import androidx.compose.runtime.remember
1212
import androidx.compose.ui.Modifier
1313
import androidx.compose.ui.graphics.Color
14+
import androidx.compose.ui.res.stringResource
1415
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
1516
import com.ninecraft.booket.core.common.constants.ErrorDialogSpec
1617
import com.ninecraft.booket.core.common.event.ErrorEvent
@@ -70,7 +71,8 @@ class MainActivity : ComponentActivity() {
7071
dialogSpec.value?.let { spec ->
7172
ReedDialog(
7273
description = spec.message,
73-
confirmButtonText = spec.buttonLabel,
74+
confirmButtonText = stringResource(spec.buttonLabelResId),
75+
7476
onConfirmRequest = {
7577
spec.action()
7678
dialogSpec.value = null

feature/splash/src/main/kotlin/com/ninecraft/booket/splash/SplashPresenter.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ import androidx.compose.runtime.getValue
66
import androidx.compose.runtime.mutableStateOf
77
import androidx.compose.runtime.rememberCoroutineScope
88
import androidx.compose.runtime.setValue
9+
import com.ninecraft.booket.core.common.constants.ErrorScope
10+
import com.ninecraft.booket.core.common.utils.postErrorDialog
911
import com.ninecraft.booket.core.data.api.repository.AuthRepository
1012
import com.ninecraft.booket.core.data.api.repository.UserRepository
1113
import com.ninecraft.booket.core.model.AutoLoginState
1214
import com.ninecraft.booket.core.model.OnboardingState
15+
import com.ninecraft.booket.core.ui.R
1316
import com.ninecraft.booket.feature.screens.HomeScreen
1417
import com.ninecraft.booket.feature.screens.LoginScreen
1518
import com.ninecraft.booket.feature.screens.OnboardingScreen
@@ -50,8 +53,13 @@ class SplashPresenter @AssistedInject constructor(
5053
navigator.resetRoot(LoginScreen)
5154
}
5255
}
53-
.onFailure {
54-
navigator.resetRoot(LoginScreen)
56+
.onFailure { exception ->
57+
postErrorDialog(
58+
errorScope = ErrorScope.GLOBAL,
59+
exception = exception,
60+
buttonLabelResId = R.string.retry,
61+
action = { checkTermsAgreement() },
62+
)
5563
}
5664
}
5765
}

0 commit comments

Comments
 (0)