This commit is contained in:
Milan Cerovsky 2025-04-25 11:44:22 +02:00
parent 616f4cce13
commit b54a09dcff
4 changed files with 13 additions and 17 deletions

View File

@ -4,7 +4,9 @@ import co.electriccoin.zcash.preference.model.entry.BooleanPreferenceDefault
import co.electriccoin.zcash.preference.model.entry.NullableBooleanPreferenceDefault
import co.electriccoin.zcash.preference.model.entry.PreferenceKey
interface BooleanStorageProvider : StorageProvider<Boolean>
interface BooleanStorageProvider : StorageProvider<Boolean> {
suspend fun flip()
}
interface NullableBooleanStorageProvider : NullableStorageProvider<Boolean>
@ -14,6 +16,10 @@ abstract class BaseBooleanStorageProvider(
) : BaseStorageProvider<Boolean>(),
BooleanStorageProvider {
override val default = BooleanPreferenceDefault(key = key, defaultValue = default)
override suspend fun flip() {
store(!get())
}
}
abstract class BaseNullableBooleanStorageProvider(

View File

@ -1,30 +1,22 @@
package co.electriccoin.zcash.ui.common.usecase
import co.electriccoin.zcash.ui.common.datasource.AccountDataSource
import co.electriccoin.zcash.ui.common.repository.ConfigurationRepository
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
class GetCoinbaseStatusUseCase(
private val configurationRepository: ConfigurationRepository,
private val accountDataSource: AccountDataSource,
) {
@OptIn(ExperimentalCoroutinesApi::class)
fun observe() =
configurationRepository
.isCoinbaseAvailable
.filterNotNull()
.flatMapLatest { isAvailable ->
.map { isAvailable ->
if (isAvailable) {
accountDataSource.selectedAccount.map {
Status.ENABLED
}
Status.ENABLED
} else {
flowOf(Status.UNAVAILABLE)
Status.UNAVAILABLE
}
}.distinctUntilChanged()
}

View File

@ -55,9 +55,7 @@ class ShieldFundsInfoViewModel(
initialValue = null
)
private fun onCheckboxClick() = viewModelScope.launch {
shieldFundsInfoProvider.store(!shieldFundsInfoProvider.get())
}
private fun onCheckboxClick() = viewModelScope.launch { shieldFundsInfoProvider.flip() }
private fun onNotNowClick() = navigationRouter.back()

View File

@ -34,8 +34,8 @@
<string name="home_info_backup_message_1">Si pierdes acceso a la app o a tu dispositivo, conocer la Frase Secreta de Recuperación es la única forma de recuperar tus fondos. Nosotros no podemos verla ni ayudarte a recuperarla.</string>
<string name="home_info_backup_message_2">Cualquiera que tenga acceso a tu Frase Secreta de Recuperación tendrá control total de tu billetera, así que mantenla segura y no la compartas con nadie.</string>
<string name="home_info_backup_checkbox">He leído y entiendo los riesgos de no respaldar mi billetera.</string>
<string name="home_info_transparent_not_now">Not now</string>
<string name="home_info_transparent_checkbox">Do not show this message again.</string>
<string name="home_info_transparent_not_now">Ahora no</string>
<string name="home_info_transparent_checkbox">No mostrar este mensaje de nuevo.</string>
<string name="home_info_transparent_balance_shield">Proteger</string>
<string name="home_info_transparent_title">Siempre proteger fondos transparentes</string>
<string name="home_info_transparent_subtitle">Para proteger la privacidad del usuario, Zashi no permite gastar ZEC transparentes. Toca el botón "Proteger" para hacer que tus fondos transparentes se puedan usar y mantener tu saldo de Zashi privado.</string>