feat: Improve screen transition animations and simplify account handling in MainActivity

This commit is contained in:
k1ngsterr1
2026-01-18 18:18:32 +05:00
parent b8aba7714c
commit f7e63dbee1

View File

@@ -170,15 +170,13 @@ class MainActivity : ComponentActivity() {
targetState = when { targetState = when {
showSplash -> "splash" showSplash -> "splash"
showOnboarding && hasExistingAccount == false -> "onboarding" showOnboarding && hasExistingAccount == false -> "onboarding"
// 🔥 КРИТИЧНО: если currentAccount != null - сразу на main без ожидания isLoggedIn
currentAccount != null -> "main"
isLoggedIn != true && hasExistingAccount == false -> "auth_new" isLoggedIn != true && hasExistingAccount == false -> "auth_new"
isLoggedIn != true && hasExistingAccount == true -> "auth_unlock" isLoggedIn != true && hasExistingAccount == true -> "auth_unlock"
else -> "main" else -> "main"
}, },
transitionSpec = { transitionSpec = {
fadeIn(animationSpec = tween(300)) togetherWith fadeIn(animationSpec = tween(600)) togetherWith
fadeOut(animationSpec = tween(200)) fadeOut(animationSpec = tween(600))
}, },
label = "screenTransition" label = "screenTransition"
) { screen -> ) { screen ->
@@ -212,13 +210,7 @@ class MainActivity : ComponentActivity() {
currentAccount = account currentAccount = account
hasExistingAccount = true hasExistingAccount = true
// Save as last logged account // Save as last logged account
account?.let { account?.let { accountManager.setLastLoggedPublicKey(it.publicKey) }
accountManager.setLastLoggedPublicKey(it.publicKey)
// 🔥 КРИТИЧНО: Сразу устанавливаем флаг логина чтобы не было Loading экрана
scope.launch {
accountManager.setCurrentAccount(it.publicKey)
}
}
// 📤 Отправляем FCM токен на сервер после успешной аутентификации // 📤 Отправляем FCM токен на сервер после успешной аутентификации
account?.let { sendFcmTokenToServer(it) } account?.let { sendFcmTokenToServer(it) }
@@ -362,22 +354,13 @@ fun MainScreen(
onToggleTheme: () -> Unit = {}, onToggleTheme: () -> Unit = {},
onLogout: () -> Unit = {} onLogout: () -> Unit = {}
) { ) {
// 🔥 Используем моковый аккаунт если account == null (для предотвращения крашей) val accountName = account?.name ?: "Account"
val effectiveAccount = account ?: DecryptedAccount( val accountPhone = account?.publicKey?.take(16)?.let {
publicKey = "loading",
privateKey = "loading",
seedPhrase = emptyList(),
privateKeyHash = "loading",
name = "Loading..."
)
val accountName = effectiveAccount.name
val accountPhone = effectiveAccount.publicKey.take(16).let {
"+${it.take(1)} ${it.substring(1, 4)} ${it.substring(4, 7)}${it.substring(7)}" "+${it.take(1)} ${it.substring(1, 4)} ${it.substring(4, 7)}${it.substring(7)}"
} } ?: "+7 775 9932587"
val accountPublicKey = effectiveAccount.publicKey val accountPublicKey = account?.publicKey ?: "04c266b98ae5"
val accountPrivateKey = effectiveAccount.privateKey val accountPrivateKey = account?.privateKey ?: ""
val privateKeyHash = effectiveAccount.privateKeyHash val privateKeyHash = account?.privateKeyHash ?: ""
// Состояние протокола для передачи в SearchScreen // Состояние протокола для передачи в SearchScreen
val protocolState by ProtocolManager.state.collectAsState() val protocolState by ProtocolManager.state.collectAsState()