From 52212bfde3c4900e6b00952f8c56a37d470732ba Mon Sep 17 00:00:00 2001 From: Kimberly Crevecoeur Date: Wed, 2 Aug 2023 14:20:55 -0700 Subject: [PATCH] fix settings to preview navigation bug --- app/src/main/java/com/google/jetpackcamera/ui/JcaApp.kt | 5 ++++- .../com/google/jetpackcamera/settings/SettingsScreen.kt | 7 ++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/google/jetpackcamera/ui/JcaApp.kt b/app/src/main/java/com/google/jetpackcamera/ui/JcaApp.kt index 24c3d3fd..77ded6c4 100644 --- a/app/src/main/java/com/google/jetpackcamera/ui/JcaApp.kt +++ b/app/src/main/java/com/google/jetpackcamera/ui/JcaApp.kt @@ -56,6 +56,9 @@ private fun JetpackCameraNavHost( onNavigateToSettings = { navController.navigate(SettingsRoute) } ) } - composable(SettingsRoute) { SettingsScreen(navController = navController) } + composable(SettingsRoute) { + SettingsScreen(onNavigateToPreview = { navController.navigate(PreviewRoute) } + ) + } } } diff --git a/feature/settings/src/main/java/com/google/jetpackcamera/settings/SettingsScreen.kt b/feature/settings/src/main/java/com/google/jetpackcamera/settings/SettingsScreen.kt index c53fb271..7783e556 100644 --- a/feature/settings/src/main/java/com/google/jetpackcamera/settings/SettingsScreen.kt +++ b/feature/settings/src/main/java/com/google/jetpackcamera/settings/SettingsScreen.kt @@ -25,7 +25,6 @@ import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.hilt.navigation.compose.hiltViewModel -import androidx.navigation.NavController import com.google.jetpackcamera.settings.ui.DarkModeSetting import com.google.jetpackcamera.settings.ui.DefaultCameraFacing import com.google.jetpackcamera.settings.ui.FlashModeSetting @@ -41,7 +40,7 @@ private const val TAG = "SettingsScreen" @Composable fun SettingsScreen( viewModel: SettingsViewModel = hiltViewModel(), - navController: NavController) { + onNavigateToPreview: () -> Unit ) { val settingsUiState by viewModel.settingsUiState.collectAsState() Column( @@ -50,9 +49,7 @@ fun SettingsScreen( ) { SettingsPageHeader( title = stringResource(id = R.string.settings_title), - navBack = { - navController.popBackStack() - } + navBack = onNavigateToPreview ) SettingsList(uiState = settingsUiState, viewModel = viewModel) }