From e8647a9a27214c46536144f249d8b85012a783ec Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Tue, 15 Oct 2024 07:26:54 +0200 Subject: [PATCH] feat: Add navigation to Matomo & Sentry screens --- .../SettingsDataManagementMatomoScreen.kt | 85 +++++++++++++++++++ .../settings/SettingsDataManagementScreen.kt | 9 +- .../SettingsDataManagementSentryScreen.kt | 85 +++++++++++++++++++ .../ui/screen/main/settings/SettingsScreen.kt | 2 +- .../main/settings/SettingsScreenWrapper.kt | 14 ++- 5 files changed, 188 insertions(+), 7 deletions(-) create mode 100644 app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt create mode 100644 app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt new file mode 100644 index 000000000..f6092d78d --- /dev/null +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementMatomoScreen.kt @@ -0,0 +1,85 @@ +/* + * 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.SettingsOptionScreens.* +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 SettingsDataManagementMatomoScreen( + navigateBack: (() -> Unit)?, + // onItemClick: (SettingsOptionScreens) -> Unit, +) { + SmallWindowTopAppBarScaffold( + smallWindowTopAppBar = { + SwissTransferTopAppBar( + titleRes = R.string.settingsOptionDataManagement, + navigationMenu = TopAppBarButton.backButton(navigateBack ?: {}), + ) + }, + ) { + Column( + modifier = Modifier.verticalScroll(rememberScrollState()), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Text( + text = stringResource(R.string.matomo), + style = SwissTransferTheme.typography.bodyRegular, + color = SwissTransferTheme.colors.primaryTextColor, + modifier = Modifier.padding(Margin.Medium), + ) + } + } +} + +@PreviewSmallWindow +@Composable +private fun SettingsDataManagementScreenPreview() { + SwissTransferTheme { + Surface { + SettingsDataManagementScreen({}, {}) + } + } +} 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 index 4376612bb..8f9b03c5a 100644 --- 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 @@ -39,6 +39,7 @@ 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.SettingsOptionScreens.* 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 @@ -49,7 +50,7 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow @Composable fun SettingsDataManagementScreen( navigateBack: (() -> Unit)?, - onViewSourceCodeClicked: () -> Unit, + onItemClick: (SettingsOptionScreens) -> Unit, ) { SmallWindowTopAppBarScaffold( smallWindowTopAppBar = { @@ -76,7 +77,7 @@ fun SettingsDataManagementScreen( ) SharpRippleButton( modifier = Modifier.fillMaxWidth(), - onClick = { onViewSourceCodeClicked() }, + onClick = { onItemClick(DATA_MANAGEMENT_SOURCE_CODE) }, ) { Text( text = stringResource(R.string.settingsDataManagementSourceCode), @@ -93,7 +94,7 @@ fun SettingsDataManagementScreen( icon = AppIcons.Matomo.image(), endIcon = CHEVRON, shouldTintIcon = false, - onClick = { /* TODO */ }, + onClick = { onItemClick(DATA_MANAGEMENT_MATOMO) }, ) SettingItem( titleRes = R.string.sentry, @@ -101,7 +102,7 @@ fun SettingsDataManagementScreen( icon = AppIcons.Sentry.image(), endIcon = CHEVRON, shouldTintIcon = false, - onClick = { /* TODO */ }, + onClick = { onItemClick(DATA_MANAGEMENT_SENTRY) }, ) } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt new file mode 100644 index 000000000..39d42cfdd --- /dev/null +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDataManagementSentryScreen.kt @@ -0,0 +1,85 @@ +/* + * 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.SettingsOptionScreens.* +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 SettingsDataManagementSentryScreen( + navigateBack: (() -> Unit)?, + // onItemClick: (SettingsOptionScreens) -> Unit, +) { + SmallWindowTopAppBarScaffold( + smallWindowTopAppBar = { + SwissTransferTopAppBar( + titleRes = R.string.settingsOptionDataManagement, + navigationMenu = TopAppBarButton.backButton(navigateBack ?: {}), + ) + }, + ) { + Column( + modifier = Modifier.verticalScroll(rememberScrollState()), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Text( + text = stringResource(R.string.sentry), + style = SwissTransferTheme.typography.bodyRegular, + color = SwissTransferTheme.colors.primaryTextColor, + modifier = Modifier.padding(Margin.Medium), + ) + } + } +} + +@PreviewSmallWindow +@Composable +private fun SettingsDataManagementScreenPreview() { + SwissTransferTheme { + Surface { + SettingsDataManagementScreen({}, {}) + } + } +} 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 5b7f81db6..338d94fa1 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 @@ -191,7 +191,7 @@ enum class SettingsOptionScreens { THEME, NOTIFICATIONS, VALIDITY_PERIOD, DOWNLOAD_LIMIT, EMAIL_LANGUAGE, DISCOVER_INFOMANIAK, SHARE_IDEAS, GIVE_FEEDBACK, - DATA_MANAGEMENT, + DATA_MANAGEMENT, DATA_MANAGEMENT_SOURCE_CODE, DATA_MANAGEMENT_MATOMO, DATA_MANAGEMENT_SENTRY, } @PreviewAllWindows 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 1080d5bfd..69d117fd6 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 @@ -157,12 +157,22 @@ private fun DetailPane( ) DATA_MANAGEMENT -> SettingsDataManagementScreen( navigateBack = navigateBack, - onViewSourceCodeClicked = { context.openUrl(sourceCodeURL) }, + onItemClick = { item -> + if (item == DATA_MANAGEMENT_SOURCE_CODE) { + context.openUrl(sourceCodeURL) + } else { + // Navigate to the detail pane with the passed item + navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, item) + } + }, ) + DATA_MANAGEMENT_MATOMO -> SettingsDataManagementMatomoScreen(navigateBack) + DATA_MANAGEMENT_SENTRY -> SettingsDataManagementSentryScreen(navigateBack) NOTIFICATIONS, DISCOVER_INFOMANIAK, SHARE_IDEAS, - GIVE_FEEDBACK -> Unit + GIVE_FEEDBACK, + DATA_MANAGEMENT_SOURCE_CODE -> Unit null -> NoSelectionEmptyState() } }