Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duress pin additions2 #6661

Merged
merged 4 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package io.horizontalsystems.bankwallet.modules.pin
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
Expand Down Expand Up @@ -73,7 +72,7 @@ fun SetDuressPinIntroScreen(navController: NavController) {
) {
InfoText(
text = stringResource(R.string.DuressPin_Description),
paddingValues = PaddingValues(32.dp, 12.dp, 32.dp, 32.dp)
paddingBottom = 32.dp
)
HeaderText(text = stringResource(R.string.DuressPin_Notes))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.horizontalsystems.bankwallet.modules.pin

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
Expand Down Expand Up @@ -85,7 +85,7 @@ fun SetDuressPinSelectAccountsScreen(navController: NavController) {
) {
InfoText(
text = stringResource(R.string.DuressPinSelectAccounts_Description),
paddingValues = PaddingValues(32.dp, 12.dp, 32.dp, 32.dp)
paddingBottom = 32.dp
)

if (regularAccounts.isNotEmpty()) {
Expand Down Expand Up @@ -127,12 +127,17 @@ private fun ItemsSection(
title: String,
items: List<Account>,
selected: SnapshotStateList<String>,
function: (Account, Boolean) -> Unit,
onToggle: (Account, Boolean) -> Unit,
) {
HeaderText(text = title)
CellUniversalLawrenceSection(items) { account ->
val checked = selected.contains(account.id)
RowUniversal(
modifier = Modifier.padding(horizontal = 16.dp)
modifier = Modifier
.padding(horizontal = 16.dp)
.clickable {
onToggle.invoke(account, !checked)
}
) {
Column {
body_leah(text = account.name)
Expand All @@ -149,9 +154,9 @@ private fun ItemsSection(
}
HFillSpacer(minWidth = 8.dp)
HsCheckbox(
checked = selected.contains(account.id),
checked = checked,
onCheckedChange = {
function.invoke(account, it)
onToggle.invoke(account, it)
},
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ import androidx.compose.material.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.lifecycle.viewmodel.compose.viewModel
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.modules.pin.unlock.PinConfirmViewModel
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.components.AppBar
import io.horizontalsystems.bankwallet.ui.compose.components.HsBackButton
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_lucian

@Composable
fun PinConfirm(
Expand Down Expand Up @@ -47,20 +44,7 @@ fun PinConfirm(
) {
PinTopBlock(
modifier = Modifier.weight(1f),
title = {
val error = viewModel.uiState.error
if (error != null) {
subhead2_lucian(
text = error,
textAlign = TextAlign.Center
)
} else {
subhead2_grey(
text = stringResource(R.string.Unlock_EnterPasscode),
textAlign = TextAlign.Center
)
}
},
title = stringResource(R.string.Unlock_EnterPasscode),
enteredCount = viewModel.uiState.enteredCount,
showShakeAnimation = viewModel.uiState.showShakeAnimation,
inputState = viewModel.uiState.inputState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.compose.material.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.lifecycle.viewmodel.compose.viewModel
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.modules.pin.set.PinSetModule
Expand All @@ -17,8 +16,6 @@ import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.animations.CrossSlide
import io.horizontalsystems.bankwallet.ui.compose.components.AppBar
import io.horizontalsystems.bankwallet.ui.compose.components.HsBackButton
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_lucian

@Composable
fun PinSet(
Expand Down Expand Up @@ -59,31 +56,14 @@ fun PinSet(
when (stage) {
PinSetModule.SetStage.Enter -> {
PinTopBlock(
title = {
val error = viewModel.uiState.error
if (error != null) {
subhead2_lucian(
text = error,
textAlign = TextAlign.Center
)
} else {
subhead2_grey(
text = description,
textAlign = TextAlign.Center
)
}
},
title = description,
error = viewModel.uiState.error,
enteredCount = viewModel.uiState.enteredCount,
)
}
PinSetModule.SetStage.Confirm -> {
PinTopBlock(
title = {
subhead2_grey(
text = stringResource(R.string.PinSet_ConfirmInfo),
textAlign = TextAlign.Center
)
},
title = stringResource(R.string.PinSet_ConfirmInfo),
enteredCount = viewModel.uiState.enteredCount,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
Expand All @@ -19,21 +18,23 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.modules.pin.PinModule
import io.horizontalsystems.bankwallet.modules.pin.unlock.PinUnlockModule.InputState
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.animations.shake
import io.horizontalsystems.bankwallet.ui.compose.components.headline1_leah
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_jacob
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_lucian

@Composable
fun PinTopBlock(
modifier: Modifier = Modifier,
title: @Composable ColumnScope.() -> Unit,
title: String,
error: String? = null,
enteredCount: Int,
showShakeAnimation: Boolean = false,
inputState: InputState = InputState.Enabled(),
Expand All @@ -51,7 +52,16 @@ fun PinTopBlock(
modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.Bottom
) {
title()
if (error != null) {
subhead2_lucian(
text = error,
)
} else {
subhead2_grey(
text = title,
textAlign = TextAlign.Center
)
}
Spacer(Modifier.height(16.dp))
}

Expand Down Expand Up @@ -121,7 +131,7 @@ fun Preview_PinTopBlockEnabled() {
.background(color = ComposeAppTheme.colors.tyler)
) {
PinTopBlock(
title = { headline1_leah(text = "text") },
title = "text",
enteredCount = 3,
showShakeAnimation = false,
)
Expand All @@ -138,7 +148,7 @@ fun Preview_PinTopBlockLocked() {
.background(color = ComposeAppTheme.colors.tyler)
) {
PinTopBlock(
title = { headline1_leah(text = "text") },
title = "text",
enteredCount = 3,
showShakeAnimation = false,
inputState = InputState.Locked("12:33")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.modules.pin.unlock.PinUnlockModule
import io.horizontalsystems.bankwallet.modules.pin.unlock.PinUnlockViewModel
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_lucian
import io.horizontalsystems.bankwallet.ui.compose.components.title3_leah

@Composable
Expand Down Expand Up @@ -92,14 +90,7 @@ fun PinUnlock(
) {
PinTopBlock(
modifier = Modifier.weight(1f),
title = {
val error = uiState.error
if (error != null) {
subhead2_lucian(text = error)
} else {
subhead2_grey(text = stringResource(R.string.Unlock_EnterPasscode),)
}
},
title = stringResource(R.string.Unlock_EnterPasscode),
enteredCount = uiState.enteredCount,
showShakeAnimation = uiState.showShakeAnimation,
inputState = uiState.inputState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.App
import io.horizontalsystems.bankwallet.core.providers.Translator
import io.horizontalsystems.bankwallet.modules.pin.PinModule
import io.horizontalsystems.bankwallet.modules.pin.core.ILockoutManager
import io.horizontalsystems.bankwallet.modules.pin.core.LockoutManager
Expand All @@ -34,7 +32,6 @@ class PinConfirmViewModel(

var uiState by mutableStateOf(
PinConfirmViewState(
error = null,
enteredCount = 0,
unlocked = false,
showShakeAnimation = false,
Expand All @@ -59,7 +56,6 @@ class PinConfirmViewModel(

enteredPin += number.toString()
uiState = uiState.copy(
error = null,
enteredCount = enteredPin.length
)

Expand All @@ -68,7 +64,6 @@ class PinConfirmViewModel(
uiState = uiState.copy(unlocked = true)
} else {
uiState = uiState.copy(
error = Translator.getString(R.string.Unlock_Incorrect),
showShakeAnimation = true
)
viewModelScope.launch {
Expand All @@ -88,7 +83,6 @@ class PinConfirmViewModel(
if (enteredPin.isNotEmpty()) {
enteredPin = enteredPin.dropLast(1)
uiState = uiState.copy(
error = null,
enteredCount = enteredPin.length,
showShakeAnimation = false
)
Expand Down Expand Up @@ -152,7 +146,6 @@ class PinConfirmViewModel(
}

data class PinConfirmViewState(
val error: String?,
val enteredCount: Int,
val unlocked: Boolean,
val showShakeAnimation: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ object PinUnlockModule {
}

data class PinUnlockViewState(
val error: String?,
val enteredCount: Int,
val fingerScannerEnabled: Boolean,
val unlocked: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.providers.Translator
import io.horizontalsystems.bankwallet.modules.pin.PinModule
import io.horizontalsystems.bankwallet.modules.pin.core.ILockoutManager
import io.horizontalsystems.bankwallet.modules.pin.core.LockoutState
Expand All @@ -30,7 +28,6 @@ class PinUnlockViewModel(

var uiState by mutableStateOf(
PinUnlockViewState(
error = null,
enteredCount = 0,
fingerScannerEnabled = systemInfoManager.biometricAuthSupported && pinComponent.isBiometricAuthEnabled,
unlocked = false,
Expand Down Expand Up @@ -62,7 +59,6 @@ class PinUnlockViewModel(

enteredPin += number.toString()
uiState = uiState.copy(
error = null,
enteredCount = enteredPin.length
)

Expand All @@ -71,7 +67,6 @@ class PinUnlockViewModel(
uiState = uiState.copy(unlocked = true)
} else {
uiState = uiState.copy(
error = Translator.getString(R.string.Unlock_Incorrect),
showShakeAnimation = true
)
viewModelScope.launch {
Expand All @@ -91,7 +86,6 @@ class PinUnlockViewModel(
if (enteredPin.isNotEmpty()) {
enteredPin = enteredPin.dropLast(1)
uiState = uiState.copy(
error = null,
enteredCount = enteredPin.length,
showShakeAnimation = false
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.horizontalsystems.bankwallet.modules.settings.security

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.defaultMinSize
Expand Down Expand Up @@ -177,7 +176,7 @@ private fun SecurityCenterScreen(
}
InfoText(
text = stringResource(R.string.Appearance_BalanceAutoHide_Description),
paddingValues = PaddingValues(start = 32.dp, top = 12.dp, end = 32.dp, bottom = 32.dp)
paddingBottom = 32.dp
)

TorBlock(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.horizontalsystems.bankwallet.modules.settings.security.ui

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.size
import androidx.compose.material.Icon
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -58,6 +57,6 @@ fun TorBlock(

InfoText(
text = stringResource(R.string.SettingsSecurity_TorConnectionDescription),
paddingValues = PaddingValues(start = 32.dp, top = 12.dp, end = 32.dp, bottom = 32.dp)
paddingBottom = 32.dp
)
}
Loading