Fixed order

This commit is contained in:
dankito 2024-09-20 05:51:57 +02:00
parent abc9ceb29e
commit 3b72d95234
1 changed files with 8 additions and 7 deletions

View File

@ -31,23 +31,24 @@ fun App(repository: BankingRepository? = null) {
val colors = MaterialTheme.colors.copy(primary = Colors.Primary, primaryVariant = Colors.PrimaryDark, onPrimary = Color.White, val colors = MaterialTheme.colors.copy(primary = Colors.Primary, primaryVariant = Colors.PrimaryDark, onPrimary = Color.White,
secondary = Colors.Accent, secondaryVariant = Colors.Accent, onSecondary = Color.White) secondary = Colors.Accent, secondaryVariant = Colors.Accent, onSecondary = Color.White)
val appSettings = DI.uiState.appSettings.collectAsState().value
var isLoggedIn by remember(appSettings.authenticationMethod) { mutableStateOf(appSettings.authenticationMethod == AppAuthenticationMethod.None) }
var isInitialized by remember { mutableStateOf(false) } var isInitialized by remember { mutableStateOf(false) }
val coroutineScope = rememberCoroutineScope()
try { try {
if (isInitialized == false) { if (isInitialized == false) {
DI.setRepository(repository ?: SqliteBankingRepository()) DI.setRepository(repository ?: SqliteBankingRepository()) // setting repository sets AppSettings, which is required below to determine if user needs to log in
} }
} catch (e: Throwable) { } catch (e: Throwable) {
Log.error(e) { "Could not set repository" } Log.error(e) { "Could not set repository" }
} }
val appSettings = DI.uiState.appSettings.collectAsState().value
var isLoggedIn by remember(appSettings.authenticationMethod) { mutableStateOf(appSettings.authenticationMethod == AppAuthenticationMethod.None) }
val coroutineScope = rememberCoroutineScope()
MaterialTheme(colors = colors, typography = typography) { MaterialTheme(colors = colors, typography = typography) {
if (isLoggedIn == false) { if (isLoggedIn == false) {
LoginScreen(appSettings) { LoginScreen(appSettings) {