diff --git a/appcompose/src/main/java/com/readrops/app/compose/ComposeAppModule.kt b/appcompose/src/main/java/com/readrops/app/compose/ComposeAppModule.kt index d4591007..33a93804 100644 --- a/appcompose/src/main/java/com/readrops/app/compose/ComposeAppModule.kt +++ b/appcompose/src/main/java/com/readrops/app/compose/ComposeAppModule.kt @@ -31,7 +31,7 @@ val composeAppModule = module { factory { (itemId: Int) -> ItemScreenModel(get(), itemId) } - factory { (accountType: AccountType) -> AccountCredentialsScreenModel(accountType, get()) } + factory { (accountType: AccountType) -> AccountCredentialsScreenModel(accountType, get(), androidContext()) } single { GetFoldersWithFeeds(get()) } diff --git a/appcompose/src/main/java/com/readrops/app/compose/account/AccountScreenModel.kt b/appcompose/src/main/java/com/readrops/app/compose/account/AccountScreenModel.kt index 92626199..8432d189 100644 --- a/appcompose/src/main/java/com/readrops/app/compose/account/AccountScreenModel.kt +++ b/appcompose/src/main/java/com/readrops/app/compose/account/AccountScreenModel.kt @@ -138,6 +138,8 @@ class AccountScreenModel( fun resetOPMLState() = _accountState.update { it.copy(opmlExportUri = null, opmlExportSuccess = false) } + + fun resetCloseHome() = _closeHome.update { false } } @Stable diff --git a/appcompose/src/main/java/com/readrops/app/compose/account/AccountTab.kt b/appcompose/src/main/java/com/readrops/app/compose/account/AccountTab.kt index da959ba5..af9d520a 100644 --- a/appcompose/src/main/java/com/readrops/app/compose/account/AccountTab.kt +++ b/appcompose/src/main/java/com/readrops/app/compose/account/AccountTab.kt @@ -80,6 +80,7 @@ object AccountTab : Tab { if (closeHome) { navigator.replaceAll(AccountSelectionScreen()) + screenModel.resetCloseHome() } val opmlImportLauncher = diff --git a/appcompose/src/main/java/com/readrops/app/compose/account/credentials/AccountCredentialsScreenModel.kt b/appcompose/src/main/java/com/readrops/app/compose/account/credentials/AccountCredentialsScreenModel.kt index 8d93c028..d9a46745 100644 --- a/appcompose/src/main/java/com/readrops/app/compose/account/credentials/AccountCredentialsScreenModel.kt +++ b/appcompose/src/main/java/com/readrops/app/compose/account/credentials/AccountCredentialsScreenModel.kt @@ -1,5 +1,6 @@ package com.readrops.app.compose.account.credentials +import android.content.Context import android.content.SharedPreferences import android.util.Patterns import cafe.adriel.voyager.core.model.StateScreenModel @@ -20,21 +21,20 @@ import org.koin.core.parameter.parametersOf class AccountCredentialsScreenModel( private val accountType: AccountType, private val database: Database, + private val context: Context, private val dispatcher: CoroutineDispatcher = Dispatchers.IO ) : StateScreenModel(AccountCredentialsState(name = accountType.name)), KoinComponent { + init { + mutableState.update { it.copy(name = context.resources.getString(accountType.typeName)) } + } + fun onEvent(event: Event): Unit = with(mutableState) { when (event) { is Event.LoginEvent -> update { it.copy(login = event.value, loginError = null) } is Event.NameEvent -> update { it.copy(name = event.value, nameError = null) } - is Event.PasswordEvent -> update { - it.copy( - password = event.value, - passwordError = null - ) - } - + is Event.PasswordEvent -> update { it.copy(password = event.value, passwordError = null) } is Event.URLEvent -> update { it.copy(url = event.value, urlError = null) } } }