From 2d27c7b1842e9dad868aa13a4d6e851bc6e09e8e Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Tue, 20 Aug 2024 08:43:55 +0200 Subject: [PATCH] Add SettingOptionItemPreview --- .../ui/components/SettingOption.kt | 23 +++++++++++++++++++ .../main/settings/SettingsThemeScreen.kt | 1 + 2 files changed, 24 insertions(+) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SettingOption.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SettingOption.kt index 4ba127064..24be130bb 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SettingOption.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SettingOption.kt @@ -18,19 +18,24 @@ package com.infomaniak.swisstransfer.ui.components +import android.content.res.Configuration import androidx.annotation.StringRes import androidx.compose.foundation.layout.* import androidx.compose.foundation.selection.selectable import androidx.compose.foundation.selection.selectableGroup import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon +import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable 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 com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.icons.AppIcons +import com.infomaniak.swisstransfer.ui.icons.app.Add import com.infomaniak.swisstransfer.ui.icons.app.Checkmark import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme @@ -81,3 +86,21 @@ interface SettingOption { val title: Int val icon: ImageVector? } + +@Preview(name = "Light") +@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@Composable +private fun SettingOptionItemPreview() { + SwissTransferTheme { + Surface { + Column { + val item = object : SettingOption { + override val title: Int = R.string.appName + override val icon: ImageVector = AppIcons.Add + } + SettingOptionItem(item, true) {} + SettingOptionItem(item, false) {} + } + } + } +} diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsThemeScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsThemeScreen.kt index 9d73ed71a..e1bec2524 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsThemeScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsThemeScreen.kt @@ -38,6 +38,7 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewTablet fun SettingsThemeScreen() { Column { SettingTitle(titleRes = R.string.appName) + val (selectedItem, setSelectedItem) = rememberSaveable { mutableIntStateOf(0) } // TODO: Use DataStore or Realm MutuallyExclusiveOptions(ThemeOption.entries, selectedItem, setSelectedItem) }