From a3414667490ce54295b46f4d3928eb8fcb9b3ac1 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 20 Oct 2022 20:35:07 +0200 Subject: [PATCH] Don't show login screen when already logged in --- app/src/main/java/dev/lonami/talaria/TalariaApp.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/dev/lonami/talaria/TalariaApp.kt b/app/src/main/java/dev/lonami/talaria/TalariaApp.kt index 4952b7f..a6efd88 100644 --- a/app/src/main/java/dev/lonami/talaria/TalariaApp.kt +++ b/app/src/main/java/dev/lonami/talaria/TalariaApp.kt @@ -12,6 +12,7 @@ import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController +import dev.lonami.talaria.bindings.Native import dev.lonami.talaria.ui.ChatScreen import dev.lonami.talaria.ui.DialogScreen import dev.lonami.talaria.ui.LoginScreen @@ -46,6 +47,7 @@ fun TalariaApp() { val currentScreen = TalariaScreen.valueOf(backStackEntry?.destination?.route ?: TalariaScreen.Login.name) + val loggedIn by remember { mutableStateOf(!Native.needLogin()) } var selectedDialog by remember { mutableStateOf("") } Scaffold( @@ -59,7 +61,11 @@ fun TalariaApp() { ) { innerPadding -> NavHost( navController = navController, - startDestination = TalariaScreen.Login.name, + startDestination = if (loggedIn) { + TalariaScreen.Login.name + } else { + TalariaScreen.Dialog.name + }, Modifier.padding(innerPadding) ) { composable(route = TalariaScreen.Dialog.name) {