From 9c6116ebc3899f724044b7c425ff9dbedf8626c0 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Tue, 17 Sep 2024 10:07:19 +0200 Subject: [PATCH] Close NewTransfer activity when clicking on cross --- .../swisstransfer/ui/NewTransferActivity.kt | 2 +- .../ui/screen/newtransfer/NewTransferNavHost.kt | 13 ++++++++++--- .../ui/screen/newtransfer/NewTransferScreen.kt | 7 +++---- .../newtransfer/importfiles/ImportFilesScreen.kt | 6 +++--- .../newtransfer/importfiles/TransferTypeScreen.kt | 6 +++--- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/NewTransferActivity.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/NewTransferActivity.kt index c46c75322..7621d7333 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/NewTransferActivity.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/NewTransferActivity.kt @@ -33,7 +33,7 @@ class NewTransferActivity : ComponentActivity() { enableEdgeToEdge() setContent { SwissTransferTheme { - NewTransferScreen() + NewTransferScreen(closeActivity = { finish() }) } } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferNavHost.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferNavHost.kt index ef0533c5e..12a3530db 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferNavHost.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferNavHost.kt @@ -31,14 +31,21 @@ import com.infomaniak.swisstransfer.ui.screen.newtransfer.upload.UploadProgressS import com.infomaniak.swisstransfer.ui.screen.newtransfer.upload.UploadSuccessScreen @Composable -fun NewTransferNavHost(navController: NavHostController) { +fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Unit) { NavHost(navController, NewTransferNavigation.startDestination) { composable { - ImportFilesScreen(navigateToTransferTypeScreen = { navController.navigate(TransferTypeDestination) }) + ImportFilesScreen( + navigateToTransferTypeScreen = { navController.navigate(TransferTypeDestination) }, + closeActivity = closeActivity, + ) } composable { - TransferTypeScreen(navigateToTransfer = { /* TODO */ }, popBack = { navController.navigateUp() }) + TransferTypeScreen( + navigateToTransfer = { /* TODO */ }, + popBack = { navController.navigateUp() }, + closeActivity = closeActivity, + ) } composable { TransferOptionsScreen() diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferScreen.kt index e04eebb84..16ce58113 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferScreen.kt @@ -24,10 +24,9 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewMobile import com.infomaniak.swisstransfer.ui.utils.PreviewTablet @Composable -fun NewTransferScreen() { +fun NewTransferScreen(closeActivity: () -> Unit) { val navController = rememberNavController() - - NewTransferNavHost(navController) + NewTransferNavHost(navController, closeActivity) } @PreviewMobile @@ -35,6 +34,6 @@ fun NewTransferScreen() { @Composable private fun NewTransferPreview() { SwissTransferTheme { - NewTransferScreen() + NewTransferScreen {} } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt index a98b662f7..bdd3b5d74 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt @@ -40,7 +40,7 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewMobile import com.infomaniak.swisstransfer.ui.utils.PreviewTablet @Composable -fun ImportFilesScreen(navigateToTransferTypeScreen: () -> Unit) { +fun ImportFilesScreen(navigateToTransferTypeScreen: () -> Unit, closeActivity: () -> Unit) { var showUploadSourceChoiceBottomSheet by rememberSaveable { mutableStateOf(false) } BottomStickyButtonScaffold( @@ -48,7 +48,7 @@ fun ImportFilesScreen(navigateToTransferTypeScreen: () -> Unit) { SwissTransferTobAppBar( titleRes = R.string.importFilesScreenTitle, navigationMenu = null, - TopAppBarButton.closeButton { /* TODO */ }, + TopAppBarButton.closeButton { closeActivity() }, ) }, topButton = { modifier -> @@ -104,7 +104,7 @@ private fun UploadSourceChoiceBottomSheet( @Composable private fun ImportFilesScreenPreview() { SwissTransferTheme { - ImportFilesScreen {} + ImportFilesScreen({}, {}) } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/TransferTypeScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/TransferTypeScreen.kt index 390e2d8bf..4c0314209 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/TransferTypeScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/TransferTypeScreen.kt @@ -44,12 +44,12 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewMobile import com.infomaniak.swisstransfer.ui.utils.PreviewTablet @Composable -fun TransferTypeScreen(navigateToTransfer: (TransferType) -> Unit, popBack: () -> Unit) { +fun TransferTypeScreen(navigateToTransfer: (TransferType) -> Unit, popBack: () -> Unit, closeActivity: () -> Unit) { Scaffold(topBar = { SwissTransferTobAppBar( titleRes = R.string.transferTypeScreenTitle, navigationMenu = TopAppBarButton.backButton(popBack), - TopAppBarButton.closeButton { /* TODO */ }, + TopAppBarButton.closeButton { closeActivity() }, ) }) { contentPaddings -> Column( @@ -108,6 +108,6 @@ enum class TransferType( @Composable private fun TransferTypeScreenPreview() { SwissTransferTheme { - TransferTypeScreen({}) {} + TransferTypeScreen({}, {}, {}) } }