diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDownloadsLimitScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDownloadsLimitScreen.kt index ca4ed8d9e..a4b0d71a1 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDownloadsLimitScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDownloadsLimitScreen.kt @@ -86,7 +86,7 @@ private fun SettingsThemeScreenPreview() { SettingsDownloadsLimitScreen( downloadLimit = DownloadLimit.TWOHUNDREDFIFTY, navigateBack = {}, - onDownloadLimitChange = {} + onDownloadLimitChange = {}, ) } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsEmailLanguageScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsEmailLanguageScreen.kt index 7bf3b7ef3..3aa88b978 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsEmailLanguageScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsEmailLanguageScreen.kt @@ -45,7 +45,7 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewMobile fun SettingsEmailLanguageScreen( emailLanguage: EmailLanguage, navigateBack: (() -> Unit)?, - onEmailLanguageChange: (EmailLanguage) -> Unit + onEmailLanguageChange: (EmailLanguage) -> Unit, ) { Scaffold(topBar = { val canDisplayBackButton = navigateBack?.let { TopAppBarButton.backButton(navigateBack) } @@ -88,7 +88,7 @@ private fun SettingsThemeScreenPreview() { SettingsEmailLanguageScreen( emailLanguage = EmailLanguage.FRENCH, navigateBack = {}, - onEmailLanguageChange = {} + onEmailLanguageChange = {}, ) } } 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 d3a47b030..483fb0e5f 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 @@ -79,6 +79,7 @@ fun SettingsScreen( description = appSettings.theme.getString(), endIcon = CHEVRON, onClick = { onItemClick(THEME) }, + ) SettingItem( titleRes = R.string.settingsOptionNotifications, isSelected = { selectedSetting == NOTIFICATIONS }, @@ -93,7 +94,7 @@ fun SettingsScreen( SettingItem( titleRes = R.string.settingsOptionValidityPeriod, isSelected = { selectedSetting == VALIDITY_PERIOD }, - icon = AppIcons.FileBadgeArrowDown, + icon = AppIcons.ArrowDownFile, description = appSettings.validityPeriod.getString(), endIcon = CHEVRON, onClick = { onItemClick(VALIDITY_PERIOD) }, diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt index ee5f906e8..432ef5234 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt @@ -59,15 +59,14 @@ fun SettingsScreenWrapper( detailPane = { DetailPane(safeAppSettings, settingsViewModel, navigator = this) }, ) } +} - @OptIn(ExperimentalMaterial3AdaptiveApi::class) - @Composable - private fun DetailPane( - settingsViewModel: SettingsViewModel, - navigator: ThreePaneScaffoldNavigator, - appSettings: AppSettings - ) { - var lastSelectedScreen by rememberSaveable { mutableStateOf(null) } +@OptIn(ExperimentalMaterial3AdaptiveApi::class) +@Composable +private fun ListPane(navigator: ThreePaneScaffoldNavigator, appSettings: AppSettings) { + val context = LocalContext.current + val aboutURL = stringResource(R.string.urlAbout) + val userReportURL = stringResource(R.string.urlUserReportAndroid) SettingsScreen( appSettings, @@ -103,45 +102,49 @@ private fun DetailPane( val navigateBack: (() -> Unit)? = if (navigator.canNavigateBack()) navigateBackCallback else null when (destination) { - THEME -> { - SettingsThemeScreen(appSettings.theme, navigateBack) { - settingsViewModel.setTheme(it) - } - DOWNLOAD_LIMIT -> { - val downloadLimit = appSettings.downloadLimit - SettingsDownloadsLimitScreen(downloadLimit, navigateBack) { - settingsViewModel.setDownloadLimit(it) - } - } - EMAIL_LANGUAGE -> { - val emailLanguage = appSettings.emailLanguage - SettingsEmailLanguageScreen(emailLanguage, navigateBack) { - settingsViewModel.setEmailLanguage(it) - } - } - NOTIFICATIONS, - DISCOVER_INFOMANIAK, - SHARE_IDEAS, - GIVE_FEEDBACK -> Unit - null -> NoSelectionEmptyState() - } + THEME -> SettingsThemeScreen( + theme = appSettings.theme, + navigateBack = navigateBack, + onThemeUpdate = settingsViewModel::setTheme, + ) + VALIDITY_PERIOD -> SettingsValidityPeriodScreen( + validityPeriod = appSettings.validityPeriod, + navigateBack = navigateBack, + onValidityPeriodChange = settingsViewModel::setValidityPeriod, + ) + DOWNLOAD_LIMIT -> SettingsDownloadsLimitScreen( + downloadLimit = appSettings.downloadLimit, + navigateBack = navigateBack, + onDownloadLimitChange = settingsViewModel::setDownloadLimit, + ) + EMAIL_LANGUAGE -> SettingsEmailLanguageScreen( + emailLanguage = appSettings.emailLanguage, + navigateBack = navigateBack, + onEmailLanguageChange = settingsViewModel::setEmailLanguage, + ) + NOTIFICATIONS, + DISCOVER_INFOMANIAK, + SHARE_IDEAS, + GIVE_FEEDBACK -> Unit + null -> NoSelectionEmptyState() } +} - // Show the detail pane content if selected item is available - @Composable - private fun NoSelectionEmptyState() { - Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { - Text("Select a setting item", color = SwissTransferTheme.colors.secondaryTextColor) - } +// Show the detail pane content if selected item is available +@Composable +private fun NoSelectionEmptyState() { + Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { + Text("Select a setting item", color = SwissTransferTheme.colors.secondaryTextColor) } +} - @PreviewMobile - @PreviewTablet - @Composable - private fun SettingsScreenWrapperPreview() { - SwissTransferTheme { - Surface(color = MaterialTheme.colorScheme.background) { - SettingsScreenWrapper() - } +@PreviewMobile +@PreviewTablet +@Composable +private fun SettingsScreenWrapperPreview() { + SwissTransferTheme { + Surface(color = MaterialTheme.colorScheme.background) { + SettingsScreenWrapper() } } +} 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 6809979ec..e30770521 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 @@ -49,7 +49,7 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewMobile fun SettingsThemeScreen( theme: Theme, navigateBack: (() -> Unit)?, - onThemeUpdate: (Theme) -> Unit + onThemeUpdate: (Theme) -> Unit, ) { Scaffold(topBar = { val canDisplayBackButton = navigateBack?.let { TopAppBarButton.backButton(navigateBack) } @@ -87,7 +87,7 @@ enum class ThemeOption( private fun SettingsThemeScreenPreview() { SwissTransferTheme { Surface { - SettingsThemeScreen(Theme.SYSTEM, {}, {}) + SettingsThemeScreen(theme = Theme.SYSTEM, navigateBack = {}, onThemeUpdate = {}) } } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsViewModel.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsViewModel.kt index fe2cce813..2f647e85e 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsViewModel.kt @@ -15,7 +15,6 @@ * 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.lifecycle.ViewModel diff --git a/settings.gradle.kts b/settings.gradle.kts index 37a59afac..1a80ad33d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,7 +17,7 @@ dependencyResolutionManagement { @Suppress("UnstableApiUsage") repositories { google() - //mavenLocal() TODO Do not put this in production + // mavenLocal() // TODO Do not put this in production mavenCentral() maven { url = uri("https://jitpack.io") } }