From 760f070e2d15b0c2e9c791b2ef49530ae52c41e3 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Mon, 14 Oct 2024 17:49:13 +0200 Subject: [PATCH] feat: Add SettingsDataManagementScreen --- .../settings/SettingsDataManagementScreen.kt | 118 ++++++++++++++++++ .../main/settings/SettingsScreenWrapper.kt | 8 ++ 2 files changed, 126 insertions(+) create mode 100644 app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt new file mode 100644 index 000000000..4376612bb --- /dev/null +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementScreen.kt @@ -0,0 +1,118 @@ +/* + * 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.Image +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +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.res.stringResource +import com.infomaniak.swisstransfer.R +import com.infomaniak.swisstransfer.ui.components.SharpRippleButton +import com.infomaniak.swisstransfer.ui.components.SwissTransferTopAppBar +import com.infomaniak.swisstransfer.ui.components.TopAppBarButton +import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons +import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus +import com.infomaniak.swisstransfer.ui.images.icons.Matomo +import com.infomaniak.swisstransfer.ui.images.icons.Sentry +import com.infomaniak.swisstransfer.ui.images.illus.DataProtection +import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold +import com.infomaniak.swisstransfer.ui.screen.main.settings.components.EndIconType.CHEVRON +import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingItem +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.PreviewSmallWindow + +@Composable +fun SettingsDataManagementScreen( + navigateBack: (() -> Unit)?, + onViewSourceCodeClicked: () -> Unit, +) { + SmallWindowTopAppBarScaffold( + smallWindowTopAppBar = { + SwissTransferTopAppBar( + titleRes = R.string.settingsOptionDataManagement, + navigationMenu = TopAppBarButton.backButton(navigateBack ?: {}), + ) + }, + ) { + Column( + modifier = Modifier.verticalScroll(rememberScrollState()), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Image( + imageVector = AppIllus.DataProtection, // TODO: Handle dark theme + contentDescription = null, + modifier = Modifier.padding(Margin.Medium), + ) + Text( + text = stringResource(R.string.settingsDataManagementDescription), + style = SwissTransferTheme.typography.bodyRegular, + color = SwissTransferTheme.colors.primaryTextColor, + modifier = Modifier.padding(Margin.Medium), + ) + SharpRippleButton( + modifier = Modifier.fillMaxWidth(), + onClick = { onViewSourceCodeClicked() }, + ) { + Text( + text = stringResource(R.string.settingsDataManagementSourceCode), + style = SwissTransferTheme.typography.bodyMedium, + color = SwissTransferTheme.materialColors.primary, + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = Dimens.SettingHorizontalMargin, vertical = Dimens.SettingVerticalMargin), + ) + } + SettingItem( + titleRes = R.string.matomo, + isSelected = { false }, + icon = AppIcons.Matomo.image(), + endIcon = CHEVRON, + shouldTintIcon = false, + onClick = { /* TODO */ }, + ) + SettingItem( + titleRes = R.string.sentry, + isSelected = { false }, + icon = AppIcons.Sentry.image(), + endIcon = CHEVRON, + shouldTintIcon = false, + onClick = { /* TODO */ }, + ) + } + } +} + +@PreviewSmallWindow +@Composable +private fun SettingsDataManagementScreenPreview() { + SwissTransferTheme { + Surface { + SettingsDataManagementScreen({}, {}) + } + } +} 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 56bf8b4ef..aa2e24b02 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 @@ -123,6 +123,7 @@ private fun DetailPane( emailLanguage: GetSetCallbacks, ) { var lastSelectedScreen by rememberSaveable { mutableStateOf(null) } + val context = LocalContext.current val destination = navigator.currentDestination?.content ?: lastSelectedScreen navigator.currentDestination?.content?.let { lastSelectedScreen = it } @@ -130,6 +131,9 @@ private fun DetailPane( val navigateBackCallback: () -> Unit = { navigator.navigateBack() } val navigateBack: (() -> Unit)? = if (navigator.canNavigateBack()) navigateBackCallback else null + // TODO: Update this URL when we know what we want. + val sourceCodeURL = stringResource(R.string.urlSourceCode) + when (destination) { THEME -> SettingsThemeScreen( theme = theme.get(), @@ -151,6 +155,10 @@ private fun DetailPane( navigateBack = navigateBack, onEmailLanguageChange = { emailLanguage.set(it) }, ) + DATA_MANAGEMENT -> SettingsDataManagementScreen( + navigateBack = navigateBack, + onViewSourceCodeClicked = { context.openUrl(sourceCodeURL) }, + ) NOTIFICATIONS, DISCOVER_INFOMANIAK, SHARE_IDEAS,