diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/App.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/App.kt index aee372b..ae2303c 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/App.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/App.kt @@ -31,23 +31,24 @@ fun App(repository: BankingRepository? = null) { val colors = MaterialTheme.colors.copy(primary = Colors.Primary, primaryVariant = Colors.PrimaryDark, onPrimary = 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) } - val coroutineScope = rememberCoroutineScope() - try { 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) { 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) { if (isLoggedIn == false) { LoginScreen(appSettings) {