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 b59396bca..204b810fd 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 @@ -28,6 +28,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.SharpRippleButton @@ -39,19 +40,25 @@ import com.infomaniak.swisstransfer.ui.images.icons.matomo.Matomo import com.infomaniak.swisstransfer.ui.images.icons.sentry.Sentry import com.infomaniak.swisstransfer.ui.images.illus.dataProtection.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.SettingsOptionScreens.DATA_MANAGEMENT_MATOMO +import com.infomaniak.swisstransfer.ui.screen.main.settings.SettingsOptionScreens.DATA_MANAGEMENT_SENTRY 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.PreviewAllWindows +import com.infomaniak.swisstransfer.ui.utils.openUrl @Composable fun SettingsDataManagementScreen( navigateBack: (() -> Unit)?, onItemClick: (SettingsOptionScreens) -> Unit, ) { + + val context = LocalContext.current + val sourceCodeURL = stringResource(R.string.urlSourceCode) // TODO: Update this URL when we know what we want + SmallWindowTopAppBarScaffold( smallWindowTopAppBar = { SwissTransferTopAppBar( @@ -77,7 +84,7 @@ fun SettingsDataManagementScreen( ) SharpRippleButton( modifier = Modifier.fillMaxWidth(), - onClick = { onItemClick(DATA_MANAGEMENT_SOURCE_CODE) }, + onClick = { context.openUrl(sourceCodeURL) }, ) { Text( text = stringResource(R.string.settingsDataManagementSourceCode), 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 338d94fa1..0a2a68384 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_SOURCE_CODE, DATA_MANAGEMENT_MATOMO, DATA_MANAGEMENT_SENTRY, + DATA_MANAGEMENT, 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 69d117fd6..838f23ce2 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,7 +123,6 @@ 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 } @@ -131,9 +130,6 @@ 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(), @@ -158,12 +154,8 @@ private fun DetailPane( DATA_MANAGEMENT -> SettingsDataManagementScreen( navigateBack = navigateBack, 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) - } + // Navigate to the detail pane with the passed item + navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, item) }, ) DATA_MANAGEMENT_MATOMO -> SettingsDataManagementMatomoScreen(navigateBack) @@ -172,7 +164,6 @@ private fun DetailPane( DISCOVER_INFOMANIAK, SHARE_IDEAS, GIVE_FEEDBACK, - DATA_MANAGEMENT_SOURCE_CODE -> Unit null -> NoSelectionEmptyState() } }