From 60bc392967235a4bcb75fccedc3c60f16649d539 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Fri, 1 Nov 2024 11:12:26 +0100 Subject: [PATCH] feat: Add `PreviewLightAndDark` for Components --- .../swisstransfer/ui/components/BottomSheetItem.kt | 6 ++---- .../swisstransfer/ui/components/CrossCircleButton.kt | 6 ++---- .../infomaniak/swisstransfer/ui/components/FileItem.kt | 6 ++---- .../swisstransfer/ui/components/FileItemList.kt | 6 ++---- .../swisstransfer/ui/components/SmallFileItem.kt | 6 ++---- .../swisstransfer/ui/components/SwissTransferCard.kt | 6 ++---- .../ui/components/SwissTransferTopAppBar.kt | 6 ++---- .../ui/components/transfer/TransferFilePreview.kt | 6 ++---- .../swisstransfer/ui/components/transfer/TransferItem.kt | 6 ++---- .../ui/components/transfer/TransferItemList.kt | 6 ++---- .../swisstransfer/ui/images/icons/matomo/Matomo.kt | 6 ++---- .../ui/images/icons/qrInfomaniak/QrInfomaniak.kt | 6 ++---- .../swisstransfer/ui/images/icons/sentry/Sentry.kt | 6 ++---- .../swisstransfer/ui/images/illus/beers/Beers.kt | 6 ++---- .../ui/images/illus/dataProtection/DataProtection.kt | 6 ++---- .../ui/images/illus/mascotDead/MascotDead.kt | 6 ++---- .../swisstransfer/ui/images/illus/matomo/Matomo.kt | 6 ++---- .../swisstransfer/ui/images/illus/sentry/Sentry.kt | 6 ++---- .../screen/main/received/components/ReceivedEmptyFab.kt | 6 ++---- .../ui/screen/main/settings/components/SettingItem.kt | 6 ++---- .../main/settings/components/SingleSelectOptions.kt | 6 ++---- .../ui/screen/main/settings/components/Titles.kt | 9 +++------ .../importfiles/components/ImportedFilesCard.kt | 6 ++---- .../importfiles/components/TransferAdvancedSetting.kt | 6 ++---- .../importfiles/components/TransferAdvancedSettings.kt | 6 ++---- .../importfiles/components/TransferTypeButton.kt | 6 ++---- .../importfiles/components/TransferTypeButtons.kt | 6 ++---- .../ui/utils/{MultiplePreview.kt => MultiplePreviews.kt} | 7 ++++++- 28 files changed, 61 insertions(+), 111 deletions(-) rename app/src/main/java/com/infomaniak/swisstransfer/ui/utils/{MultiplePreview.kt => MultiplePreviews.kt} (91%) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/BottomSheetItem.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/BottomSheetItem.kt index 7f0a47bcf..6dc922ed2 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/BottomSheetItem.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/BottomSheetItem.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.components -import android.content.res.Configuration import androidx.annotation.StringRes import androidx.compose.foundation.layout.* import androidx.compose.material3.Icon @@ -28,13 +27,13 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons import com.infomaniak.swisstransfer.ui.images.icons.Camera import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark private val BOTTOM_SHEET_ITEM_HEIGHT = 56.dp @@ -68,8 +67,7 @@ fun BottomSheetItem(imageVector: ImageVector, @StringRes titleRes: Int, onClick: } } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun ChoiceItemPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/CrossCircleButton.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/CrossCircleButton.kt index 783c98a6e..3da08268b 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/CrossCircleButton.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/CrossCircleButton.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.components -import android.content.res.Configuration import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.* @@ -27,7 +26,6 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.coerceAtLeast import androidx.compose.ui.unit.dp @@ -36,6 +34,7 @@ import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons import com.infomaniak.swisstransfer.ui.images.icons.CrossThick import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable @OptIn(ExperimentalMaterial3Api::class) @@ -64,8 +63,7 @@ fun BoxScope.CrossCircleButton(onClick: (() -> Unit)?, size: Dp = 48.dp) { } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun CrossCircleButtonPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt index 7fd3abb28..263ac02de 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.components -import android.content.res.Configuration import android.text.format.Formatter import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.background @@ -28,7 +27,6 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi @@ -37,6 +35,7 @@ import com.infomaniak.swisstransfer.ui.theme.CustomShapes import com.infomaniak.swisstransfer.ui.theme.Dimens import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable fun FileItem( @@ -123,8 +122,7 @@ private fun FileItemContent( } } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun FileItemPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItemList.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItemList.kt index 583e0fcc2..d22039d48 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItemList.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItemList.kt @@ -17,20 +17,19 @@ */ package com.infomaniak.swisstransfer.ui.components -import android.content.res.Configuration import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height import androidx.compose.foundation.lazy.grid.* 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.unit.dp import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi import com.infomaniak.swisstransfer.ui.previewparameter.FileUiListPreviewParameter import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable fun FileItemList( @@ -75,8 +74,7 @@ fun FileItemList( } } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun FileItemListPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SmallFileItem.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SmallFileItem.kt index ff8b3e106..70890eed5 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SmallFileItem.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SmallFileItem.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.components -import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.material3.Surface @@ -25,7 +24,6 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Shape -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp @@ -35,6 +33,7 @@ import com.infomaniak.swisstransfer.ui.previewparameter.FileUiListPreviewParamet import com.infomaniak.swisstransfer.ui.theme.CustomShapes import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable fun SmallFileItem( @@ -66,8 +65,7 @@ enum class SmallFileTileSize(val size: Dp, val shape: Shape) { fun iconCircleSize(): Dp = 2f / 3 * size } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun SmallFileItemPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SwissTransferCard.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SwissTransferCard.kt index 8055386d1..5e8f63299 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SwissTransferCard.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SwissTransferCard.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.components -import android.content.res.Configuration import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.padding @@ -28,11 +27,11 @@ import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.infomaniak.swisstransfer.ui.theme.CustomShapes import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable fun SwissTransferCard(modifier: Modifier = Modifier, content: @Composable ColumnScope.() -> Unit) { @@ -44,8 +43,7 @@ fun SwissTransferCard(modifier: Modifier = Modifier, content: @Composable Column ) } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun SwissTransferCardPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SwissTransferTopAppBar.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SwissTransferTopAppBar.kt index 602f2948b..6c2cb84cf 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SwissTransferTopAppBar.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SwissTransferTopAppBar.kt @@ -17,20 +17,19 @@ */ package com.infomaniak.swisstransfer.ui.components -import android.content.res.Configuration import androidx.annotation.StringRes import androidx.compose.material3.* import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons import com.infomaniak.swisstransfer.ui.images.icons.Add import com.infomaniak.swisstransfer.ui.images.icons.ArrowLeft import com.infomaniak.swisstransfer.ui.images.icons.Cross import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable @OptIn(ExperimentalMaterial3Api::class) @@ -75,8 +74,7 @@ data class TopAppBarButton( } } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun SwissTransferTopAppBarPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferFilePreview.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferFilePreview.kt index 0aeb11f0d..fbeedb957 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferFilePreview.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferFilePreview.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.components.transfer -import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.material3.Card @@ -28,7 +27,6 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi import com.infomaniak.swisstransfer.ui.components.SmallFileItem @@ -37,6 +35,7 @@ import com.infomaniak.swisstransfer.ui.previewparameter.FileUiListPreviewParamet import com.infomaniak.swisstransfer.ui.theme.CustomShapes import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable fun TransferFilePreview(file: FileUi? = null, remainingFilesCount: Int? = null) { @@ -75,8 +74,7 @@ fun TransferFilePreview(file: FileUi? = null, remainingFilesCount: Int? = null) } } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun Preview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItem.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItem.kt index 56686f9b5..2b457782e 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItem.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItem.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.components.transfer -import android.content.res.Configuration import android.text.format.Formatter import androidx.compose.foundation.layout.* import androidx.compose.material3.* @@ -27,7 +26,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import com.infomaniak.core2.FORMAT_DATE_SIMPLE import com.infomaniak.core2.FORMAT_DATE_TITLE @@ -41,6 +39,7 @@ import com.infomaniak.swisstransfer.ui.previewparameter.TransferUiListPreviewPar import com.infomaniak.swisstransfer.ui.theme.CustomShapes import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark import java.util.Date @OptIn(ExperimentalLayoutApi::class) @@ -116,8 +115,7 @@ fun TransferItem(transfer: TransferUi, onClick: () -> Unit) { } } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun Preview(@PreviewParameter(TransferUiListPreviewParameter::class) transfers: List) { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItemList.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItemList.kt index f42a4c505..f5888ec72 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItemList.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItemList.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.components.transfer -import android.content.res.Configuration import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height @@ -27,13 +26,13 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.TransferUi import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.previewparameter.TransferUiListPreviewParameter import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable fun TransferItemList( @@ -66,8 +65,7 @@ fun TransferItemList( } } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun Preview(@PreviewParameter(TransferUiListPreviewParameter::class) transfers: List) { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/matomo/Matomo.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/matomo/Matomo.kt index af95ef338..815c15eee 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/matomo/Matomo.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/matomo/Matomo.kt @@ -17,17 +17,16 @@ */ package com.infomaniak.swisstransfer.ui.images.icons.matomo -import android.content.res.Configuration import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.ui.images.AppImages import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons import com.infomaniak.swisstransfer.ui.images.ThemedImage import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark val AppIcons.Matomo: ThemedImage get() = _matomo ?: object : ThemedImage { @@ -37,8 +36,7 @@ val AppIcons.Matomo: ThemedImage private var _matomo: ThemedImage? = null -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun Preview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/qrInfomaniak/QrInfomaniak.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/qrInfomaniak/QrInfomaniak.kt index 3ac56b79a..ea862bc31 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/qrInfomaniak/QrInfomaniak.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/qrInfomaniak/QrInfomaniak.kt @@ -17,17 +17,16 @@ */ package com.infomaniak.swisstransfer.ui.images.icons.qrInfomaniak -import android.content.res.Configuration import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.ui.images.AppImages import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons import com.infomaniak.swisstransfer.ui.images.ThemedImage import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark val AppIcons.QrInfomaniak: ThemedImage get() = _qrInfomaniak ?: object : ThemedImage { @@ -37,8 +36,7 @@ val AppIcons.QrInfomaniak: ThemedImage private var _qrInfomaniak: ThemedImage? = null -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun Preview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/sentry/Sentry.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/sentry/Sentry.kt index fa3418fe1..aad51a081 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/sentry/Sentry.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/sentry/Sentry.kt @@ -17,17 +17,16 @@ */ package com.infomaniak.swisstransfer.ui.images.icons.sentry -import android.content.res.Configuration import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.ui.images.AppImages import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons import com.infomaniak.swisstransfer.ui.images.ThemedImage import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark val AppIcons.Sentry: ThemedImage get() = _sentry ?: object : ThemedImage { @@ -37,8 +36,7 @@ val AppIcons.Sentry: ThemedImage private var _sentry: ThemedImage? = null -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun Preview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/beers/Beers.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/beers/Beers.kt index e853e3e3f..c6a37f5b4 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/beers/Beers.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/beers/Beers.kt @@ -17,17 +17,16 @@ */ package com.infomaniak.swisstransfer.ui.images.illus.beers -import android.content.res.Configuration import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.ui.images.AppImages import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus import com.infomaniak.swisstransfer.ui.images.ThemedImage import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark val AppIllus.Beers: ThemedImage get() = _beers ?: object : ThemedImage { @@ -37,8 +36,7 @@ val AppIllus.Beers: ThemedImage private var _beers: ThemedImage? = null -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun Preview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/dataProtection/DataProtection.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/dataProtection/DataProtection.kt index 65a52772a..34ac564d8 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/dataProtection/DataProtection.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/dataProtection/DataProtection.kt @@ -17,17 +17,16 @@ */ package com.infomaniak.swisstransfer.ui.images.illus.dataProtection -import android.content.res.Configuration import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.ui.images.AppImages import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus import com.infomaniak.swisstransfer.ui.images.ThemedImage import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark val AppIllus.DataProtection: ThemedImage get() = _dataProtection ?: object : ThemedImage { @@ -37,8 +36,7 @@ val AppIllus.DataProtection: ThemedImage private var _dataProtection: ThemedImage? = null -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun Preview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/mascotDead/MascotDead.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/mascotDead/MascotDead.kt index 66f50769c..f407e3e3b 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/mascotDead/MascotDead.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/mascotDead/MascotDead.kt @@ -17,17 +17,16 @@ */ package com.infomaniak.swisstransfer.ui.images.illus.mascotDead -import android.content.res.Configuration import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.ui.images.AppImages import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus import com.infomaniak.swisstransfer.ui.images.ThemedImage import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark val AppIllus.MascotDead: ThemedImage get() = _mascotDead ?: object : ThemedImage { @@ -37,8 +36,7 @@ val AppIllus.MascotDead: ThemedImage private var _mascotDead: ThemedImage? = null -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun Preview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/matomo/Matomo.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/matomo/Matomo.kt index 6c72f19e4..57d6022f9 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/matomo/Matomo.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/matomo/Matomo.kt @@ -17,17 +17,16 @@ */ package com.infomaniak.swisstransfer.ui.images.illus.matomo -import android.content.res.Configuration import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.ui.images.AppImages import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus import com.infomaniak.swisstransfer.ui.images.ThemedImage import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark val AppIllus.Matomo: ThemedImage get() = _matomo ?: object : ThemedImage { @@ -37,8 +36,7 @@ val AppIllus.Matomo: ThemedImage private var _matomo: ThemedImage? = null -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun Preview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/sentry/Sentry.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/sentry/Sentry.kt index a8aa1dc95..a78f0b0f9 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/sentry/Sentry.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/illus/sentry/Sentry.kt @@ -17,17 +17,16 @@ */ package com.infomaniak.swisstransfer.ui.images.illus.sentry -import android.content.res.Configuration import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.ui.images.AppImages import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus import com.infomaniak.swisstransfer.ui.images.ThemedImage import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark val AppIllus.Sentry: ThemedImage get() = _sentry ?: object : ThemedImage { @@ -37,8 +36,7 @@ val AppIllus.Sentry: ThemedImage private var _sentry: ThemedImage? = null -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun Preview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/components/ReceivedEmptyFab.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/components/ReceivedEmptyFab.kt index 87bda11c6..6015ed56a 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/components/ReceivedEmptyFab.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/components/ReceivedEmptyFab.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.screen.main.received.components -import android.content.res.Configuration import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize @@ -29,7 +28,6 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import androidx.constraintlayout.compose.ConstraintLayout import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.NewTransferFab @@ -38,6 +36,7 @@ import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus import com.infomaniak.swisstransfer.ui.images.illus.ArrowRightCurved import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable fun ReceivedEmptyFab(isMessageVisible: () -> Boolean) { @@ -76,8 +75,7 @@ fun ReceivedEmptyFab(isMessageVisible: () -> Boolean) { } } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun ReceivedEmptyFabPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/SettingItem.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/SettingItem.kt index d3b6e97b1..1c5a4933b 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/SettingItem.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/SettingItem.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.screen.main.settings.components -import android.content.res.Configuration import androidx.annotation.StringRes import androidx.compose.foundation.layout.* import androidx.compose.foundation.selection.selectableGroup @@ -29,7 +28,6 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.SharpRippleButton @@ -41,6 +39,7 @@ import com.infomaniak.swisstransfer.ui.images.icons.Folder import com.infomaniak.swisstransfer.ui.theme.Dimens import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark private val ITEM_MIN_HEIGHT = 56.dp @@ -109,8 +108,7 @@ private fun SettingItemContent( } } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun SettingItemPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/SingleSelectOptions.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/SingleSelectOptions.kt index 19442f6d1..02ccc8559 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/SingleSelectOptions.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/SingleSelectOptions.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.screen.main.settings.components -import android.content.res.Configuration import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.scaleIn import androidx.compose.animation.scaleOut @@ -35,7 +34,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.vectorResource -import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.SharpRippleButton import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons @@ -43,6 +41,7 @@ import com.infomaniak.swisstransfer.ui.images.icons.Add import com.infomaniak.swisstransfer.ui.images.icons.Checkmark import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable fun SingleSelectOptions(items: List, selectedItem: () -> Int, setSelectedItem: (Int) -> Unit) { @@ -101,8 +100,7 @@ interface SettingOption { @Composable get() = imageVector ?: imageVectorResId?.let { ImageVector.vectorResource(it) } } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun SettingOptionItemPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/Titles.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/Titles.kt index 55c9d64c7..c78efbb2f 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/Titles.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/Titles.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.screen.main.settings.components -import android.content.res.Configuration import androidx.annotation.StringRes import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.padding @@ -26,11 +25,11 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.theme.Dimens import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable fun SettingTitle(@StringRes titleRes: Int) { @@ -58,8 +57,7 @@ private fun UnpaddedTitle(modifier: Modifier, titleRes: Int) { ) } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun OptionTitlePreview() { SwissTransferTheme { @@ -71,8 +69,7 @@ private fun OptionTitlePreview() { } } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun SettingTitlePreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/ImportedFilesCard.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/ImportedFilesCard.kt index 798190219..fcb0ad05d 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/ImportedFilesCard.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/ImportedFilesCard.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.components -import android.content.res.Configuration import android.os.Parcelable import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyRow @@ -28,7 +27,6 @@ import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.pluralStringResource -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi @@ -42,6 +40,7 @@ import com.infomaniak.swisstransfer.ui.theme.CustomShapes import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.HumanReadableSizeUtils.formatSpaceLeft +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark import kotlinx.parcelize.Parcelize @Composable @@ -125,8 +124,7 @@ private data class TransferLazyRowKey( } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun ImportedFilesCardPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferAdvancedSetting.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferAdvancedSetting.kt index c5d4107c4..3618596cf 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferAdvancedSetting.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferAdvancedSetting.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.components -import android.content.res.Configuration import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.size @@ -28,7 +27,6 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.ui.components.SharpRippleButton import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons import com.infomaniak.swisstransfer.ui.images.icons.ChevronRightThick @@ -37,6 +35,7 @@ import com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.TransferAd import com.infomaniak.swisstransfer.ui.theme.Dimens import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable fun TransferAdvancedSetting( @@ -78,8 +77,7 @@ private fun SettingValue(selectedSetting: () -> TransferAdvancedOptionsEnum) { ) } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun TransferTypeButtonsPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferAdvancedSettings.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferAdvancedSettings.kt index 7e42d20d1..e19d5885b 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferAdvancedSettings.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferAdvancedSettings.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.components -import android.content.res.Configuration import androidx.annotation.StringRes import androidx.compose.foundation.layout.padding import androidx.compose.material3.Surface @@ -27,7 +26,6 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector -import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.SwissTransferCard import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons @@ -42,6 +40,7 @@ import com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.PasswordTr import com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.TransferAdvancedOptionsEnum import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable fun TransferAdvancedSettings( @@ -64,8 +63,7 @@ enum class TransferAdvancedSettingType(val buttonIcon: ImageVector, @StringRes v LANGUAGE(buttonIcon = AppIcons.SpeechBubble, buttonText = R.string.settingsOptionEmailLanguage), } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun TransferTypeButtonsPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButton.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButton.kt index d16bf60df..dab38170a 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButton.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButton.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.components -import android.content.res.Configuration import androidx.compose.foundation.border import androidx.compose.foundation.layout.* import androidx.compose.material3.* @@ -25,11 +24,11 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.ui.theme.CustomShapes import com.infomaniak.swisstransfer.ui.theme.Dimens import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable fun TransferTypeButton( @@ -59,8 +58,7 @@ fun TransferTypeButton( } } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun TransferTypeButtonPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButtons.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButtons.kt index 139c86b1d..3aa431ae9 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButtons.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButtons.kt @@ -17,7 +17,6 @@ */ package com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.components -import android.content.res.Configuration import androidx.annotation.PluralsRes import androidx.annotation.StringRes import androidx.compose.foundation.horizontalScroll @@ -28,7 +27,6 @@ import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector -import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons import com.infomaniak.swisstransfer.ui.images.icons.Chain @@ -38,6 +36,7 @@ import com.infomaniak.swisstransfer.ui.images.icons.WifiWave import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.GetSetCallbacks +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable fun TransferTypeButtons(transferType: GetSetCallbacks) { @@ -88,8 +87,7 @@ enum class TransferType( ), } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@PreviewLightAndDark @Composable private fun TransferTypeButtonsPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/MultiplePreview.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/MultiplePreviews.kt similarity index 91% rename from app/src/main/java/com/infomaniak/swisstransfer/ui/utils/MultiplePreview.kt rename to app/src/main/java/com/infomaniak/swisstransfer/ui/utils/MultiplePreviews.kt index 226079cf9..0e1356abd 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/MultiplePreview.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/MultiplePreviews.kt @@ -68,7 +68,12 @@ annotation class PreviewSmallWindow ) annotation class PreviewLargeWindow -// Small + Large +// Small + Large (for Screens) @PreviewSmallWindow @PreviewLargeWindow annotation class PreviewAllWindows + +// Light + Dark (for Components) +@Preview(name = "Light") +@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +annotation class PreviewLightAndDark