Skip to content

Commit

Permalink
Close NewTransfer activity when clicking on cross
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Sep 17, 2024
1 parent 55b2025 commit 9c6116e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class NewTransferActivity : ComponentActivity() {
enableEdgeToEdge()
setContent {
SwissTransferTheme {
NewTransferScreen()
NewTransferScreen(closeActivity = { finish() })
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ImportFilesDestination> {
ImportFilesScreen(navigateToTransferTypeScreen = { navController.navigate(TransferTypeDestination) })
ImportFilesScreen(
navigateToTransferTypeScreen = { navController.navigate(TransferTypeDestination) },
closeActivity = closeActivity,
)
}
composable<TransferTypeDestination> {
TransferTypeScreen(navigateToTransfer = { /* TODO */ }, popBack = { navController.navigateUp() })
TransferTypeScreen(
navigateToTransfer = { /* TODO */ },
popBack = { navController.navigateUp() },
closeActivity = closeActivity,
)
}
composable<TransferOptionsDestination> {
TransferOptionsScreen()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ 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
@PreviewTablet
@Composable
private fun NewTransferPreview() {
SwissTransferTheme {
NewTransferScreen()
NewTransferScreen {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ 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(
topBar = {
SwissTransferTobAppBar(
titleRes = R.string.importFilesScreenTitle,
navigationMenu = null,
TopAppBarButton.closeButton { /* TODO */ },
TopAppBarButton.closeButton { closeActivity() },
)
},
topButton = { modifier ->
Expand Down Expand Up @@ -104,7 +104,7 @@ private fun UploadSourceChoiceBottomSheet(
@Composable
private fun ImportFilesScreenPreview() {
SwissTransferTheme {
ImportFilesScreen {}
ImportFilesScreen({}, {})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -108,6 +108,6 @@ enum class TransferType(
@Composable
private fun TransferTypeScreenPreview() {
SwissTransferTheme {
TransferTypeScreen({}) {}
TransferTypeScreen({}, {}, {})
}
}

0 comments on commit 9c6116e

Please sign in to comment.