#1420 Code cleanup

Closes #1420
This commit is contained in:
Milan Cerovsky 2024-09-05 12:05:20 +02:00
parent db652d6a39
commit 95ac835b9c
15 changed files with 307 additions and 293 deletions

View File

@ -27,7 +27,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.testTag import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.Role import androidx.compose.ui.semantics.Role
@ -52,22 +51,22 @@ fun RadioButton(
) { ) {
Row( Row(
modifier = modifier =
modifier modifier
.clip(RoundedCornerShape(12.dp)) .clip(RoundedCornerShape(12.dp))
.clickable( .clickable(
indication = rememberRipple(), indication = rememberRipple(),
interactionSource = remember { MutableInteractionSource() }, interactionSource = remember { MutableInteractionSource() },
onClick = state.onClick, onClick = state.onClick,
role = Role.Button, role = Role.Button,
) )
.padding(horizontal = 20.dp) .padding(horizontal = 20.dp)
.then( .then(
if (testTag != null) { if (testTag != null) {
Modifier.testTag(testTag) Modifier.testTag(testTag)
} else { } else {
Modifier Modifier
} }
), ),
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween horizontalArrangement = Arrangement.SpaceBetween
) { ) {
@ -84,12 +83,12 @@ fun RadioButton(
style = ZcashTheme.extendedTypography.radioButton, style = ZcashTheme.extendedTypography.radioButton,
color = ZcashTheme.colors.textPrimary, color = ZcashTheme.colors.textPrimary,
modifier = modifier =
Modifier.padding( Modifier.padding(
top = 14.dp, top = 14.dp,
bottom = if (state.subtitle == null) 14.dp else 0.dp, bottom = if (state.subtitle == null) 14.dp else 0.dp,
start = 0.dp, start = 0.dp,
end = ZcashTheme.dimens.spacingDefault end = ZcashTheme.dimens.spacingDefault
) )
) )
if (state.subtitle != null) { if (state.subtitle != null) {
@ -99,11 +98,11 @@ fun RadioButton(
fontWeight = FontWeight.Normal, fontWeight = FontWeight.Normal,
color = ZcashTheme.zashiColors.textTertiary, color = ZcashTheme.zashiColors.textTertiary,
modifier = modifier =
Modifier.padding( Modifier.padding(
bottom = 6.dp, bottom = 6.dp,
start = 0.dp, start = 0.dp,
end = ZcashTheme.dimens.spacingDefault end = ZcashTheme.dimens.spacingDefault
) )
) )
} }
} }
@ -161,29 +160,30 @@ data class RadioButtonState(
@Suppress("UnusedPrivateMember") @Suppress("UnusedPrivateMember")
@PreviewScreens @PreviewScreens
@Composable @Composable
private fun RadioButtonPreview() = ZcashTheme { private fun RadioButtonPreview() =
BlankBgColumn { ZcashTheme {
var isChecked by remember { mutableStateOf(false) } BlankBgColumn {
var isChecked by remember { mutableStateOf(false) }
RadioButton( RadioButton(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
state = state =
RadioButtonState( RadioButtonState(
text = stringRes("test"), text = stringRes("test"),
isChecked = isChecked, isChecked = isChecked,
onClick = { isChecked = !isChecked }, onClick = { isChecked = !isChecked },
), ),
trailingContent = { trailingContent = {
Text(text = "Trailing text") Text(text = "Trailing text")
} }
) )
RadioButton( RadioButton(
state = state =
RadioButtonState( RadioButtonState(
text = stringRes("test"), text = stringRes("test"),
isChecked = true, isChecked = true,
onClick = {}, onClick = {},
), ),
) )
}
} }
}

View File

@ -193,8 +193,11 @@ class WalletRepositoryImpl(
// complete quickly, it isn't guaranteed to complete before persistExistingWallet() // complete quickly, it isn't guaranteed to complete before persistExistingWallet()
// unless a mutex is used here. // unless a mutex is used here.
persistWalletMutex.withLock { persistWalletMutex.withLock {
StandardPreferenceKeys.ONBOARDING_STATE.putValue(standardPreferenceProvider(), onboardingState StandardPreferenceKeys.ONBOARDING_STATE.putValue(
.toNumber()) standardPreferenceProvider(),
onboardingState
.toNumber()
)
} }
} }
} }

View File

