diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDurationValidityScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDurationValidityScreen.kt new file mode 100644 index 0000000000..db8ff2f3ce --- /dev/null +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDurationValidityScreen.kt @@ -0,0 +1,68 @@ +/* + * Infomaniak SwissTransfer - Android + * Copyright (C) 2024 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.infomaniak.swisstransfer.ui.screen.main.settings + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Surface +import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.res.pluralStringResource +import com.infomaniak.swisstransfer.R +import com.infomaniak.swisstransfer.ui.screen.main.settings.components.MutuallyExclusiveOptions +import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingOption +import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingTitle +import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewMobile +import com.infomaniak.swisstransfer.ui.utils.PreviewTablet + +@Composable +fun SettingsValidityPeriodScreen() { + Column(modifier = Modifier.verticalScroll(rememberScrollState())) { + SettingTitle(titleRes = R.string.settingsValidityPeriodTitle) + + val (selectedItem, setSelectedItem) = rememberSaveable { mutableIntStateOf(0) } // TODO: Use DataStore or Realm + MutuallyExclusiveOptions(ValidityPeriod.entries, selectedItem, setSelectedItem) + } +} + +enum class ValidityPeriod( + override val title: @Composable () -> String, + override val icon: ImageVector? = null +) : SettingOption { + THIRTY({ pluralStringResource(R.plurals.settingsValidityPeriodValue, 30, 30) }), + FIFTEEN({ pluralStringResource(R.plurals.settingsValidityPeriodValue, 15, 15) }), + SEVEN({ pluralStringResource(R.plurals.settingsValidityPeriodValue, 7, 7) }), + ONE({ pluralStringResource(R.plurals.settingsValidityPeriodValue, 1, 1) }), +} + +@PreviewMobile +@PreviewTablet +@Composable +private fun SettingsThemeScreenPreview() { + SwissTransferTheme { + Surface { + SettingsValidityPeriodScreen() + } + } +} diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt index 1498cc72a8..5b6f705391 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt @@ -80,7 +80,7 @@ fun SettingsScreenWrapper( when (destination) { THEME -> SettingsThemeScreen() NOTIFICATIONS -> {} - VALIDITY_PERIOD -> {} + VALIDITY_PERIOD -> SettingsValidityPeriodScreen() DOWNLOAD_LIMIT -> {} EMAIL_LANGUAGE -> {} DISCOVER_INFOMANIAK -> {} 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 f1a53a1803..0c4206dc4f 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 @@ -27,6 +27,7 @@ import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.res.stringResource import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.icons.AppIcons import com.infomaniak.swisstransfer.ui.icons.app.BlackAndWhiteCircle @@ -49,10 +50,10 @@ fun SettingsThemeScreen() { } } -enum class ThemeOption(override val title: Int, override val icon: ImageVector) : SettingOption { - SYSTEM(R.string.settingsOptionThemeSystem, AppIcons.BlackAndWhiteCircle), - LIGHT(R.string.settingsOptionThemeLight, AppIcons.WhiteCircle), - DARK(R.string.settingsOptionThemeDark, AppIcons.BlackCircle), +enum class ThemeOption(override val title: @Composable () -> String, override val icon: ImageVector) : SettingOption { + SYSTEM({ stringResource(R.string.settingsOptionThemeSystem) }, AppIcons.BlackAndWhiteCircle), + LIGHT({ stringResource(R.string.settingsOptionThemeLight) }, AppIcons.WhiteCircle), + DARK({ stringResource(R.string.settingsOptionThemeDark) }, AppIcons.BlackCircle), } @PreviewMobile diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/MutuallyExclusiveOptions.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/MutuallyExclusiveOptions.kt index 335a6f3351..794f350037 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/MutuallyExclusiveOptions.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/MutuallyExclusiveOptions.kt @@ -19,7 +19,6 @@ package com.infomaniak.swisstransfer.ui.screen.main.settings.components import android.content.res.Configuration -import androidx.annotation.StringRes import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.scaleIn import androidx.compose.animation.scaleOut @@ -72,7 +71,7 @@ private fun SettingOptionItem(item: SettingOption, isSelected: Boolean, onClick: Spacer(modifier = Modifier.width(Margin.Medium)) } - Text(text = stringResource(id = item.title), Modifier.weight(1f)) + Text(text = item.title.invoke(), Modifier.weight(1f)) if (isSelected) Spacer(modifier = Modifier.width(Margin.Medium)) AnimatedVisibility( @@ -91,8 +90,7 @@ private fun SettingOptionItem(item: SettingOption, isSelected: Boolean, onClick: } interface SettingOption { - @get:StringRes - val title: Int + val title: @Composable () -> String val icon: ImageVector? } @@ -104,7 +102,7 @@ private fun SettingOptionItemPreview() { Surface { Column { val item = object : SettingOption { - override val title: Int = R.string.appName + override val title: @Composable () -> String = { stringResource(R.string.appName) } override val icon: ImageVector = AppIcons.Add } SettingOptionItem(item, true) {} diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 998ef976b5..7414d8f517 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -34,6 +34,7 @@ Über Standardeinstellungen General + Wähle Sie eine Präferenz Entdecken Sie Infomaniak Limit für Downloads Sprache der E-Mail @@ -41,12 +42,17 @@ Benachrichtigungen Teile deine Ideen Thema - Sombre - Clair - Système + Dunkelheit + Licht + System Dauer der Gültigkeit Wähle ein Thema aus Einstellungen + Legen Sie eine Standardgültigkeitsdauer für Ihre Überweisungen fest + + %d Tag + %d Tage + Geteilte Dateien Inhalt der Übertragung : E-Mail diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index ae6ec4f99d..a6c74bd228 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -34,6 +34,7 @@ Quiénes somos Ajustes por defecto General + Seleccione una preferencia Descubrir Infomaniak Límite de descarga Idioma del correo electrónico @@ -41,12 +42,17 @@ Notificaciones Comparte tus ideas Tema - Sombre - Clair - Système + Oscuro + Luz + Sistema Periodo de validez Seleccione un tema Parámetros + Establezca un periodo de validez por defecto para sus transferencias + + día %d + %d días + Archivos compartidos Contenido de la transferencia : Correo electrónico diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 7e1472ff08..6e17045131 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -34,6 +34,7 @@ A propos Paramètres par défaut Général + Sélectionne une préférence Découvrir Infomaniak Limite de téléchargements Langue de l’e-mail @@ -47,6 +48,11 @@ Durée de validité Sélectionne un thème Paramètres + Défini une durée de validité par défaut pour tes transferts + + %d jour + %d jours + Fichiers partagés Contenu du transfert : E-mail diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index fd2df147bc..fe387359d7 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -34,6 +34,7 @@ Chi siamo Impostazioni predefinite Generale + Selezionare una preferenza Scoprire Infomaniak Limite di download Lingua della posta elettronica @@ -41,12 +42,17 @@ Notifiche Condividete le vostre idee Tema - Sombre - Clair - Système + Scuro + Chiaro + Sistema Periodo di validità Selezionare un tema Parametri + Impostare un periodo di validità predefinito per i trasferimenti + + %d giorno + %d giorni + File condivisi Contenuto del trasferimento : Email diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e3c115a6c2..aec54f7d40 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -37,6 +37,7 @@ About Default settings Général + Select a preference Discover Infomaniak Download limit Email language @@ -44,12 +45,17 @@ Notifications Share your ideas Theme - Sombre - Clair - Système + Dark + Light + System Validity period Select a theme Settings + Set a default validity period for your transfers + + %d day + %d days + Shared files Transfer content: Email