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 43a1a3fe0..a2451dfd2 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 @@ -52,6 +52,7 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un navigateToUploadSuccess = { transferLink -> navController.navigate(UploadSuccessDestination(args.transferType, transferLink)) }, + navigateToUploadError = { navController.navigate(UploadErrorDestination) }, closeActivity = closeActivity ) } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadProgressScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadProgressScreen.kt index 1a620ce1a..81abd69f5 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadProgressScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadProgressScreen.kt @@ -48,6 +48,7 @@ fun UploadProgressScreen( uploadProgressViewModel: UploadProgressViewModel = hiltViewModel(), totalSizeInBytes: Long, navigateToUploadSuccess: (String) -> Unit, + navigateToUploadError: () -> Unit, closeActivity: () -> Unit, ) { val uiState by uploadProgressViewModel.transferProgressUiState.collectAsStateWithLifecycle() @@ -63,7 +64,7 @@ fun UploadProgressScreen( uploadProgressViewModel.trackUploadProgress() } - HandleProgressState({ uiState }, navigateToUploadSuccess) + HandleProgressState({ uiState }, navigateToUploadSuccess, navigateToUploadError) UploadProgressScreen( progressState = { uiState }, @@ -80,17 +81,14 @@ fun UploadProgressScreen( @Composable private fun HandleProgressState( uiState: () -> UploadProgressUiState, - navigateToUploadSuccess: (String) -> Unit + navigateToUploadSuccess: (String) -> Unit, + navigateToUploadError: () -> Unit, ) { val currentUiState = uiState() LaunchedEffect(uiState()) { when (currentUiState) { - is UploadProgressUiState.Success -> { - navigateToUploadSuccess(currentUiState.transferLink) - } - is UploadProgressUiState.Cancelled -> { - // TODO: navigate to failure screen - } + is UploadProgressUiState.Success -> navigateToUploadSuccess(currentUiState.transferLink) + is UploadProgressUiState.Cancelled -> navigateToUploadError() else -> Unit } }