From 95ac835b9c69de972a9b722a7ecef3e29ea0327c Mon Sep 17 00:00:00 2001 From: Milan Cerovsky Date: Thu, 5 Sep 2024 12:05:20 +0200 Subject: [PATCH] #1420 Code cleanup Closes #1420 --- .../zcash/ui/design/component/RadioButton.kt | 104 ++++---- .../ui/common/repository/WalletRepository.kt | 7 +- .../ui/common/viewmodel/WalletViewModel.kt | 13 +- .../ui/screen/account/view/AccountView.kt | 2 +- .../screen/chooseserver/ChooseServerView.kt | 239 +++++++++--------- .../zcash/ui/screen/exchangerate/BottomBar.kt | 8 +- .../ui/screen/exchangerate/ZashiButton.kt | 35 +-- .../ui/screen/exchangerate/ZashiTextField.kt | 178 +++++++------ .../exchangerate/optin/ExchangeRateOptIn.kt | 2 +- .../settings/SettingsExchangeRateOptIn.kt | 2 +- .../widget/StyledExchangeBalance.kt | 2 +- .../widget/StyledExchangeLabel.kt | 2 +- .../widget/StyledExchangeRateOptIn.kt | 2 +- .../widget/StyledExchangeUnavailablePopup.kt | 2 +- .../zcash/ui/screenshot/ZcashUiTestRunner.kt | 2 + 15 files changed, 307 insertions(+), 293 deletions(-) diff --git a/ui-design-lib/src/main/java/co/electriccoin/zcash/ui/design/component/RadioButton.kt b/ui-design-lib/src/main/java/co/electriccoin/zcash/ui/design/component/RadioButton.kt index e9b139b7..42929335 100644 --- a/ui-design-lib/src/main/java/co/electriccoin/zcash/ui/design/component/RadioButton.kt +++ b/ui-design-lib/src/main/java/co/electriccoin/zcash/ui/design/component/RadioButton.kt @@ -27,7 +27,6 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.painterResource import androidx.compose.ui.semantics.Role @@ -52,22 +51,22 @@ fun RadioButton( ) { Row( modifier = - modifier - .clip(RoundedCornerShape(12.dp)) - .clickable( - indication = rememberRipple(), - interactionSource = remember { MutableInteractionSource() }, - onClick = state.onClick, - role = Role.Button, - ) - .padding(horizontal = 20.dp) - .then( - if (testTag != null) { - Modifier.testTag(testTag) - } else { - Modifier - } - ), + modifier + .clip(RoundedCornerShape(12.dp)) + .clickable( + indication = rememberRipple(), + interactionSource = remember { MutableInteractionSource() }, + onClick = state.onClick, + role = Role.Button, + ) + .padding(horizontal = 20.dp) + .then( + if (testTag != null) { + Modifier.testTag(testTag) + } else { + Modifier + } + ), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.SpaceBetween ) { @@ -84,12 +83,12 @@ fun RadioButton( style = ZcashTheme.extendedTypography.radioButton, color = ZcashTheme.colors.textPrimary, modifier = - Modifier.padding( - top = 14.dp, - bottom = if (state.subtitle == null) 14.dp else 0.dp, - start = 0.dp, - end = ZcashTheme.dimens.spacingDefault - ) + Modifier.padding( + top = 14.dp, + bottom = if (state.subtitle == null) 14.dp else 0.dp, + start = 0.dp, + end = ZcashTheme.dimens.spacingDefault + ) ) if (state.subtitle != null) { @@ -99,11 +98,11 @@ fun RadioButton( fontWeight = FontWeight.Normal, color = ZcashTheme.zashiColors.textTertiary, modifier = - Modifier.padding( - bottom = 6.dp, - start = 0.dp, - end = ZcashTheme.dimens.spacingDefault - ) + Modifier.padding( + bottom = 6.dp, + start = 0.dp, + end = ZcashTheme.dimens.spacingDefault + ) ) } } @@ -161,29 +160,30 @@ data class RadioButtonState( @Suppress("UnusedPrivateMember") @PreviewScreens @Composable -private fun RadioButtonPreview() = ZcashTheme { - BlankBgColumn { - var isChecked by remember { mutableStateOf(false) } +private fun RadioButtonPreview() = + ZcashTheme { + BlankBgColumn { + var isChecked by remember { mutableStateOf(false) } - RadioButton( - modifier = Modifier.fillMaxWidth(), - state = - RadioButtonState( - text = stringRes("test"), - isChecked = isChecked, - onClick = { isChecked = !isChecked }, - ), - trailingContent = { - Text(text = "Trailing text") - } - ) - RadioButton( - state = - RadioButtonState( - text = stringRes("test"), - isChecked = true, - onClick = {}, - ), - ) + RadioButton( + modifier = Modifier.fillMaxWidth(), + state = + RadioButtonState( + text = stringRes("test"), + isChecked = isChecked, + onClick = { isChecked = !isChecked }, + ), + trailingContent = { + Text(text = "Trailing text") + } + ) + RadioButton( + state = + RadioButtonState( + text = stringRes("test"), + isChecked = true, + onClick = {}, + ), + ) + } } -} diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/repository/WalletRepository.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/repository/WalletRepository.kt index 2b3baa4e..da2fd3a4 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/repository/WalletRepository.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/repository/WalletRepository.kt @@ -193,8 +193,11 @@ class WalletRepositoryImpl( // complete quickly, it isn't guaranteed to complete before persistExistingWallet() // unless a mutex is used here. persistWalletMutex.withLock { - StandardPreferenceKeys.ONBOARDING_STATE.putValue(standardPreferenceProvider(), onboardingState - .toNumber()) + StandardPreferenceKeys.ONBOARDING_STATE.putValue( + standardPreferenceProvider(), + onboardingState + .toNumber() + ) } } } diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/WalletViewModel.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/WalletViewModel.kt index cdf0b1a4..ed9909e3 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/WalletViewModel.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/WalletViewModel.kt @@ -100,18 +100,16 @@ class WalletViewModel( private val standardPreferenceProvider: StandardPreferenceProvider, private val getAvailableServers: GetDefaultServersProvider ) : AndroidViewModel(application) { - /* * Using the Mutex may be overkill, but it ensures that if multiple calls are accidentally made * that they have a consistent ordering. - */ + */ private val persistWalletMutex = Mutex() val navigationCommand = MutableSharedFlow() val backNavigationCommand = MutableSharedFlow() - /** * Synchronizer that is retained long enough to survive configuration changes. */ @@ -419,11 +417,10 @@ class WalletViewModel( ) } - - else -> { - BalanceState.Available( - totalBalance = snapshot.totalBalance(), - spendableBalance = snapshot.spendableBalance(), + else -> { + BalanceState.Available( + totalBalance = snapshot.totalBalance(), + spendableBalance = snapshot.spendableBalance(), exchangeRate = exchangeRateUsd ) } diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/AccountView.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/AccountView.kt index bdabefc1..b3c1b651 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/AccountView.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/AccountView.kt @@ -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.SmallTopAppBar 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.fixture.BalanceStateFixture 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.balances.model.StatusAction import co.electriccoin.zcash.ui.screen.exchangerate.widget.StyledExchangeOptIn -import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens import kotlinx.datetime.Clock @Suppress("UnusedPrivateMember") diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/chooseserver/ChooseServerView.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/chooseserver/ChooseServerView.kt index bfb52ece..536caaf5 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/chooseserver/ChooseServerView.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/chooseserver/ChooseServerView.kt @@ -35,7 +35,6 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.rotate -import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.painterResource @@ -98,10 +97,10 @@ fun ChooseServerView( LazyColumn( modifier = Modifier.fillMaxSize(), contentPadding = - PaddingValues( - top = paddingValues.calculateTopPadding() + ZcashTheme.dimens.spacingDefault, - bottom = paddingValues.calculateBottomPadding() + ZcashTheme.dimens.spacingDefault, - ) + PaddingValues( + top = paddingValues.calculateTopPadding() + ZcashTheme.dimens.spacingDefault, + bottom = paddingValues.calculateBottomPadding() + ZcashTheme.dimens.spacingDefault, + ) ) { if (state.fastest.servers.isEmpty() && state.fastest.isLoading) { item { @@ -127,9 +126,9 @@ fun ChooseServerView( private fun ServerLoading() { Column( modifier = - Modifier - .fillMaxWidth() - .padding(16.dp), + Modifier + .fillMaxWidth() + .padding(16.dp), horizontalAlignment = Alignment.CenterHorizontally ) { LottieProgress( @@ -190,9 +189,9 @@ fun ChooseServerBottomBar(saveButtonState: ButtonState) { ZashiButton( state = saveButtonState, modifier = - Modifier - .padding(horizontal = 24.dp) - .fillMaxWidth() + Modifier + .padding(horizontal = 24.dp) + .fillMaxWidth() ) } } @@ -205,11 +204,11 @@ private fun ChooseServerTopAppBar( SmallTopAppBar( titleText = stringResource(id = R.string.choose_server_title), subTitle = - when (subTitleState) { - TopAppBarSubTitleState.Disconnected -> stringResource(id = R.string.disconnected_label) - TopAppBarSubTitleState.Restoring -> stringResource(id = R.string.restoring_wallet_label) - TopAppBarSubTitleState.None -> null - }, + when (subTitleState) { + TopAppBarSubTitleState.Disconnected -> stringResource(id = R.string.disconnected_label) + TopAppBarSubTitleState.Restoring -> stringResource(id = R.string.restoring_wallet_label) + TopAppBarSubTitleState.None -> null + }, modifier = Modifier.testTag(CHOOSE_SERVER_TOP_APP_BAR), showTitleLogo = true, navigationAction = { @@ -239,16 +238,16 @@ private fun LazyListScope.serverListItems(state: ServerListState) { is ServerState.Custom -> CustomServerRadioButton( modifier = - Modifier - .fillMaxWidth() - .padding(start = 4.dp, end = 4.dp) - .then( - if (item.radioButtonState.isChecked) { - Modifier.background(ZcashTheme.zashiColors.bgSecondary, RoundedCornerShape(12.dp)) - } else { - Modifier - } - ), + Modifier + .fillMaxWidth() + .padding(start = 4.dp, end = 4.dp) + .then( + if (item.radioButtonState.isChecked) { + Modifier.background(ZcashTheme.zashiColors.bgSecondary, RoundedCornerShape(12.dp)) + } else { + Modifier + } + ), state = item ) @@ -256,28 +255,30 @@ private fun LazyListScope.serverListItems(state: ServerListState) { RadioButton( state = item.radioButtonState, modifier = - Modifier - .fillMaxWidth() - .padding(horizontal = 4.dp) - .then( - if (item.radioButtonState.isChecked && item.badge == null) { - Modifier.background(ZcashTheme.zashiColors.bgSecondary, RoundedCornerShape(12.dp)) - } else { - Modifier - } - ), + Modifier + .fillMaxWidth() + .padding(horizontal = 4.dp) + .then( + if (item.radioButtonState.isChecked && item.badge == null) { + Modifier.background(ZcashTheme.zashiColors.bgSecondary, RoundedCornerShape(12.dp)) + } else { + Modifier + } + ), checkedContent = { if (item.badge == null) { RadioButtonCheckedContent(item.radioButtonState) } else { Image( - painter = painterResource( - id = if (isSystemInDarkTheme()) { - drawable.ic_radio_button_checked_variant_dark - } else { - drawable.ic_radio_button_checked_variant - } - ), + painter = + painterResource( + id = + if (isSystemInDarkTheme()) { + drawable.ic_radio_button_checked_variant_dark + } else { + drawable.ic_radio_button_checked_variant + } + ), contentDescription = item.radioButtonState.text.getValue(), ) } @@ -386,13 +387,13 @@ private fun CustomServerRadioButton( keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus(true) }), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri, imeAction = ImeAction.Done), modifier = - Modifier - .fillMaxWidth() - .padding( - start = 52.dp, - end = 20.dp, - bottom = 16.dp - ) + Modifier + .fillMaxWidth() + .padding( + start = 52.dp, + end = 20.dp, + bottom = 16.dp + ) ) } } @@ -409,57 +410,8 @@ private fun ChooseServerPreview( ServerListState.Fastest( title = stringRes("Fastest Servers"), servers = - if (showFastestServerLoading) { - (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 { + if (showFastestServerLoading) { + (1..3).map { ServerState.Default( RadioButtonState( text = stringRes("Some Server"), @@ -467,20 +419,69 @@ private fun ChooseServerPreview( onClick = { 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 = {}, topAppBarSubTitleState = TopAppBarSubTitleState.None, ) @@ -493,14 +494,14 @@ private fun ChooseServerPreviewValidationDialog() = ZcashTheme { ChooseServerPreview( dialogState = - ServerDialogState.Validation( - state = - AlertDialogState( - title = stringRes("title"), - text = stringRes("text"), - ), - reason = stringRes("reason") - ) + ServerDialogState.Validation( + state = + AlertDialogState( + title = stringRes("title"), + text = stringRes("text"), + ), + reason = stringRes("reason") + ) ) } diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/BottomBar.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/BottomBar.kt index fe4e05a9..03bbc577 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/BottomBar.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/BottomBar.kt @@ -15,9 +15,9 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp 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.util.stringRes -import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens @Composable fun BottomBar( @@ -48,9 +48,9 @@ private fun BottomBarPreview() = ZashiButton( state = ButtonState(text = stringRes("Save Button")), modifier = - Modifier - .padding(horizontal = 24.dp) - .fillMaxWidth() + Modifier + .padding(horizontal = 24.dp) + .fillMaxWidth() ) } } diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/ZashiButton.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/ZashiButton.kt index fc514bda..1a0ee50d 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/ZashiButton.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/ZashiButton.kt @@ -48,25 +48,27 @@ internal fun ZashiButton( colors: ButtonColors = ZashiButtonDefaults.primaryButtonColors(), content: @Composable RowScope.(ZashiButtonScope) -> Unit = ZashiButtonDefaults.content ) { - val scope = object : ZashiButtonScope { - @Composable - override fun Text() { - Text(text = text) - } + val scope = + object : ZashiButtonScope { + @Composable + override fun Text() { + Text(text = text) + } - @Composable - override fun Loading() { - if (enabled && isLoading) { - LottieProgress( - loadingRes = if (isSystemInDarkTheme()) { - R.raw.lottie_loading - } else { - R.raw.lottie_loading_white - } - ) + @Composable + override fun Loading() { + if (enabled && isLoading) { + LottieProgress( + loadingRes = + if (isSystemInDarkTheme()) { + R.raw.lottie_loading + } else { + R.raw.lottie_loading_white + } + ) + } } } - } Button( onClick = onClick, @@ -89,7 +91,6 @@ interface ZashiButtonScope { } object ZashiButtonDefaults { - val content: @Composable RowScope.(ZashiButtonScope) -> Unit get() = { scope -> scope.Text() diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/ZashiTextField.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/ZashiTextField.kt index 0d325d06..2ebcf90f 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/ZashiTextField.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/ZashiTextField.kt @@ -64,11 +64,13 @@ fun ZashiTextField( TextFieldInternal( value = state.value.getValue(), onValueChange = state.onValueChange, - modifier = modifier then Modifier.border( - width = 1.dp, - color = ZcashTheme.zashiColors.stroke, - shape = ZashiTextFieldDefaults.shape - ), + modifier = + modifier then + Modifier.border( + width = 1.dp, + color = ZcashTheme.zashiColors.stroke, + shape = ZashiTextFieldDefaults.shape + ), enabled = state.isEnabled, readOnly = readOnly, textStyle = textStyle, @@ -121,16 +123,18 @@ private fun TextFieldInternal( modifier: Modifier = Modifier, ) { // If color is not provided via the text style, use content color as a default - val textColor = textStyle.color.takeOrElse { - colors.textColor(enabled, isError, interactionSource).value - } + val textColor = + textStyle.color.takeOrElse { + colors.textColor(enabled, isError, interactionSource).value + } val mergedTextStyle = textStyle.merge(TextStyle(color = textColor)) CompositionLocalProvider(LocalTextSelectionColors provides colors.selectionColors) { BasicTextField( value = value, - modifier = modifier - .defaultMinSize(minWidth = TextFieldDefaults.MinWidth), + modifier = + modifier + .defaultMinSize(minWidth = TextFieldDefaults.MinWidth), onValueChange = onValueChange, enabled = enabled, readOnly = readOnly, @@ -177,12 +181,13 @@ private fun TextFieldColors.textColor( ): State { val focused by interactionSource.collectIsFocusedAsState() - val targetValue = when { - !enabled -> disabledTextColor - isError -> errorTextColor - focused -> focusedTextColor - else -> unfocusedTextColor - } + val targetValue = + when { + !enabled -> disabledTextColor + isError -> errorTextColor + focused -> focusedTextColor + else -> unfocusedTextColor + } return rememberUpdatedState(targetValue) } @@ -195,7 +200,6 @@ internal fun TextFieldColors.cursorColor(isError: Boolean): State { } object ZashiTextFieldDefaults { - val shape: Shape get() = RoundedCornerShape(8.dp) @@ -206,21 +210,24 @@ object ZashiTextFieldDefaults { unfocusedTextColor: Color = ZcashTheme.zashiColors.textPrimary, disabledTextColor: Color = ZcashTheme.zashiColors.textPrimary, errorTextColor: Color = Color.Unspecified, - focusedContainerColor: Color = if (isSystemInDarkTheme()) { - ZcashTheme.zashiColors.bgSecondary - } else { - ZcashTheme.zashiColors.bgPrimary - }, - unfocusedContainerColor: Color = if (isSystemInDarkTheme()) { - ZcashTheme.zashiColors.bgSecondary - } else { - ZcashTheme.zashiColors.bgPrimary - }, - disabledContainerColor: Color = if (isSystemInDarkTheme()) { - ZcashTheme.zashiColors.bgSecondary - } else { - ZcashTheme.zashiColors.bgPrimary - }, + focusedContainerColor: Color = + if (isSystemInDarkTheme()) { + ZcashTheme.zashiColors.bgSecondary + } else { + ZcashTheme.zashiColors.bgPrimary + }, + unfocusedContainerColor: Color = + if (isSystemInDarkTheme()) { + ZcashTheme.zashiColors.bgSecondary + } else { + ZcashTheme.zashiColors.bgPrimary + }, + disabledContainerColor: Color = + if (isSystemInDarkTheme()) { + ZcashTheme.zashiColors.bgSecondary + } else { + ZcashTheme.zashiColors.bgPrimary + }, errorContainerColor: Color = Color.Unspecified, cursorColor: Color = Color.Unspecified, errorCursorColor: Color = Color.Unspecified, @@ -257,60 +264,63 @@ object ZashiTextFieldDefaults { unfocusedSuffixColor: Color = Color.Unspecified, disabledSuffixColor: Color = Color.Unspecified, errorSuffixColor: Color = Color.Unspecified, - ): TextFieldColors = TextFieldDefaults.colors( - focusedTextColor = focusedTextColor, - unfocusedTextColor = unfocusedTextColor, - disabledTextColor = disabledTextColor, - errorTextColor = errorTextColor, - focusedContainerColor = focusedContainerColor, - unfocusedContainerColor = unfocusedContainerColor, - disabledContainerColor = disabledContainerColor, - errorContainerColor = errorContainerColor, - cursorColor = cursorColor, - errorCursorColor = errorCursorColor, - selectionColors = selectionColors, - focusedIndicatorColor = focusedIndicatorColor, - unfocusedIndicatorColor = unfocusedIndicatorColor, - disabledIndicatorColor = disabledIndicatorColor, - errorIndicatorColor = errorIndicatorColor, - focusedLeadingIconColor = focusedLeadingIconColor, - unfocusedLeadingIconColor = unfocusedLeadingIconColor, - disabledLeadingIconColor = disabledLeadingIconColor, - errorLeadingIconColor = errorLeadingIconColor, - focusedTrailingIconColor = focusedTrailingIconColor, - unfocusedTrailingIconColor = unfocusedTrailingIconColor, - disabledTrailingIconColor = disabledTrailingIconColor, - errorTrailingIconColor = errorTrailingIconColor, - focusedLabelColor = focusedLabelColor, - unfocusedLabelColor = unfocusedLabelColor, - disabledLabelColor = disabledLabelColor, - errorLabelColor = errorLabelColor, - focusedPlaceholderColor = focusedPlaceholderColor, - unfocusedPlaceholderColor = unfocusedPlaceholderColor, - disabledPlaceholderColor = disabledPlaceholderColor, - errorPlaceholderColor = errorPlaceholderColor, - focusedSupportingTextColor = focusedSupportingTextColor, - unfocusedSupportingTextColor = unfocusedSupportingTextColor, - disabledSupportingTextColor = disabledSupportingTextColor, - errorSupportingTextColor = errorSupportingTextColor, - focusedPrefixColor = focusedPrefixColor, - unfocusedPrefixColor = unfocusedPrefixColor, - disabledPrefixColor = disabledPrefixColor, - errorPrefixColor = errorPrefixColor, - focusedSuffixColor = focusedSuffixColor, - unfocusedSuffixColor = unfocusedSuffixColor, - disabledSuffixColor = disabledSuffixColor, - errorSuffixColor = errorSuffixColor, - ) + ): TextFieldColors = + TextFieldDefaults.colors( + focusedTextColor = focusedTextColor, + unfocusedTextColor = unfocusedTextColor, + disabledTextColor = disabledTextColor, + errorTextColor = errorTextColor, + focusedContainerColor = focusedContainerColor, + unfocusedContainerColor = unfocusedContainerColor, + disabledContainerColor = disabledContainerColor, + errorContainerColor = errorContainerColor, + cursorColor = cursorColor, + errorCursorColor = errorCursorColor, + selectionColors = selectionColors, + focusedIndicatorColor = focusedIndicatorColor, + unfocusedIndicatorColor = unfocusedIndicatorColor, + disabledIndicatorColor = disabledIndicatorColor, + errorIndicatorColor = errorIndicatorColor, + focusedLeadingIconColor = focusedLeadingIconColor, + unfocusedLeadingIconColor = unfocusedLeadingIconColor, + disabledLeadingIconColor = disabledLeadingIconColor, + errorLeadingIconColor = errorLeadingIconColor, + focusedTrailingIconColor = focusedTrailingIconColor, + unfocusedTrailingIconColor = unfocusedTrailingIconColor, + disabledTrailingIconColor = disabledTrailingIconColor, + errorTrailingIconColor = errorTrailingIconColor, + focusedLabelColor = focusedLabelColor, + unfocusedLabelColor = unfocusedLabelColor, + disabledLabelColor = disabledLabelColor, + errorLabelColor = errorLabelColor, + focusedPlaceholderColor = focusedPlaceholderColor, + unfocusedPlaceholderColor = unfocusedPlaceholderColor, + disabledPlaceholderColor = disabledPlaceholderColor, + errorPlaceholderColor = errorPlaceholderColor, + focusedSupportingTextColor = focusedSupportingTextColor, + unfocusedSupportingTextColor = unfocusedSupportingTextColor, + disabledSupportingTextColor = disabledSupportingTextColor, + errorSupportingTextColor = errorSupportingTextColor, + focusedPrefixColor = focusedPrefixColor, + unfocusedPrefixColor = unfocusedPrefixColor, + disabledPrefixColor = disabledPrefixColor, + errorPrefixColor = errorPrefixColor, + focusedSuffixColor = focusedSuffixColor, + unfocusedSuffixColor = unfocusedSuffixColor, + disabledSuffixColor = disabledSuffixColor, + errorSuffixColor = errorSuffixColor, + ) } @Suppress("UnusedPrivateMember") @PreviewScreens @Composable -private fun ZashiTextFieldPreview() = ZcashTheme { - ZashiTextField( - state = TextFieldState( - value = stringRes("Text") - ) {} - ) -} +private fun ZashiTextFieldPreview() = + ZcashTheme { + ZashiTextField( + state = + TextFieldState( + value = stringRes("Text") + ) {} + ) + } diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/optin/ExchangeRateOptIn.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/optin/ExchangeRateOptIn.kt index 7832929b..f4b40f01 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/optin/ExchangeRateOptIn.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/optin/ExchangeRateOptIn.kt @@ -18,12 +18,12 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import co.electriccoin.zcash.ui.R 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.screen.exchangerate.BaseExchangeRateOptIn import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButton import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButtonDefaults import co.electriccoin.zcash.ui.screen.exchangerate.ZashiTextButton -import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens @Composable fun ExchangeRateOptIn( diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/settings/SettingsExchangeRateOptIn.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/settings/SettingsExchangeRateOptIn.kt index 72eee23d..2779436b 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/settings/SettingsExchangeRateOptIn.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/settings/SettingsExchangeRateOptIn.kt @@ -27,12 +27,12 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import co.electriccoin.zcash.ui.R 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.screen.exchangerate.BaseExchangeRateOptIn import co.electriccoin.zcash.ui.screen.exchangerate.SecondaryCard import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButton import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButtonDefaults -import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens @Composable fun SettingsExchangeRateOptIn( diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/widget/StyledExchangeBalance.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/widget/StyledExchangeBalance.kt index 0897bcec..e873fc9e 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/widget/StyledExchangeBalance.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/widget/StyledExchangeBalance.kt @@ -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.design.component.BlankSurface 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.util.StringResource import co.electriccoin.zcash.ui.design.util.getValue import co.electriccoin.zcash.ui.design.util.stringRes import co.electriccoin.zcash.ui.fixture.ObserveFiatCurrencyResultFixture -import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens import kotlinx.datetime.Clock @Suppress("LongParameterList", "ComplexCondition") diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/widget/StyledExchangeLabel.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/widget/StyledExchangeLabel.kt index 78b37e54..0ac837b7 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/widget/StyledExchangeLabel.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/widget/StyledExchangeLabel.kt @@ -9,10 +9,10 @@ import cash.z.ecc.android.sdk.model.FiatCurrencyConversion import cash.z.ecc.android.sdk.model.Zatoshi import co.electriccoin.zcash.ui.common.wallet.ExchangeRateState 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.util.StringResource import co.electriccoin.zcash.ui.design.util.stringRes -import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens import kotlinx.datetime.Clock @Suppress("LongParameterList", "ComplexCondition") diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/widget/StyledExchangeRateOptIn.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/widget/StyledExchangeRateOptIn.kt index 5318a70e..80b09513 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/widget/StyledExchangeRateOptIn.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/widget/StyledExchangeRateOptIn.kt @@ -24,11 +24,11 @@ import androidx.compose.ui.unit.sp import co.electriccoin.zcash.ui.R import co.electriccoin.zcash.ui.common.wallet.ExchangeRateState 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.screen.exchangerate.SecondaryCard import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButton import co.electriccoin.zcash.ui.screen.exchangerate.ZashiButtonDefaults -import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens @Suppress("LongMethod") @Composable diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/widget/StyledExchangeUnavailablePopup.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/widget/StyledExchangeUnavailablePopup.kt index 2951a784..fd67a891 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/widget/StyledExchangeUnavailablePopup.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/exchangerate/widget/StyledExchangeUnavailablePopup.kt @@ -35,8 +35,8 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.compose.ui.window.Popup 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.theme.ZcashTheme @Composable internal fun StyledExchangeUnavailablePopup( diff --git a/ui-screenshot-test/src/main/java/co/electroniccoin/zcash/ui/screenshot/ZcashUiTestRunner.kt b/ui-screenshot-test/src/main/java/co/electroniccoin/zcash/ui/screenshot/ZcashUiTestRunner.kt index 2a07a82d..9ff65b13 100644 --- a/ui-screenshot-test/src/main/java/co/electroniccoin/zcash/ui/screenshot/ZcashUiTestRunner.kt +++ b/ui-screenshot-test/src/main/java/co/electroniccoin/zcash/ui/screenshot/ZcashUiTestRunner.kt @@ -3,6 +3,7 @@ package co.electroniccoin.zcash.ui.screenshot import android.app.Application import android.content.Context import co.electriccoin.zcash.di.coreModule +import co.electriccoin.zcash.di.providerModule import co.electriccoin.zcash.di.repositoryModule import co.electriccoin.zcash.di.useCaseModule import co.electriccoin.zcash.di.viewModelModule @@ -29,6 +30,7 @@ class ZcashUiTestApplication : Application() { androidContext(this@ZcashUiTestApplication) modules( coreModule, + providerModule, repositoryModule, useCaseModule, viewModelModule