feat: implement import mode in authentication flow and update UI accordingly
This commit is contained in:
@@ -42,6 +42,7 @@ fun AuthFlow(
|
||||
)
|
||||
}
|
||||
var showCreateModal by remember { mutableStateOf(false) }
|
||||
var isImportMode by remember { mutableStateOf(false) }
|
||||
|
||||
// Handle system back button
|
||||
BackHandler(enabled = currentScreen != AuthScreen.UNLOCK && !(currentScreen == AuthScreen.WELCOME && !hasExistingAccount)) {
|
||||
@@ -54,10 +55,22 @@ fun AuthFlow(
|
||||
}
|
||||
AuthScreen.CONFIRM_SEED -> currentScreen = AuthScreen.SEED_PHRASE
|
||||
AuthScreen.SET_PASSWORD -> {
|
||||
currentScreen = if (hasExistingAccount) AuthScreen.UNLOCK else AuthScreen.CONFIRM_SEED
|
||||
if (isImportMode) {
|
||||
currentScreen = AuthScreen.IMPORT_SEED
|
||||
} else if (hasExistingAccount) {
|
||||
currentScreen = AuthScreen.UNLOCK
|
||||
} else {
|
||||
currentScreen = AuthScreen.CONFIRM_SEED
|
||||
}
|
||||
}
|
||||
AuthScreen.IMPORT_SEED -> {
|
||||
currentScreen = if (hasExistingAccount) AuthScreen.WELCOME else AuthScreen.WELCOME
|
||||
if (isImportMode && hasExistingAccount) {
|
||||
// Came from UnlockScreen recover — go back to unlock
|
||||
currentScreen = AuthScreen.UNLOCK
|
||||
isImportMode = false
|
||||
} else {
|
||||
currentScreen = AuthScreen.WELCOME
|
||||
}
|
||||
}
|
||||
else -> {} // UNLOCK doesn't have back navigation
|
||||
}
|
||||
@@ -129,9 +142,11 @@ fun AuthFlow(
|
||||
SetPasswordScreen(
|
||||
seedPhrase = seedPhrase,
|
||||
isDarkTheme = isDarkTheme,
|
||||
isImportMode = isImportMode,
|
||||
onBack = {
|
||||
// If there are existing accounts, allow going back to unlock screen
|
||||
if (hasExistingAccount) {
|
||||
if (isImportMode) {
|
||||
currentScreen = AuthScreen.IMPORT_SEED
|
||||
} else if (hasExistingAccount) {
|
||||
currentScreen = AuthScreen.UNLOCK
|
||||
} else {
|
||||
currentScreen = AuthScreen.CONFIRM_SEED
|
||||
@@ -144,7 +159,14 @@ fun AuthFlow(
|
||||
AuthScreen.IMPORT_SEED -> {
|
||||
ImportSeedPhraseScreen(
|
||||
isDarkTheme = isDarkTheme,
|
||||
onBack = { currentScreen = AuthScreen.WELCOME },
|
||||
onBack = {
|
||||
if (isImportMode && hasExistingAccount) {
|
||||
currentScreen = AuthScreen.UNLOCK
|
||||
isImportMode = false
|
||||
} else {
|
||||
currentScreen = AuthScreen.WELCOME
|
||||
}
|
||||
},
|
||||
onSeedPhraseImported = { words ->
|
||||
seedPhrase = words
|
||||
currentScreen = AuthScreen.SET_PASSWORD
|
||||
@@ -160,7 +182,13 @@ fun AuthFlow(
|
||||
onSwitchAccount = {
|
||||
// Navigate to create new account screen
|
||||
// Don't reset selectedAccountId so last logged account is remembered
|
||||
isImportMode = false
|
||||
currentScreen = AuthScreen.WELCOME
|
||||
},
|
||||
onRecover = {
|
||||
// Go directly to seed import (like Desktop's "recover your password")
|
||||
isImportMode = true
|
||||
currentScreen = AuthScreen.IMPORT_SEED
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import kotlinx.coroutines.launch
|
||||
fun SetPasswordScreen(
|
||||
seedPhrase: List<String>,
|
||||
isDarkTheme: Boolean,
|
||||
isImportMode: Boolean = false,
|
||||
onBack: () -> Unit,
|
||||
onAccountCreated: (DecryptedAccount) -> Unit
|
||||
) {
|
||||
@@ -191,7 +192,7 @@ fun SetPasswordScreen(
|
||||
enter = fadeIn(tween(400, delayMillis = 100))
|
||||
) {
|
||||
Text(
|
||||
text = "Protect Your Account",
|
||||
text = if (isImportMode) "Recover Account" else "Protect Your Account",
|
||||
fontSize = if (isKeyboardVisible) 20.sp else 24.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = textColor
|
||||
@@ -205,7 +206,9 @@ fun SetPasswordScreen(
|
||||
enter = fadeIn(tween(500, delayMillis = 200))
|
||||
) {
|
||||
Text(
|
||||
text =
|
||||
text = if (isImportMode)
|
||||
"Set a password to protect your recovered account.\nYou'll need it to unlock Rosetta."
|
||||
else
|
||||
"This password encrypts your keys locally.\nYou'll need it to unlock Rosetta.",
|
||||
fontSize = if (isKeyboardVisible) 12.sp else 14.sp,
|
||||
color = secondaryTextColor,
|
||||
@@ -568,7 +571,7 @@ fun SetPasswordScreen(
|
||||
)
|
||||
} else {
|
||||
Text(
|
||||
text = "Create Account",
|
||||
text = if (isImportMode) "Recover Account" else "Create Account",
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.SemiBold
|
||||
)
|
||||
|
||||
@@ -156,7 +156,8 @@ fun UnlockScreen(
|
||||
isDarkTheme: Boolean,
|
||||
selectedAccountId: String? = null,
|
||||
onUnlocked: (DecryptedAccount) -> Unit,
|
||||
onSwitchAccount: () -> Unit = {}
|
||||
onSwitchAccount: () -> Unit = {},
|
||||
onRecover: () -> Unit = {}
|
||||
) {
|
||||
val themeAnimSpec =
|
||||
tween<Color>(durationMillis = 500, easing = CubicBezierEasing(0.4f, 0f, 0.2f, 1f))
|
||||
@@ -716,23 +717,41 @@ fun UnlockScreen(
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
TextButton(onClick = onSwitchAccount) {
|
||||
TextButton(onClick = onRecover) {
|
||||
Icon(
|
||||
painter = TelegramIcons.AddContact,
|
||||
painter = TelegramIcons.Unlock,
|
||||
contentDescription = null,
|
||||
tint = PrimaryBlue,
|
||||
modifier = Modifier.size(18.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(
|
||||
text = "Create or import account",
|
||||
text = "Recover account",
|
||||
color = PrimaryBlue,
|
||||
fontSize = 15.sp,
|
||||
fontWeight = FontWeight.Medium
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
|
||||
TextButton(onClick = onSwitchAccount) {
|
||||
Icon(
|
||||
painter = TelegramIcons.AddContact,
|
||||
contentDescription = null,
|
||||
tint = secondaryTextColor,
|
||||
modifier = Modifier.size(18.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(
|
||||
text = "Create new account",
|
||||
color = secondaryTextColor,
|
||||
fontSize = 14.sp,
|
||||
fontWeight = FontWeight.Normal
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1014,7 +1014,7 @@ fun ProfileScreen(
|
||||
clip = false
|
||||
)
|
||||
.clip(CircleShape)
|
||||
.background(if (isDarkTheme) Color(0xFF2C2C2E) else PrimaryBlue)
|
||||
.background(if (isDarkTheme) Color(0xFF2A2A2A) else Color(0xFF0D8CF4))
|
||||
.clickable { showPhotoPicker = true },
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
@@ -1795,7 +1795,7 @@ fun TelegramToggleItem(
|
||||
val textColor = if (isDarkTheme) Color.White else Color.Black
|
||||
val secondaryTextColor = if (isDarkTheme) Color(0xFF8E8E93) else Color(0xFF666666)
|
||||
val iconColor = if (isDarkTheme) Color(0xFF8E8E93) else Color(0xFF666666)
|
||||
val accentColor = if (isDarkTheme) PrimaryBlueDark else PrimaryBlue
|
||||
val accentColor = if (isDarkTheme) Color(0xFF2A2A2A) else Color(0xFF0D8CF4)
|
||||
val dividerColor = if (isDarkTheme) Color(0xFF3A3A3A) else Color(0xFFE0E0E0)
|
||||
|
||||
Column {
|
||||
|
||||
Reference in New Issue
Block a user