mirror of https://github.com/readrops/Readrops.git
Fix some Account screens related issues
This commit is contained in:
parent
303d7b6786
commit
338e64eca8
|
@ -31,7 +31,7 @@ val composeAppModule = module {
|
||||||
|
|
||||||
factory { (itemId: Int) -> ItemScreenModel(get(), itemId) }
|
factory { (itemId: Int) -> ItemScreenModel(get(), itemId) }
|
||||||
|
|
||||||
factory { (accountType: AccountType) -> AccountCredentialsScreenModel(accountType, get()) }
|
factory { (accountType: AccountType) -> AccountCredentialsScreenModel(accountType, get(), androidContext()) }
|
||||||
|
|
||||||
single { GetFoldersWithFeeds(get()) }
|
single { GetFoldersWithFeeds(get()) }
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,8 @@ class AccountScreenModel(
|
||||||
|
|
||||||
fun resetOPMLState() =
|
fun resetOPMLState() =
|
||||||
_accountState.update { it.copy(opmlExportUri = null, opmlExportSuccess = false) }
|
_accountState.update { it.copy(opmlExportUri = null, opmlExportSuccess = false) }
|
||||||
|
|
||||||
|
fun resetCloseHome() = _closeHome.update { false }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Stable
|
@Stable
|
||||||
|
|
|
@ -80,6 +80,7 @@ object AccountTab : Tab {
|
||||||
|
|
||||||
if (closeHome) {
|
if (closeHome) {
|
||||||
navigator.replaceAll(AccountSelectionScreen())
|
navigator.replaceAll(AccountSelectionScreen())
|
||||||
|
screenModel.resetCloseHome()
|
||||||
}
|
}
|
||||||
|
|
||||||
val opmlImportLauncher =
|
val opmlImportLauncher =
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.readrops.app.compose.account.credentials
|
package com.readrops.app.compose.account.credentials
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.util.Patterns
|
import android.util.Patterns
|
||||||
import cafe.adriel.voyager.core.model.StateScreenModel
|
import cafe.adriel.voyager.core.model.StateScreenModel
|
||||||
|
@ -20,21 +21,20 @@ import org.koin.core.parameter.parametersOf
|
||||||
class AccountCredentialsScreenModel(
|
class AccountCredentialsScreenModel(
|
||||||
private val accountType: AccountType,
|
private val accountType: AccountType,
|
||||||
private val database: Database,
|
private val database: Database,
|
||||||
|
private val context: Context,
|
||||||
private val dispatcher: CoroutineDispatcher = Dispatchers.IO
|
private val dispatcher: CoroutineDispatcher = Dispatchers.IO
|
||||||
) : StateScreenModel<AccountCredentialsState>(AccountCredentialsState(name = accountType.name)),
|
) : StateScreenModel<AccountCredentialsState>(AccountCredentialsState(name = accountType.name)),
|
||||||
KoinComponent {
|
KoinComponent {
|
||||||
|
|
||||||
|
init {
|
||||||
|
mutableState.update { it.copy(name = context.resources.getString(accountType.typeName)) }
|
||||||
|
}
|
||||||
|
|
||||||
fun onEvent(event: Event): Unit = with(mutableState) {
|
fun onEvent(event: Event): Unit = with(mutableState) {
|
||||||
when (event) {
|
when (event) {
|
||||||
is Event.LoginEvent -> update { it.copy(login = event.value, loginError = null) }
|
is Event.LoginEvent -> update { it.copy(login = event.value, loginError = null) }
|
||||||
is Event.NameEvent -> update { it.copy(name = event.value, nameError = null) }
|
is Event.NameEvent -> update { it.copy(name = event.value, nameError = null) }
|
||||||
is Event.PasswordEvent -> update {
|
is Event.PasswordEvent -> update { it.copy(password = event.value, passwordError = null) }
|
||||||
it.copy(
|
|
||||||
password = event.value,
|
|
||||||
passwordError = null
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
is Event.URLEvent -> update { it.copy(url = event.value, urlError = null) }
|
is Event.URLEvent -> update { it.copy(url = event.value, urlError = null) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue