Code cleanup

This commit is contained in:
Milan Cerovsky 2024-08-19 13:25:41 +02:00
parent 1cdaca1473
commit a418fcf833
6 changed files with 12 additions and 18 deletions

View File

@ -131,7 +131,7 @@ ZCASH_EMULATOR_WTF_API_KEY=
# Optional absolute path to a Zcash SDK checkout.
# When blank, it pulls the SDK from Maven.
# When set, it uses the path for a Gradle included build. Path can either be absolute or relative to the root of this app's Gradle project.
SDK_INCLUDED_BUILD_PATH=
SDK_INCLUDED_BUILD_PATH=/Users/milancerovsky/Developer/zcash/zcash-android-wallet-sdk
# When blank, it pulls the BIP-39 library from Maven.
# When set, it uses the path for a Gradle included build. Path can either be absolute or relative to the root of this app's Gradle project.

View File

@ -3,9 +3,9 @@
package co.electriccoin.zcash.ui.design.theme
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.graphics.Color
// TODO [#1555]: replace by new design system
@Immutable
data class ExchangeRateColors(
val btnSecondaryBg: Color,
@ -29,6 +29,3 @@ internal val DarkExchangeRateColorPalette =
btnSecondaryFg = Color(0xFFFFFFFF),
btnSpinnerDisabled = Color(0xFF3D3A3B)
)
@Suppress("CompositionLocalAllowlist")
internal val LocalExchangeRateColors = staticCompositionLocalOf<ExchangeRateColors> { error("no colors specified") }

View File

@ -6,6 +6,7 @@ import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.graphics.Color
// TODO [#1555]: extract colors to separate file
@Immutable
data class ZashiColors(
val textLight: Color,
@ -23,6 +24,7 @@ data class ZashiColors(
val btnPrimaryFg: Color,
val btnPrimaryFgDisabled: Color,
val btnTextFg: Color,
val exchangeRateColors: ExchangeRateColors
)
internal val LightZashiColorPalette =
@ -41,7 +43,8 @@ internal val LightZashiColorPalette =
btnPrimaryBgDisabled = Color(0xFFEBEBE6),
btnPrimaryFg = Color(0xFFFFFFFF),
btnPrimaryFgDisabled = Color(0xFF94907B),
btnTextFg = Color(0xFF231F20)
btnTextFg = Color(0xFF231F20),
exchangeRateColors = LightExchangeRateColorPalette
)
internal val DarkZashiColorPalette =
@ -60,7 +63,8 @@ internal val DarkZashiColorPalette =
btnPrimaryBgDisabled = Color(0xFF343031),
btnPrimaryFg = Color(0xFF231F20),
btnPrimaryFgDisabled = Color(0xFF7E7C7C),
btnTextFg = Color(0xFFE8E8E8)
btnTextFg = Color(0xFFE8E8E8),
exchangeRateColors = DarkExchangeRateColorPalette
)
@Suppress("CompositionLocalAllowlist")

View File

@ -30,12 +30,10 @@ fun ZcashTheme(
val baseColors = if (useDarkMode) DarkColorPalette else LightColorPalette
val extendedColors = if (useDarkMode) DarkExtendedColorPalette else LightExtendedColorPalette
val zashiColors = if (useDarkMode) DarkZashiColorPalette else LightZashiColorPalette
val exchangeRateColors = if (useDarkMode) DarkExchangeRateColorPalette else LightExchangeRateColorPalette
CompositionLocalProvider(
LocalExtendedColors provides extendedColors,
LocalZashiColors provides zashiColors,
LocalExchangeRateColors provides exchangeRateColors,
) {
ProvideDimens {
MaterialTheme(
@ -70,8 +68,4 @@ object ZcashTheme {
val zashiColors: ZashiColors
@Composable
get() = LocalZashiColors.current
val exchangeRateColors: ExchangeRateColors
@Composable
get() = LocalExchangeRateColors.current
}

View File

@ -122,7 +122,6 @@ dependencies {
implementation(projects.sdkExtLib)
implementation(projects.spackleAndroidLib)
api(projects.uiDesignLib)
implementation("androidx.graphics:graphics-shapes-android:1.0.0-rc01")
androidTestImplementation(projects.testLib)
androidTestImplementation(libs.bundles.androidx.test)

View File

@ -65,7 +65,7 @@ fun StyledExchangeBalance(
isHideBalances: Boolean = false,
hiddenBalancePlaceholder: StringResource =
stringRes(co.electriccoin.zcash.ui.design.R.string.hide_balance_placeholder),
textColor: Color = ZcashTheme.exchangeRateColors.btnSecondaryFg,
textColor: Color = ZcashTheme.zashiColors.exchangeRateColors.btnSecondaryFg,
style: TextStyle = ZcashTheme.typography.primary.titleSmall.copy(fontWeight = FontWeight.SemiBold)
) {
when (state) {
@ -161,7 +161,7 @@ private fun ExchangeAvailableRateLabelInternal(
if (state.isRefreshEnabled) {
textColor
} else {
ZcashTheme.exchangeRateColors.btnSpinnerDisabled
ZcashTheme.zashiColors.exchangeRateColors.btnSpinnerDisabled
}
)
)
@ -275,7 +275,7 @@ private fun ExchangeRateButton(
ButtonDefaults.elevatedButtonColors(
containerColor =
if (isEnabled && enableBorder) {
ZcashTheme.exchangeRateColors.btnSecondaryBg
ZcashTheme.zashiColors.exchangeRateColors.btnSecondaryBg
} else {
Color.Unspecified
},
@ -285,7 +285,7 @@ private fun ExchangeRateButton(
),
border =
if (isEnabled && enableBorder) {
BorderStroke(1.dp, ZcashTheme.exchangeRateColors.btnSecondaryBorder)
BorderStroke(1.dp, ZcashTheme.zashiColors.exchangeRateColors.btnSecondaryBorder)
} else {
BorderStroke(1.dp, Color.Transparent)
},