@ -100,18 +100,16 @@ class WalletViewModel(
private val standardPreferenceProvider: StandardPreferenceProvider, private val standardPreferenceProvider: StandardPreferenceProvider,
private val getAvailableServers: GetDefaultServersProvider private val getAvailableServers: GetDefaultServersProvider
) : AndroidViewModel(application) { ) : AndroidViewModel(application) {
/* /*
* Using the Mutex may be overkill, but it ensures that if multiple calls are accidentally made * Using the Mutex may be overkill, but it ensures that if multiple calls are accidentally made
* that they have a consistent ordering. * that they have a consistent ordering.
*/ */
private val persistWalletMutex = Mutex() private val persistWalletMutex = Mutex()
val navigationCommand = MutableSharedFlow<String>() val navigationCommand = MutableSharedFlow<String>()
val backNavigationCommand = MutableSharedFlow<Unit>() val backNavigationCommand = MutableSharedFlow<Unit>()
/** /**
* Synchronizer that is retained long enough to survive configuration changes. * Synchronizer that is retained long enough to survive configuration changes.
*/ */
@ -419,11 +417,10 @@ class WalletViewModel(
) )
} }
else -> {
else -> { BalanceState.Available(
BalanceState.Available( totalBalance = snapshot.totalBalance(),
totalBalance = snapshot.totalBalance(), spendableBalance = snapshot.spendableBalance(),
spendableBalance = snapshot.spendableBalance(),
exchangeRate = exchangeRateUsd exchangeRate = exchangeRateUsd
) )
} }

View File

@ -41,6 +41,7 @@ import co.electriccoin.zcash.ui.common.wallet.ExchangeRateState
import co.electriccoin.zcash.ui.design.component.BlankBgScaffold import co.electriccoin.zcash.ui.design.component.BlankBgScaffold
import co.electriccoin.zcash.ui.design.component.SmallTopAppBar import co.electriccoin.zcash.ui.design.component.SmallTopAppBar
import co.electriccoin.zcash.ui.design.component.TopAppBarHideBalancesNavigation import co.electriccoin.zcash.ui.design.component.TopAppBarHideBalancesNavigation
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
import co.electriccoin.zcash.ui.design.theme.ZcashTheme import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.fixture.BalanceStateFixture import co.electriccoin.zcash.ui.fixture.BalanceStateFixture
import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture
@ -49,7 +50,6 @@ import co.electriccoin.zcash.ui.screen.account.fixture.TransactionsFixture
import co.electriccoin.zcash.ui.screen.account.model.TransactionUiState import co.electriccoin.zcash.ui.screen.account.model.TransactionUiState
import co.electriccoin.zcash.ui.screen.balances.model.StatusAction import co.electriccoin.zcash.ui.screen.balances.model.StatusAction
import co.electriccoin.zcash.ui.screen.exchangerate.widget.StyledExchangeOptIn import co.electriccoin.zcash.ui.screen.exchangerate.widget.StyledExchangeOptIn
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
import kotlinx.datetime.Clock import kotlinx.datetime.Clock
@Suppress("UnusedPrivateMember") @Suppress("UnusedPrivateMember")

View File

