feat: Enhance back navigation in AuthFlow and add back button in WelcomeScreen for better user experience
This commit is contained in:
@@ -37,15 +37,22 @@ fun AuthFlow(
|
||||
var showCreateModal by remember { mutableStateOf(false) }
|
||||
|
||||
// Handle system back button
|
||||
BackHandler(enabled = currentScreen != AuthScreen.UNLOCK && currentScreen != AuthScreen.WELCOME) {
|
||||
BackHandler(enabled = currentScreen != AuthScreen.UNLOCK && !(currentScreen == AuthScreen.WELCOME && !hasExistingAccount)) {
|
||||
when (currentScreen) {
|
||||
AuthScreen.SEED_PHRASE -> currentScreen = AuthScreen.WELCOME
|
||||
AuthScreen.WELCOME -> {
|
||||
if (hasExistingAccount) currentScreen = AuthScreen.UNLOCK
|
||||
}
|
||||
AuthScreen.SEED_PHRASE -> {
|
||||
currentScreen = if (hasExistingAccount) AuthScreen.WELCOME else AuthScreen.WELCOME
|
||||
}
|
||||
AuthScreen.CONFIRM_SEED -> currentScreen = AuthScreen.SEED_PHRASE
|
||||
AuthScreen.SET_PASSWORD -> {
|
||||
currentScreen = if (hasExistingAccount) AuthScreen.UNLOCK else AuthScreen.CONFIRM_SEED
|
||||
}
|
||||
AuthScreen.IMPORT_SEED -> currentScreen = AuthScreen.WELCOME
|
||||
else -> {} // UNLOCK and WELCOME don't have back navigation
|
||||
AuthScreen.IMPORT_SEED -> {
|
||||
currentScreen = if (hasExistingAccount) AuthScreen.WELCOME else AuthScreen.WELCOME
|
||||
}
|
||||
else -> {} // UNLOCK doesn't have back navigation
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +91,8 @@ fun AuthFlow(
|
||||
AuthScreen.WELCOME -> {
|
||||
WelcomeScreen(
|
||||
isDarkTheme = isDarkTheme,
|
||||
hasExistingAccount = hasExistingAccount,
|
||||
onBack = { currentScreen = AuthScreen.UNLOCK },
|
||||
onCreateSeed = { currentScreen = AuthScreen.SEED_PHRASE },
|
||||
onImportSeed = { currentScreen = AuthScreen.IMPORT_SEED }
|
||||
)
|
||||
|
||||
@@ -35,6 +35,8 @@ val AuthSurfaceLight = Color(0xFFF5F5F5)
|
||||
@Composable
|
||||
fun WelcomeScreen(
|
||||
isDarkTheme: Boolean,
|
||||
hasExistingAccount: Boolean = false,
|
||||
onBack: () -> Unit = {},
|
||||
onCreateSeed: () -> Unit,
|
||||
onImportSeed: () -> Unit
|
||||
) {
|
||||
@@ -67,6 +69,22 @@ fun WelcomeScreen(
|
||||
.fillMaxSize()
|
||||
.background(backgroundColor)
|
||||
) {
|
||||
// Back button when coming from UnlockScreen
|
||||
if (hasExistingAccount) {
|
||||
IconButton(
|
||||
onClick = onBack,
|
||||
modifier = Modifier
|
||||
.statusBarsPadding()
|
||||
.padding(4.dp)
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.ArrowBack,
|
||||
contentDescription = "Back",
|
||||
tint = textColor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
|
||||
@@ -436,9 +436,13 @@ fun ChatsListScreen(
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.background(Color(0x20FF3B30))
|
||||
.clickable {
|
||||
scope.launch { drawerState.close() }
|
||||
scope.launch {
|
||||
drawerState.close()
|
||||
// Wait for drawer to close before logout
|
||||
kotlinx.coroutines.delay(150)
|
||||
onLogout()
|
||||
}
|
||||
}
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
@@ -484,6 +488,7 @@ fun ChatsListScreen(
|
||||
animationSpec = tween(400)
|
||||
)
|
||||
) {
|
||||
key(isDarkTheme) {
|
||||
TopAppBar(
|
||||
navigationIcon = {
|
||||
IconButton(
|
||||
@@ -705,6 +710,7 @@ fun ChatsListScreen(
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
floatingActionButton = {
|
||||
AnimatedVisibility(
|
||||
|
||||
Reference in New Issue
Block a user