Fix some Account screens related issues

This commit is contained in:
Shinokuni 2024-06-02 17:14:57 +02:00
parent 303d7b6786
commit 338e64eca8
4 changed files with 11 additions and 8 deletions

View File

@ -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()) }

View File

@ -138,6 +138,8 @@ class AccountScreenModel(
fun resetOPMLState() =
_accountState.update { it.copy(opmlExportUri = null, opmlExportSuccess = false) }
fun resetCloseHome() = _closeHome.update { false }
}
@Stable

View File

@ -80,6 +80,7 @@ object AccountTab : Tab {
if (closeHome) {
navigator.replaceAll(AccountSelectionScreen())
screenModel.resetCloseHome()
}
val opmlImportLauncher =

View File

@ -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>(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) }
}
}