@ -35,7 +35,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate import androidx.compose.ui.draw.rotate
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.testTag import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
@ -98,10 +97,10 @@ fun ChooseServerView(
LazyColumn( LazyColumn(
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
contentPadding = contentPadding =
PaddingValues( PaddingValues(
top = paddingValues.calculateTopPadding() + ZcashTheme.dimens.spacingDefault, top = paddingValues.calculateTopPadding() + ZcashTheme.dimens.spacingDefault,
bottom = paddingValues.calculateBottomPadding() + ZcashTheme.dimens.spacingDefault, bottom = paddingValues.calculateBottomPadding() + ZcashTheme.dimens.spacingDefault,
) )
) { ) {
if (state.fastest.servers.isEmpty() && state.fastest.isLoading) { if (state.fastest.servers.isEmpty() && state.fastest.isLoading) {
item { item {
@ -127,9 +126,9 @@ fun ChooseServerView(
private fun ServerLoading() { private fun ServerLoading() {
Column( Column(
modifier = modifier =
Modifier Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(16.dp), .padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
LottieProgress( LottieProgress(
@ -190,9 +189,9 @@ fun ChooseServerBottomBar(saveButtonState: ButtonState) {
ZashiButton( ZashiButton(
state = saveButtonState, state = saveButtonState,
modifier = modifier =
Modifier Modifier
.padding(horizontal = 24.dp) .padding(horizontal = 24.dp)
.fillMaxWidth() .fillMaxWidth()
) )
} }
} }
@ -205,11 +204,11 @@ private fun ChooseServerTopAppBar(
SmallTopAppBar( SmallTopAppBar(
titleText = stringResource(id = R.string.choose_server_title), titleText = stringResource(id = R.string.choose_server_title),
subTitle = subTitle =
when (subTitleState) { when (subTitleState) {
TopAppBarSubTitleState.Disconnected -> stringResource(id = R.string.disconnected_label) TopAppBarSubTitleState.Disconnected -> stringResource(id = R.string.disconnected_label)
TopAppBarSubTitleState.Restoring -> stringResource(id = R.string.restoring_wallet_label) TopAppBarSubTitleState.Restoring -> stringResource(id = R.string.restoring_wallet_label)
TopAppBarSubTitleState.None -> null TopAppBarSubTitleState.None -> null
}, },
modifier = Modifier.testTag(CHOOSE_SERVER_TOP_APP_BAR), modifier = Modifier.testTag(CHOOSE_SERVER_TOP_APP_BAR),
showTitleLogo = true, showTitleLogo = true,
navigationAction = { navigationAction = {
@ -239,16 +238,16 @@ private fun LazyListScope.serverListItems(state: ServerListState) {
is ServerState.Custom -> is ServerState.Custom ->
CustomServerRadioButton( CustomServerRadioButton(
modifier = modifier =
Modifier Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(start = 4.dp, end = 4.dp) .padding(start = 4.dp, end = 4.dp)
.then( .then(
if (item.radioButtonState.isChecked) { if (item.radioButtonState.isChecked) {
Modifier.background(ZcashTheme.zashiColors.bgSecondary, RoundedCornerShape(12.dp)) Modifier.background(ZcashTheme.zashiColors.bgSecondary, RoundedCornerShape(12.dp))
} else { } else {
Modifier Modifier
} }
), ),
state = item state = item
) )
@ -256,28 +255,30 @@ private fun LazyListScope.serverListItems(state: ServerListState) {
RadioButton( RadioButton(
state = item.radioButtonState, state = item.radioButtonState,
modifier = modifier =
Modifier Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 4.dp) .padding(horizontal = 4.dp)
.then( .then(
if (item.radioButtonState.isChecked && item.badge == null) { if (item.radioButtonState.isChecked && item.badge == null) {
Modifier.background(ZcashTheme.zashiColors.bgSecondary, RoundedCornerShape(12.dp)) Modifier.background(ZcashTheme.zashiColors.bgSecondary, RoundedCornerShape(12.dp))
} else { } else {
Modifier Modifier
} }
), ),
checkedContent = { checkedContent = {
if (item.badge == null) { if (item.badge == null) {
RadioButtonCheckedContent(item.radioButtonState) RadioButtonCheckedContent(item.radioButtonState)
} else { } else {
Image( Image(
painter = painterResource( painter =
id = if (isSystemInDarkTheme()) { painterResource(
drawable.ic_radio_button_checked_variant_dark id =
} else { if (isSystemInDarkTheme()) {
drawable.ic_radio_button_checked_variant drawable.ic_radio_button_checked_variant_dark
} } else {
), drawable.ic_radio_button_checked_variant
}
),
contentDescription = item.radioButtonState.text.getValue(), contentDescription = item.radioButtonState.text.getValue(),
) )
} }
@ -386,13 +387,13 @@ private fun CustomServerRadioButton(
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus(true) }), keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus(true) }),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri, imeAction = ImeAction.Done), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri, imeAction = ImeAction.Done),
modifier = modifier =
Modifier Modifier
.fillMaxWidth() .fillMaxWidth()
.padding( .padding(
start = 52.dp, start = 52.dp,
end = 20.dp, end = 20.dp,
bottom = 16.dp bottom = 16.dp
) )
) )
} }
} }
@ -409,57 +410,8 @@ private fun ChooseServerPreview(
ServerListState.Fastest( ServerListState.Fastest(
title = stringRes("Fastest Servers"), title = stringRes("Fastest Servers"),
servers = servers =
if (showFastestServerLoading) { if (showFastestServerLoading) {
(1..3).map { (1..3).map {
ServerState.Default(
RadioButtonState(
text = stringRes("Some Server"),
isChecked = selectionIndex == it,
onClick = {
selectionIndex = it
},
subtitle = null,
),
badge = null
)
}
} else {
listOf()
},
retryButton =
ButtonState(
text = stringRes("Save Button"),
onClick = {},
),
isLoading = true,
)
ChooseServerView(
state =
ChooseServerState(
fastest = fastestServers,
other =
ServerListState.Other(
title = stringRes("Other Servers"),
servers =
(4..<12).map {
if (it == 5) {
ServerState.Custom(
RadioButtonState(
text = stringRes("Custom Server"),
isChecked = selectionIndex == it,
onClick = {
selectionIndex = it
}
),
newServerTextFieldState =
TextFieldState(
value = stringRes(""),
error = null,
isEnabled = true,
onValueChange = { },
),
)
} else {
ServerState.Default( ServerState.Default(
RadioButtonState( RadioButtonState(
text = stringRes("Some Server"), text = stringRes("Some Server"),
@ -467,20 +419,69 @@ private fun ChooseServerPreview(
onClick = { onClick = {
selectionIndex = it selectionIndex = it
}, },
subtitle = if (it == 6) stringRes("Default") else null, subtitle = null,
), ),
badge = if (it == 6) stringRes("Active") else null, badge = null
) )
} }
} } else {
listOf()
},
retryButton =
ButtonState(
text = stringRes("Save Button"),
onClick = {},
),
isLoading = true,
)
ChooseServerView(
state =
ChooseServerState(
fastest = fastestServers,
other =
ServerListState.Other(
title = stringRes("Other Servers"),
servers =
(4..<12).map {
if (it == 5) {
ServerState.Custom(
RadioButtonState(
text = stringRes("Custom Server"),
isChecked = selectionIndex == it,
onClick = {
selectionIndex = it
}
),
newServerTextFieldState =
TextFieldState(
value = stringRes(""),
error = null,
isEnabled = true,
onValueChange = { },
),
)
} else {
ServerState.Default(
RadioButtonState(
text = stringRes("Some Server"),
isChecked = selectionIndex == it,
onClick = {
selectionIndex = it
},
subtitle = if (it == 6) stringRes("Default") else null,
),
badge = if (it == 6) stringRes("Active") else null,
)
}
}
),
saveButton =
ButtonState(
text = stringRes("Save Button"),
onClick = {},
),
dialogState = dialogState
), ),
saveButton =
ButtonState(
text = stringRes("Save Button"),
onClick = {},
),
dialogState = dialogState
),
onBack = {}, onBack = {},
topAppBarSubTitleState = TopAppBarSubTitleState.None, topAppBarSubTitleState = TopAppBarSubTitleState.None,
) )
@ -493,14 +494,14 @@ private fun ChooseServerPreviewValidationDialog() =
ZcashTheme { ZcashTheme {
ChooseServerPreview( ChooseServerPreview(
dialogState = dialogState =
ServerDialogState.Validation( ServerDialogState.Validation(
state = state =
AlertDialogState( AlertDialogState(
title = stringRes("title"), title = stringRes("title"),
text = stringRes("text"), text = stringRes("text"),
), ),
reason = stringRes("reason") reason = stringRes("reason")
) )
) )
} }

View File

@ -15,9 +15,9 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import co.electriccoin.zcash.ui.design.component.ButtonState import co.electriccoin.zcash.ui.design.component.ButtonState
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
import co.electriccoin.zcash.ui.design.theme.ZcashTheme import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.design.util.stringRes import co.electriccoin.zcash.ui.design.util.stringRes
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
@Composable @Composable
fun BottomBar( fun BottomBar(
@ -48,9 +48,9 @@ private fun BottomBarPreview() =
ZashiButton( ZashiButton(
state = ButtonState(text = stringRes("Save Button")), state = ButtonState(text = stringRes("Save Button")),
modifier = modifier =
Modifier Modifier
.padding(horizontal = 24.dp) .padding(horizontal = 24.dp)
.fillMaxWidth() .fillMaxWidth()
) )
} }
} }

View File

@ -48,25 +48,27 @@ internal fun ZashiButton(
colors: ButtonColors = ZashiButtonDefaults.primaryButtonColors(), colors: ButtonColors = ZashiButtonDefaults.primaryButtonColors(),
content: @Composable RowScope.(ZashiButtonScope) -> Unit = ZashiButtonDefaults.content content: @Composable RowScope.(ZashiButtonScope) -> Unit = ZashiButtonDefaults.content
) { ) {
val scope = object : ZashiButtonScope { val scope =
@Composable object : ZashiButtonScope {
override fun Text() { @Composable
Text(text = text) override fun Text() {
} Text(text = text)
}
@Composable @Composable
override fun Loading() { override fun Loading() {
if (enabled && isLoading) { if (enabled && isLoading) {
LottieProgress( LottieProgress(
loadingRes = if (isSystemInDarkTheme()) { loadingRes =
R.raw.lottie_loading if (isSystemInDarkTheme()) {
} else { R.raw.lottie_loading
R.raw.lottie_loading_white } else {
} R.raw.lottie_loading_white
) }
)
}
} }
} }
}
Button( Button(
onClick = onClick, onClick = onClick,
@ -89,7 +91,6 @@ interface ZashiButtonScope {
} }
object ZashiButtonDefaults { object ZashiButtonDefaults {
val content: @Composable RowScope.(ZashiButtonScope) -> Unit val content: @Composable RowScope.(ZashiButtonScope) -> Unit
get() = { scope -> get() = { scope ->
scope.Text() scope.Text()

View File

@ -64,11 +64,13 @@ fun ZashiTextField(
TextFieldInternal( TextFieldInternal(
value = state.value.getValue(), value = state.value.getValue(),
onValueChange = state.onValueChange, onValueChange = state.onValueChange,
modifier = modifier then Modifier.border( modifier =
width = 1.dp, modifier then
color = ZcashTheme.zashiColors.stroke, Modifier.border(
shape = ZashiTextFieldDefaults.shape width = 1.dp,
), color = ZcashTheme.zashiColors.stroke,
shape = ZashiTextFieldDefaults.shape
),
enabled = state.isEnabled, enabled = state.isEnabled,
readOnly = readOnly, readOnly = readOnly,
textStyle = textStyle, textStyle = textStyle,
@ -121,16 +123,18 @@ private fun TextFieldInternal(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
// If color is not provided via the text style, use content color as a default // If color is not provided via the text style, use content color as a default
val textColor = textStyle.color.takeOrElse { val textColor =
colors.textColor(enabled, isError, interactionSource).value textStyle.color.takeOrElse {
} colors.textColor(enabled, isError, interactionSource).value
}
val mergedTextStyle = textStyle.merge(TextStyle(color = textColor)) val mergedTextStyle = textStyle.merge(TextStyle(color = textColor))
CompositionLocalProvider(LocalTextSelectionColors provides colors.selectionColors) { CompositionLocalProvider(LocalTextSelectionColors provides colors.selectionColors) {
BasicTextField( BasicTextField(
value = value, value = value,
modifier = modifier modifier =
.defaultMinSize(minWidth = TextFieldDefaults.MinWidth), modifier
.defaultMinSize(minWidth = TextFieldDefaults.MinWidth),
onValueChange = onValueChange, onValueChange = onValueChange,
enabled = enabled, enabled = enabled,
readOnly = readOnly, readOnly = readOnly,
@ -177,12 +181,13 @@ private fun TextFieldColors.textColor(
): State<Color> { ): State<Color> {
val focused by interactionSource.collectIsFocusedAsState() val focused by interactionSource.collectIsFocusedAsState()
val targetValue = when { val targetValue =
!enabled -> disabledTextColor when {
isError -> errorTextColor !enabled -> disabledTextColor
focused -> focusedTextColor isError -> errorTextColor
else -> unfocusedTextColor focused -> focusedTextColor
} else -> unfocusedTextColor
}
return rememberUpdatedState(targetValue) return rememberUpdatedState(targetValue)
} }
@ -195,7 +200,6 @@ internal fun TextFieldColors.cursorColor(isError: Boolean): State<Color> {
} }
object ZashiTextFieldDefaults { object ZashiTextFieldDefaults {
val shape: Shape val shape: Shape
get() = RoundedCornerShape(8.dp) get() = RoundedCornerShape(8.dp)
@ -206,21 +210,24 @@ object ZashiTextFieldDefaults {
unfocusedTextColor: Color = ZcashTheme.zashiColors.textPrimary, unfocusedTextColor: Color = ZcashTheme.zashiColors.textPrimary,
disabledTextColor: Color = ZcashTheme.zashiColors.textPrimary, disabledTextColor: Color = ZcashTheme.zashiColors.textPrimary,
errorTextColor: Color = Color.Unspecified, errorTextColor: Color = Color.Unspecified,
focusedContainerColor: Color = if (isSystemInDarkTheme()) { focusedContainerColor: Color =
ZcashTheme.zashiColors.bgSecondary if (isSystemInDarkTheme()) {
} else { ZcashTheme.zashiColors.bgSecondary
ZcashTheme.zashiColors.bgPrimary } else {
}, ZcashTheme.zashiColors.bgPrimary
unfocusedContainerColor: Color = if (isSystemInDarkTheme()) { },
ZcashTheme.zashiColors.bgSecondary unfocusedContainerColor: Color =
} else { if (isSystemInDarkTheme()) {
ZcashTheme.zashiColors.bgPrimary ZcashTheme.zashiColors.bgSecondary
}, } else {
disabledContainerColor: Color = if (isSystemInDarkTheme()) { ZcashTheme.zashiColors.bgPrimary
ZcashTheme.zashiColors.bgSecondary },
} else { disabledContainerColor: Color =
ZcashTheme.zashiColors.bgPrimary if (isSystemInDarkTheme()) {
}, ZcashTheme.zashiColors.bgSecondary
} else {
ZcashTheme.zashiColors.bgPrimary
},
errorContainerColor: Color = Color.Unspecified, errorContainerColor: Color = Color.Unspecified,
cursorColor: Color = Color.Unspecified, cursorColor: Color = Color.Unspecified,
errorCursorColor: Color = Color.Unspecified, errorCursorColor: Color = Color.Unspecified,
@ -257,60 +264,63 @@ object ZashiTextFieldDefaults {
unfocusedSuffixColor: Color = Color.Unspecified, unfocusedSuffixColor: Color = Color.Unspecified,
disabledSuffixColor: Color = Color.Unspecified, disabledSuffixColor: Color = Color.Unspecified,
errorSuffixColor: Color = Color.Unspecified, errorSuffixColor: Color = Color.Unspecified,
): TextFieldColors = TextFieldDefaults.colors( ): TextFieldColors =
focusedTextColor = focusedTextColor, TextFieldDefaults.colors(
unfocusedTextColor = unfocusedTextColor, focusedTextColor = focusedTextColor,
disabledTextColor = disabledTextColor, unfocusedTextColor = unfocusedTextColor,
errorTextColor = errorTextColor, disabledTextColor = disabledTextColor,
focusedContainerColor = focusedContainerColor, errorTextColor = errorTextColor,
unfocusedContainerColor = unfocusedContainerColor, focusedContainerColor = focusedContainerColor,
disabledContainerColor = disabledContainerColor, unfocusedContainerColor = unfocusedContainerColor,
errorContainerColor = errorContainerColor, disabledContainerColor = disabledContainerColor,
cursorColor = cursorColor, errorContainerColor = errorContainerColor,
errorCursorColor = errorCursorColor, cursorColor = cursorColor,
selectionColors = selectionColors, errorCursorColor = errorCursorColor,
focusedIndicatorColor = focusedIndicatorColor, selectionColors = selectionColors,
unfocusedIndicatorColor = unfocusedIndicatorColor, focusedIndicatorColor = focusedIndicatorColor,
disabledIndicatorColor = disabledIndicatorColor, unfocusedIndicatorColor = unfocusedIndicatorColor,
errorIndicatorColor = errorIndicatorColor, disabledIndicatorColor = disabledIndicatorColor,
focusedLeadingIconColor = focusedLeadingIconColor, errorIndicatorColor = errorIndicatorColor,
unfocusedLeadingIconColor = unfocusedLeadingIconColor, focusedLeadingIconColor = focusedLeadingIconColor,
disabledLeadingIconColor = disabledLeadingIconColor, unfocusedLeadingIconColor = unfocusedLeadingIconColor,
errorLeadingIconColor = errorLeadingIconColor, disabledLeadingIconColor = disabledLeadingIconColor,
focusedTrailingIconColor = focusedTrailingIconColor, errorLeadingIconColor = errorLeadingIconColor,
unfocusedTrailingIconColor = unfocusedTrailingIconColor, focusedTrailingIconColor = focusedTrailingIconColor,
disabledTrailingIconColor = disabledTrailingIconColor, unfocusedTrailingIconColor = unfocusedTrailingIconColor,
errorTrailingIconColor = errorTrailingIconColor, disabledTrailingIconColor = disabledTrailingIconColor,
focusedLabelColor = focusedLabelColor, errorTrailingIconColor = errorTrailingIconColor,
unfocusedLabelColor = unfocusedLabelColor, focusedLabelColor = focusedLabelColor,
disabledLabelColor = disabledLabelColor, unfocusedLabelColor = unfocusedLabelColor,
errorLabelColor = errorLabelColor, disabledLabelColor = disabledLabelColor,
focusedPlaceholderColor = focusedPlaceholderColor, errorLabelColor = errorLabelColor,
unfocusedPlaceholderColor = unfocusedPlaceholderColor, focusedPlaceholderColor = focusedPlaceholderColor,
disabledPlaceholderColor = disabledPlaceholderColor, unfocusedPlaceholderColor = unfocusedPlaceholderColor,
errorPlaceholderColor = errorPlaceholderColor, disabledPlaceholderColor = disabledPlaceholderColor,
focusedSupportingTextColor = focusedSupportingTextColor, errorPlaceholderColor = errorPlaceholderColor,
unfocusedSupportingTextColor = unfocusedSupportingTextColor, focusedSupportingTextColor = focusedSupportingTextColor,
disabledSupportingTextColor = disabledSupportingTextColor, unfocusedSupportingTextColor = unfocusedSupportingTextColor,
errorSupportingTextColor = errorSupportingTextColor, disabledSupportingTextColor = disabledSupportingTextColor,
focusedPrefixColor = focusedPrefixColor, errorSupportingTextColor = errorSupportingTextColor,
unfocusedPrefixColor = unfocusedPrefixColor, focusedPrefixColor = focusedPrefixColor,
disabledPrefixColor = disabledPrefixColor, unfocusedPrefixColor = unfocusedPrefixColor,
errorPrefixColor = errorPrefixColor, disabledPrefixColor = disabledPrefixColor,
focusedSuffixColor = focusedSuffixColor, errorPrefixColor = errorPrefixColor,
unfocusedSuffixColor = unfocusedSuffixColor, focusedSuffixColor = focusedSuffixColor,
disabledSuffixColor = disabledSuffixColor, unfocusedSuffixColor = unfocusedSuffixColor,
errorSuffixColor = errorSuffixColor, disabledSuffixColor = disabledSuffixColor,
) errorSuffixColor = errorSuffixColor,
)
} }
@Suppress("UnusedPrivateMember") @Suppress("UnusedPrivateMember")
@PreviewScreens @PreviewScreens
@Composable @Composable
private fun ZashiTextFieldPreview() = ZcashTheme { private fun ZashiTextFieldPreview() =
ZashiTextField( ZcashTheme {
state = TextFieldState( ZashiTextField(
value = stringRes("Text") state =
) {} TextFieldState(
) value = stringRes("Text")
} ) {}
)
}

View File

@ -18,12 +18,12 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import co.electriccoin.zcash.ui.R import co.electriccoin.zcash.ui.R
import co.electriccoin.zcash.ui.design.component.BlankSurface import co.electriccoin.zcash.ui.design.component.BlankSurface
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
import co.electriccoin.zcash.ui.design.theme.ZcashTheme import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.screen.exchangerate.BaseExchangeRateOptIn import co.electriccoin.zcash.ui.screen.exchangerate.BaseExchangeRateOptIn
import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButton import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButton
import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButtonDefaults import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButtonDefaults
import co.electriccoin.zcash.ui.screen.exchangerate.ZashiTextButton import co.electriccoin.zcash.ui.screen.exchangerate.ZashiTextButton
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
@Composable @Composable
fun ExchangeRateOptIn( fun ExchangeRateOptIn(

View File

@ -27,12 +27,12 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import co.electriccoin.zcash.ui.R import co.electriccoin.zcash.ui.R
import co.electriccoin.zcash.ui.design.component.BlankSurface import co.electriccoin.zcash.ui.design.component.BlankSurface
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
import co.electriccoin.zcash.ui.design.theme.ZcashTheme import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.screen.exchangerate.BaseExchangeRateOptIn import co.electriccoin.zcash.ui.screen.exchangerate.BaseExchangeRateOptIn
import co.electriccoin.zcash.ui.screen.exchangerate.SecondaryCard import co.electriccoin.zcash.ui.screen.exchangerate.SecondaryCard
import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButton import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButton
import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButtonDefaults import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButtonDefaults
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
@Composable @Composable
fun SettingsExchangeRateOptIn( fun SettingsExchangeRateOptIn(

View File

@ -42,12 +42,12 @@ import co.electriccoin.zcash.ui.common.extension.toKotlinLocale
import co.electriccoin.zcash.ui.common.wallet.ExchangeRateState import co.electriccoin.zcash.ui.common.wallet.ExchangeRateState
import co.electriccoin.zcash.ui.design.component.BlankSurface import co.electriccoin.zcash.ui.design.component.BlankSurface
import co.electriccoin.zcash.ui.design.component.LottieProgress import co.electriccoin.zcash.ui.design.component.LottieProgress
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
import co.electriccoin.zcash.ui.design.theme.ZcashTheme import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.design.util.StringResource import co.electriccoin.zcash.ui.design.util.StringResource
import co.electriccoin.zcash.ui.design.util.getValue import co.electriccoin.zcash.ui.design.util.getValue
import co.electriccoin.zcash.ui.design.util.stringRes import co.electriccoin.zcash.ui.design.util.stringRes
import co.electriccoin.zcash.ui.fixture.ObserveFiatCurrencyResultFixture import co.electriccoin.zcash.ui.fixture.ObserveFiatCurrencyResultFixture
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
import kotlinx.datetime.Clock import kotlinx.datetime.Clock
@Suppress("LongParameterList", "ComplexCondition") @Suppress("LongParameterList", "ComplexCondition")

View File

@ -9,10 +9,10 @@ import cash.z.ecc.android.sdk.model.FiatCurrencyConversion
import cash.z.ecc.android.sdk.model.Zatoshi import cash.z.ecc.android.sdk.model.Zatoshi
import co.electriccoin.zcash.ui.common.wallet.ExchangeRateState import co.electriccoin.zcash.ui.common.wallet.ExchangeRateState
import co.electriccoin.zcash.ui.design.component.BlankSurface import co.electriccoin.zcash.ui.design.component.BlankSurface
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
import co.electriccoin.zcash.ui.design.theme.ZcashTheme import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.design.util.StringResource import co.electriccoin.zcash.ui.design.util.StringResource
import co.electriccoin.zcash.ui.design.util.stringRes import co.electriccoin.zcash.ui.design.util.stringRes
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
import kotlinx.datetime.Clock import kotlinx.datetime.Clock
@Suppress("LongParameterList", "ComplexCondition") @Suppress("LongParameterList", "ComplexCondition")

View File

@ -24,11 +24,11 @@ import androidx.compose.ui.unit.sp
import co.electriccoin.zcash.ui.R import co.electriccoin.zcash.ui.R
import co.electriccoin.zcash.ui.common.wallet.ExchangeRateState import co.electriccoin.zcash.ui.common.wallet.ExchangeRateState
import co.electriccoin.zcash.ui.design.component.BlankSurface import co.electriccoin.zcash.ui.design.component.BlankSurface
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
import co.electriccoin.zcash.ui.design.theme.ZcashTheme import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.screen.exchangerate.SecondaryCard import co.electriccoin.zcash.ui.screen.exchangerate.SecondaryCard
import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButton import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButton
import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButtonDefaults import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButtonDefaults
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
@Suppress("LongMethod") @Suppress("LongMethod")
@Composable @Composable

View File

@ -35,8 +35,8 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Popup import androidx.compose.ui.window.Popup
import co.electriccoin.zcash.ui.R import co.electriccoin.zcash.ui.R
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
@Composable @Composable
internal fun StyledExchangeUnavailablePopup( internal fun StyledExchangeUnavailablePopup(

View File

@ -3,6 +3,7 @@ package co.electroniccoin.zcash.ui.screenshot
import android.app.Application import android.app.Application
import android.content.Context import android.content.Context
import co.electriccoin.zcash.di.coreModule import co.electriccoin.zcash.di.coreModule
import co.electriccoin.zcash.di.providerModule
import co.electriccoin.zcash.di.repositoryModule import co.electriccoin.zcash.di.repositoryModule
import co.electriccoin.zcash.di.useCaseModule import co.electriccoin.zcash.di.useCaseModule
import co.electriccoin.zcash.di.viewModelModule import co.electriccoin.zcash.di.viewModelModule
@ -29,6 +30,7 @@ class ZcashUiTestApplication : Application() {
androidContext(this@ZcashUiTestApplication) androidContext(this@ZcashUiTestApplication)
modules( modules(
coreModule, coreModule,
providerModule,
repositoryModule, repositoryModule,
useCaseModule, useCaseModule,
viewModelModule viewModelModule