-
Notifications
You must be signed in to change notification settings - Fork 1
Custom Splash 구현 #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Splash 구현 #76
Changes from all commits
4253487
bf5720e
a2adc38
5b2c9f9
16ddaf5
51289d2
608cb97
7ce7805
76b887c
e1213a3
32d6931
945d270
fd56f75
96370ee
efd4f35
9517a03
543444b
96779c3
4b7ca0c
4e9569f
0b96d82
31cc636
41e2971
1e6064d
d8e7423
a56515a
0152beb
5c00978
aaa7bd8
1df9ad7
523ac5f
6e95088
64d3a2b
091a857
94ad204
7c20540
55de528
7b43d25
715e6ab
1ffd329
8b1289b
c01db06
2db6984
85da5c4
a7353f3
bb3f648
6532397
bf9150b
71574ff
8f08cda
8c536f5
ab127fc
a0e2765
82f0e2a
a97cf9a
582620d
196c075
703e733
8503833
aca853b
b58937e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| package com.team.prezel.ui | ||
|
|
||
| import androidx.activity.compose.BackHandler | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.LaunchedEffect | ||
| import androidx.compose.runtime.Stable | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.runtime.setValue | ||
| import androidx.compose.ui.platform.LocalResources | ||
| import com.team.prezel.R | ||
| import com.team.prezel.core.designsystem.component.snackbar.dismissById | ||
| import com.team.prezel.core.designsystem.component.snackbar.showPrezelSnackbar | ||
| import com.team.prezel.core.navigation.NavigationState | ||
| import com.team.prezel.core.ui.LocalSnackbarHostState | ||
|
|
||
| private const val SNACKBAR_IDENTIFIER = "DoubleBackToExitHandler" | ||
|
|
||
| @Stable | ||
| private sealed interface BackPressState { | ||
| data object Idle : BackPressState | ||
|
|
||
| data object Pressed : BackPressState | ||
| } | ||
|
|
||
| @Composable | ||
| internal fun DoubleBackToExitHandler(navigationState: NavigationState) { | ||
| var backPressState by remember { mutableStateOf<BackPressState>(BackPressState.Idle) } | ||
| val snackbarState = LocalSnackbarHostState.current | ||
| val resources = LocalResources.current | ||
| val isTopLevelScreen = navigationState.currentKey in navigationState.topLevelKeys | ||
|
|
||
| LaunchedEffect(backPressState, isTopLevelScreen) { | ||
| if (backPressState == BackPressState.Idle) { | ||
| snackbarState.dismissById(SNACKBAR_IDENTIFIER) | ||
| return@LaunchedEffect | ||
| } | ||
|
|
||
| if (!isTopLevelScreen) { | ||
| backPressState = BackPressState.Idle | ||
| return@LaunchedEffect | ||
| } | ||
|
|
||
| snackbarState.showPrezelSnackbar( | ||
| id = SNACKBAR_IDENTIFIER, | ||
| message = resources.getString(R.string.double_back_to_exit_snackbar_message), | ||
| actionLabel = resources.getString(R.string.double_back_to_exit_snackbar_action_label), | ||
| onAction = { backPressState = BackPressState.Idle }, | ||
| onDismiss = { backPressState = BackPressState.Idle }, | ||
| ) | ||
|
Comment on lines
+34
to
+51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result:
Sources: 기존 스낵바가 표시 중일 때 종료 안내가 큐에 밀려 앱이 닫힐 수 있습니다. Line 44의 문제는 첫 뒤로가기 시 수정 방향 if (!isTopLevelScreen) {
backPressState = BackPressState.Idle
return@LaunchedEffect
}
+ // 종료 안내를 즉시 표시하기 위해 기존 스낵바를 먼저 닫습니다.
+ snackbarState.currentSnackbarData?.dismiss()
snackbarState.showPrezelSnackbar(
id = SNACKBAR_IDENTIFIER,
message = resources.getString(R.string.double_back_to_exit_snackbar_message),
actionLabel = resources.getString(R.string.double_back_to_exit_snackbar_action_label),
onAction = { backPressState = BackPressState.Idle },
onDismiss = { backPressState = BackPressState.Idle },
)🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| LaunchedEffect(navigationState.currentTopLevelKey) { | ||
| backPressState = BackPressState.Idle | ||
| } | ||
|
|
||
| BackHandler( | ||
| enabled = isTopLevelScreen && backPressState == BackPressState.Idle, | ||
| onBack = { | ||
| backPressState = BackPressState.Pressed | ||
| }, | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <resources> | ||
|
|
||
| <style name="Theme.Prezel" parent="android:Theme.Material.Light.NoActionBar" /> | ||
|
|
||
| <style name="Theme.PrezelSplashScreen" parent="Theme.Prezel"> | ||
| <item name="android:windowDisablePreview">true</item> | ||
| <item name="android:windowBackground">@color/white</item> | ||
| </style> | ||
moondev03 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </resources> | ||
Uh oh!
There was an error while loading. Please reload this page.