diff --git a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/AddCustomTokenContent.kt b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/AddCustomTokenContent.kt index 55afd696af..afff4bf8e5 100644 --- a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/AddCustomTokenContent.kt +++ b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/AddCustomTokenContent.kt @@ -15,6 +15,7 @@ import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.tap.features.customtoken.impl.presentation.states.AddCustomTokenStateHolder import com.tangem.tap.features.customtoken.impl.presentation.ui.components.AddCustomTokenFloatingButton import com.tangem.tap.features.customtoken.impl.presentation.ui.components.AddCustomTokenForm @@ -70,7 +71,7 @@ internal fun AddCustomTokenContent(state: AddCustomTokenStateHolder.Content, mod @Preview @Composable private fun Preview_AddCustomTokenContent() { - TangemTheme { + TangemThemePreview { AddCustomTokenContent(state = AddCustomTokenPreviewData.createContent()) } } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/AddCustomTokenScreen.kt b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/AddCustomTokenScreen.kt index 3824462da3..d2e3729321 100644 --- a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/AddCustomTokenScreen.kt +++ b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/AddCustomTokenScreen.kt @@ -1,11 +1,12 @@ package com.tangem.tap.features.customtoken.impl.presentation.ui +import android.content.res.Configuration import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider -import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.tap.features.customtoken.impl.presentation.states.AddCustomTokenStateHolder /** @@ -24,21 +25,12 @@ internal fun AddCustomTokenScreen(stateHolder: AddCustomTokenStateHolder, modifi } @Preview(showSystemUi = true) +@Preview(showSystemUi = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_AddCustomTokenScreen_Light( +private fun Preview_AddCustomTokenScreen( @PreviewParameter(AddCustomTokenScreenProvider::class) stateHolder: AddCustomTokenStateHolder, ) { - TangemTheme(isDark = false) { - AddCustomTokenScreen(stateHolder) - } -} - -@Preview(showSystemUi = true) -@Composable -private fun Preview_AddCustomTokenScreen_Dark( - @PreviewParameter(AddCustomTokenScreenProvider::class) stateHolder: AddCustomTokenStateHolder, -) { - TangemTheme(isDark = true) { + TangemThemePreview { AddCustomTokenScreen(stateHolder) } } diff --git a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/AddCustomTokenTestContent.kt b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/AddCustomTokenTestContent.kt index 48ffb09110..3bb17cddb9 100644 --- a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/AddCustomTokenTestContent.kt +++ b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/AddCustomTokenTestContent.kt @@ -19,6 +19,7 @@ import com.tangem.core.ui.components.PrimaryButton import com.tangem.core.ui.components.SpacerH8 import com.tangem.core.ui.components.atoms.Hand import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.tap.features.customtoken.impl.presentation.models.AddCustomTokenChooseTokenBottomSheet import com.tangem.tap.features.customtoken.impl.presentation.models.AddCustomTokenChooseTokenBottomSheet.TestTokenItem import com.tangem.tap.features.customtoken.impl.presentation.models.AddCustomTokenTestBlock @@ -242,7 +243,7 @@ private fun TestBlock( @Preview @Composable private fun Preview_AddCustomTokenTestContent() { - TangemTheme { + TangemThemePreview { AddCustomTokenTestContent(state = AddCustomTokenPreviewData.createTestContent()) } } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenFloatingButton.kt b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenFloatingButton.kt index a55ee2f29e..3cc1d4847a 100644 --- a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenFloatingButton.kt +++ b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenFloatingButton.kt @@ -11,6 +11,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider import com.tangem.core.ui.components.PrimaryButtonIconStart import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.tap.features.customtoken.impl.presentation.models.AddCustomTokenFloatingButton import com.tangem.wallet.R @@ -42,7 +43,7 @@ internal fun AddCustomTokenFloatingButton(model: AddCustomTokenFloatingButton, m private fun Preview_AddCustomTokenFloatingButton( @PreviewParameter(AddCustomTokenFloatingButtonProvider::class) model: AddCustomTokenFloatingButton, ) { - TangemTheme { + TangemThemePreview { AddCustomTokenFloatingButton(model) } } diff --git a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenForm.kt b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenForm.kt index dd1293ba65..58da365d81 100644 --- a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenForm.kt +++ b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenForm.kt @@ -13,6 +13,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.tap.common.compose.TangemTextFieldsDefault import com.tangem.tap.features.customtoken.impl.presentation.models.AddCustomTokenForm import com.tangem.tap.features.customtoken.impl.presentation.models.AddCustomTokenInputField @@ -195,7 +196,7 @@ private fun SelectorField(model: AddCustomTokenSelectorField) { @Preview @Composable private fun Preview_AddCustomTokenForm(@PreviewParameter(AddCustomTokenFormProvider::class) model: AddCustomTokenForm) { - TangemTheme { + TangemThemePreview { AddCustomTokenForm(model) } } diff --git a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenToolbar.kt b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenToolbar.kt index 81d0f52912..030f130a1a 100644 --- a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenToolbar.kt +++ b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenToolbar.kt @@ -10,6 +10,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.R import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.tap.features.details.ui.cardsettings.TextReference import com.tangem.tap.features.details.ui.cardsettings.resolveReference @@ -54,7 +55,7 @@ internal fun AddCustomTokenToolbar(title: TextReference, onBackButtonClick: () - @Preview @Composable internal fun Preview_AddCustomTokenToolbar() { - TangemTheme { + TangemThemePreview { AddCustomTokenToolbar(title = TextReference.Res(R.string.add_custom_token_title), onBackButtonClick = {}) } } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenWarnings.kt b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenWarnings.kt index a00fc2d4fb..a323a8a982 100644 --- a/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenWarnings.kt +++ b/app/src/main/java/com/tangem/tap/features/customtoken/impl/presentation/ui/components/AddCustomTokenWarnings.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.customtoken.impl.presentation.ui.components +import android.content.res.Configuration import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize @@ -15,6 +16,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.sp import com.tangem.core.ui.res.TangemColorPalette +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.tap.features.customtoken.impl.presentation.models.AddCustomTokenWarning import com.tangem.tap.features.customtoken.impl.presentation.ui.AddCustomTokenPreviewData @@ -71,17 +73,10 @@ private fun AddCustomTokenWarning(warning: AddCustomTokenWarning) { } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_AddCustomTokenWarnings_Light() { - TangemTheme { - AddCustomTokenWarnings(warnings = AddCustomTokenPreviewData.createWarnings()) - } -} - -@Preview -@Composable -private fun Preview_AddCustomTokenWarnings_Dark() { - TangemTheme(isDark = true) { +private fun Preview_AddCustomTokenWarnings() { + TangemThemePreview { AddCustomTokenWarnings(warnings = AddCustomTokenPreviewData.createWarnings()) } } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/appcurrency/AppCurrencySelectorScreen.kt b/app/src/main/java/com/tangem/tap/features/details/ui/appcurrency/AppCurrencySelectorScreen.kt index a38cac5c0a..b29b503a39 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/appcurrency/AppCurrencySelectorScreen.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/appcurrency/AppCurrencySelectorScreen.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.details.ui.appcurrency +import android.content.res.Configuration import androidx.compose.foundation.LocalIndication import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource @@ -25,6 +26,7 @@ import com.tangem.core.ui.components.RectangleShimmer import com.tangem.core.ui.components.SpacerW import com.tangem.core.ui.event.EventEffect import com.tangem.core.ui.event.consumedEvent +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.tap.features.details.ui.appcurrency.AppCurrencySelectorState.Currency import com.tangem.wallet.R @@ -302,21 +304,12 @@ private val RadioButtonColors: RadioButtonColors // region Preview @Preview(showBackground = true, widthDp = 360, heightDp = 720) +@Preview(showBackground = true, widthDp = 360, heightDp = 720, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun AppCurrencySelectorScreenPreview_Light( +private fun AppCurrencySelectorScreenPreview( @PreviewParameter(AppCurrencySelectorStateProvider::class) param: AppCurrencySelectorState, ) { - TangemTheme(isDark = false) { - AppCurrencySelectorScreen(param) - } -} - -@Preview(showBackground = true, widthDp = 360, heightDp = 720) -@Composable -private fun AppCurrencySelectorScreenPreview_Dark( - @PreviewParameter(AppCurrencySelectorStateProvider::class) param: AppCurrencySelectorState, -) { - TangemTheme(isDark = true) { + TangemThemePreview { AppCurrencySelectorScreen(param) } } diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/AppSettingsScreen.kt b/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/AppSettingsScreen.kt index 7c99ed8b24..c60f34ecce 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/AppSettingsScreen.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/AppSettingsScreen.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.details.ui.appsettings +import android.content.res.Configuration import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items @@ -10,6 +11,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.domain.apptheme.model.AppThemeMode import com.tangem.tap.features.details.ui.appsettings.AppSettingsScreenState.Item @@ -70,21 +72,12 @@ private fun AppSettings(state: AppSettingsScreenState.Content) { // region Preview @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun AppSettingsScreenPreview_Light( +private fun AppSettingsScreenPreview( @PreviewParameter(AppSettingsScreenStateProvider::class) state: AppSettingsScreenState, ) { - TangemTheme { - AppSettingsScreen(state = state, onBackClick = {}) - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun AppSettingsScreenPreview_Dark( - @PreviewParameter(AppSettingsScreenStateProvider::class) state: AppSettingsScreenState, -) { - TangemTheme(isDark = true) { + TangemThemePreview { AppSettingsScreen(state = state, onBackClick = {}) } } diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsAlertDialog.kt b/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsAlertDialog.kt index 1dce42e622..b7b5b15da2 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsAlertDialog.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsAlertDialog.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.details.ui.appsettings.components +import android.content.res.Configuration import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview @@ -8,7 +9,7 @@ import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameter import com.tangem.core.ui.components.BasicDialog import com.tangem.core.ui.components.DialogButton import com.tangem.core.ui.extensions.resolveReference -import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.tap.features.details.ui.appsettings.AppSettingsDialogsFactory import com.tangem.tap.features.details.ui.appsettings.AppSettingsScreenState.Dialog import com.tangem.wallet.R @@ -34,17 +35,10 @@ internal fun SettingsAlertDialog(dialog: Dialog.Alert) { // region Preview @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun AlertDialogPreview_Light(@PreviewParameter(AlertDialogProvider::class) dialog: Dialog.Alert) { - TangemTheme { - SettingsAlertDialog(dialog = dialog) - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun AlertDialogPreview_Dark(@PreviewParameter(AlertDialogProvider::class) dialog: Dialog.Alert) { - TangemTheme(isDark = true) { +private fun AlertDialogPreview(@PreviewParameter(AlertDialogProvider::class) dialog: Dialog.Alert) { + TangemThemePreview { SettingsAlertDialog(dialog = dialog) } } diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsButtonItem.kt b/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsButtonItem.kt index 946c62d2f2..17dccc7a63 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsButtonItem.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsButtonItem.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.details.ui.appsettings.components +import android.content.res.Configuration import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth @@ -14,6 +15,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.tap.features.details.ui.appsettings.AppSettingsItemsFactory import com.tangem.tap.features.details.ui.appsettings.AppSettingsScreenState.Item @@ -52,17 +54,10 @@ internal fun SettingsButtonItem(item: Item.Button, modifier: Modifier = Modifier // region Preview @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun ButtonItemPreview_Light(@PreviewParameter(ButtonItemProvider::class) item: Item.Button) { - TangemTheme { - SettingsButtonItem(item = item) - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun ButtonItemPreview_Dark(@PreviewParameter(ButtonItemProvider::class) item: Item.Button) { - TangemTheme(isDark = true) { +private fun ButtonItemPreview(@PreviewParameter(ButtonItemProvider::class) item: Item.Button) { + TangemThemePreview { SettingsButtonItem(item = item) } } diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsCardItem.kt b/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsCardItem.kt index 1560b14a43..1e43c8f328 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsCardItem.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsCardItem.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.details.ui.appsettings.components +import android.content.res.Configuration import androidx.compose.foundation.layout.* import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon @@ -16,6 +17,7 @@ import androidx.compose.ui.unit.dp import com.tangem.core.ui.components.SpacerH4 import com.tangem.core.ui.components.SpacerW16 import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.tap.features.details.ui.appsettings.AppSettingsItemsFactory import com.tangem.tap.features.details.ui.appsettings.AppSettingsScreenState.Item @@ -59,17 +61,10 @@ internal fun SettingsCardItem(item: Item.Card, modifier: Modifier = Modifier) { // region Preview @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun CardItemPreview_Light(@PreviewParameter(CardItemProvider::class) item: Item.Card) { - TangemTheme { - SettingsCardItem(item = item) - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun CardItemPreview_Dark(@PreviewParameter(CardItemProvider::class) item: Item.Card) { - TangemTheme(isDark = true) { +private fun CardItemPreview(@PreviewParameter(CardItemProvider::class) item: Item.Card) { + TangemThemePreview { SettingsCardItem(item = item) } } diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsSelectorDialog.kt b/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsSelectorDialog.kt index 8c1a93e307..41b568b7ed 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsSelectorDialog.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsSelectorDialog.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.details.ui.appsettings.components +import android.content.res.Configuration import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview @@ -8,7 +9,7 @@ import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameter import com.tangem.core.ui.components.DialogButton import com.tangem.core.ui.components.SelectorDialog import com.tangem.core.ui.extensions.resolveReference -import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.tap.features.details.ui.appsettings.AppSettingsDialogsFactory import com.tangem.tap.features.details.ui.appsettings.AppSettingsScreenState.Dialog import com.tangem.wallet.R @@ -31,17 +32,10 @@ internal fun SettingsSelectorDialog(dialog: Dialog.Selector) { // region Preview @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun SettingsSelectorDialogPreview_Light(@PreviewParameter(DialogProvider::class) param: Dialog.Selector) { - TangemTheme(isDark = false) { - SettingsSelectorDialog(param) - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun SettingsSelectorDialogPreview_Dark(@PreviewParameter(DialogProvider::class) param: Dialog.Selector) { - TangemTheme(isDark = true) { +private fun SettingsSelectorDialogPreview(@PreviewParameter(DialogProvider::class) param: Dialog.Selector) { + TangemThemePreview { SettingsSelectorDialog(param) } } diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsSwitchItem.kt b/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsSwitchItem.kt index dfbc486b5c..a8476e3bd2 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsSwitchItem.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/appsettings/components/SettingsSwitchItem.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.details.ui.appsettings.components +import android.content.res.Configuration import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -16,6 +17,7 @@ import com.tangem.core.ui.components.SpacerH4 import com.tangem.core.ui.components.SpacerW32 import com.tangem.core.ui.components.TangemSwitch import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.tap.features.details.ui.appsettings.AppSettingsItemsFactory import com.tangem.tap.features.details.ui.appsettings.AppSettingsScreenState.Item @@ -71,17 +73,10 @@ internal fun SettingsSwitchItem(item: Item.Switch, modifier: Modifier = Modifier // region Preview @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun SwitchItemPreview_Light(@PreviewParameter(SwitchItemProvider::class) item: Item.Switch) { - TangemTheme { - SettingsSwitchItem(item = item) - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun SwitchItemPreview_Dark(@PreviewParameter(SwitchItemProvider::class) item: Item.Switch) { - TangemTheme(isDark = true) { +private fun SwitchItemPreview(@PreviewParameter(SwitchItemProvider::class) item: Item.Switch) { + TangemThemePreview { SettingsSwitchItem(item = item) } } diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/cardsettings/CardSettingsScreen.kt b/app/src/main/java/com/tangem/tap/features/details/ui/cardsettings/CardSettingsScreen.kt index b528123bb7..b0e2785b32 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/cardsettings/CardSettingsScreen.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/cardsettings/CardSettingsScreen.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.details.ui.cardsettings +import android.content.res.Configuration import androidx.compose.foundation.* import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn @@ -12,6 +13,7 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.tap.features.details.ui.common.DetailsMainButton import com.tangem.tap.features.details.ui.common.SettingsScreensScaffold @@ -182,17 +184,10 @@ private fun CardSettingsScreenStateSample() { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun CardSettingsScreenStatePreview_Light() { - TangemTheme { - CardSettingsScreenStateSample() - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun CardSettingsScreenStatePreview_Dark() { - TangemTheme(isDark = true) { +private fun CardSettingsScreenStatePreview() { + TangemThemePreview { CardSettingsScreenStateSample() } } diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsScreen.kt b/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsScreen.kt index ec5a34ac4e..f31718287c 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsScreen.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsScreen.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.details.ui.details +import android.content.res.Configuration import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyRow @@ -23,6 +24,7 @@ import com.tangem.core.ui.event.consumedEvent import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.res.TangemColorPalette +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.tap.features.details.ui.common.ScreenTitle import com.tangem.tap.features.details.ui.common.SettingsScreensScaffold @@ -236,19 +238,10 @@ private fun TangemAppVersion(appNameRes: Int, version: String, modifier: Modifie // region Preview @Preview(showBackground = true, widthDp = 360, heightDp = 900) +@Preview(showBackground = true, widthDp = 360, heightDp = 900, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun DetailsScreenPreview_Light( - @PreviewParameter(DetailsScreenStateProvider::class) param: DetailsScreenState, -) { - TangemTheme(isDark = false) { - DetailsScreen(param, onBackClick = {}) - } -} - -@Preview(showBackground = true, widthDp = 360, heightDp = 900) -@Composable -private fun DetailsScreenPreview_Dark(@PreviewParameter(DetailsScreenStateProvider::class) param: DetailsScreenState) { - TangemTheme(isDark = true) { +private fun DetailsScreenPreview(@PreviewParameter(DetailsScreenStateProvider::class) param: DetailsScreenState) { + TangemThemePreview { DetailsScreen(param, onBackClick = {}) } } diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/resetcard/ResetCardScreen.kt b/app/src/main/java/com/tangem/tap/features/details/ui/resetcard/ResetCardScreen.kt index 35b4c9bae8..b0ccd93897 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/resetcard/ResetCardScreen.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/resetcard/ResetCardScreen.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.details.ui.resetcard +import android.content.res.Configuration import androidx.compose.animation.AnimatedContent import androidx.compose.foundation.* import androidx.compose.foundation.layout.* @@ -12,6 +13,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.components.* +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.tap.features.details.ui.cardsettings.TextReference import com.tangem.tap.features.details.ui.cardsettings.resolveReference @@ -228,17 +230,10 @@ private fun ResetCardScreenSample(modifier: Modifier = Modifier) { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun ResetCardScreenPreview_Light() { - TangemTheme { - ResetCardScreenSample() - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun ResetCardScreenPreview_Dark() { - TangemTheme(isDark = true) { +private fun ResetCardScreenPreview() { + TangemThemePreview { ResetCardScreenSample() } } diff --git a/app/src/main/java/com/tangem/tap/features/home/compose/StoriesScreen.kt b/app/src/main/java/com/tangem/tap/features/home/compose/StoriesScreen.kt index 844d5e6663..1b0c69fb9c 100644 --- a/app/src/main/java/com/tangem/tap/features/home/compose/StoriesScreen.kt +++ b/app/src/main/java/com/tangem/tap/features/home/compose/StoriesScreen.kt @@ -21,6 +21,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.test.TestTags import com.tangem.tap.features.home.compose.content.* import com.tangem.tap.features.home.compose.views.HomeButtons @@ -213,7 +214,7 @@ private data class StoriesScreenContentConfig( private fun StoriesScreenContentPreview( @PreviewParameter(StoriesScreenContentConfigProvider::class) config: StoriesScreenContentConfig, ) { - TangemTheme { + TangemThemePreview { StoriesScreenContent(config = config) } } diff --git a/app/src/main/java/com/tangem/tap/features/home/compose/views/HomeButtons.kt b/app/src/main/java/com/tangem/tap/features/home/compose/views/HomeButtons.kt index 3a9ebaf1bf..be6823d684 100644 --- a/app/src/main/java/com/tangem/tap/features/home/compose/views/HomeButtons.kt +++ b/app/src/main/java/com/tangem/tap/features/home/compose/views/HomeButtons.kt @@ -16,6 +16,7 @@ import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameter import com.tangem.core.ui.components.SpacerW12 import com.tangem.core.ui.components.buttons.common.TangemButtonIconPosition import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.test.TestTags import com.tangem.wallet.R @@ -73,7 +74,7 @@ private fun OrderCardButton(onClick: () -> Unit, modifier: Modifier = Modifier) @Preview(showBackground = true, widthDp = 360) @Composable private fun HomeButtonsPreview(@PreviewParameter(HomeButtonsParameterProvider::class) state: HomeButtonsState) { - TangemTheme { + TangemThemePreview { Box( modifier = Modifier.background(Color.Black), ) { diff --git a/app/src/main/java/com/tangem/tap/features/home/compose/views/SearchCurrenciesButton.kt b/app/src/main/java/com/tangem/tap/features/home/compose/views/SearchCurrenciesButton.kt index 4e91ce98bc..e3e237954e 100644 --- a/app/src/main/java/com/tangem/tap/features/home/compose/views/SearchCurrenciesButton.kt +++ b/app/src/main/java/com/tangem/tap/features/home/compose/views/SearchCurrenciesButton.kt @@ -11,6 +11,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.components.buttons.common.TangemButtonIconPosition import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.wallet.R @Composable @@ -29,7 +30,7 @@ internal fun SearchCurrenciesButton(onClick: () -> Unit, modifier: Modifier = Mo @Preview(showBackground = true, widthDp = 360) @Composable private fun SearchCurrenciesButtonPreview() { - TangemTheme { + TangemThemePreview { Box( modifier = Modifier .background(color = Color.Black) diff --git a/app/src/main/java/com/tangem/tap/features/main/ui/components/ModalNotificationScreen.kt b/app/src/main/java/com/tangem/tap/features/main/ui/components/ModalNotificationScreen.kt index 587b734dc0..72c36caf54 100644 --- a/app/src/main/java/com/tangem/tap/features/main/ui/components/ModalNotificationScreen.kt +++ b/app/src/main/java/com/tangem/tap/features/main/ui/components/ModalNotificationScreen.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.main.ui.components +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.material.Icon @@ -17,6 +18,7 @@ import com.tangem.core.ui.components.SecondaryButton import com.tangem.core.ui.components.atoms.Hand import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.extensions.resourceReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.tap.features.main.model.ActionConfig import com.tangem.tap.features.main.model.ModalNotification @@ -82,27 +84,12 @@ internal fun ModalNotificationContent(notification: ModalNotification, modifier: // region Preview @Preview(widthDp = 360, heightDp = 404) +@Preview(widthDp = 360, heightDp = 404, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun ModalNotificationContentPreview_Light( +private fun ModalNotificationContentPreview( @PreviewParameter(GlobalNotificationProvider::class) param: ModalNotification, ) { - TangemTheme(isDark = false) { - ModalNotificationContent( - notification = param, - modifier = Modifier.background( - color = TangemTheme.colors.background.primary, - shape = TangemTheme.shapes.bottomSheet, - ), - ) - } -} - -@Preview(widthDp = 360, heightDp = 404) -@Composable -private fun ModalNotificationContentPreview_Dark( - @PreviewParameter(GlobalNotificationProvider::class) param: ModalNotification, -) { - TangemTheme(isDark = true) { + TangemThemePreview { ModalNotificationContent( notification = param, modifier = Modifier.background( diff --git a/app/src/main/java/com/tangem/tap/features/saveWallet/ui/components/EnrollBiometricsDialogConent.kt b/app/src/main/java/com/tangem/tap/features/saveWallet/ui/components/EnrollBiometricsDialogConent.kt index 9113d5001d..115bd8d273 100644 --- a/app/src/main/java/com/tangem/tap/features/saveWallet/ui/components/EnrollBiometricsDialogConent.kt +++ b/app/src/main/java/com/tangem/tap/features/saveWallet/ui/components/EnrollBiometricsDialogConent.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.saveWallet.ui.components +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.runtime.Composable @@ -9,6 +10,7 @@ import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.R import com.tangem.core.ui.components.BasicDialog import com.tangem.core.ui.components.DialogButton +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.tap.features.saveWallet.ui.models.EnrollBiometricsDialog @@ -40,17 +42,10 @@ private fun EnrollBiometricDialogContentSample(modifier: Modifier = Modifier) { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun EnrollBiometricDialogContentPreview_Light() { - TangemTheme { - EnrollBiometricDialogContentSample() - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun EnrollBiometricDialogContentPreview_Dark() { - TangemTheme(isDark = true) { +private fun EnrollBiometricDialogContentPreview() { + TangemThemePreview { EnrollBiometricDialogContentSample() } } diff --git a/app/src/main/java/com/tangem/tap/features/saveWallet/ui/components/SaveWalletScreenContent.kt b/app/src/main/java/com/tangem/tap/features/saveWallet/ui/components/SaveWalletScreenContent.kt index a8bbc46f02..c7679a466d 100644 --- a/app/src/main/java/com/tangem/tap/features/saveWallet/ui/components/SaveWalletScreenContent.kt +++ b/app/src/main/java/com/tangem/tap/features/saveWallet/ui/components/SaveWalletScreenContent.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.saveWallet.ui.components +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -27,6 +28,7 @@ import com.tangem.core.ui.components.SpacerHHalf import com.tangem.core.ui.components.SpacerW24 import com.tangem.core.ui.components.SpacerW8 import com.tangem.core.ui.components.atoms.Hand +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.wallet.R @@ -196,17 +198,10 @@ private fun SaveWalletScreenContentSample(modifier: Modifier = Modifier) { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun SaveWalletScreenContentPreview_Light() { - TangemTheme { - SaveWalletScreenContentSample() - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun SaveWalletScreenContentPreview_Dark() { - TangemTheme(isDark = true) { +private fun SaveWalletScreenContentPreview() { + TangemThemePreview { SaveWalletScreenContentSample() } } diff --git a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/DetailedNetworksList.kt b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/DetailedNetworksList.kt index 806c161a01..12620898b6 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/DetailedNetworksList.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/DetailedNetworksList.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.tokens.impl.presentation.ui +import android.content.res.Configuration import androidx.compose.animation.* import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.combinedClickable @@ -22,6 +23,7 @@ import androidx.compose.ui.text.withStyle import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.sp import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.tap.features.tokens.impl.presentation.states.NetworkItemState import com.tangem.tap.features.tokens.impl.presentation.states.TokenItemState import kotlinx.collections.immutable.ImmutableCollection @@ -135,9 +137,10 @@ private fun RowScope.NetworkTitle(model: NetworkItemState) { } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_DetailedNetworksList_ManageAccess_Light() { - TangemTheme { +private fun Preview_DetailedNetworksList_ManageAccess() { + TangemThemePreview { DetailedNetworksList( isExpanded = true, token = TokenListPreviewData.createManageToken(), @@ -147,33 +150,10 @@ private fun Preview_DetailedNetworksList_ManageAccess_Light() { } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_DetailedNetworksList_ManageAccess_Dark() { - TangemTheme { - DetailedNetworksList( - isExpanded = true, - token = TokenListPreviewData.createManageToken(), - networks = TokenListPreviewData.createManageNetworksList(), - ) - } -} - -@Preview -@Composable -private fun Preview_DetailedNetworksList_ReadAccess_Light() { - TangemTheme { - DetailedNetworksList( - isExpanded = true, - token = TokenListPreviewData.createReadToken(), - networks = TokenListPreviewData.createReadNetworksList(), - ) - } -} - -@Preview -@Composable -private fun Preview_DetailedNetworksList_ReadAccess_Dark() { - TangemTheme { +private fun Preview_DetailedNetworksList_ReadAccess() { + TangemThemePreview { DetailedNetworksList( isExpanded = true, token = TokenListPreviewData.createReadToken(), diff --git a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/NetworkItemArrow.kt b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/NetworkItemArrow.kt index 671961ab61..b51b65f1c0 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/NetworkItemArrow.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/NetworkItemArrow.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.tokens.impl.presentation.ui +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.material.Icon @@ -9,6 +10,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.wallet.R @@ -39,25 +41,10 @@ internal fun NetworkItemArrow(itemHeight: Dp, isLastItem: Boolean) { } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_NetworkItemArrow_Column_Light() { - TangemTheme(isDark = false) { - Column( - modifier = Modifier - .fillMaxWidth() - .background(color = TangemTheme.colors.background.primary) - .padding(start = TangemTheme.dimens.size36), - ) { - NetworkItemArrow(itemHeight = TangemTheme.dimens.size62, isLastItem = false) - NetworkItemArrow(itemHeight = TangemTheme.dimens.size62, isLastItem = true) - } - } -} - -@Preview -@Composable -private fun Preview_NetworkItemArrow_Column_Dark() { - TangemTheme(isDark = true) { +private fun Preview_NetworkItemArrow_Column() { + TangemThemePreview { Column( modifier = Modifier .fillMaxWidth() diff --git a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokenItem.kt b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokenItem.kt index bae044a2a6..ce1967b48b 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokenItem.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokenItem.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.tokens.impl.presentation.ui +import android.content.res.Configuration import androidx.compose.animation.* import androidx.compose.foundation.background import androidx.compose.foundation.isSystemInDarkTheme @@ -24,6 +25,7 @@ import androidx.constraintlayout.compose.Dimension import coil.compose.SubcomposeAsyncImage import coil.request.ImageRequest import com.tangem.core.ui.components.CurrencyPlaceholderIcon +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.utils.ImageBackgroundContrastChecker import com.tangem.tap.features.tokens.impl.presentation.states.TokenItemState @@ -216,33 +218,19 @@ private fun ChangeNetworksViewButton(isExpanded: Boolean, onClick: () -> Unit, m } @Preview(showBackground = true) +@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_TokenItem_ManageAccess_Light() { - TangemTheme(isDark = false) { - TokenItem(model = TokenListPreviewData.createManageToken()) - } -} - -@Preview() -@Composable -private fun Preview_TokenItem_ManageAccess_Dark() { - TangemTheme(isDark = true) { +private fun Preview_TokenItem_ManageAccess() { + TangemThemePreview { TokenItem(model = TokenListPreviewData.createManageToken()) } } @Preview(showBackground = true) +@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_TokenItem_ReadAccess_Light() { - TangemTheme(isDark = false) { - TokenItem(model = TokenListPreviewData.createReadToken()) - } -} - -@Preview() -@Composable -private fun Preview_TokenItem_ReadAccess_Dark() { - TangemTheme(isDark = true) { +private fun Preview_TokenItem_ReadAccess() { + TangemThemePreview { TokenItem(model = TokenListPreviewData.createReadToken()) } } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokensListScreen.kt b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokensListScreen.kt index 70335b9609..56366dfb51 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokensListScreen.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokensListScreen.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.tokens.impl.presentation.ui +import android.content.res.Configuration import androidx.activity.compose.BackHandler import androidx.compose.animation.Crossfade import androidx.compose.foundation.background @@ -34,6 +35,7 @@ import androidx.paging.compose.collectAsLazyPagingItems import androidx.paging.compose.itemContentType import androidx.paging.compose.itemKey import com.tangem.core.ui.components.PrimaryButton +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.tap.features.tokens.impl.presentation.states.TokenItemState import com.tangem.tap.features.tokens.impl.presentation.states.TokensListStateHolder @@ -193,21 +195,12 @@ private fun SaveChangesButton(showProgress: Boolean, onClick: () -> Unit, modifi } @Preview(showSystemUi = true) +@Preview(showSystemUi = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_TokensListScreen_Light( +private fun Preview_TokensListScreen( @PreviewParameter(TokensListScreenProvider::class) stateHolder: TokensListStateHolder, ) { - TangemTheme(isDark = false) { - TokensListScreen(stateHolder) - } -} - -@Preview(showSystemUi = true) -@Composable -private fun Preview_TokensListScreen_Dark( - @PreviewParameter(TokensListScreenProvider::class) stateHolder: TokensListStateHolder, -) { - TangemTheme(isDark = true) { + TangemThemePreview { TokensListScreen(stateHolder) } } diff --git a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokensListToolbar.kt b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokensListToolbar.kt index 71aba31a33..5e0aafc999 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokensListToolbar.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokensListToolbar.kt @@ -25,6 +25,7 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.sp import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.tap.features.tokens.impl.presentation.states.TokensListToolbarState import com.tangem.tap.features.tokens.impl.presentation.states.TokensListToolbarState.InputField import com.tangem.tap.features.tokens.impl.presentation.states.TokensListToolbarState.Title @@ -171,7 +172,7 @@ private fun Hint(value: String) { @Preview @Composable private fun Preview_AddTokensToolbar_EditAccess() { - TangemTheme { + TangemThemePreview { TokensListToolbar( state = Title.Manage( titleResId = R.string.main_manage_tokens, @@ -186,7 +187,7 @@ private fun Preview_AddTokensToolbar_EditAccess() { @Preview @Composable private fun Preview_AddTokensToolbar_ReadAccess() { - TangemTheme { + TangemThemePreview { TokensListToolbar( state = Title.Read( titleResId = R.string.common_search_tokens, @@ -202,7 +203,7 @@ private fun Preview_AddTokensToolbar_ReadAccess() { private fun Preview_AddTokensToolbar_SearchInputField() { var value by remember { mutableStateOf("") } - TangemTheme { + TangemThemePreview { TokensListToolbar( state = InputField( onBackButtonClick = {}, diff --git a/app/src/main/java/com/tangem/tap/features/welcome/ui/components/WarningDialog.kt b/app/src/main/java/com/tangem/tap/features/welcome/ui/components/WarningDialog.kt index ca9a8d5769..a6315d5b1e 100644 --- a/app/src/main/java/com/tangem/tap/features/welcome/ui/components/WarningDialog.kt +++ b/app/src/main/java/com/tangem/tap/features/welcome/ui/components/WarningDialog.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.welcome.ui.components +import android.content.res.Configuration import androidx.compose.foundation.layout.Column import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @@ -7,7 +8,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.components.BasicDialog import com.tangem.core.ui.components.DialogButton -import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.tap.features.welcome.ui.model.WarningModel import com.tangem.wallet.R @@ -72,17 +73,10 @@ private fun BiometricsLockoutDialogSample(modifier: Modifier = Modifier) { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun BiometricsLockoutDialogPreview_Light() { - TangemTheme { - BiometricsLockoutDialogSample() - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun BiometricsLockoutDialogPreview_Dark() { - TangemTheme(isDark = true) { +private fun BiometricsLockoutDialogPreview() { + TangemThemePreview { BiometricsLockoutDialogSample() } } @@ -100,17 +94,10 @@ private fun BiometricsLockoutDialog_Permanent_Sample(modifier: Modifier = Modifi } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun BiometricsLockoutDialog_Permanent_Preview_Light() { - TangemTheme { - BiometricsLockoutDialog_Permanent_Sample() - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun BiometricsLockoutDialog_Permanent_Preview_Dark() { - TangemTheme(isDark = true) { +private fun BiometricsLockoutDialog_Permanent_Preview() { + TangemThemePreview { BiometricsLockoutDialog_Permanent_Sample() } } @@ -123,17 +110,10 @@ private fun KeyInvalidatedWarningSample(modifier: Modifier = Modifier) { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun KeyInvalidatedWarningPreview_Light() { - TangemTheme { - KeyInvalidatedWarningSample() - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun KeyInvalidatedWarningPreview_Dark() { - TangemTheme(isDark = true) { +private fun KeyInvalidatedWarningPreview() { + TangemThemePreview { KeyInvalidatedWarningSample() } } @@ -146,17 +126,10 @@ private fun BiometricDisabledWarningSample(modifier: Modifier = Modifier) { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun BiometricDisabledWarningPreview_Light() { - TangemTheme { - BiometricDisabledWarningSample() - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun BiometricDisabledWarningPreview_Dark() { - TangemTheme(isDark = true) { +private fun BiometricDisabledWarningPreview() { + TangemThemePreview { BiometricDisabledWarningSample() } } diff --git a/app/src/main/java/com/tangem/tap/features/welcome/ui/components/WelcomeScreenContent.kt b/app/src/main/java/com/tangem/tap/features/welcome/ui/components/WelcomeScreenContent.kt index cc83e0d893..5aca214e93 100644 --- a/app/src/main/java/com/tangem/tap/features/welcome/ui/components/WelcomeScreenContent.kt +++ b/app/src/main/java/com/tangem/tap/features/welcome/ui/components/WelcomeScreenContent.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.welcome.ui.components +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.material.Icon @@ -12,6 +13,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.components.* +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.wallet.R @@ -97,17 +99,10 @@ private fun WelcomeScreenContentSample(modifier: Modifier = Modifier) { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun WelcomeScreenContentPreview_Light() { - TangemTheme { - WelcomeScreenContentSample() - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun WelcomeScreenContentPreview_Dark() { - TangemTheme(isDark = true) { +private fun WelcomeScreenContentPreview() { + TangemThemePreview { WelcomeScreenContentSample() } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/Buttons.kt b/core/ui/src/main/java/com/tangem/core/ui/components/Buttons.kt index 1e2301844b..bb17fcf7b6 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/Buttons.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/Buttons.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components +import android.content.res.Configuration import androidx.annotation.DrawableRes import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement @@ -12,6 +13,7 @@ import androidx.compose.ui.graphics.Shape import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.R import com.tangem.core.ui.components.buttons.common.* +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme // region TextButton @@ -319,17 +321,10 @@ private fun PrimaryButtonSample() { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun PrimaryButtonPreview_Light() { - TangemTheme { - PrimaryButtonSample() - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun PrimaryButtonPreview_Dark() { - TangemTheme(isDark = true) { +private fun PrimaryButtonPreview() { + TangemThemePreview { PrimaryButtonSample() } } @@ -383,17 +378,10 @@ private fun SecondaryButtonSample() { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun SecondaryButtonPreview_Light() { - TangemTheme { - SecondaryButtonSample() - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun SecondaryButtonPreview_Dark() { - TangemTheme(isDark = true) { +private fun SecondaryButtonPreview() { + TangemThemePreview { SecondaryButtonSample() } } @@ -414,19 +402,11 @@ private fun TextButtonSample() { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun TextButtonPreview_LightTheme() { - TangemTheme { +private fun TextButtonPreview() { + TangemThemePreview { TextButtonSample() } } - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun TextButtonPreview_DarkTheme() { - TangemTheme(isDark = true) { - TextButtonSample() - } -} - // endregion Preview \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/ButtonsDeprecated.kt b/core/ui/src/main/java/com/tangem/core/ui/components/ButtonsDeprecated.kt index 5654a037e7..e8612296a5 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/ButtonsDeprecated.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/ButtonsDeprecated.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components +import android.content.res.Configuration import androidx.annotation.DrawableRes import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.fillMaxWidth @@ -16,15 +17,17 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.R import com.tangem.core.ui.res.ButtonColorType +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TextColorType import com.tangem.core.ui.res.buttonColor import com.tangem.core.ui.res.textColor @Preview(widthDp = 328, heightDp = 48, showBackground = true) +@Preview(widthDp = 328, heightDp = 48, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_PrimaryStartIconButton_Enabled_InLightTheme() { - TangemTheme(isDark = false) { +private fun Preview_PrimaryStartIconButton_Enabled() { + TangemThemePreview { PrimaryStartIconButton( text = "Manage tokens", iconResId = R.drawable.ic_tangem_24, @@ -35,22 +38,10 @@ private fun Preview_PrimaryStartIconButton_Enabled_InLightTheme() { } @Preview(widthDp = 328, heightDp = 48, showBackground = true) +@Preview(widthDp = 328, heightDp = 48, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_PrimaryStartIconButton_Enabled_InDarkTheme() { - TangemTheme(isDark = true) { - PrimaryStartIconButton( - text = "Manage tokens", - iconResId = R.drawable.ic_tangem_24, - enabled = true, - onClick = {}, - ) - } -} - -@Preview(widthDp = 328, heightDp = 48, showBackground = true) -@Composable -private fun Preview_PrimaryStartIconButton_Disabled_InLightTheme() { - TangemTheme(isDark = false) { +private fun Preview_PrimaryStartIconButton_Disabled() { + TangemThemePreview { PrimaryStartIconButton( text = "Manage tokens", iconResId = R.drawable.ic_tangem_24, @@ -61,22 +52,10 @@ private fun Preview_PrimaryStartIconButton_Disabled_InLightTheme() { } @Preview(widthDp = 328, heightDp = 48, showBackground = true) +@Preview(widthDp = 328, heightDp = 48, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_PrimaryStartIconButton_Disabled_InDarkTheme() { - TangemTheme(isDark = true) { - PrimaryStartIconButton( - text = "Manage tokens", - iconResId = R.drawable.ic_tangem_24, - enabled = false, - onClick = {}, - ) - } -} - -@Preview(widthDp = 328, heightDp = 48, showBackground = true) -@Composable -private fun Preview_PrimaryEndIconButton_Enabled_InLightTheme() { - TangemTheme(isDark = false) { +private fun Preview_PrimaryEndIconButton_Enabled() { + TangemThemePreview { PrimaryEndIconButton( text = "Manage tokens", iconResId = R.drawable.ic_tangem_24, @@ -87,35 +66,10 @@ private fun Preview_PrimaryEndIconButton_Enabled_InLightTheme() { } @Preview(widthDp = 328, heightDp = 48, showBackground = true) +@Preview(widthDp = 328, heightDp = 48, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_PrimaryEndIconButton_Enabled_InDarkTheme() { - TangemTheme(isDark = true) { - PrimaryEndIconButton( - text = "Manage tokens", - iconResId = R.drawable.ic_tangem_24, - enabled = true, - onClick = {}, - ) - } -} - -@Preview(widthDp = 328, heightDp = 48, showBackground = true) -@Composable -private fun Preview_PrimaryEndIconButton_Disabled_InLightTheme() { - TangemTheme(isDark = false) { - PrimaryEndIconButton( - text = "Manage tokens", - iconResId = R.drawable.ic_tangem_24, - enabled = false, - onClick = {}, - ) - } -} - -@Preview(widthDp = 328, heightDp = 48, showBackground = true) -@Composable -private fun Preview_PrimaryEndIconButton_Disabled_InDarkTheme() { - TangemTheme(isDark = true) { +private fun Preview_PrimaryEndIconButton_Disabled() { + TangemThemePreview { PrimaryEndIconButton( text = "Manage tokens", iconResId = R.drawable.ic_tangem_24, diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/Cards.kt b/core/ui/src/main/java/com/tangem/core/ui/components/Cards.kt index 91dd9a2506..380c6bd97b 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/Cards.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/Cards.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components +import android.content.res.Configuration import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -22,6 +23,7 @@ import com.tangem.core.ui.components.states.Item import com.tangem.core.ui.components.states.SelectableItemsState import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.valentinilk.shimmer.shimmer import kotlinx.collections.immutable.toImmutableList @@ -650,34 +652,19 @@ private fun CardsPreview() { } @Preview(showBackground = true) +@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_Cards_InLightTheme() { - TangemTheme(isDark = false) { - CardsPreview() - } -} - -@Preview(showBackground = true) -@Composable -private fun Preview_InfoCardWithWarning_InDarkTheme() { - TangemTheme(isDark = true) { +private fun Preview_Cards() { + TangemThemePreview { CardsPreview() } } @Preview(widthDp = 328, heightDp = 48, showBackground = true) +@Preview(widthDp = 328, heightDp = 48, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_SimpleInfoCard_InLightTheme() { - TangemTheme(isDark = false) { - SmallInfoCard(startText = "Balance", endText = "0.4405434 BTC") - SmallInfoCardWithDisclaimer(startText = "Balance", endText = "0.4405434 BTC", disclaimer = "test") - } -} - -@Preview(widthDp = 328, heightDp = 48, showBackground = true) -@Composable -private fun Preview_SimpleInfoCard_InDarkTheme() { - TangemTheme(isDark = true) { +private fun Preview_SimpleInfoCard() { + TangemThemePreview { SmallInfoCard(startText = "Balance", endText = "0.4405434 BTC") SmallInfoCardWithDisclaimer(startText = "Balance", endText = "0.4405434 BTC", disclaimer = "test") } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/CurrencyPlaceholderIcon.kt b/core/ui/src/main/java/com/tangem/core/ui/components/CurrencyPlaceholderIcon.kt index 8d10e7486c..71b0550226 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/CurrencyPlaceholderIcon.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/CurrencyPlaceholderIcon.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.padding @@ -11,6 +12,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -39,19 +41,11 @@ fun CurrencyPlaceholderIcon(id: String, modifier: Modifier = Modifier) { // region preview @Preview(showBackground = true, heightDp = 40, widthDp = 40) +@Preview(showBackground = true, heightDp = 40, widthDp = 40, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_CurrencyPlaceholderIcon_InLightTheme() { - TangemTheme(isDark = false) { +private fun Preview_CurrencyPlaceholderIcon() { + TangemThemePreview { CurrencyPlaceholderIcon(id = "DAI") } } - -@Preview(showBackground = true, heightDp = 40, widthDp = 40) -@Composable -private fun Preview_CurrencyPlaceholderIcon_InDarkTheme() { - TangemTheme(isDark = true) { - CurrencyPlaceholderIcon(id = "DAI") - } -} - // endregion preview \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/Dialogs.kt b/core/ui/src/main/java/com/tangem/core/ui/components/Dialogs.kt index 658d6af9f6..18ca78091a 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/Dialogs.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/Dialogs.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components +import android.content.res.Configuration import androidx.compose.foundation.LocalIndication import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -26,6 +27,7 @@ import com.tangem.core.ui.R import com.tangem.core.ui.components.SelctorDialogParamsProvider.SelectorDialogParams import com.tangem.core.ui.components.buttons.common.TangemButtonsDefaults import com.tangem.core.ui.components.fields.SimpleDialogTextField +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf @@ -450,33 +452,19 @@ private fun BasicDialogPreview() { } @Preview(showBackground = true) +@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_SimpleOkDialog_InLightTheme() { - TangemTheme(isDark = false) { +private fun Preview_SimpleOkDialog() { + TangemThemePreview { SimpleOkDialogPreview() } } @Preview(showBackground = true) +@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_BasicDialog_InLightTheme() { - TangemTheme(isDark = false) { - BasicDialogPreview() - } -} - -@Preview(showBackground = true) -@Composable -private fun Preview_SimpleOkDialog_InDarkTheme() { - TangemTheme(isDark = true) { - SimpleOkDialogPreview() - } -} - -@Preview(showBackground = true) -@Composable -private fun Preview_BasicDialog_InDarkTheme() { - TangemTheme(isDark = true) { +private fun Preview_BasicDialog() { + TangemThemePreview { BasicDialogPreview() } } @@ -498,17 +486,10 @@ private fun WarningBasicDialogSample(modifier: Modifier = Modifier) { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun WarningBasicDialogPreview_Light() { - TangemTheme { - WarningBasicDialogSample() - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun WarningBasicDialogPreview_Dark() { - TangemTheme(isDark = true) { +private fun WarningBasicDialogPreview() { + TangemThemePreview { WarningBasicDialogSample() } } @@ -532,44 +513,19 @@ private fun TextInputDialogSample(modifier: Modifier = Modifier) { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun TextInputDialogPreview_Light() { - TangemTheme { +private fun TextInputDialogPreview() { + TangemThemePreview { TextInputDialogSample() } } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun TextInputDialogPreview_Dark() { - TangemTheme(isDark = true) { - TextInputDialogSample() - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun SelectorDialogPreview_Light( - @PreviewParameter(SelctorDialogParamsProvider::class) param: SelectorDialogParams, -) { - TangemTheme(isDark = false) { - SelectorDialog( - title = param.title, - items = param.items, - selectedItemIndex = param.selectedItemIndex, - confirmButton = DialogButton(title = "Cancel", onClick = {}), - onSelect = {}, - onDismissDialog = {}, - ) - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun SelectorDialogPreview_Dark( - @PreviewParameter(SelctorDialogParamsProvider::class) param: SelectorDialogParams, -) { - TangemTheme(isDark = true) { +private fun SelectorDialogPreview(@PreviewParameter(SelctorDialogParamsProvider::class) param: SelectorDialogParams) { + TangemThemePreview { SelectorDialog( title = param.title, items = param.items, diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/Notifier.kt b/core/ui/src/main/java/com/tangem/core/ui/components/Notifier.kt index a646f37f33..5e3e78a06a 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/Notifier.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/Notifier.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.heightIn @@ -13,6 +14,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview /** * [Show in Figma](https://www.figma.com/file/14ISV23YB1yVW1uNVwqrKv/Android?type=design&node-id=68%3A20&mode=design&t=WSV3AxC6zV1y0CHF-1) @@ -44,17 +46,10 @@ fun Notifier( } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun TangemNotifierPreview_Light(@PreviewParameter(NotifierProvider::class) text: String) { - TangemTheme(isDark = false) { - Notifier(text = text) - } -} - -@Preview -@Composable -private fun TangemNotifierPreview_Dark(@PreviewParameter(NotifierProvider::class) text: String) { - TangemTheme(isDark = true) { +private fun TangemNotifierPreview(@PreviewParameter(NotifierProvider::class) text: String) { + TangemThemePreview { Notifier(text = text) } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/Shimmers.kt b/core/ui/src/main/java/com/tangem/core/ui/components/Shimmers.kt index 311fe1aae8..ddb5122ee1 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/Shimmers.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/Shimmers.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components +import android.content.res.Configuration import androidx.compose.animation.core.LinearEasing import androidx.compose.animation.core.RepeatMode import androidx.compose.animation.core.infiniteRepeatable @@ -18,6 +19,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import com.tangem.core.ui.res.LocalIsInDarkTheme import com.tangem.core.ui.res.TangemColorPalette +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.valentinilk.shimmer.* @@ -90,37 +92,24 @@ private val TangemShimmerColors: List // region preview +@Preview(showBackground = true) +@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable private fun ShimmersPreview() { - Column( - modifier = Modifier - .fillMaxWidth() - .background(TangemTheme.colors.background.primary), - verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing18), - ) { - RectangleShimmer( + TangemThemePreview { + Column( modifier = Modifier .fillMaxWidth() - .height(TangemTheme.dimens.size24), - ) - CircleShimmer(modifier = Modifier.size(size = TangemTheme.dimens.size42)) + .background(TangemTheme.colors.background.primary), + verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing18), + ) { + RectangleShimmer( + modifier = Modifier + .fillMaxWidth() + .height(TangemTheme.dimens.size24), + ) + CircleShimmer(modifier = Modifier.size(size = TangemTheme.dimens.size42)) + } } } - -@Preview(showBackground = true) -@Composable -private fun Shimmers_InLightTheme() { - TangemTheme(isDark = false) { - ShimmersPreview() - } -} - -@Preview(showBackground = true) -@Composable -private fun Shimmers_InDarkTheme() { - TangemTheme(isDark = true) { - ShimmersPreview() - } -} - // endregion preview \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/TextFields.kt b/core/ui/src/main/java/com/tangem/core/ui/components/TextFields.kt index f8312aa659..055eaab6f7 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/TextFields.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/TextFields.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components +import android.content.res.Configuration import androidx.annotation.DrawableRes import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.animateColorAsState @@ -25,6 +26,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.tangem.core.ui.R +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -505,17 +507,10 @@ private fun OutlineTextFieldSample(modifier: Modifier = Modifier) { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun OutlineTextFieldPreview_Light() { - TangemTheme { - OutlineTextFieldSample() - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun OutlineTextFieldPreview_Dark() { - TangemTheme(isDark = true) { +private fun OutlineTextFieldPreview() { + TangemThemePreview { OutlineTextFieldSample() } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/Warnings.kt b/core/ui/src/main/java/com/tangem/core/ui/components/Warnings.kt index fe2a681d08..cee6370513 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/Warnings.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/Warnings.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components +import android.content.res.Configuration import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth @@ -13,6 +14,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.R +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -179,42 +181,29 @@ private fun WarningCardMaterial3Style(onClick: (() -> Unit)? = null, content: @C // region Preview +@Preview(showBackground = true) +@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable private fun WarningsPreview() { - Column(modifier = Modifier.fillMaxWidth()) { - WarningCard( - title = "Exchange rate has expired", - description = "To access all the networks, you need to scan the card.", - ) - SpacerH32() - ClickableWarningCard( - title = "Exchange rate has expired", - description = "To access all the networks, you need to scan the card.", - onClick = {}, - ) - SpacerH32() - RefreshableWarningCard( - title = "Exchange rate has expired", - description = "To access all the networks, you need to scan the card.", - onClick = {}, - ) + TangemThemePreview { + Column(modifier = Modifier.fillMaxWidth()) { + WarningCard( + title = "Exchange rate has expired", + description = "To access all the networks, you need to scan the card.", + ) + SpacerH32() + ClickableWarningCard( + title = "Exchange rate has expired", + description = "To access all the networks, you need to scan the card.", + onClick = {}, + ) + SpacerH32() + RefreshableWarningCard( + title = "Exchange rate has expired", + description = "To access all the networks, you need to scan the card.", + onClick = {}, + ) + } } } - -@Preview(showBackground = true) -@Composable -private fun Preview_Warning_InLightTheme() { - TangemTheme(isDark = false) { - WarningsPreview() - } -} - -@Preview(showBackground = true) -@Composable -private fun Preview_Warning_InDarkTheme() { - TangemTheme(isDark = true) { - WarningsPreview() - } -} - // endregion Preview \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithAdditionalButtons.kt b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithAdditionalButtons.kt index 1b910ca269..685358db13 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithAdditionalButtons.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithAdditionalButtons.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.appbar +import android.content.res.Configuration import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.heightIn @@ -15,6 +16,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.R import com.tangem.core.ui.components.appbar.models.AdditionalButton +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -71,9 +73,10 @@ fun AppBarWithAdditionalButtons( } @Preview(widthDp = 360, heightDp = 56, showBackground = true) +@Preview(widthDp = 360, heightDp = 56, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_AppBarWithAdditionalButtons_InLightTheme() { - TangemTheme(isDark = false) { +private fun Preview_AppBarWithAdditionalButtons() { + TangemThemePreview { AppBarWithAdditionalButtons( text = "Tangem", startButton = AdditionalButton( @@ -89,27 +92,10 @@ private fun Preview_AppBarWithAdditionalButtons_InLightTheme() { } @Preview(widthDp = 360, heightDp = 56, showBackground = true) +@Preview(widthDp = 360, heightDp = 56, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_AppBarWithAdditionalButtons_InDarkTheme() { - TangemTheme(isDark = true) { - AppBarWithAdditionalButtons( - text = "Tangem", - startButton = AdditionalButton( - iconRes = R.drawable.ic_scan_24, - onIconClicked = {}, - ), - endButton = AdditionalButton( - iconRes = R.drawable.ic_more_vertical_24, - onIconClicked = {}, - ), - ) - } -} - -@Preview(widthDp = 360, heightDp = 56, showBackground = true) -@Composable -private fun Preview_AppBarWithOnlyStartButtons_InLightTheme() { - TangemTheme(isDark = false) { +private fun Preview_AppBarWithOnlyStartButtons() { + TangemThemePreview { AppBarWithAdditionalButtons( text = "Tangem", startButton = AdditionalButton( @@ -121,37 +107,10 @@ private fun Preview_AppBarWithOnlyStartButtons_InLightTheme() { } @Preview(widthDp = 360, heightDp = 56, showBackground = true) +@Preview(widthDp = 360, heightDp = 56, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_AppBarWithOnlyStartButtons_InDarkTheme() { - TangemTheme(isDark = true) { - AppBarWithAdditionalButtons( - text = "Tangem", - startButton = AdditionalButton( - iconRes = R.drawable.ic_scan_24, - onIconClicked = {}, - ), - ) - } -} - -@Preview(widthDp = 360, heightDp = 56, showBackground = true) -@Composable -private fun Preview_AppBarWithOnlyEndButtons_InLightTheme() { - TangemTheme(isDark = false) { - AppBarWithAdditionalButtons( - text = "Tangem", - endButton = AdditionalButton( - iconRes = R.drawable.ic_more_vertical_24, - onIconClicked = {}, - ), - ) - } -} - -@Preview(widthDp = 360, heightDp = 56, showBackground = true) -@Composable -private fun Preview_AppBarWithOnlyEndButtons_InDarkTheme() { - TangemTheme(isDark = true) { +private fun Preview_AppBarWithOnlyEndButtons() { + TangemThemePreview { AppBarWithAdditionalButtons( text = "Tangem", endButton = AdditionalButton( diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButton.kt b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButton.kt index afb57565f8..80d3014615 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButton.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButton.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.appbar +import android.content.res.Configuration import androidx.annotation.DrawableRes import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -15,6 +16,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.R +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -67,17 +69,10 @@ fun AppBarWithBackButton( } @Preview(widthDp = 360, heightDp = 56, showBackground = true) +@Preview(widthDp = 360, heightDp = 56, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun PreviewAppBarWithBackButtonInLightTheme() { - TangemTheme(isDark = false) { - AppBarWithBackButton(text = "Title", onBackClick = {}) - } -} - -@Preview(widthDp = 360, heightDp = 56, showBackground = true) -@Composable -private fun PreviewAppBarWithBackButtonInDarkTheme() { - TangemTheme(isDark = true) { +private fun PreviewAppBarWithBackButton() { + TangemThemePreview { AppBarWithBackButton(text = "Title", onBackClick = {}) } } \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButtonAndIcon.kt b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButtonAndIcon.kt index 405217433f..0006bdad9d 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButtonAndIcon.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButtonAndIcon.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.appbar +import android.content.res.Configuration import androidx.annotation.DrawableRes import androidx.compose.animation.* import androidx.compose.foundation.clickable @@ -11,6 +12,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.R +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme @Composable @@ -53,22 +55,10 @@ fun AppBarWithBackButtonAndIcon( } @Preview(widthDp = 360, heightDp = 56, showBackground = true) +@Preview(widthDp = 360, heightDp = 56, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun PreviewAppBarWithBackButtonAndIconInLightTheme() { - TangemTheme(isDark = false) { - AppBarWithBackButtonAndIcon( - text = "Title", - iconRes = R.drawable.ic_qrcode_scan_24, - onBackClick = {}, - onIconClick = {}, - ) - } -} - -@Preview(widthDp = 360, heightDp = 56, showBackground = true) -@Composable -private fun PreviewAppBarWithBackButtonAndIconInDarkTheme() { - TangemTheme(isDark = true) { +private fun PreviewAppBarWithBackButtonAndIcon() { + TangemThemePreview { AppBarWithBackButtonAndIcon( text = "Title", iconRes = R.drawable.ic_qrcode_scan_24, diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButtonAndIconContent.kt b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButtonAndIconContent.kt index c65bf02622..fae3598a38 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButtonAndIconContent.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButtonAndIconContent.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.appbar +import android.content.res.Configuration import androidx.annotation.DrawableRes import androidx.compose.animation.* import androidx.compose.foundation.background @@ -17,6 +18,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.R +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -98,34 +100,10 @@ fun AppBarWithBackButtonAndIconContent( } @Preview(widthDp = 360, heightDp = 56, showBackground = true) +@Preview(widthDp = 360, heightDp = 56, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun PreviewAppBarWithBackButtonAndIconInLightTheme() { - TangemTheme(isDark = false) { - AppBarWithBackButtonAndIconContent( - text = "Title", - onBackClick = {}, - iconContent = { - Row { - Icon( - painter = painterResource(id = R.drawable.ic_qrcode_scan_24), - tint = TangemTheme.colors.icon.primary1, - contentDescription = null, - ) - Icon( - painter = painterResource(id = R.drawable.ic_flash_on_24), - tint = TangemTheme.colors.icon.primary1, - contentDescription = null, - ) - } - }, - ) - } -} - -@Preview(widthDp = 360, heightDp = 56, showBackground = true) -@Composable -private fun PreviewAppBarWithBackButtonAndIconInDarkTheme() { - TangemTheme(isDark = true) { +private fun PreviewAppBarWithBackButtonAndIcon() { + TangemThemePreview { AppBarWithBackButtonAndIconContent( text = "Title", subtitle = "Subtitle", diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithSearch.kt b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithSearch.kt index 4dfd01d36d..ab6996b21d 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithSearch.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithSearch.kt @@ -26,6 +26,7 @@ import com.tangem.core.ui.R import com.tangem.core.ui.components.SpacerWMax import com.tangem.core.ui.components.TangemTextFieldsDefault import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview /** * App bar with close icon and search functionality @@ -228,7 +229,7 @@ private fun ExpandedSearchView( @Preview @Composable private fun CollapsedSearchViewPreview() { - TangemTheme { + TangemThemePreview { ExpandableSearchView( title = "Choose Token", onBackClick = {}, @@ -245,7 +246,7 @@ private fun CollapsedSearchViewPreview() { @Preview @Composable private fun ExpandedSearchViewPreview() { - TangemTheme { + TangemThemePreview { ExpandableSearchView( title = "Choose Token", onBackClick = {}, diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/atoms/Hand.kt b/core/ui/src/main/java/com/tangem/core/ui/components/atoms/Hand.kt index f3d155f5a2..1f9dd3beca 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/atoms/Hand.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/atoms/Hand.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.atoms +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.runtime.Composable @@ -8,6 +9,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -52,17 +54,10 @@ private fun HandSample(modifier: Modifier = Modifier) { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun HandPreview_Light() { - TangemTheme { - HandSample() - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun HandPreview_Dark() { - TangemTheme(isDark = true) { +private fun HandPreview() { + TangemThemePreview { HandSample() } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/atoms/text/EllipsisText.kt b/core/ui/src/main/java/com/tangem/core/ui/components/atoms/text/EllipsisText.kt index d95b813ee1..d7ed2b5dd2 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/atoms/text/EllipsisText.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/atoms/text/EllipsisText.kt @@ -23,6 +23,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.TextUnit import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview sealed class TextEllipsis { @@ -219,7 +220,7 @@ private fun offsetEndEllipsisText( @Preview(widthDp = 200) @Composable private fun EllipsisTexPreview(@PreviewParameter(EllipsisTexPreviewParameterProvider::class) ellipsis: TextEllipsis) { - TangemTheme { + TangemThemePreview { EllipsisText( text = "11111111111111111111111111111111111111111111111111 END", ellipsis = ellipsis, diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/buttons/HorizontalActionChips.kt b/core/ui/src/main/java/com/tangem/core/ui/components/buttons/HorizontalActionChips.kt index a6c3ee8402..715a630ed3 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/buttons/HorizontalActionChips.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/buttons/HorizontalActionChips.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.buttons +import android.content.res.Configuration import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxWidth @@ -15,6 +16,7 @@ import com.tangem.core.ui.R import com.tangem.core.ui.components.buttons.actions.ActionButton import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig import com.tangem.core.ui.extensions.TextReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf @@ -41,21 +43,12 @@ fun HorizontalActionChips( // region Preview @Preview(widthDp = 360) +@Preview(widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_HorizontalActionChips_Light( +private fun Preview_HorizontalActionChips( @PreviewParameter(ActionButtonConfigProvider::class) buttons: HorizontalActionChips, ) { - TangemTheme(isDark = false) { - HorizontalActionChips(buttons = buttons.buttons) - } -} - -@Preview(widthDp = 360) -@Composable -private fun Preview_HorizontalActionChips_Dark( - @PreviewParameter(ActionButtonConfigProvider::class) buttons: HorizontalActionChips, -) { - TangemTheme(isDark = true) { + TangemThemePreview { HorizontalActionChips(buttons = buttons.buttons) } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/buttons/SmallButton.kt b/core/ui/src/main/java/com/tangem/core/ui/components/buttons/SmallButton.kt index 60bc4a690f..15f640bdbf 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/buttons/SmallButton.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/buttons/SmallButton.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.buttons +import android.content.res.Configuration import androidx.compose.animation.animateColorAsState import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -14,6 +15,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -90,17 +92,10 @@ private fun SmallButton(config: SmallButtonConfig, isPrimary: Boolean, modifier: } @Preview(showBackground = true) +@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_SmallButton_Light() { - TangemTheme(isDark = false) { - ButtonsSample() - } -} - -@Preview(showBackground = true) -@Composable -private fun Preview_SmallButton_Dark() { - TangemTheme(isDark = true) { +private fun Preview_SmallButton() { + TangemThemePreview { ButtonsSample() } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/buttons/actions/Actions.kt b/core/ui/src/main/java/com/tangem/core/ui/components/buttons/actions/Actions.kt index 3d0b87e26a..6c7e926dae 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/buttons/actions/Actions.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/buttons/actions/Actions.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.buttons.actions +import android.content.res.Configuration import androidx.compose.animation.animateColorAsState import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -23,6 +24,7 @@ import com.tangem.core.ui.components.SpacerW8 import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview /** * Rounded action button @@ -133,33 +135,19 @@ private fun Button( } @Preview(group = "RoundedActionButton", showBackground = true) +@Preview(group = "RoundedActionButton", showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_RoundedActionButton_Light(@PreviewParameter(ActionStateProvider::class) state: ActionButtonConfig) { - TangemTheme(isDark = false) { - RoundedActionButton(state) - } -} - -@Preview(group = "RoundedActionButton", showBackground = true) -@Composable -private fun Preview_RoundedActionButton_Dark(@PreviewParameter(ActionStateProvider::class) state: ActionButtonConfig) { - TangemTheme(isDark = true) { +private fun Preview_RoundedActionButton(@PreviewParameter(ActionStateProvider::class) state: ActionButtonConfig) { + TangemThemePreview { RoundedActionButton(state) } } @Preview(group = "ActionButton", showBackground = true) +@Preview(group = "ActionButton", showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_ActionButton_Light(@PreviewParameter(ActionStateProvider::class) state: ActionButtonConfig) { - TangemTheme(isDark = false) { - ActionButton(state) - } -} - -@Preview(group = "ActionButton", showBackground = true) -@Composable -private fun Preview_ActionButton_Dark(@PreviewParameter(ActionStateProvider::class) state: ActionButtonConfig) { - TangemTheme(isDark = true) { +private fun Preview_ActionButton(@PreviewParameter(ActionStateProvider::class) state: ActionButtonConfig) { + TangemThemePreview { ActionButton(state) } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/buttons/segmentedbutton/SegmentedButton.kt b/core/ui/src/main/java/com/tangem/core/ui/components/buttons/segmentedbutton/SegmentedButton.kt index f3cbfca76d..0bfeb822a6 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/buttons/segmentedbutton/SegmentedButton.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/buttons/segmentedbutton/SegmentedButton.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.buttons.segmentedbutton +import android.content.res.Configuration import androidx.compose.animation.animateColorAsState import androidx.compose.animation.core.Spring import androidx.compose.animation.core.spring @@ -20,6 +21,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.persistentListOf @@ -102,29 +104,12 @@ inline fun SegmentedButtons( } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun SegmentedButtonsPreview_Light( +private fun SegmentedButtonsPreview( @PreviewParameter(SegmentedButtonsPreviewProvider::class) config: PersistentList, ) { - TangemTheme { - SegmentedButtons( - config = config, - onClick = {}, - ) { - Text( - text = it.text, - modifier = Modifier.padding(TangemTheme.dimens.spacing16), - ) - } - } -} - -@Preview -@Composable -private fun SegmentedButtonsPreview_Dark( - @PreviewParameter(SegmentedButtonsPreviewProvider::class) config: PersistentList, -) { - TangemTheme(isDark = true) { + TangemThemePreview { SegmentedButtons( config = config, onClick = {}, diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/fields/AmountTextField.kt b/core/ui/src/main/java/com/tangem/core/ui/components/fields/AmountTextField.kt index c095c2b8fd..73a58d56a1 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/fields/AmountTextField.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/fields/AmountTextField.kt @@ -27,6 +27,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameterProvider import com.tangem.core.ui.components.fields.visualtransformations.AmountVisualTransformation import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.utils.* import java.text.DecimalFormat @@ -128,7 +129,7 @@ private fun AmountTextFieldPreview( @PreviewParameter(AmountTextFieldPreviewProvider::class) amount: AmountTextFieldPreviewData, ) { var text by remember { mutableStateOf(amount.value.orEmpty()) } - TangemTheme { + TangemThemePreview { AmountTextField( value = text, decimals = amount.decimals, diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/icons/identicon/IdentIcon.kt b/core/ui/src/main/java/com/tangem/core/ui/components/icons/identicon/IdentIcon.kt index 23f26292ee..c4f107369a 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/icons/identicon/IdentIcon.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/icons/identicon/IdentIcon.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.icons.identicon +import android.content.res.Configuration import androidx.compose.foundation.Canvas import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.size @@ -13,6 +14,7 @@ import androidx.compose.ui.text.intl.Locale import androidx.compose.ui.text.toLowerCase import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.res.LocalIsInDarkTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme private const val GAP_WIDTH = 1f @@ -62,9 +64,10 @@ fun IdentIcon(address: String, modifier: Modifier = Modifier) { //region preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun IdentIconPreview_Light() { - TangemTheme { +private fun IdentIconPreview() { + TangemThemePreview { IdentIcon( address = "0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359", modifier = Modifier @@ -72,17 +75,4 @@ private fun IdentIconPreview_Light() { ) } } - -@Preview -@Composable -private fun IdentIconPreview_Dark() { - TangemTheme(isDark = true) { - IdentIcon( - address = "0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359", - modifier = Modifier - .size(TangemTheme.dimens.size40), - ) - } -} - //endregion \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowApprox.kt b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowApprox.kt index 6310a11f5a..2bd8311866 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowApprox.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowApprox.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.inputrow +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.material3.Icon @@ -16,6 +17,7 @@ import com.tangem.core.ui.components.currency.tokenicon.TokenIconState import com.tangem.core.ui.components.inputrow.inner.DividerContainer import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -123,40 +125,36 @@ private fun InputRowApproxItem( //region Preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun InputRowApproxPreview_Light() { - TangemTheme { - InputRowApprox( - leftIcon = TokenIconState.Loading, - leftTitle = TextReference.Str("Left title USD"), - leftSubtitle = TextReference.Str("Left subtitle USD"), - leftTitleEllipsisOffset = 3, - rightIcon = TokenIconState.Loading, - rightTitle = TextReference.Str("Right title Right title Right title Right title Right title USD"), - rightSubtitle = TextReference.Str("Right subtitle Right subtitle Right subtitle USD"), - rightTitleEllipsisOffset = 3, - modifier = Modifier - .background(TangemTheme.colors.background.action), - ) - } -} - -@Preview -@Composable -private fun InputRowApproxPreview_Dark() { - TangemTheme(isDark = true) { - InputRowApprox( - leftIcon = TokenIconState.Loading, - leftTitle = TextReference.Str("Left title Left title Left title Left title Left title USD"), - leftSubtitle = TextReference.Str("Left subtitle Left subtitle Left subtitle USD"), - leftTitleEllipsisOffset = 3, - rightIcon = TokenIconState.Loading, - rightTitle = TextReference.Str("Right title USD"), - rightSubtitle = TextReference.Str("Right subtitle USD"), - rightTitleEllipsisOffset = 3, - modifier = Modifier - .background(TangemTheme.colors.background.action), - ) +private fun InputRowApproxPreview() { + TangemThemePreview { + Column { + InputRowApprox( + leftIcon = TokenIconState.Loading, + leftTitle = TextReference.Str("Left title USD"), + leftSubtitle = TextReference.Str("Left subtitle USD"), + leftTitleEllipsisOffset = 3, + rightIcon = TokenIconState.Loading, + rightTitle = TextReference.Str("Right title Right title Right title Right title Right title USD"), + rightSubtitle = TextReference.Str("Right subtitle Right subtitle Right subtitle USD"), + rightTitleEllipsisOffset = 3, + modifier = Modifier + .background(TangemTheme.colors.background.action), + ) + InputRowApprox( + leftIcon = TokenIconState.Loading, + leftTitle = TextReference.Str("Left title Left title Left title Left title Left title USD"), + leftSubtitle = TextReference.Str("Left subtitle Left subtitle Left subtitle USD"), + leftTitleEllipsisOffset = 3, + rightIcon = TokenIconState.Loading, + rightTitle = TextReference.Str("Right title USD"), + rightSubtitle = TextReference.Str("Right subtitle USD"), + rightTitleEllipsisOffset = 3, + modifier = Modifier + .background(TangemTheme.colors.background.action), + ) + } } } //endregion \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowBestRate.kt b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowBestRate.kt index 620e3346cf..3f711de362 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowBestRate.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowBestRate.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.inputrow +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource @@ -27,6 +28,7 @@ import com.tangem.core.ui.components.currency.tokenicon.LoadingIcon import com.tangem.core.ui.components.inputrow.inner.DividerContainer import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -154,30 +156,12 @@ private fun InnerIcon(imageUrl: String) { //region preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun InputRowBestRatePreview_Light( +private fun InputRowBestRatePreview( @PreviewParameter(InputRowBestRatePreviewDataProvider::class) data: InputRowBestRatePreviewData, ) { - TangemTheme { - InputRowBestRate( - imageUrl = "", - title = data.title, - titleExtra = data.titleExtra, - subtitle = data.subtitle, - showTag = data.showTag, - onIconClick = data.iconClick, - modifier = Modifier - .background(TangemTheme.colors.background.action), - ) - } -} - -@Preview -@Composable -private fun InputRowBestRatePreview_Dark( - @PreviewParameter(InputRowBestRatePreviewDataProvider::class) data: InputRowBestRatePreviewData, -) { - TangemTheme(isDark = true) { + TangemThemePreview { InputRowBestRate( imageUrl = "", title = data.title, diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowDefault.kt b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowDefault.kt index e41ac02d17..4222d238c0 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowDefault.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowDefault.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.inputrow +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource @@ -19,6 +20,7 @@ import com.tangem.core.ui.R import com.tangem.core.ui.components.inputrow.inner.DividerContainer import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -94,27 +96,12 @@ fun InputRowDefault( //region preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun InputRowDefaultPreview_Light( +private fun InputRowDefaultPreview( @PreviewParameter(InputRowDefaultPreviewDataProvider::class) data: InputRowDefaultPreviewData, ) { - TangemTheme { - InputRowDefault( - title = TextReference.Str(data.title), - text = TextReference.Str(data.text), - iconRes = data.iconRes, - showDivider = data.showDivider, - modifier = Modifier.background(TangemTheme.colors.background.action), - ) - } -} - -@Preview -@Composable -private fun InputRowDefaultPreview_Dark( - @PreviewParameter(InputRowDefaultPreviewDataProvider::class) data: InputRowDefaultPreviewData, -) { - TangemTheme(isDark = true) { + TangemThemePreview { InputRowDefault( title = TextReference.Str(data.title), text = TextReference.Str(data.text), diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowEnter.kt b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowEnter.kt index f81372c3da..4d1490891f 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowEnter.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowEnter.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.inputrow +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource @@ -22,6 +23,7 @@ import com.tangem.core.ui.components.inputrow.inner.DividerContainer import com.tangem.core.ui.components.fields.SimpleTextField import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -106,28 +108,12 @@ fun InputRowEnter( //region preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun InputRowEnterPreview_Light( +private fun InputRowEnterPreview( @PreviewParameter(InputRowEnterPreviewDataProvider::class) data: InputRowEnterPreviewData, ) { - TangemTheme { - InputRowEnter( - title = TextReference.Str(data.title), - text = data.text, - iconRes = data.iconRes, - showDivider = data.showDivider, - onValueChange = {}, - modifier = Modifier.background(TangemTheme.colors.background.action), - ) - } -} - -@Preview -@Composable -private fun InputRowEnterPreview_Dark( - @PreviewParameter(InputRowEnterPreviewDataProvider::class) data: InputRowEnterPreviewData, -) { - TangemTheme(isDark = true) { + TangemThemePreview { InputRowEnter( title = TextReference.Str(data.title), text = data.text, diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowEnterInfo.kt b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowEnterInfo.kt index 25debb16dc..c9e01fd85f 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowEnterInfo.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowEnterInfo.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.inputrow +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.text.KeyboardOptions @@ -16,6 +17,7 @@ import com.tangem.core.ui.components.inputrow.inner.DividerContainer import com.tangem.core.ui.components.fields.SimpleTextField import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -92,28 +94,12 @@ fun InputRowEnterInfo( //region preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun InputRowEnterInfoPreview_Light( +private fun InputRowEnterInfoPreview( @PreviewParameter(InputRowEnterInfoPreviewDataProvider::class) data: InputRowEnterInfoPreviewData, ) { - TangemTheme { - InputRowEnterInfo( - title = data.title, - text = data.text, - info = data.info, - showDivider = data.showDivider, - onValueChange = {}, - modifier = Modifier.background(TangemTheme.colors.background.action), - ) - } -} - -@Preview -@Composable -private fun InputRowEnterInfoPreview_Dark( - @PreviewParameter(InputRowEnterInfoPreviewDataProvider::class) data: InputRowEnterInfoPreviewData, -) { - TangemTheme(isDark = true) { + TangemThemePreview { InputRowEnterInfo( title = data.title, text = data.text, diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowImage.kt b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowImage.kt index 1754c3b8bc..35ba18ad8a 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowImage.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowImage.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.inputrow +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource @@ -22,6 +23,7 @@ import com.tangem.core.ui.components.currency.tokenicon.TokenIcon import com.tangem.core.ui.components.currency.tokenicon.TokenIconState import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -120,31 +122,12 @@ fun InputRowImage( //region preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun InputRowInputEnterInfoPreview_Light( +private fun InputRowInputEnterInfoPreview( @PreviewParameter(InputRowImagePreviewDataProvider::class) data: InputRowImagePreviewData, ) { - TangemTheme { - InputRowImage( - title = data.title, - modifier = Modifier.background(TangemTheme.colors.background.action), - subtitle = data.subtitle, - caption = data.caption, - tokenIconState = data.iconState, - iconRes = data.actionIconRes, - onIconClick = {}, - showNetworkIcon = false, - showDivider = data.showDivider, - ) - } -} - -@Preview -@Composable -private fun InputRowImagePreview_Dark( - @PreviewParameter(InputRowImagePreviewDataProvider::class) data: InputRowImagePreviewData, -) { - TangemTheme(isDark = true) { + TangemThemePreview { InputRowImage( title = data.title, modifier = Modifier.background(TangemTheme.colors.background.action), diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowRecipient.kt b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowRecipient.kt index 41bbc546b7..de4873ae76 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowRecipient.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowRecipient.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.inputrow +import android.content.res.Configuration import androidx.compose.animation.AnimatedContent import androidx.compose.foundation.background import androidx.compose.foundation.layout.* @@ -22,6 +23,7 @@ import com.tangem.core.ui.components.inputrow.inner.DividerContainer import com.tangem.core.ui.components.inputrow.inner.PasteButton import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import kotlinx.coroutines.delay @@ -149,11 +151,12 @@ private fun RowScope.InputIcon(isLoading: Boolean, value: String) { //region preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun InputRowRecipientPreview_Light( +private fun InputRowRecipientPreview( @PreviewParameter(InputRowRecipientPreviewDataProvider::class) value: InputRowRecipientPreviewData, ) { - TangemTheme { + TangemThemePreview { InputRowRecipient( value = value.value, title = TextReference.Res(R.string.send_recipient), @@ -169,27 +172,6 @@ private fun InputRowRecipientPreview_Light( } } -@Preview -@Composable -private fun InputRowRecipientPreview_Dark( - @PreviewParameter(InputRowRecipientPreviewDataProvider::class) value: InputRowRecipientPreviewData, -) { - TangemTheme(isDark = true) { - InputRowRecipient( - value = value.value, - title = TextReference.Res(R.string.send_recipient), - placeholder = TextReference.Res(R.string.send_optional_field), - error = TextReference.Str("Error"), - isLoading = value.isLoading, - isError = value.isError, - showDivider = true, - onValueChange = {}, - onPasteClick = {}, - modifier = Modifier.background(TangemTheme.colors.background.primary), - ) - } -} - private data class InputRowRecipientPreviewData( val value: String, val isError: Boolean, diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowRecipientDefault.kt b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowRecipientDefault.kt index 8ae6b1b386..94f75c6a56 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowRecipientDefault.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/InputRowRecipientDefault.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.inputrow +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.RoundedCornerShape @@ -15,6 +16,7 @@ import com.tangem.core.ui.components.icons.identicon.IdentIcon import com.tangem.core.ui.components.inputrow.inner.DividerContainer import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -79,9 +81,10 @@ fun InputRowRecipientDefault( //region preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun InputRowRecipientPreview_Light() { - TangemTheme { +private fun InputRowRecipientPreview() { + TangemThemePreview { InputRowRecipientDefault( value = "0x391316d97a07027a0702c8A002c8A0C25d8470", title = TextReference.Res(R.string.send_recipient), @@ -90,17 +93,4 @@ private fun InputRowRecipientPreview_Light() { ) } } - -@Preview -@Composable -private fun InputRowRecipientPreview_Dark() { - TangemTheme(isDark = true) { - InputRowRecipientDefault( - value = "0x391316d97a07027a0702c8A002c8A0C25d8470", - title = TextReference.Res(R.string.send_recipient), - showDivider = false, - modifier = Modifier.background(TangemTheme.colors.background.primary), - ) - } -} //endregion \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/inner/PasteButton.kt b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/inner/PasteButton.kt index 49c308e97e..c3538cb57d 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/inner/PasteButton.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/inner/PasteButton.kt @@ -22,6 +22,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.R import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.utils.DEFAULT_ANIMATION_DURATION /** @@ -100,7 +101,7 @@ fun CrossIcon(onClick: (String) -> Unit, modifier: Modifier = Modifier) { @Composable private fun PasteButtonPreview() { var isVisible by remember { mutableStateOf(true) } - TangemTheme { + TangemThemePreview { PasteButton( isPasteButtonVisible = isVisible, onClick = { isVisible = !isVisible }, diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/marketprice/MarketPriceBlock.kt b/core/ui/src/main/java/com/tangem/core/ui/components/marketprice/MarketPriceBlock.kt index 873d6dbcb2..606416093a 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/marketprice/MarketPriceBlock.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/marketprice/MarketPriceBlock.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.marketprice +import android.content.res.Configuration import androidx.compose.animation.AnimatedContent import androidx.compose.foundation.background import androidx.compose.foundation.layout.* @@ -19,6 +20,7 @@ import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameter import androidx.compose.ui.unit.Dp import com.tangem.core.ui.R import com.tangem.core.ui.components.RectangleShimmer +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.utils.BigDecimalFormatter @@ -203,23 +205,13 @@ private fun QuoteTimeStatus() { // region Preview @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_MarketPriceBlock_Light( +private fun Preview_MarketPriceBlock( @PreviewParameter(WalletMarketPriceBlockStateProvider::class) state: MarketPriceBlockState, ) { - TangemTheme(isDark = false) { - MarketPriceBlock(state = state) - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun Preview_MarketPriceBlock_Dark( - @PreviewParameter(WalletMarketPriceBlockStateProvider::class) - state: MarketPriceBlockState, -) { - TangemTheme(isDark = true) { + TangemThemePreview { MarketPriceBlock(state = state) } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/notifications/Notification.kt b/core/ui/src/main/java/com/tangem/core/ui/components/notifications/Notification.kt index c352cf41eb..6d339e48dd 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/notifications/Notification.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/notifications/Notification.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.notifications +import android.content.res.Configuration import androidx.annotation.DrawableRes import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.Image @@ -29,6 +30,7 @@ import com.tangem.core.ui.components.* import com.tangem.core.ui.components.buttons.common.TangemButtonSize import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.components.notifications.NotificationConfig.ButtonsState as NotificationButtonsState @@ -269,22 +271,13 @@ private fun CloseableIconButton(onClick: (() -> Unit)?, modifier: Modifier = Mod } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_Notification_Light( +private fun Preview_Notification( @PreviewParameter(NotificationConfigProvider::class) config: NotificationConfig, ) { - TangemTheme(isDark = false) { - Notification(config) - } -} - -@Preview -@Composable -private fun Preview_Notification_Dark( - @PreviewParameter(NotificationConfigProvider::class) config: NotificationConfig, -) { - TangemTheme(isDark = true) { + TangemThemePreview { Notification(config) } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/notifications/NotificationWithBackground.kt b/core/ui/src/main/java/com/tangem/core/ui/components/notifications/NotificationWithBackground.kt index e4e8a06833..00945dbb44 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/notifications/NotificationWithBackground.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/notifications/NotificationWithBackground.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.notifications +import android.content.res.Configuration import androidx.compose.foundation.Image import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource @@ -32,6 +33,7 @@ import com.tangem.core.ui.extensions.wrappedList import com.tangem.core.ui.res.LocalIsInDarkTheme import com.tangem.core.ui.res.TangemColorPalette.Dark6 import com.tangem.core.ui.res.TangemColorPalette.Light4 +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -149,21 +151,12 @@ fun NotificationWithBackground(config: NotificationConfig, modifier: Modifier = //region preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun NotificationWithBackgroundPreview_Light( +private fun NotificationWithBackgroundPreview( @PreviewParameter(NotificationWithBackgroundPreviewProvider::class) config: NotificationConfig, ) { - TangemTheme { - NotificationWithBackground(config = config) - } -} - -@Preview -@Composable -private fun NotificationWithBackgroundPreview_Dark( - @PreviewParameter(NotificationWithBackgroundPreviewProvider::class) config: NotificationConfig, -) { - TangemTheme(isDark = true) { + TangemThemePreview { NotificationWithBackground(config = config) } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/rows/ActionRow.kt b/core/ui/src/main/java/com/tangem/core/ui/components/rows/ActionRow.kt index 0c2a785acc..36c44d81b3 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/rows/ActionRow.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/rows/ActionRow.kt @@ -13,6 +13,7 @@ import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.R import com.tangem.core.ui.components.SpacerH28 import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview /** * Simple clickable action row, without input and icon @@ -66,7 +67,7 @@ fun SimpleActionRow(title: String, description: String, modifier: Modifier = Mod @Composable private fun SimpleActionRowPreview() { Column { - TangemTheme(isDark = false) { + TangemThemePreview(isDark = false) { SimpleActionRow( title = "Title", description = "Description", @@ -75,7 +76,7 @@ private fun SimpleActionRowPreview() { SpacerH28() - TangemTheme(isDark = false) { + TangemThemePreview(isDark = false) { SimpleActionRow( title = "Title", description = "Description", diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/rows/SelectorRowItem.kt b/core/ui/src/main/java/com/tangem/core/ui/components/rows/SelectorRowItem.kt index b919363574..6795d2e0f3 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/rows/SelectorRowItem.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/rows/SelectorRowItem.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.rows +import android.content.res.Configuration import androidx.annotation.DrawableRes import androidx.annotation.StringRes import androidx.compose.animation.animateColorAsState @@ -21,6 +22,7 @@ import com.tangem.core.ui.components.atoms.text.EllipsisText import com.tangem.core.ui.components.atoms.text.TextEllipsis import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme @Composable @@ -132,25 +134,10 @@ private fun RowScope.SelectorValueContent( } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun SelectorRowItemPreview_Light() { - TangemTheme { - SelectorRowItem( - titleRes = R.string.common_fee_selector_option_slow, - iconRes = R.drawable.ic_tortoise_24, - preDot = TextReference.Str("1000 ETH"), - postDot = TextReference.Str("1000 $"), - ellipsizeOffset = 4, - isSelected = true, - onSelect = { }, - ) - } -} - -@Preview -@Composable -private fun SelectorRowItemPreview_Dark() { - TangemTheme(isDark = true) { +private fun SelectorRowItemPreview() { + TangemThemePreview { SelectorRowItem( titleRes = R.string.common_fee_selector_option_slow, iconRes = R.drawable.ic_tortoise_24, diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/Transaction.kt b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/Transaction.kt index 271e85f311..3c76514a21 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/Transaction.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/Transaction.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.transactions +import android.content.res.Configuration import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -32,6 +33,7 @@ import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.extensions.stringReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import java.util.UUID @@ -318,21 +320,10 @@ private fun LockedContent(modifier: Modifier = Modifier) { } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_TransactionItem_LightTheme( - @PreviewParameter(TransactionItemStateProvider::class) state: TransactionState, -) { - TangemTheme(isDark = false) { - Transaction(state = state, isBalanceHidden = false) - } -} - -@Preview -@Composable -private fun Preview_TransactionItem_DarkTheme( - @PreviewParameter(TransactionItemStateProvider::class) state: TransactionState, -) { - TangemTheme(isDark = true) { +private fun Preview_TransactionItem(@PreviewParameter(TransactionItemStateProvider::class) state: TransactionState) { + TangemThemePreview { Transaction(state = state, isBalanceHidden = false) } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TransactionDoneTitle.kt b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TransactionDoneTitle.kt index 6f23701fea..8a7b6bd599 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TransactionDoneTitle.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TransactionDoneTitle.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.transactions +import android.content.res.Configuration import androidx.annotation.StringRes import androidx.compose.foundation.Image import androidx.compose.foundation.background @@ -15,6 +16,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.R +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.utils.DateTimeFormatters import com.tangem.core.ui.utils.toTimeFormat @@ -62,23 +64,10 @@ fun TransactionDoneTitle(@StringRes titleRes: Int, date: Long, modifier: Modifie // region Previews @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun TransactionDoneTitlePreview_Light() { - TangemTheme { - TransactionDoneTitle( - titleRes = R.string.sent_transaction_sent_title, - date = 0, - modifier = Modifier - .background(TangemTheme.colors.background.tertiary) - .padding(TangemTheme.dimens.spacing16), - ) - } -} - -@Preview -@Composable -private fun TransactionDoneTitlePreview_Dark() { - TangemTheme(isDark = true) { +private fun TransactionDoneTitlePreview() { + TangemThemePreview { TransactionDoneTitle( titleRes = R.string.sent_transaction_sent_title, date = 0, diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TxHistoryGroupTitle.kt b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TxHistoryGroupTitle.kt index b2b02d9e1a..e0298ceaed 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TxHistoryGroupTitle.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TxHistoryGroupTitle.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.transactions +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxWidth @@ -11,6 +12,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.components.transactions.state.TxHistoryState.TxHistoryItemState +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import java.util.UUID @@ -42,19 +44,10 @@ internal fun TxHistoryGroupTitle(config: TxHistoryItemState.GroupTitle, modifier } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_TransactionsBlockGroupTitle_Light() { - TangemTheme(isDark = false) { - TxHistoryGroupTitle( - config = TxHistoryItemState.GroupTitle(title = "Today", itemKey = UUID.randomUUID().toString()), - ) - } -} - -@Preview -@Composable -private fun Preview_TransactionsBlockGroupTitle_Dark() { - TangemTheme(isDark = true) { +private fun Preview_TransactionsBlockGroupTitle() { + TangemThemePreview { TxHistoryGroupTitle( config = TxHistoryItemState.GroupTitle(title = "Today", itemKey = UUID.randomUUID().toString()), ) diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TxHistoryTitle.kt b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TxHistoryTitle.kt index 352c19d181..3a7f89969c 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TxHistoryTitle.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TxHistoryTitle.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.transactions +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* @@ -12,6 +13,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.R +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -59,17 +61,10 @@ internal fun TxHistoryTitle(onExploreClick: () -> Unit, modifier: Modifier = Mod } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_TransactionsBlockTitle_Light() { - TangemTheme(isDark = false) { - TxHistoryTitle(onExploreClick = {}) - } -} - -@Preview -@Composable -private fun Preview_TransactionsBlockTitle_Dark() { - TangemTheme(isDark = true) { +private fun Preview_TransactionsBlockTitle() { + TangemThemePreview { TxHistoryTitle(onExploreClick = {}) } } \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/empty/EmptyTransactionBlock.kt b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/empty/EmptyTransactionBlock.kt index c2b7368924..a6d96d536d 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/empty/EmptyTransactionBlock.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/empty/EmptyTransactionBlock.kt @@ -1,5 +1,6 @@ package com.tangem.core.ui.components.transactions.empty +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.material3.Icon @@ -15,6 +16,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider import com.tangem.core.ui.components.buttons.actions.ActionButton import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme /** @@ -87,20 +89,11 @@ private fun PairButtons(state: EmptyTransactionsBlockState.ButtonsState.PairButt @Composable @Preview(widthDp = 360, showBackground = true) -private fun EmptyTransactionBlock_Light( +@Preview(widthDp = 360, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) +private fun EmptyTransactionBlockPreview( @PreviewParameter(EmptyTransactionBlockStateProvider::class) state: EmptyTransactionsBlockState, ) { - TangemTheme { - EmptyTransactionBlock(state = state) - } -} - -@Composable -@Preview(widthDp = 360, showBackground = true) -private fun EmptyTransactionBlock_Dark( - @PreviewParameter(EmptyTransactionBlockStateProvider::class) state: EmptyTransactionsBlockState, -) { - TangemTheme(isDark = true) { + TangemThemePreview { EmptyTransactionBlock(state = state) } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/TangemThemePreview.kt b/core/ui/src/main/java/com/tangem/core/ui/res/TangemThemePreview.kt new file mode 100644 index 0000000000..2a9e0caf65 --- /dev/null +++ b/core/ui/src/main/java/com/tangem/core/ui/res/TangemThemePreview.kt @@ -0,0 +1,21 @@ +package com.tangem.core.ui.res + +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.runtime.Composable + +@Composable +fun TangemThemePreview( + isDark: Boolean? = null, + typography: TangemTypography = TangemTheme.typography, + dimens: TangemDimens = TangemTheme.dimens, + content: @Composable () -> Unit, +) { + val isDarkTheme = isDark ?: isSystemInDarkTheme() + + TangemTheme( + isDark = isDarkTheme, + typography = typography, + dimens = dimens, + content = content, + ) +} \ No newline at end of file diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/AddCustomTokenScreen.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/AddCustomTokenScreen.kt index d335aaca71..d5691e9017 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/AddCustomTokenScreen.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/AddCustomTokenScreen.kt @@ -1,5 +1,6 @@ package com.tangem.managetokens.presentation.addcustomtoken.ui +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn @@ -24,6 +25,7 @@ import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig import com.tangem.core.ui.components.keyboardAsState import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.features.managetokens.impl.R import com.tangem.managetokens.presentation.common.state.AlertState import com.tangem.managetokens.presentation.common.state.ChooseWalletState @@ -287,17 +289,10 @@ private fun TokenTextFieldTitle(state: TextFieldState?, title: String) { } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_ChooseDerivationScreen_Light() { - TangemTheme(isDark = false) { - AddCustomTokenScreen(state = AddCustomTokenPreviewData.state) - } -} - -@Preview -@Composable -private fun Preview_ChooseDerivationScreen_Dark() { - TangemTheme(isDark = true) { +private fun Preview_ChooseDerivationScreen() { + TangemThemePreview { AddCustomTokenScreen(state = AddCustomTokenPreviewData.state) } } \ No newline at end of file diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/ChooseDerivationScreen.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/ChooseDerivationScreen.kt index 3422e1cf8e..a7805cbb96 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/ChooseDerivationScreen.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/ChooseDerivationScreen.kt @@ -1,5 +1,6 @@ package com.tangem.managetokens.presentation.addcustomtoken.ui +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* @@ -13,6 +14,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.decorations.roundedShapeItemDecoration +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.features.managetokens.impl.R import com.tangem.managetokens.presentation.common.ui.components.SimpleSelectionBlock @@ -98,17 +100,10 @@ private fun DerivationsList(state: ChooseDerivationState) { } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_ChooseDerivationScreen_Light() { - TangemTheme(isDark = false) { - ChooseDerivationScreen(state = ChooseDerivationPreviewData.state) - } -} - -@Preview -@Composable -private fun Preview_ChooseDerivationScreen_Dark() { - TangemTheme(isDark = true) { +private fun Preview_ChooseDerivationScreen() { + TangemThemePreview { ChooseDerivationScreen(state = ChooseDerivationPreviewData.state) } } \ No newline at end of file diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/ChooseNetworkCustomScreen.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/ChooseNetworkCustomScreen.kt index 4ee903652e..6777fc4fbc 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/ChooseNetworkCustomScreen.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/ChooseNetworkCustomScreen.kt @@ -1,5 +1,6 @@ package com.tangem.managetokens.presentation.addcustomtoken.ui +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* @@ -13,6 +14,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.decorations.roundedShapeItemDecoration +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.features.managetokens.impl.R import com.tangem.managetokens.presentation.common.ui.components.NetworkItem @@ -78,17 +80,10 @@ internal fun ChooseNetworkCustomScreen(state: ChooseNetworkState, modifier: Modi } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_ChooseNetworkScreen_Light() { - TangemTheme(isDark = false) { - ChooseNetworkCustomScreen(ChooseNetworkCustomPreviewData.state) - } -} - -@Preview -@Composable -private fun Preview_ChooseNetworkScreen_Dark() { - TangemTheme(isDark = true) { +private fun Preview_ChooseNetworkScreen() { + TangemThemePreview { ChooseNetworkCustomScreen(ChooseNetworkCustomPreviewData.state) } } \ No newline at end of file diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/common/ui/ChooseWalletScreen.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/common/ui/ChooseWalletScreen.kt index 878a5f28e1..121faaba26 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/common/ui/ChooseWalletScreen.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/common/ui/ChooseWalletScreen.kt @@ -1,5 +1,6 @@ package com.tangem.managetokens.presentation.common.ui +import android.content.res.Configuration import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -23,6 +24,7 @@ import com.tangem.core.ui.components.SpacerW12 import com.tangem.core.ui.components.SpacerWMax import com.tangem.core.ui.decorations.roundedShapeItemDecoration import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.features.managetokens.impl.R import com.tangem.managetokens.presentation.common.state.ChooseWalletState import com.tangem.managetokens.presentation.common.state.WalletState @@ -137,19 +139,10 @@ private fun WalletItem(wallet: WalletState, selectedWallet: WalletState?, modifi } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_ChooseWalletScreen_Light() { - TangemTheme(isDark = false) { - ChooseWalletScreen( - state = ChooseWalletStatePreviewData.state, - ) - } -} - -@Preview -@Composable -private fun Preview_ChooseWalletScreen_Dark() { - TangemTheme(isDark = false) { +private fun Preview_ChooseWalletScreen() { + TangemThemePreview { ChooseWalletScreen( state = ChooseWalletStatePreviewData.state, ) diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/common/ui/components/NetworkItem.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/common/ui/components/NetworkItem.kt index 0359b28aa1..553a6bd999 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/common/ui/components/NetworkItem.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/common/ui/components/NetworkItem.kt @@ -1,5 +1,6 @@ package com.tangem.managetokens.presentation.common.ui.components +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* @@ -18,6 +19,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider import com.tangem.core.ui.components.SpacerW import com.tangem.core.ui.components.TangemSwitch +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.features.managetokens.impl.R import com.tangem.managetokens.presentation.common.state.NetworkItemState @@ -122,17 +124,10 @@ internal fun NetworkIcon(model: NetworkItemState, modifier: Modifier = Modifier) } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_NetworkItem_Light(@PreviewParameter(NetworkItemStateProvider::class) state: NetworkItemState) { - TangemTheme(isDark = false) { - NetworkItem(state, tokenState = TokenItemStatePreviewData.loadedPriceDown as TokenItemState.Loaded) - } -} - -@Preview -@Composable -private fun Preview_NetworkItem_Dark(@PreviewParameter(NetworkItemStateProvider::class) state: NetworkItemState) { - TangemTheme(isDark = true) { +private fun Preview_NetworkItem(@PreviewParameter(NetworkItemStateProvider::class) state: NetworkItemState) { + TangemThemePreview { NetworkItem(state, tokenState = TokenItemStatePreviewData.loadedPriceDown as TokenItemState.Loaded) } } diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/common/ui/components/SimpleSelectionBlock.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/common/ui/components/SimpleSelectionBlock.kt index c136cb1e28..e7ad5cf31b 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/common/ui/components/SimpleSelectionBlock.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/common/ui/components/SimpleSelectionBlock.kt @@ -1,5 +1,6 @@ package com.tangem.managetokens.presentation.common.ui.components +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column @@ -12,6 +13,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.components.SpacerH +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme @Composable @@ -54,17 +56,10 @@ fun SimpleSelectionBlock( } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_SimpleSelectionBlock_Light() { - TangemTheme(isDark = false) { - SimpleSelectionBlock(title = "Wallet", subtitle = "Family Wallet", onClick = { }) - } -} - -@Preview -@Composable -private fun Preview_SimpleSelectionBlock_Dark() { - TangemTheme(isDark = true) { +private fun Preview_SimpleSelectionBlock() { + TangemThemePreview { SimpleSelectionBlock(title = "Wallet", subtitle = "Family Wallet", onClick = { }) } } \ No newline at end of file diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/ChooseNetworkScreen.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/ChooseNetworkScreen.kt index ead0700da2..2f5d51df8a 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/ChooseNetworkScreen.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/ChooseNetworkScreen.kt @@ -1,5 +1,6 @@ package com.tangem.managetokens.presentation.managetokens.ui +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* @@ -17,6 +18,7 @@ import com.tangem.core.ui.components.SpacerH import com.tangem.core.ui.components.SpacerW import com.tangem.core.ui.components.WarningCardTitleOnly import com.tangem.core.ui.decorations.roundedShapeItemDecoration +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.features.managetokens.impl.R import com.tangem.managetokens.presentation.common.state.ChooseWalletState @@ -187,20 +189,10 @@ private fun NonNativeNetworksHeader(onNonNativeNetworkHintClick: () -> Unit) { } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_ChooseNetworkScreen_Light() { - TangemTheme(isDark = false) { - ChooseNetworkScreen( - state = TokenItemStatePreviewData.loadedPriceDown as TokenItemState.Loaded, - walletState = ChooseWalletStatePreviewData.state, - ) - } -} - -@Preview -@Composable -private fun Preview_ChooseNetworkScreen_Dark() { - TangemTheme(isDark = true) { +private fun Preview_ChooseNetworkScreen() { + TangemThemePreview { ChooseNetworkScreen( state = TokenItemStatePreviewData.loadedPriceDown as TokenItemState.Loaded, walletState = ChooseWalletStatePreviewData.state, diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/ManageTokensScreen.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/ManageTokensScreen.kt index 12f7a0a191..15197a8e4a 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/ManageTokensScreen.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/ManageTokensScreen.kt @@ -1,5 +1,6 @@ package com.tangem.managetokens.presentation.managetokens.ui +import android.content.res.Configuration import androidx.compose.animation.core.animateDpAsState import androidx.compose.foundation.background import androidx.compose.foundation.layout.* @@ -22,6 +23,7 @@ import com.tangem.core.ui.components.Keyboard import com.tangem.core.ui.components.SpacerH18 import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig import com.tangem.core.ui.components.keyboardAsState +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.managetokens.presentation.addcustomtoken.ui.AddCustomTokenBottomSheet import com.tangem.managetokens.presentation.common.state.AlertState @@ -177,23 +179,13 @@ private fun ManageTokensBottomSheet(selectedToken: TokenItemState.Loaded, state: } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_ManageTokensScreen_LightTheme( +private fun Preview_ManageTokensScreen( @PreviewParameter(ManageTokensConfigProvider::class) state: ManageTokensState, ) { - TangemTheme(isDark = false) { - ManageTokensScreen(state) {} - } -} - -@Preview -@Composable -private fun Preview_ManageTokensScreen_DarkTheme( - @PreviewParameter(ManageTokensConfigProvider::class) - state: ManageTokensState, -) { - TangemTheme(isDark = true) { + TangemThemePreview { ManageTokensScreen(state) {} } } diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/AddCustomTokenButton.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/AddCustomTokenButton.kt index 195bb4d60c..32962c70db 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/AddCustomTokenButton.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/AddCustomTokenButton.kt @@ -1,5 +1,6 @@ package com.tangem.managetokens.presentation.managetokens.ui.components +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* @@ -14,6 +15,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.components.SpacerW import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.features.managetokens.impl.R @Composable @@ -49,17 +51,10 @@ internal fun AddCustomTokenButton(onButtonClick: () -> Unit, modifier: Modifier } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun AddCustomTokenButton_Preview_Light() { - TangemTheme(isDark = false) { - AddCustomTokenButton(onButtonClick = { }) - } -} - -@Preview -@Composable -private fun AddCustomTokenButton_Preview_Dark() { - TangemTheme(isDark = true) { +private fun AddCustomTokenButton_Preview() { + TangemThemePreview { AddCustomTokenButton(onButtonClick = { }) } } \ No newline at end of file diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/DerivationNotification.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/DerivationNotification.kt index a18fffaf56..d1f3822c9b 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/DerivationNotification.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/DerivationNotification.kt @@ -1,5 +1,6 @@ package com.tangem.managetokens.presentation.managetokens.ui.components +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape @@ -18,6 +19,7 @@ import com.tangem.core.ui.components.SpacerW import com.tangem.core.ui.components.notifications.NotificationConfig import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.features.managetokens.impl.R import com.tangem.managetokens.presentation.managetokens.state.previewdata.DerivationNotificationStatePreviewData @@ -127,17 +129,10 @@ private fun TextsBlock(title: TextReference, subtitle: TextReference) { } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_ManageTokensScreen_LightTheme() { - TangemTheme(isDark = false) { - DerivationNotification(DerivationNotificationStatePreviewData.state.config) - } -} - -@Preview -@Composable -private fun Preview_ManageTokensScreen_DarkTheme() { - TangemTheme(isDark = true) { +private fun Preview_ManageTokensScreen() { + TangemThemePreview { DerivationNotification(DerivationNotificationStatePreviewData.state.config) } } \ No newline at end of file diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/PriceChangesChart.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/PriceChangesChart.kt index 998dbebc72..1a18c5ee93 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/PriceChangesChart.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/PriceChangesChart.kt @@ -14,6 +14,7 @@ import androidx.compose.ui.graphics.drawscope.DrawScope import androidx.compose.ui.graphics.drawscope.Stroke import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf @@ -105,7 +106,7 @@ private fun getValuePercentageForRange(value: Float, max: Float, min: Float): Fl @Preview(widthDp = 150, heightDp = 150, showBackground = true) @Composable private fun Chart_Positive_Preview() { - TangemTheme(isDark = true) { + TangemThemePreview(isDark = true) { PriceChangesChart( persistentListOf(1f, 2f, 4f, 1f, 5f), ) @@ -115,7 +116,7 @@ private fun Chart_Positive_Preview() { @Preview(widthDp = 150, heightDp = 150, showBackground = true) @Composable private fun Chart_Negative_Preview() { - TangemTheme(isDark = true) { + TangemThemePreview(isDark = true) { PriceChangesChart( persistentListOf(10f, 2f, 4f, 1f, 5f), ) @@ -125,7 +126,7 @@ private fun Chart_Negative_Preview() { @Preview(widthDp = 150, heightDp = 150, showBackground = true) @Composable private fun Chart_Neutral_Preview() { - TangemTheme(isDark = true) { + TangemThemePreview(isDark = true) { PriceChangesChart( persistentListOf(5f, 2f, 4f, 1f, 5f), ) diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/SearchBar.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/SearchBar.kt index 6040c96260..8faf911ebb 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/SearchBar.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/SearchBar.kt @@ -1,5 +1,6 @@ package com.tangem.managetokens.presentation.managetokens.ui.components +import android.content.res.Configuration import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.shape.RoundedCornerShape @@ -20,6 +21,7 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.features.managetokens.impl.R import com.tangem.managetokens.presentation.managetokens.state.SearchBarState @@ -107,20 +109,13 @@ private fun searchbarTextFieldColors(): TextFieldColors { } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_TokensSearchBar_Light( +private fun Preview_TokensSearchBar( @PreviewParameter(SearchBarkConfigProvider::class) state: SearchBarState, ) { - TangemTheme(isDark = false) { - TokensSearchBar(state) - } -} - -@Preview -@Composable -private fun Preview_TokensSearchBar_Dark(@PreviewParameter(SearchBarkConfigProvider::class) state: SearchBarState) { - TangemTheme(isDark = true) { + TangemThemePreview { TokensSearchBar(state) } } diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/TokenButton.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/TokenButton.kt index f3f76effd3..3829ec91db 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/TokenButton.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/TokenButton.kt @@ -1,5 +1,6 @@ package com.tangem.managetokens.presentation.managetokens.ui.components +import android.content.res.Configuration import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Box @@ -18,6 +19,7 @@ import com.tangem.core.ui.components.buttons.PrimarySmallButton import com.tangem.core.ui.components.buttons.SecondarySmallButton import com.tangem.core.ui.components.buttons.SmallButtonConfig import com.tangem.core.ui.extensions.resourceReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.features.managetokens.impl.R import com.tangem.managetokens.presentation.managetokens.state.TokenButtonType @@ -66,17 +68,10 @@ internal fun TokenButton(type: TokenButtonType, onClick: () -> Unit, modifier: M } @Preview(backgroundColor = 0xffffff, showBackground = true) +@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun TokenButton_Light_Preview(@PreviewParameter(TokenButtonTypeProvider::class) type: TokenButtonType) { - TangemTheme(isDark = false) { - TokenButton(type = type, {}) - } -} - -@Preview(showBackground = true) -@Composable -private fun TokenButton_Dark_Preview(@PreviewParameter(TokenButtonTypeProvider::class) type: TokenButtonType) { - TangemTheme(isDark = true) { +private fun TokenButton_Preview(@PreviewParameter(TokenButtonTypeProvider::class) type: TokenButtonType) { + TangemThemePreview { TokenButton(type = type, {}) } } diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/TokenRowItem.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/TokenRowItem.kt index d92f0a8b81..50cf504643 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/TokenRowItem.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/ui/components/TokenRowItem.kt @@ -1,5 +1,6 @@ package com.tangem.managetokens.presentation.managetokens.ui.components +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.material3.Surface @@ -14,6 +15,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider import androidx.compose.ui.unit.Dp import com.tangem.core.ui.components.* +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.managetokens.presentation.managetokens.state.QuotesState import com.tangem.managetokens.presentation.managetokens.state.TokenItemState @@ -182,17 +184,10 @@ private fun BaseSurface(modifier: Modifier = Modifier, content: @Composable () - // region Preview @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_Tokens_LightTheme(@PreviewParameter(TokenConfigProvider::class) state: TokenItemState) { - TangemTheme(isDark = false) { - TokenRowItem(state) - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun Preview_Tokens_DarkTheme(@PreviewParameter(TokenConfigProvider::class) state: TokenItemState) { - TangemTheme(isDark = true) { +private fun Preview_Tokens(@PreviewParameter(TokenConfigProvider::class) state: TokenItemState) { + TangemThemePreview { TokenRowItem(state) } } diff --git a/features/onboarding/src/main/java/com/tangem/feature/onboarding/presentation/wallet2/ui/ImportSeedPhraseScreen.kt b/features/onboarding/src/main/java/com/tangem/feature/onboarding/presentation/wallet2/ui/ImportSeedPhraseScreen.kt index abc2bfff70..de2ffddcbc 100644 --- a/features/onboarding/src/main/java/com/tangem/feature/onboarding/presentation/wallet2/ui/ImportSeedPhraseScreen.kt +++ b/features/onboarding/src/main/java/com/tangem/feature/onboarding/presentation/wallet2/ui/ImportSeedPhraseScreen.kt @@ -1,5 +1,6 @@ package com.tangem.feature.onboarding.presentation.wallet2.ui +import android.content.res.Configuration import androidx.compose.animation.* import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -21,6 +22,7 @@ import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameter import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.IntOffset import com.tangem.core.ui.components.* +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.feature.onboarding.R import com.tangem.feature.onboarding.presentation.wallet2.model.ButtonState @@ -204,11 +206,12 @@ private fun Modifier.rowPadding(index: Int, rowSize: Int, outSide: Dp, inSide: D } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun SuggestionsBlockPreview_Light( +private fun SuggestionsBlockPreview( @PreviewParameter(SuggestionsPreviewParamsProvider::class) suggestions: ImmutableList, ) { - TangemTheme(isDark = false) { + TangemThemePreview { SuggestionsBlock( suggestionsList = suggestions, onClick = {}, @@ -217,24 +220,12 @@ private fun SuggestionsBlockPreview_Light( } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun SuggestionsBlockPreview_Dark( +private fun ImportSeedPhraseScreenPreview( @PreviewParameter(SuggestionsPreviewParamsProvider::class) suggestions: ImmutableList, ) { - TangemTheme(isDark = true) { - SuggestionsBlock( - suggestionsList = suggestions, - onClick = {}, - ) - } -} - -@Preview -@Composable -private fun ImportSeedPhraseScreenPreview_Light( - @PreviewParameter(SuggestionsPreviewParamsProvider::class) suggestions: ImmutableList, -) { - TangemTheme(isDark = false) { + TangemThemePreview { Box(modifier = Modifier.background(TangemTheme.colors.background.primary)) { ImportSeedPhraseScreen( ImportSeedPhraseState( diff --git a/features/onboarding/src/main/java/com/tangem/feature/onboarding/presentation/wallet2/ui/PassphraseInfoBottomSheet.kt b/features/onboarding/src/main/java/com/tangem/feature/onboarding/presentation/wallet2/ui/PassphraseInfoBottomSheet.kt index ee04bfe228..9228432a75 100644 --- a/features/onboarding/src/main/java/com/tangem/feature/onboarding/presentation/wallet2/ui/PassphraseInfoBottomSheet.kt +++ b/features/onboarding/src/main/java/com/tangem/feature/onboarding/presentation/wallet2/ui/PassphraseInfoBottomSheet.kt @@ -18,6 +18,7 @@ import com.tangem.core.ui.components.PrimaryButton import com.tangem.core.ui.components.bottomsheets.TangemBottomSheet import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.onboarding.R import com.tangem.feature.onboarding.presentation.wallet2.model.ShowPassphraseInfoBottomSheetContent @@ -83,7 +84,7 @@ fun PassphraseInfoBottomSheetContent(content: ShowPassphraseInfoBottomSheetConte @Preview @Composable private fun PassphraseInfoBottomSheetContentPreview() { - TangemTheme { + TangemThemePreview { PassphraseInfoBottomSheetContent(ShowPassphraseInfoBottomSheetContent { }) } } \ No newline at end of file diff --git a/features/onboarding/src/main/java/com/tangem/feature/onboarding/presentation/wallet2/ui/YourSeedPhraseScreen.kt b/features/onboarding/src/main/java/com/tangem/feature/onboarding/presentation/wallet2/ui/YourSeedPhraseScreen.kt index 609e2df784..9fafacb32a 100644 --- a/features/onboarding/src/main/java/com/tangem/feature/onboarding/presentation/wallet2/ui/YourSeedPhraseScreen.kt +++ b/features/onboarding/src/main/java/com/tangem/feature/onboarding/presentation/wallet2/ui/YourSeedPhraseScreen.kt @@ -1,5 +1,6 @@ package com.tangem.feature.onboarding.presentation.wallet2.ui +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.rememberScrollState @@ -16,6 +17,7 @@ import com.tangem.core.ui.components.PrimaryButton import com.tangem.core.ui.components.SpacerH16 import com.tangem.core.ui.components.buttons.segmentedbutton.SegmentedButtons import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.onboarding.R import com.tangem.feature.onboarding.presentation.wallet2.model.* import com.tangem.feature.onboarding.presentation.wallet2.ui.components.DescriptionSubTitleText @@ -164,9 +166,10 @@ private inline fun VerticalGrid( } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable private fun YourSeedPhraseScreenPreview_Light() { - TangemTheme(isDark = false) { + TangemThemePreview { YourSeedPhraseScreen( state = YourSeedPhraseState( segmentSeedState = SegmentSeedState( diff --git a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AgreementBottomSheetContent.kt b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AgreementBottomSheetContent.kt index bc175c5bff..e44e192d0d 100644 --- a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AgreementBottomSheetContent.kt +++ b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AgreementBottomSheetContent.kt @@ -1,5 +1,6 @@ package com.tangem.feature.referral.ui +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth @@ -16,6 +17,7 @@ import androidx.compose.ui.unit.dp import com.google.accompanist.web.WebView import com.google.accompanist.web.rememberWebViewState import com.tangem.core.ui.components.appbar.AppBarWithAdditionalButtons +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.feature.referral.presentation.R @@ -58,17 +60,10 @@ private fun AgreementHtmlView(url: String) { } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_AgreementBottomSheet_InLightTheme() { - TangemTheme(isDark = false) { - AgreementBottomSheetContent(url = "https://tangem.com/en/") - } -} - -@Preview -@Composable -private fun Preview_AgreementBottomSheet_InDarkTheme() { - TangemTheme(isDark = true) { +private fun Preview_AgreementBottomSheet() { + TangemThemePreview { AgreementBottomSheetContent(url = "https://tangem.com/en/") } } \ No newline at end of file diff --git a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AgreementText.kt b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AgreementText.kt index d29a6c996b..e005f91c7b 100644 --- a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AgreementText.kt +++ b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AgreementText.kt @@ -1,5 +1,6 @@ package com.tangem.feature.referral.ui +import android.content.res.Configuration import androidx.annotation.StringRes import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box @@ -15,6 +16,7 @@ import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.withStyle import androidx.compose.ui.tooling.preview.Preview +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.feature.referral.presentation.R @@ -53,19 +55,10 @@ private fun annotatedAgreementString(firstPart: String): AnnotatedString { } @Preview(widthDp = 360, showBackground = true) +@Preview(widthDp = 360, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_AgreementText_InLightTheme() { - TangemTheme(isDark = false) { - Box(modifier = Modifier.background(TangemTheme.colors.background.primary)) { - AgreementText(firstPartResId = R.string.referral_tos_not_enroled_prefix, onClick = {}) - } - } -} - -@Preview(widthDp = 360, showBackground = true) -@Composable -private fun Preview_AgreementText_InDarkTheme() { - TangemTheme(isDark = true) { +private fun Preview_AgreementText() { + TangemThemePreview { Box(modifier = Modifier.background(TangemTheme.colors.background.primary)) { AgreementText(firstPartResId = R.string.referral_tos_not_enroled_prefix, onClick = {}) } diff --git a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AwardItems.kt b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AwardItems.kt index a85c1a0f07..5f11c074e1 100644 --- a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AwardItems.kt +++ b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AwardItems.kt @@ -10,6 +10,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.TextStyle import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview @Suppress("LongParameterList") @Composable @@ -56,8 +57,8 @@ internal fun AwardText( @Preview(widthDp = 360, showBackground = true) @Composable -private fun Preview_AwardItem_Light() { - TangemTheme { +private fun Preview_AwardItem() { + TangemThemePreview { AwardText( startText = "startText", startTextColor = TangemTheme.colors.text.tertiary, diff --git a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/NonParticipateBottomBlock.kt b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/NonParticipateBottomBlock.kt index 78a8239dc0..d79e4a6f6b 100644 --- a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/NonParticipateBottomBlock.kt +++ b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/NonParticipateBottomBlock.kt @@ -1,5 +1,6 @@ package com.tangem.feature.referral.ui +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding @@ -8,6 +9,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.components.PrimaryEndIconButton +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.feature.referral.presentation.R @@ -28,19 +30,10 @@ internal fun NonParticipateBottomBlock(onAgreementClick: () -> Unit, onParticipa } @Preview(widthDp = 360, showBackground = true) +@Preview(widthDp = 360, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_NonParticipateBottomBlock_InLightTheme() { - TangemTheme(isDark = false) { - Column(Modifier.background(TangemTheme.colors.background.primary)) { - NonParticipateBottomBlock(onAgreementClick = {}, onParticipateClick = {}) - } - } -} - -@Preview(widthDp = 360, showBackground = true) -@Composable -private fun Preview_NonParticipateBottomBlock_InDarkTheme() { - TangemTheme(isDark = true) { +private fun Preview_NonParticipateBottomBlock() { + TangemThemePreview { Column(Modifier.background(TangemTheme.colors.background.primary)) { NonParticipateBottomBlock(onAgreementClick = {}, onParticipateClick = {}) } diff --git a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ParticipateBottomBlock.kt b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ParticipateBottomBlock.kt index 3417b6931f..69c37e25c9 100644 --- a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ParticipateBottomBlock.kt +++ b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ParticipateBottomBlock.kt @@ -2,6 +2,7 @@ package com.tangem.feature.referral.ui import android.content.Context import android.content.Intent +import android.content.res.Configuration import androidx.compose.animation.* import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -31,6 +32,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider import androidx.core.content.ContextCompat.startActivity import com.tangem.core.ui.components.* +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.feature.referral.domain.models.ExpectedAward import com.tangem.feature.referral.domain.models.ExpectedAwards @@ -318,11 +320,12 @@ private fun Context.shareText(text: String) { } @Preview(widthDp = 360, showBackground = true) +@Preview(widthDp = 360, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun ParticipateBottomBlockPreview_Light( +private fun ParticipateBottomBlockPreview( @PreviewParameter(ParticipateBottomBlockDataProvider::class) data: ParticipateBottomBlockData, ) { - TangemTheme(isDark = false) { + TangemThemePreview { Column(Modifier.background(TangemTheme.colors.background.secondary)) { ParticipateBottomBlock( purchasedWalletCount = data.purchasedWalletCount, @@ -339,42 +342,10 @@ private fun ParticipateBottomBlockPreview_Light( } @Preview(widthDp = 360, showBackground = true) +@Preview(widthDp = 360, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun ParticipateBottomBlockPreview_Dark( - @PreviewParameter(ParticipateBottomBlockDataProvider::class) state: ParticipateBottomBlockData, -) { - TangemTheme(isDark = true) { - Column(Modifier.background(TangemTheme.colors.background.secondary)) { - ParticipateBottomBlock( - purchasedWalletCount = state.purchasedWalletCount, - code = state.code, - shareLink = state.shareLink, - expectedAwards = state.expectedAwards, - onAgreementClick = state.onAgreementClick, - onShowCopySnackbar = state.onShowCopySnackbar, - onCopyClick = state.onCopyClick, - onShareClick = state.onShareClick, - ) - } - } -} - -@Preview(widthDp = 360, showBackground = true) -@Composable -private fun LessMoreButton_Light() { - TangemTheme(isDark = false) { - LessMoreButton( - isExpanded = remember { - mutableStateOf(false) - }, - ) - } -} - -@Preview(widthDp = 360, showBackground = true) -@Composable -private fun LessMoreButton_Dark() { - TangemTheme(isDark = true) { +private fun LessMoreButtonPreview() { + TangemThemePreview { LessMoreButton( isExpanded = remember { mutableStateOf(false) diff --git a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ReferralScreen.kt b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ReferralScreen.kt index 74f9653422..cdff31bf58 100644 --- a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ReferralScreen.kt +++ b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ReferralScreen.kt @@ -1,5 +1,6 @@ package com.tangem.feature.referral.ui +import android.content.res.Configuration import androidx.annotation.DrawableRes import androidx.compose.foundation.Image import androidx.compose.foundation.background @@ -27,6 +28,7 @@ import com.tangem.core.ui.components.SpacerH16 import com.tangem.core.ui.components.SpacerH24 import com.tangem.core.ui.components.SpacerH32 import com.tangem.core.ui.components.appbar.AppBarWithBackButton +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.feature.referral.domain.models.ExpectedAward import com.tangem.feature.referral.domain.models.ExpectedAwards @@ -446,9 +448,10 @@ private fun getMessageForErrorSnackbar(errorSnackbar: ErrorSnackbar): String { } @Preview(widthDp = 360, showBackground = true) +@Preview(widthDp = 360, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_ReferralScreen_Participant_InLightTheme() { - TangemTheme(isDark = false) { +private fun Preview_ReferralScreen_Participant() { + TangemThemePreview { ReferralScreen( stateHolder = ReferralStateHolder( headerState = HeaderState(onBackClicked = {}), @@ -475,38 +478,10 @@ private fun Preview_ReferralScreen_Participant_InLightTheme() { } @Preview(widthDp = 360, showBackground = true) +@Preview(widthDp = 360, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_ReferralScreen_Participant_InDarkTheme() { - TangemTheme(isDark = true) { - ReferralScreen( - stateHolder = ReferralStateHolder( - headerState = HeaderState(onBackClicked = {}), - referralInfoState = ReferralInfoState.ParticipantContent( - award = "10 USDT", - networkName = "Tron", - address = "ma80...zk8q2", - discount = "10%", - purchasedWalletCount = 3, - code = "x4JdK", - shareLink = "", - url = "", - expectedAwards = null, - ), - errorSnackbar = ErrorSnackbar(DemoModeException()) {}, - analytics = Analytics( - onAgreementClicked = {}, - onCopyClicked = {}, - onShareClicked = {}, - ), - ), - ) - } -} - -@Preview(widthDp = 360, showBackground = true) -@Composable -private fun Preview_ReferralScreen_Participant_With_Referrals_InLightTheme() { - TangemTheme(isDark = false) { +private fun Preview_ReferralScreen_Participant_With_Referrals() { + TangemThemePreview { ReferralScreen( stateHolder = ReferralStateHolder( headerState = HeaderState(onBackClicked = {}), @@ -549,9 +524,10 @@ private fun Preview_ReferralScreen_Participant_With_Referrals_InLightTheme() { } @Preview(widthDp = 360, showBackground = true) +@Preview(widthDp = 360, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_ReferralScreen_NonParticipant_InLightTheme() { - TangemTheme(isDark = false) { +private fun Preview_ReferralScreen_NonParticipant() { + TangemThemePreview { ReferralScreen( stateHolder = ReferralStateHolder( headerState = HeaderState(onBackClicked = {}), @@ -574,53 +550,10 @@ private fun Preview_ReferralScreen_NonParticipant_InLightTheme() { } @Preview(widthDp = 360, showBackground = true) +@Preview(widthDp = 360, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_ReferralScreen_NonParticipant_InDarkTheme() { - TangemTheme(isDark = true) { - ReferralScreen( - stateHolder = ReferralStateHolder( - headerState = HeaderState(onBackClicked = {}), - referralInfoState = ReferralInfoState.NonParticipantContent( - award = "10 USDT", - networkName = "Tron", - discount = "10%", - url = "", - onParticipateClicked = {}, - ), - errorSnackbar = null, - analytics = Analytics( - onAgreementClicked = {}, - onCopyClicked = {}, - onShareClicked = {}, - ), - ), - ) - } -} - -@Preview(widthDp = 360, showBackground = true) -@Composable -private fun Preview_ReferralScreen_Loading_InLightTheme() { - TangemTheme(isDark = false) { - ReferralScreen( - stateHolder = ReferralStateHolder( - headerState = HeaderState(onBackClicked = {}), - referralInfoState = ReferralInfoState.Loading, - errorSnackbar = null, - analytics = Analytics( - onAgreementClicked = {}, - onCopyClicked = {}, - onShareClicked = {}, - ), - ), - ) - } -} - -@Preview(widthDp = 360, showBackground = true) -@Composable -private fun Preview_ReferralScreen_Loading_InDarkTheme() { - TangemTheme(isDark = true) { +private fun Preview_ReferralScreen_Loading() { + TangemThemePreview { ReferralScreen( stateHolder = ReferralStateHolder( headerState = HeaderState(onBackClicked = {}), diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/amount/SendAmountContent.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/amount/SendAmountContent.kt index 01d23d4edb..0c51b1dd4f 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/amount/SendAmountContent.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/amount/SendAmountContent.kt @@ -1,5 +1,6 @@ package com.tangem.features.send.impl.presentation.ui.amount +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn @@ -8,6 +9,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameterProvider +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.features.send.impl.presentation.state.SendStates import com.tangem.features.send.impl.presentation.state.previewdata.AmountStatePreviewData @@ -43,25 +45,12 @@ internal fun SendAmountContent( // region Preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun AmountFieldPreview_Light( +private fun AmountFieldPreview( @PreviewParameter(AmountFieldPreviewProvider::class) amountState: SendStates.AmountState, ) { - TangemTheme { - SendAmountContent( - amountState = amountState, - isBalanceHiding = false, - clickIntents = SendClickIntentsStub, - ) - } -} - -@Preview -@Composable -private fun AmountFieldPreview_Dark( - @PreviewParameter(AmountFieldPreviewProvider::class) amountState: SendStates.AmountState, -) { - TangemTheme(isDark = true) { + TangemThemePreview { SendAmountContent( amountState = amountState, isBalanceHiding = false, diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/fee/SendSpeedSelector.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/fee/SendSpeedSelector.kt index 270d4954f9..f403cf423b 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/fee/SendSpeedSelector.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/fee/SendSpeedSelector.kt @@ -1,5 +1,6 @@ package com.tangem.features.send.impl.presentation.ui.fee +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth @@ -18,6 +19,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameterProvider import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.features.send.impl.R import com.tangem.features.send.impl.presentation.state.SendStates import com.tangem.features.send.impl.presentation.state.fee.FeeType @@ -107,21 +109,12 @@ private fun FooterText(onReadMoreClick: () -> Unit) { // region Preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun SendSpeedSelectorPreview_Light( +private fun SendSpeedSelectorPreview( @PreviewParameter(SendSpeedSelectorPreviewProvider::class) feeState: SendStates.FeeState, ) { - TangemTheme { - SendSpeedSelector(state = feeState, clickIntents = SendClickIntentsStub) - } -} - -@Preview -@Composable -private fun SendSpeedSelectorPreview_Dark( - @PreviewParameter(SendSpeedSelectorPreviewProvider::class) feeState: SendStates.FeeState, -) { - TangemTheme(isDark = true) { + TangemThemePreview { SendSpeedSelector(state = feeState, clickIntents = SendClickIntentsStub) } } diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/recipient/ListItemWithIcon.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/recipient/ListItemWithIcon.kt index 9ef9f60a21..3f2106d79d 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/recipient/ListItemWithIcon.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/recipient/ListItemWithIcon.kt @@ -1,5 +1,6 @@ package com.tangem.features.send.impl.presentation.ui.recipient +import android.content.res.Configuration import androidx.annotation.DrawableRes import androidx.compose.animation.AnimatedContent import androidx.compose.animation.fadeIn @@ -27,6 +28,7 @@ import com.tangem.core.ui.components.atoms.text.EllipsisText import com.tangem.core.ui.components.atoms.text.TextEllipsis import com.tangem.core.ui.components.icons.identicon.IdentIcon import com.tangem.core.ui.extensions.rememberHapticFeedback +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.features.send.impl.R @@ -180,28 +182,12 @@ private fun ListItemLoading(modifier: Modifier = Modifier) { // region preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun ListItemWithIconPreview_Light( +private fun ListItemWithIconPreview( @PreviewParameter(ListItemWithIconPreviewProvider::class) config: ListItemWithIconPreviewConfig, ) { - TangemTheme { - ListItemWithIcon( - title = config.title, - subtitle = config.subtitle, - subtitleEndOffset = config.subtitleEndOffset, - subtitleIconRes = config.iconRes, - onClick = {}, - isLoading = config.isLoading, - ) - } -} - -@Preview -@Composable -private fun ListItemWithIconPreview_Dark( - @PreviewParameter(ListItemWithIconPreviewProvider::class) config: ListItemWithIconPreviewConfig, -) { - TangemTheme(isDark = true) { + TangemThemePreview { ListItemWithIcon( title = config.title, subtitle = config.subtitle, diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/send/AmountBlock.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/send/AmountBlock.kt index ab68759908..3533b2a175 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/send/AmountBlock.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/send/AmountBlock.kt @@ -1,5 +1,6 @@ package com.tangem.features.send.impl.presentation.ui.send +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column @@ -16,6 +17,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameterProvider import com.tangem.core.ui.components.ResizableText import com.tangem.core.ui.components.currency.tokenicon.TokenIcon +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.utils.BigDecimalFormatter import com.tangem.features.send.impl.presentation.state.SendStates @@ -84,11 +86,10 @@ internal fun AmountBlock( // region Preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun AmountBlockPreview_Light( - @PreviewParameter(AmountBlockPreviewProvider::class) value: SendStates.AmountState, -) { - TangemTheme { +private fun AmountBlockPreview(@PreviewParameter(AmountBlockPreviewProvider::class) value: SendStates.AmountState) { + TangemThemePreview { AmountBlock( amountState = value, isSuccess = false, @@ -98,21 +99,6 @@ private fun AmountBlockPreview_Light( } } -@Preview -@Composable -private fun AmountBlockPreview_Dark( - @PreviewParameter(AmountBlockPreviewProvider::class) value: SendStates.AmountState, -) { - TangemTheme(isDark = true) { - AmountBlock( - amountState = value, - isSuccess = true, - isEditingDisabled = false, - onClick = {}, - ) - } -} - private class AmountBlockPreviewProvider : PreviewParameterProvider { override val values: Sequence get() = sequenceOf( diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/send/FeeBlock.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/send/FeeBlock.kt index 54ef73296a..9e762ae382 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/send/FeeBlock.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/send/FeeBlock.kt @@ -1,5 +1,6 @@ package com.tangem.features.send.impl.presentation.ui.send +import android.content.res.Configuration import androidx.compose.animation.AnimatedContent import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -15,6 +16,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameterProvider import com.tangem.core.ui.components.RectangleShimmer import com.tangem.core.ui.components.rows.SelectorRowItem +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.utils.BigDecimalFormatter import com.tangem.features.send.impl.R @@ -110,21 +112,10 @@ private fun BoxScope.FeeError(feeSelectorState: FeeSelectorState) { // region Preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun FeeBlockPreview_Light(@PreviewParameter(FeeBlockPreviewProvider::class) value: SendStates.FeeState) { - TangemTheme { - FeeBlock( - feeState = value, - isSuccess = true, - onClick = {}, - ) - } -} - -@Preview -@Composable -private fun FeeBlockPreview_Dark(@PreviewParameter(FeeBlockPreviewProvider::class) value: SendStates.FeeState) { - TangemTheme(isDark = true) { +private fun FeeBlockPreview(@PreviewParameter(FeeBlockPreviewProvider::class) value: SendStates.FeeState) { + TangemThemePreview { FeeBlock( feeState = value, isSuccess = true, diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/send/RecipientBlock.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/send/RecipientBlock.kt index e3b92db56c..0b4752d640 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/send/RecipientBlock.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/send/RecipientBlock.kt @@ -1,5 +1,6 @@ package com.tangem.features.send.impl.presentation.ui.send +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* @@ -15,6 +16,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameterProvider import com.tangem.core.ui.components.icons.identicon.IdentIcon import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.res.TangemTheme import com.tangem.features.send.impl.presentation.state.SendStates import com.tangem.features.send.impl.presentation.state.fields.SendTextField @@ -97,26 +99,12 @@ private fun MemoBlock(memo: SendTextField.RecipientMemo?) { // region Preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun RecipientBlockPreview_Light( +private fun RecipientBlockPreview( @PreviewParameter(RecipientBlockPreviewProvider::class) value: SendStates.RecipientState, ) { - TangemTheme { - RecipientBlock( - recipientState = value, - isSuccess = true, - isEditingDisabled = false, - onClick = {}, - ) - } -} - -@Preview -@Composable -private fun RecipientBlockPreview_Dark( - @PreviewParameter(RecipientBlockPreviewProvider::class) value: SendStates.RecipientState, -) { - TangemTheme(isDark = true) { + TangemThemePreview { RecipientBlock( recipientState = value, isSuccess = true, diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ChooseFeeBottomSheet.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ChooseFeeBottomSheet.kt index 35f1fb8fe4..8b1ac6f243 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ChooseFeeBottomSheet.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ChooseFeeBottomSheet.kt @@ -23,6 +23,7 @@ import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.extensions.stringReference import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.swap.domain.models.ui.FeeType import com.tangem.feature.swap.models.states.ChooseFeeBottomSheetConfig import com.tangem.feature.swap.models.states.FeeItemState @@ -168,7 +169,7 @@ private fun ChooseFeeBottomSheetContent_Preview() { ), ).toImmutableList() Column { - TangemTheme(isDark = true) { + TangemThemePreview(isDark = true) { ChooseFeeBottomSheetContent( ChooseFeeBottomSheetConfig( selectedFee = FeeType.NORMAL, @@ -183,7 +184,7 @@ private fun ChooseFeeBottomSheetContent_Preview() { SpacerH24() - TangemTheme(isDark = false) { + TangemThemePreview(isDark = false) { ChooseFeeBottomSheetContent( ChooseFeeBottomSheetConfig( selectedFee = FeeType.NORMAL, diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ChooseProviderBottomSheet.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ChooseProviderBottomSheet.kt index 4015137fcd..960b9d3373 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ChooseProviderBottomSheet.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ChooseProviderBottomSheet.kt @@ -18,6 +18,7 @@ import com.tangem.core.ui.components.bottomsheets.TangemBottomSheet import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig import com.tangem.core.ui.extensions.stringReference import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.swap.models.states.ChooseProviderBottomSheetConfig import com.tangem.feature.swap.models.states.PercentDifference import com.tangem.feature.swap.models.states.ProviderState @@ -128,7 +129,7 @@ private fun ChooseProviderBottomSheet_Preview() { alertText = stringReference("Unavailable"), ), ) - TangemTheme(isDark = false) { + TangemThemePreview(isDark = false) { ChooseProviderBottomSheetContent( ChooseProviderBottomSheetConfig( selectedProviderId = "1", diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/FeeItem.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/FeeItem.kt index f379ae3511..e4c3b974ca 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/FeeItem.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/FeeItem.kt @@ -12,6 +12,7 @@ import com.tangem.core.ui.components.rows.SimpleActionRow import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.extensions.stringReference import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.swap.domain.models.ui.FeeType import com.tangem.feature.swap.models.states.FeeItemState @@ -63,13 +64,13 @@ private fun FeeItemPreview() { onClick = {}, ) Column { - TangemTheme(isDark = false) { + TangemThemePreview(isDark = false) { FeeItem(state = state) } SpacerH24() - TangemTheme(isDark = true) { + TangemThemePreview(isDark = true) { FeeItem(state = state) } } diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ProviderItem.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ProviderItem.kt index 723d81e622..2707fa77b2 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ProviderItem.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ProviderItem.kt @@ -1,5 +1,6 @@ package com.tangem.feature.swap.ui +import android.content.res.Configuration import androidx.compose.animation.AnimatedContent import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -27,6 +28,7 @@ import com.tangem.core.ui.components.RectangleShimmer import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.extensions.stringReference import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.swap.models.states.PercentDifference import com.tangem.feature.swap.models.states.ProviderState @@ -390,25 +392,12 @@ private fun PermissionBadgeItem(modifier: Modifier = Modifier) { // region Preview @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun ProviderItemPreview_Light( +private fun ProviderItemPreview( @PreviewParameter(ProviderItemParameterProvider::class) state: Pair, ) { - TangemTheme { - ProviderItem( - modifier = Modifier.background(TangemTheme.colors.background.action), - state = state.first, - isSelected = state.second, - ) - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun ProviderItemPreview_Dark( - @PreviewParameter(ProviderItemParameterProvider::class) state: Pair, -) { - TangemTheme(isDark = true) { + TangemThemePreview { ProviderItem( modifier = Modifier.background(TangemTheme.colors.background.action), state = state.first, diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapPermissionBottomSheet.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapPermissionBottomSheet.kt index b915b4c0a5..8ac175588a 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapPermissionBottomSheet.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapPermissionBottomSheet.kt @@ -1,5 +1,6 @@ package com.tangem.feature.swap.ui +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* @@ -17,6 +18,7 @@ import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.swap.models.ApprovePermissionButton import com.tangem.feature.swap.models.ApproveType import com.tangem.feature.swap.models.CancelPermissionButton @@ -291,17 +293,10 @@ private fun getTitleForApproveType(approveType: ApproveType): String = when (app // region preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_AgreementBottomSheet_InLightTheme() { - TangemTheme(isDark = false) { - SwapPermissionBottomSheetContent(content = previewData) - } -} - -@Preview -@Composable -private fun Preview_AgreementBottomSheet_InDarkTheme() { - TangemTheme(isDark = true) { +private fun Preview_AgreementBottomSheet() { + TangemThemePreview { SwapPermissionBottomSheetContent(content = previewData) } } diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapScreenContent.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapScreenContent.kt index f0441ea811..1137f0f264 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapScreenContent.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapScreenContent.kt @@ -1,5 +1,6 @@ package com.tangem.feature.swap.ui +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* @@ -30,6 +31,7 @@ import com.tangem.core.ui.extensions.getActiveIconResByCoinId import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.extensions.stringReference import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.swap.domain.models.ui.FeeType import com.tangem.feature.swap.domain.models.ui.PriceImpact import com.tangem.feature.swap.models.* @@ -512,9 +514,10 @@ private val state = SwapStateHolder( ) @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable private fun SwapScreenContentPreview() { - TangemTheme(isDark = false) { + TangemThemePreview { SwapScreenContent(state = state, modifier = Modifier) } } diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapSelectTokenScreen.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapSelectTokenScreen.kt index 930039d697..081b492357 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapSelectTokenScreen.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapSelectTokenScreen.kt @@ -27,6 +27,7 @@ import com.tangem.core.ui.decorations.roundedShapeItemDecoration import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.extensions.stringReference import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.swap.models.* import com.tangem.feature.swap.presentation.R import kotlinx.collections.immutable.ImmutableList @@ -303,7 +304,7 @@ private val title = TokenToSelectState.Title( @Preview @Composable private fun TokenScreenPreview() { - TangemTheme(isDark = false) { + TangemThemePreview { SwapSelectTokenScreen( state = SwapSelectTokenStateHolder( availableTokens = listOf(title, token, token, token).toImmutableList(), @@ -320,7 +321,7 @@ private fun TokenScreenPreview() { @Preview @Composable private fun EmptyTokensListPreview() { - TangemTheme(isDark = false) { + TangemThemePreview { EmptyTokensList() } } \ No newline at end of file diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapSuccessScreen.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapSuccessScreen.kt index a562a22435..11ade5db09 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapSuccessScreen.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapSuccessScreen.kt @@ -1,5 +1,6 @@ package com.tangem.feature.swap.ui +import android.content.res.Configuration import androidx.annotation.StringRes import androidx.compose.foundation.background import androidx.compose.foundation.layout.* @@ -18,6 +19,7 @@ import com.tangem.core.ui.components.inputrow.InputRowImage import com.tangem.core.ui.components.transactions.TransactionDoneTitle import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.swap.domain.models.domain.ExchangeProviderType import com.tangem.feature.swap.models.SwapSuccessStateHolder import com.tangem.feature.swap.presentation.R @@ -167,19 +169,11 @@ private val state = SwapSuccessStateHolder( ) @Preview(showBackground = true) +@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_Success_InLightTheme() { - TangemTheme(isDark = false) { +private fun Preview_Success() { + TangemThemePreview { SwapSuccessScreen(state) {} } } - -@Preview(showBackground = true) -@Composable -private fun Preview_Success_InDarkTheme() { - TangemTheme(isDark = true) { - SwapSuccessScreen(state) {} - } -} - // endregion preview \ No newline at end of file diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/TransactionCard.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/TransactionCard.kt index bd77a3f66e..db9d18b78e 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/TransactionCard.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/TransactionCard.kt @@ -38,6 +38,7 @@ import coil.request.ImageRequest import com.tangem.core.ui.R import com.tangem.core.ui.components.* import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.utils.ImageBackgroundContrastChecker import com.tangem.feature.swap.domain.models.ui.PriceImpact import com.tangem.feature.swap.models.TransactionCardType @@ -498,7 +499,7 @@ private fun makePriceImpactBalanceWarning(value: String, priceImpactPercents: In @Preview(widthDp = 328, heightDp = 116, showBackground = true) @Composable private fun Preview_TransactionCard_InLightTheme() { - TangemTheme(isDark = false) { + TangemThemePreview(isDark = false) { TransactionCardPreview() } } @@ -506,7 +507,7 @@ private fun Preview_TransactionCard_InLightTheme() { @Preview(widthDp = 328, heightDp = 116, showBackground = true) @Composable private fun Preview_TransactionCardWithPriceImpact_InLightTheme() { - TangemTheme(isDark = false) { + TangemThemePreview(isDark = false) { TransactionCardPreviewWithPriceImpact() } } @@ -514,7 +515,7 @@ private fun Preview_TransactionCardWithPriceImpact_InLightTheme() { @Preview(widthDp = 328, heightDp = 116, showBackground = true) @Composable private fun Preview_TransactionCardWithoutPriceImpact_InLightTheme() { - TangemTheme(isDark = false) { + TangemThemePreview(isDark = false) { TransactionCardPreviewWithoutPriceImpact() } } @@ -522,7 +523,7 @@ private fun Preview_TransactionCardWithoutPriceImpact_InLightTheme() { @Preview(widthDp = 328, heightDp = 116, showBackground = true) @Composable private fun Preview_TransactionCard_InDarkTheme() { - TangemTheme(isDark = false) { + TangemThemePreview(isDark = false) { TransactionCardPreview() } } @@ -530,7 +531,7 @@ private fun Preview_TransactionCard_InDarkTheme() { @Preview(widthDp = 328, heightDp = 116, showBackground = true) @Composable private fun Preview_TransactionCardWithPriceImpact_InDarkTheme() { - TangemTheme(isDark = false) { + TangemThemePreview(isDark = false) { TransactionCardPreviewWithPriceImpact() } } @@ -538,7 +539,7 @@ private fun Preview_TransactionCardWithPriceImpact_InDarkTheme() { @Preview(widthDp = 328, heightDp = 116, showBackground = true) @Composable private fun Preview_TransactionCardWithoutPriceImpact_InDarkTheme() { - TangemTheme(isDark = false) { + TangemThemePreview(isDark = false) { TransactionCardPreviewWithoutPriceImpact() } } diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/WebViewBottomSheet.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/WebViewBottomSheet.kt index eb2df9fe19..00a27d8a22 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/WebViewBottomSheet.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/WebViewBottomSheet.kt @@ -1,5 +1,6 @@ package com.tangem.feature.swap.ui +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxHeight @@ -14,6 +15,7 @@ import com.google.accompanist.web.rememberWebViewState import com.tangem.core.ui.components.bottomsheets.TangemBottomSheet import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.swap.models.states.WebViewBottomSheetConfig @Composable @@ -55,21 +57,10 @@ private fun WebViewBottomSheetContent(content: WebViewBottomSheetConfig) { } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_WebViewBottomSheetContent_InLightTheme() { - TangemTheme(isDark = false) { - WebViewBottomSheetContent( - content = WebViewBottomSheetConfig( - url = "https://tangem.com/en/", - ), - ) - } -} - -@Preview -@Composable -private fun Preview_WebViewBottomSheetContent_InDarkTheme() { - TangemTheme(isDark = true) { +private fun Preview_WebViewBottomSheetContent() { + TangemThemePreview { WebViewBottomSheetContent( content = WebViewBottomSheetConfig( url = "https://tangem.com/en/", diff --git a/features/tester/impl/src/main/java/com/tangem/feature/tester/presentation/actions/TesterActionsScreen.kt b/features/tester/impl/src/main/java/com/tangem/feature/tester/presentation/actions/TesterActionsScreen.kt index f8d9df0a78..830d10591c 100644 --- a/features/tester/impl/src/main/java/com/tangem/feature/tester/presentation/actions/TesterActionsScreen.kt +++ b/features/tester/impl/src/main/java/com/tangem/feature/tester/presentation/actions/TesterActionsScreen.kt @@ -1,5 +1,6 @@ package com.tangem.feature.tester.presentation.actions +import android.content.res.Configuration import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background import androidx.compose.foundation.layout.* @@ -12,6 +13,7 @@ import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.components.PrimaryButton import com.tangem.core.ui.components.appbar.AppBarWithBackButton import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.domain.apptheme.model.AppThemeMode import com.tangem.feature.tester.impl.R @@ -85,17 +87,10 @@ private fun TesterActionsScreenSample(modifier: Modifier = Modifier) { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun TesterActionsScreenPreview_Light() { - TangemTheme { - TesterActionsScreenSample() - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun TesterActionsScreenPreview_Dark() { - TangemTheme(isDark = true) { +private fun TesterActionsScreenPreview() { + TangemThemePreview { TesterActionsScreenSample() } } diff --git a/features/tester/impl/src/main/java/com/tangem/feature/tester/presentation/featuretoggles/ui/FeatureTogglesScreen.kt b/features/tester/impl/src/main/java/com/tangem/feature/tester/presentation/featuretoggles/ui/FeatureTogglesScreen.kt index 7ce0c9ff6d..74dddd26f0 100644 --- a/features/tester/impl/src/main/java/com/tangem/feature/tester/presentation/featuretoggles/ui/FeatureTogglesScreen.kt +++ b/features/tester/impl/src/main/java/com/tangem/feature/tester/presentation/featuretoggles/ui/FeatureTogglesScreen.kt @@ -1,5 +1,6 @@ package com.tangem.feature.tester.presentation.featuretoggles.ui +import android.content.res.Configuration import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement @@ -20,6 +21,7 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.components.appbar.AppBarWithBackButton import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.tester.impl.R import com.tangem.feature.tester.presentation.featuretoggles.models.TesterFeatureToggle import com.tangem.feature.tester.presentation.featuretoggles.state.FeatureTogglesContentState @@ -81,26 +83,10 @@ private fun FeatureToggleItem(toggle: TesterFeatureToggle, onCheckedChange: (Boo } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun PreviewFeatureTogglesScreen_InLightTheme() { - TangemTheme(isDark = false) { - FeatureTogglesScreen( - state = FeatureTogglesContentState( - featureToggles = listOf( - TesterFeatureToggle(name = "FEATURE_TOGGLE_1", isEnabled = true), - TesterFeatureToggle(name = "FEATURE_TOGGLE_2", isEnabled = false), - ), - onToggleValueChange = { _, _ -> }, - onBackClick = {}, - ), - ) - } -} - -@Preview -@Composable -private fun PreviewFeatureTogglesScreen_InDarkTheme() { - TangemTheme(isDark = true) { +private fun PreviewFeatureTogglesScreen() { + TangemThemePreview { FeatureTogglesScreen( state = FeatureTogglesContentState( featureToggles = listOf( diff --git a/features/tester/impl/src/main/java/com/tangem/feature/tester/presentation/menu/ui/TesterMenuScreen.kt b/features/tester/impl/src/main/java/com/tangem/feature/tester/presentation/menu/ui/TesterMenuScreen.kt index 4e5d7f056f..39d9c5b95c 100644 --- a/features/tester/impl/src/main/java/com/tangem/feature/tester/presentation/menu/ui/TesterMenuScreen.kt +++ b/features/tester/impl/src/main/java/com/tangem/feature/tester/presentation/menu/ui/TesterMenuScreen.kt @@ -1,5 +1,6 @@ package com.tangem.feature.tester.presentation.menu.ui +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -15,6 +16,7 @@ import androidx.compose.ui.tooling.preview.Preview import com.tangem.core.ui.components.PrimaryButton import com.tangem.core.ui.components.appbar.AppBarWithBackButton import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.tester.impl.R import com.tangem.feature.tester.presentation.menu.state.TesterMenuContentState @@ -64,23 +66,10 @@ internal fun TesterMenuScreen(state: TesterMenuContentState) { } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun PreviewTesterMenuScreen_InLightTheme() { - TangemTheme(isDark = false) { - TesterMenuScreen( - state = TesterMenuContentState( - onBackClick = {}, - onFeatureTogglesClick = {}, - onTesterActionsClick = {}, - ), - ) - } -} - -@Preview -@Composable -private fun PreviewTesterMenuScreen_InDarkTheme() { - TangemTheme(isDark = true) { +private fun PreviewTesterMenuScreen() { + TangemThemePreview { TesterMenuScreen( state = TesterMenuContentState( onBackClick = {}, diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreen.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreen.kt index 070d2b0065..ebce26c35c 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreen.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreen.kt @@ -1,5 +1,6 @@ package com.tangem.feature.tokendetails.presentation.tokendetails.ui +import android.content.res.Configuration import androidx.activity.compose.BackHandler import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.Box @@ -39,6 +40,7 @@ import com.tangem.core.ui.event.StateEvent import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.tokendetails.presentation.tokendetails.TokenDetailsPreviewData import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.TokenDetailsNotification @@ -184,21 +186,12 @@ internal fun TokenDetailsEventEffect(snackbarHostState: SnackbarHostState, event // region Preview @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun TokenDetailsScreenPreview_Light( +private fun TokenDetailsScreenPreview( @PreviewParameter(TokenDetailsScreenParameterProvider::class) state: TokenDetailsState, ) { - TangemTheme { - TokenDetailsScreen(state) - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun TokenDetailsScreenPreview_Dark( - @PreviewParameter(TokenDetailsScreenParameterProvider::class) state: TokenDetailsState, -) { - TangemTheme(isDark = true) { + TangemThemePreview { TokenDetailsScreen(state) } } diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenDetailsBalanceBlock.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenDetailsBalanceBlock.kt index e8fd329b15..3f448ae33a 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenDetailsBalanceBlock.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenDetailsBalanceBlock.kt @@ -1,5 +1,6 @@ package com.tangem.feature.tokendetails.presentation.tokendetails.ui.components +import android.content.res.Configuration import androidx.compose.foundation.layout.* import androidx.compose.material3.Surface import androidx.compose.material3.Text @@ -14,6 +15,7 @@ import com.tangem.common.Strings.STARS import com.tangem.core.ui.components.RectangleShimmer import com.tangem.core.ui.components.buttons.HorizontalActionChips import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.utils.BigDecimalFormatter import com.tangem.feature.tokendetails.presentation.tokendetails.TokenDetailsPreviewData import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsBalanceBlockState @@ -129,21 +131,12 @@ private fun CryptoBalance( } @Preview(widthDp = 328, heightDp = 152) +@Preview(widthDp = 328, heightDp = 152, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_TokenDetailsBalanceBlock_LightTheme( +private fun Preview_TokenDetailsBalanceBlock( @PreviewParameter(TokenDetailsBalanceBlockStateProvider::class) state: TokenDetailsBalanceBlockState, ) { - TangemTheme(isDark = false) { - TokenDetailsBalanceBlock(state = state, isBalanceHidden = false) - } -} - -@Preview(widthDp = 328, heightDp = 152) -@Composable -private fun Preview_TokenDetailsBalanceBlock_DarkTheme( - @PreviewParameter(TokenDetailsBalanceBlockStateProvider::class) state: TokenDetailsBalanceBlockState, -) { - TangemTheme(isDark = true) { + TangemThemePreview { TokenDetailsBalanceBlock(state = state, isBalanceHidden = false) } } diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenDetailsTopAppBar.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenDetailsTopAppBar.kt index 1ed6603ba3..3ea60b1140 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenDetailsTopAppBar.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenDetailsTopAppBar.kt @@ -1,5 +1,6 @@ package com.tangem.feature.tokendetails.presentation.tokendetails.ui.components +import android.content.res.Configuration import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -18,6 +19,7 @@ import androidx.compose.ui.util.fastForEach import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.tokendetails.presentation.tokendetails.TokenDetailsPreviewData import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsAppBarMenuConfig import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsTopAppBarConfig @@ -96,9 +98,10 @@ private fun AppBarDropdownItem( } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_TokenDetailsAppBarDropdownItem_LightTheme() { - TangemTheme(isDark = false) { +private fun Preview_TokenDetailsAppBarDropdownItem() { + TangemThemePreview { AppBarDropdownItem( modifier = Modifier.background(TangemTheme.colors.background.primary), dismissParent = {}, @@ -112,33 +115,10 @@ private fun Preview_TokenDetailsAppBarDropdownItem_LightTheme() { } @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_TokenDetailsAppBarDropdownItem_DarkTheme() { - TangemTheme(isDark = true) { - AppBarDropdownItem( - modifier = Modifier.background(TangemTheme.colors.background.primary), - dismissParent = {}, - item = TokenDetailsAppBarMenuConfig.MenuItem( - title = TextReference.Res(id = R.string.token_details_hide_token), - textColorProvider = { TangemTheme.colors.text.warning }, - onClick = { }, - ), - ) - } -} - -@Preview -@Composable -private fun Preview_TokenDetailsTopAppBar_LightTheme() { - TangemTheme(isDark = false) { - TokenDetailsTopAppBar(config = TokenDetailsPreviewData.tokenDetailsTopAppBarConfig) - } -} - -@Preview -@Composable -private fun Preview_TokenDetailsTopAppBar_DarkTheme() { - TangemTheme(isDark = true) { +private fun Preview_TokenDetailsTopAppBar() { + TangemThemePreview { TokenDetailsTopAppBar(config = TokenDetailsPreviewData.tokenDetailsTopAppBarConfig) } } \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenInfoBlock.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenInfoBlock.kt index 3982a8dc21..37f036d60f 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenInfoBlock.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenInfoBlock.kt @@ -1,5 +1,6 @@ package com.tangem.feature.tokendetails.presentation.tokendetails.ui.components +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.material.Text @@ -18,6 +19,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.tokendetails.presentation.tokendetails.TokenDetailsPreviewData import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenInfoBlockState import com.tangem.features.tokendetails.impl.R @@ -136,23 +138,13 @@ private val GrayscaleColorFilter: ColorFilter get() = ColorFilter.colorMatrix(ColorMatrix().apply { setToSaturation(GRAY_SCALE_SATURATION) }) @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun Preview_TokenInfoBlock_LightTheme( +private fun Preview_TokenInfoBlock( @PreviewParameter(TokenInfoStateProvider::class) state: TokenInfoBlockState, ) { - TangemTheme(isDark = false) { - TokenInfoBlock(state, Modifier.background(TangemTheme.colors.background.secondary)) - } -} - -@Preview -@Composable -private fun Preview_TokenInfoBlock_DarkTheme( - @PreviewParameter(TokenInfoStateProvider::class) - state: TokenInfoBlockState, -) { - TangemTheme(isDark = true) { + TangemThemePreview { TokenInfoBlock(state, Modifier.background(TangemTheme.colors.background.secondary)) } } diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/exchange/ExchangeProvider.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/exchange/ExchangeProvider.kt index 5f3527a8eb..7d1c2f14b5 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/exchange/ExchangeProvider.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/exchange/ExchangeProvider.kt @@ -22,6 +22,7 @@ import com.tangem.core.ui.R import com.tangem.core.ui.components.inputrow.InputRowBestRate import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview @Composable internal fun ExchangeProvider( @@ -90,7 +91,7 @@ internal fun ExchangeProvider( @Preview(showBackground = true) @Composable private fun ExchangeProvider_Preview() { - TangemTheme(isDark = false) { + TangemThemePreview(isDark = false) { ExchangeProvider( providerName = TextReference.Str("Changelly"), providerType = TextReference.Str("CEX"), diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/exchange/ExchangeStatusItems.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/exchange/ExchangeStatusItems.kt index 53e398e71f..1945621d19 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/exchange/ExchangeStatusItems.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/exchange/ExchangeStatusItems.kt @@ -1,5 +1,6 @@ package com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.exchange +import android.content.res.Configuration import androidx.annotation.DrawableRes import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background @@ -25,6 +26,7 @@ import com.tangem.core.ui.components.atoms.text.TextEllipsis import com.tangem.core.ui.components.currency.tokenicon.TokenIcon import com.tangem.core.ui.components.currency.tokenicon.TokenIconState import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.swap.domain.models.domain.ExchangeStatus import com.tangem.feature.tokendetails.presentation.tokendetails.state.SwapTransactionsState import com.tangem.features.tokendetails.impl.R @@ -195,31 +197,12 @@ private fun ExchangeStatusItem( //region Preview @Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun ExchangeStatusItemPreview_Light( +private fun ExchangeStatusItemPreview( @PreviewParameter(ExchangeStatusItemsPreviewParameterProvider::class) amount: String, ) { - TangemTheme { - ExchangeStatusItem( - providerName = "ChangeNow", - fromTokenIconState = TokenIconState.Loading, - toTokenIconState = TokenIconState.Loading, - fromAmount = amount, - fromSymbol = "USDT", - toSymbol = "USDT", - onClick = {}, - infoIconRes = null, - infoIconTint = null, - ) - } -} - -@Preview -@Composable -private fun ExchangeStatusItemPreview_Dark( - @PreviewParameter(ExchangeStatusItemsPreviewParameterProvider::class) amount: String, -) { - TangemTheme(isDark = true) { + TangemThemePreview { ExchangeStatusItem( providerName = "ChangeNow", fromTokenIconState = TokenIconState.Loading, diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/component/NetworkGroupItem.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/component/NetworkGroupItem.kt index c5af5a2cf6..c0d0a73b1a 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/component/NetworkGroupItem.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/component/NetworkGroupItem.kt @@ -1,5 +1,6 @@ package com.tangem.feature.wallet.presentation.common.component +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.material3.Icon @@ -13,6 +14,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.wallet.impl.R import org.burnoutcrew.reorderable.ReorderableLazyListState import org.burnoutcrew.reorderable.detectReorder @@ -92,17 +94,10 @@ private fun NetworkGroupItemSample(isDraggable: Boolean) { } @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun NetworkGroupItemPreview_Light(@PreviewParameter(NetworkGroupProvider::class) isDraggable: Boolean) { - TangemTheme { - NetworkGroupItemSample(isDraggable) - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun NetworkGroupItemPreview_Dark(@PreviewParameter(NetworkGroupProvider::class) isDraggable: Boolean) { - TangemTheme(isDark = true) { +private fun NetworkGroupItemPreview(@PreviewParameter(NetworkGroupProvider::class) isDraggable: Boolean) { + TangemThemePreview { NetworkGroupItemSample(isDraggable) } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/component/TokenItem.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/component/TokenItem.kt index 0b20c2a43a..989965b112 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/component/TokenItem.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/component/TokenItem.kt @@ -20,6 +20,7 @@ import com.tangem.core.ui.components.currency.tokenicon.TokenIcon import com.tangem.core.ui.components.marketprice.PriceChangeType import com.tangem.core.ui.extensions.rememberHapticFeedback import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.wallet.presentation.common.WalletPreviewData import com.tangem.feature.wallet.presentation.common.component.token.* import com.tangem.feature.wallet.presentation.common.state.TokenItemState @@ -392,7 +393,7 @@ private fun calculateLayoutHeight( @Preview(widthDp = 360) @Composable private fun Preview_TokenItem_InLight(@PreviewParameter(TokenItemStateProvider::class) state: TokenItemState) { - TangemTheme(isDark = false) { + TangemThemePreview(isDark = false) { TokenItem(state = state, isBalanceHidden = false) } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/OrganizeTokensScreen.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/OrganizeTokensScreen.kt index 294fe204cd..4efcf827cb 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/OrganizeTokensScreen.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/OrganizeTokensScreen.kt @@ -1,5 +1,6 @@ package com.tangem.feature.wallet.presentation.organizetokens +import android.content.res.Configuration import androidx.activity.compose.BackHandler import androidx.compose.animation.core.animateDpAsState import androidx.compose.foundation.background @@ -34,6 +35,7 @@ import com.tangem.core.ui.components.buttons.actions.RoundedActionButton import com.tangem.core.ui.event.EventEffect import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.wallet.impl.R import com.tangem.feature.wallet.presentation.common.WalletPreviewData import com.tangem.feature.wallet.presentation.common.component.DraggableNetworkGroupItem @@ -373,21 +375,12 @@ private fun getItemShape(roundingMode: DraggableItem.RoundingMode, radius: Dp): // region Preview @Preview(showBackground = true, widthDp = 360) +@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable -private fun OrganizeTokensScreenPreview_Light( +private fun OrganizeTokensScreenPreview( @PreviewParameter(OrganizeTokensStateProvider::class) state: OrganizeTokensState, ) { - TangemTheme { - OrganizeTokensScreen(state) - } -} - -@Preview(showBackground = true, widthDp = 360) -@Composable -private fun OrganizeTokensScreenPreview_Dark( - @PreviewParameter(OrganizeTokensStateProvider::class) state: OrganizeTokensState, -) { - TangemTheme(isDark = true) { + TangemThemePreview { OrganizeTokensScreen(state) } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/TokenActionsBottomSheet.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/TokenActionsBottomSheet.kt index 865a52268f..5e4db0ab08 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/TokenActionsBottomSheet.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/TokenActionsBottomSheet.kt @@ -1,5 +1,6 @@ package com.tangem.feature.wallet.presentation.wallet.ui.components +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.runtime.Composable @@ -14,6 +15,7 @@ import com.tangem.core.ui.components.getDefaultRowColors import com.tangem.core.ui.components.getWarningRowColors import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.wallet.presentation.common.WalletPreviewData import com.tangem.feature.wallet.presentation.wallet.state.model.ActionsBottomSheetConfig import com.tangem.feature.wallet.presentation.wallet.state.model.TokenActionButtonConfig @@ -49,24 +51,13 @@ private fun ActionsBottomSheetContent(actions: ImmutableList