[#1012] Customize Dark mode support for debugging
- And disable its support in the app UI by default - Closes #1012
This commit is contained in:
parent
a45176373c
commit
a70586d8b6
|
@ -213,7 +213,7 @@ androidComponents {
|
|||
BuildConfigField(
|
||||
type = "boolean",
|
||||
value = project.property("IS_CRASH_ON_STRICT_MODE_VIOLATION").toString(),
|
||||
comment = null
|
||||
comment = "Whether is the strict mode enabled"
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -102,6 +102,7 @@ tasks {
|
|||
"ZCASH_RELEASE_PACKAGE_NAME" to "co.electriccoin.zcash",
|
||||
"ZCASH_SUPPORT_EMAIL_ADDRESS" to "support@electriccoin.co",
|
||||
"IS_SECURE_SCREEN_PROTECTION_ACTIVE" to "true",
|
||||
"IS_DARK_MODE_ENABLED" to "false",
|
||||
|
||||
"ZCASH_DEBUG_KEYSTORE_PATH" to "",
|
||||
"ZCASH_RELEASE_KEYSTORE_PATH" to "",
|
||||
|
|
|
@ -65,6 +65,10 @@ ZCASH_SUPPORT_EMAIL_ADDRESS=support@electriccoin.co
|
|||
# It is enabled by default to protect the developers from revealing their wallet secrets by mistake.
|
||||
IS_SECURE_SCREEN_PROTECTION_ACTIVE=true
|
||||
|
||||
# Forcibly turn on or off the UI dark mode support. If enabled, then the device's dark mode system setting value is
|
||||
# applied.
|
||||
IS_DARK_MODE_ENABLED=false
|
||||
|
||||
# Set keystore details to enable build signing. Typically these
|
||||
# are overridden via ~/.gradle/gradle.properties to allow secure injection.
|
||||
# Debug keystore is useful if using Google Maps or Firebase, which require API keys to be linked
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import com.android.build.api.variant.BuildConfigField
|
||||
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
|
@ -10,6 +12,7 @@ android {
|
|||
|
||||
buildFeatures {
|
||||
compose = true
|
||||
buildConfig = true
|
||||
}
|
||||
|
||||
composeOptions {
|
||||
|
@ -27,6 +30,20 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
androidComponents {
|
||||
onVariants { variant ->
|
||||
// Configure dark mode support for the app runtime
|
||||
variant.buildConfigFields.put(
|
||||
"IS_APP_DARK_MODE_ENABLED",
|
||||
BuildConfigField(
|
||||
type = "boolean",
|
||||
value = project.property("IS_DARK_MODE_ENABLED").toString(),
|
||||
comment = "Whether is the app dark mode supported"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.androidx.annotation)
|
||||
implementation(libs.androidx.constraintlayout)
|
||||
|
|
|
@ -41,7 +41,7 @@ import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
|||
@Preview
|
||||
@Composable
|
||||
private fun ButtonComposablePreview() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
Column {
|
||||
PrimaryButton(onClick = { }, text = "Primary")
|
||||
|
|
|
@ -19,7 +19,7 @@ import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
|||
@Composable
|
||||
private fun ComposablePreview() {
|
||||
val checkBoxState = remember { mutableStateOf(false) }
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
CheckBox(
|
||||
onCheckedChange = { checkBoxState.value = it },
|
||||
text = "test",
|
||||
|
|
|
@ -20,7 +20,7 @@ import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
|||
@Preview
|
||||
@Composable
|
||||
private fun ComposablePreview() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
Chip(Index(0), "edict")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import androidx.compose.foundation.isSystemInDarkTheme
|
|||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import co.electriccoin.zcash.ui.design.BuildConfig
|
||||
import co.electriccoin.zcash.ui.design.theme.internal.DarkColorPalette
|
||||
import co.electriccoin.zcash.ui.design.theme.internal.DarkExtendedColorPalette
|
||||
import co.electriccoin.zcash.ui.design.theme.internal.ExtendedTypography
|
||||
|
@ -15,18 +16,28 @@ import co.electriccoin.zcash.ui.design.theme.internal.LocalTypographies
|
|||
import co.electriccoin.zcash.ui.design.theme.internal.PrimaryTypography
|
||||
import co.electriccoin.zcash.ui.design.theme.internal.Typography
|
||||
|
||||
/**
|
||||
* Commonly used top level app theme definition
|
||||
*
|
||||
* @param forceDarkMode Set this to true to force the app to use the dark mode theme, which is helpful, e.g.,
|
||||
* for the compose previews.
|
||||
*/
|
||||
@Composable
|
||||
fun ZcashTheme(
|
||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||
forceDarkMode: Boolean = false,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
val baseColors = if (darkTheme) {
|
||||
// forceDarkMode takes precedence, then decides, based on the globally defined Gradle property
|
||||
// IS_APP_DARK_MODE_ENABLED, whether the device's system dark mode is on or off.
|
||||
val useDarkMode = forceDarkMode || (BuildConfig.IS_APP_DARK_MODE_ENABLED && isSystemInDarkTheme())
|
||||
|
||||
val baseColors = if (useDarkMode) {
|
||||
DarkColorPalette
|
||||
} else {
|
||||
LightColorPalette
|
||||
}
|
||||
|
||||
val extendedColors = if (darkTheme) {
|
||||
val extendedColors = if (useDarkMode) {
|
||||
DarkExtendedColorPalette
|
||||
} else {
|
||||
LightExtendedColorPalette
|
||||
|
|
|
@ -61,7 +61,7 @@ androidComponents {
|
|||
BuildConfigField(
|
||||
type = "boolean",
|
||||
value = project.property("IS_SECURE_SCREEN_PROTECTION_ACTIVE").toString(),
|
||||
comment = null
|
||||
comment = "Whether is the SecureScreen sensitive data protection enabled"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ import co.electriccoin.zcash.ui.screen.support.model.ConfigInfo
|
|||
@Preview("About")
|
||||
@Composable
|
||||
private fun AboutPreview() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
About(
|
||||
onBack = {},
|
||||
|
|
|
@ -58,7 +58,7 @@ import kotlinx.coroutines.runBlocking
|
|||
@Preview("WalletAddresses")
|
||||
@Composable
|
||||
private fun ComposablePreview() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
WalletAddresses(
|
||||
runBlocking { WalletAddressesFixture.new() },
|
||||
|
|
|
@ -66,7 +66,7 @@ import kotlinx.collections.immutable.toPersistentList
|
|||
@Preview(name = "LongNewWalletBackup", device = Devices.PIXEL_4)
|
||||
@Composable
|
||||
private fun ComposablePreview() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
LongNewWalletBackup(
|
||||
PersistableWalletFixture.new(),
|
||||
|
|
|
@ -45,7 +45,7 @@ import kotlinx.collections.immutable.toPersistentList
|
|||
@Preview(name = "ShortNewWalletBackup", device = Devices.PIXEL_4)
|
||||
@Composable
|
||||
private fun ComposablePreviewShort() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
ShortNewWalletBackup(
|
||||
PersistableWalletFixture.new(),
|
||||
|
|
|
@ -26,7 +26,7 @@ import co.electriccoin.zcash.ui.screen.onboarding.view.Callout
|
|||
@Preview("DesignGuide")
|
||||
@Composable
|
||||
private fun ComposablePreview() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
DesignGuide()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ import java.util.Locale
|
|||
@Preview("History")
|
||||
@Composable
|
||||
private fun ComposablePreview() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
History(
|
||||
transactionState = TransactionHistorySyncState.Loading,
|
||||
|
|
|
@ -36,9 +36,7 @@ import androidx.compose.material3.Text
|
|||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.rememberDrawerState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
@ -71,7 +69,7 @@ import kotlinx.coroutines.CoroutineScope
|
|||
@Preview("Home")
|
||||
@Composable
|
||||
private fun ComposablePreview() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
Home(
|
||||
walletSnapshot = WalletSnapshotFixture.new(),
|
||||
|
|
|
@ -53,7 +53,7 @@ import co.electriccoin.zcash.ui.screen.onboarding.state.OnboardingState
|
|||
@Preview("LongOnboarding")
|
||||
@Composable
|
||||
private fun ComposablePreview() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
LongOnboarding(
|
||||
OnboardingState(OnboardingStage.Wallet),
|
||||
|
|
|
@ -46,7 +46,7 @@ import kotlinx.coroutines.delay
|
|||
@Preview("ShortOnboarding")
|
||||
@Composable
|
||||
private fun ShortOnboardingComposablePreview() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
ShortOnboarding(
|
||||
onImportWallet = {},
|
||||
|
|
|
@ -45,7 +45,7 @@ import kotlin.math.roundToInt
|
|||
@Preview("Receive")
|
||||
@Composable
|
||||
private fun ComposablePreview() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
Receive(
|
||||
walletAddress = runBlocking { WalletAddressFixture.unified() },
|
||||
|
|
|
@ -48,7 +48,7 @@ import kotlinx.coroutines.runBlocking
|
|||
@Preview("Request")
|
||||
@Composable
|
||||
private fun PreviewRequest() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
Request(
|
||||
myAddress = runBlocking { WalletAddressFixture.unified() },
|
||||
|
|
|
@ -92,7 +92,7 @@ import kotlinx.coroutines.launch
|
|||
@Preview("Restore Wallet")
|
||||
@Composable
|
||||
private fun PreviewRestore() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
RestoreWallet(
|
||||
ZcashNetwork.Mainnet,
|
||||
|
@ -123,7 +123,7 @@ private fun PreviewRestore() {
|
|||
@Preview("Restore Complete")
|
||||
@Composable
|
||||
private fun PreviewRestoreComplete() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
RestoreComplete(
|
||||
onComplete = {}
|
||||
)
|
||||
|
|
|
@ -82,7 +82,7 @@ import kotlin.math.roundToInt
|
|||
@Preview("Scan")
|
||||
@Composable
|
||||
private fun PreviewScan() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
Scan(
|
||||
snackbarHostState = SnackbarHostState(),
|
||||
|
|
|
@ -47,7 +47,7 @@ import co.electriccoin.zcash.ui.fixture.VersionInfoFixture
|
|||
@Preview("Security Warning")
|
||||
@Composable
|
||||
private fun SecurityWarningPreview() {
|
||||
ZcashTheme {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
SecurityWarning(
|
||||
snackbarHostState = SnackbarHostState(),
|
||||
|
|
|
@ -35,7 +35,7 @@ import kotlinx.collections.immutable.toPersistentList
|
|||
@Preview("Seed")
|
||||
@Composable
|
||||
private fun PreviewSeed() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
Seed(
|
||||
persistableWallet = PersistableWalletFixture.new(),
|
||||
|
|
|
@ -64,7 +64,7 @@ import kotlinx.coroutines.runBlocking
|
|||
@Composable
|
||||
@Preview("SendForm")
|
||||
private fun PreviewSendForm() {
|
||||
ZcashTheme {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
Send(
|
||||
mySpendableBalance = ZatoshiFixture.new(),
|
||||
|
@ -85,7 +85,7 @@ private fun PreviewSendForm() {
|
|||
@Composable
|
||||
@Preview("SendSuccessful")
|
||||
private fun PreviewSendSuccessful() {
|
||||
ZcashTheme {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
SendSuccessful(
|
||||
zecSend = ZecSend(
|
||||
|
@ -102,7 +102,7 @@ private fun PreviewSendSuccessful() {
|
|||
@Composable
|
||||
@Preview("SendFailure")
|
||||
private fun PreviewSendFailure() {
|
||||
ZcashTheme {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
SendFailure(
|
||||
zecSend = ZecSend(
|
||||
|
@ -119,7 +119,7 @@ private fun PreviewSendFailure() {
|
|||
@Composable
|
||||
@Preview("SendConfirmation")
|
||||
private fun PreviewSendConfirmation() {
|
||||
ZcashTheme {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
Confirmation(
|
||||
zecSend = ZecSend(
|
||||
|
|
|
@ -46,7 +46,7 @@ import co.electriccoin.zcash.ui.screen.settings.model.TroubleshootingParameters
|
|||
@Preview("Settings")
|
||||
@Composable
|
||||
private fun PreviewSettings() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
Settings(
|
||||
TroubleshootingParameters(
|
||||
|
|
|
@ -40,7 +40,7 @@ import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
|||
@Preview("Support")
|
||||
@Composable
|
||||
private fun PreviewSupport() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
Support(
|
||||
onBack = {},
|
||||
|
@ -54,7 +54,7 @@ private fun PreviewSupport() {
|
|||
@Preview("Support-Popup")
|
||||
@Composable
|
||||
private fun PreviewSupportPopup() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
SupportConfirmationDialog(
|
||||
onConfirm = {},
|
||||
|
|
|
@ -40,7 +40,7 @@ import co.electriccoin.zcash.ui.screen.update.model.UpdateState
|
|||
@Preview("Update")
|
||||
@Composable
|
||||
private fun PreviewUpdate() {
|
||||
ZcashTheme(darkTheme = false) {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
Update(
|
||||
snackbarHostState = SnackbarHostState(),
|
||||
|
|
|
@ -28,7 +28,7 @@ import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
|||
@Preview("NotEnoughSpace")
|
||||
@Composable
|
||||
private fun NotEnoughSpacePreview() {
|
||||
ZcashTheme {
|
||||
ZcashTheme(forceDarkMode = false) {
|
||||
GradientSurface {
|
||||
NotEnoughSpaceView(
|
||||
storageSpaceRequiredGigabytes = 1,
|
||||
|
|
Loading…
Reference in New Issue