diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationDestination.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationDestination.kt index da8df5fac..e84bda19f 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationDestination.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationDestination.kt @@ -70,7 +70,7 @@ sealed class NewTransferNavigation : NavigationDestination() { data object UploadErrorDestination : NewTransferNavigation() @Serializable - data class FilesDetailsDestination(val transferUuid: String? = null, val fileUuid: String? = null) : MainNavigation() + data object FilesDetailsDestination : MainNavigation() companion object { val startDestination = ImportFilesDestination diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainNavHost.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainNavHost.kt index 80d78ab49..d087d7ffe 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainNavHost.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainNavHost.kt @@ -70,6 +70,7 @@ fun MainNavHost( transferUuid = filesDetailsDestination.transferUuid, fileUuid = filesDetailsDestination.fileUuid, navigateBack = { navController.popBackStack() }, + withFileSize = false, withSpaceLeft = false, withFileDelete = false, onCloseClicked = {}, 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 ed4a300a6..eeb8b65cb 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 @@ -26,6 +26,7 @@ import androidx.navigation.compose.composable import androidx.navigation.toRoute import com.infomaniak.swisstransfer.ui.navigation.NewTransferNavigation import com.infomaniak.swisstransfer.ui.navigation.NewTransferNavigation.* +import com.infomaniak.swisstransfer.ui.navigation.NewTransferNavigation.FilesDetailsDestination import com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.FilesDetailsScreen import com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.ImportFilesScreen import com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.ValidateUserEmailScreen @@ -44,8 +45,8 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un navigateToUploadProgress = { transferType, totalSize -> navController.navigate(UploadProgressDestination(transferType, totalSize)) }, - navigateToFilesDetails = { fileUuid -> - navController.navigate(FilesDetailsDestination(fileUuid)) + navigateToFilesDetails = { + navController.navigate(FilesDetailsDestination) } ) } @@ -75,14 +76,11 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un UploadErrorScreen(navigateToImportFiles = { navController.navigate(ImportFilesDestination) }) } composable { - val filesDetailsDestination: FilesDetailsDestination = it.toRoute() val backStackEntry = remember(it) { navController.getBackStackEntry(ImportFilesDestination) } FilesDetailsScreen( importFilesViewModel = hiltViewModel(backStackEntry), - navigateToDetails = { transferUuid, fileId -> - navController.navigate(FilesDetailsDestination(transferUuid, fileId)) - }, - fileUuid = filesDetailsDestination.fileUuid, + navigateToDetails = { _, _ -> navController.navigate(FilesDetailsDestination) }, + withFileSize = true, withSpaceLeft = true, withFileDelete = true, onCloseClicked = {}, diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/FilesDetailsScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/FilesDetailsScreen.kt index ad59d51da..545bf7707 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/FilesDetailsScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/FilesDetailsScreen.kt @@ -43,6 +43,7 @@ fun FilesDetailsScreen( transferUuid: String? = null, fileUuid: String? = null, navigateToDetails: (String?, String) -> Unit, + withFileSize: Boolean, withSpaceLeft: Boolean, withFileDelete: Boolean, onCloseClicked: (() -> Unit), @@ -58,6 +59,7 @@ fun FilesDetailsScreen( transferUuid = transferUuid, files = files ?: emptyList(), navigateToDetails = navigateToDetails, + withFileSize = withFileSize, withSpaceLeft = withSpaceLeft, onFileRemoved = if (withFileDelete) { { importFilesViewModel.removeFileByUid(it) } @@ -73,6 +75,7 @@ private fun FilesDetailsScreen( transferUuid: String?, files: List, navigateToDetails: (String?, String) -> Unit, + withFileSize: Boolean, withSpaceLeft: Boolean, onFileRemoved: ((uuid: String) -> Unit)? = null, onCloseClicked: (() -> Unit), @@ -85,7 +88,7 @@ private fun FilesDetailsScreen( TopAppBarButton.closeButton { onCloseClicked() }, ) - FilesSize(files, withFileSize = false, withSpaceLeft) + FilesSize(files, withFileSize = withFileSize, withSpaceLeft) FileItemList( modifier = Modifier.padding(horizontal = Margin.Medium), files = files, @@ -112,6 +115,7 @@ private fun FilesDetailsScreenPreview(@PreviewParameter(FileUiListPreviewParamet transferUuid = "", files = files, navigateToDetails = { _, _ -> }, + withFileSize = true, withSpaceLeft = true, onCloseClicked = {}, onFileRemoved = {}, 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 5cdc80da3..f313befd0 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 @@ -56,7 +56,7 @@ fun ImportFilesScreen( importFilesViewModel: ImportFilesViewModel, closeActivity: () -> Unit, navigateToUploadProgress: (transferType: TransferTypeUi, totalSize: Long) -> Unit, - navigateToFilesDetails: (fileUuid: String?) -> Unit, + navigateToFilesDetails: () -> Unit, ) { val files by importFilesViewModel.importedFilesDebounced.collectAsStateWithLifecycle() val filesToImportCount by importFilesViewModel.filesToImportCount.collectAsStateWithLifecycle() @@ -145,7 +145,7 @@ private fun ImportFilesScreen( closeActivity: () -> Unit, shouldStartByPromptingUserForFiles: Boolean, sendTransfer: () -> Unit, - navigateToFilesDetails: (fileUuid: String?) -> Unit, + navigateToFilesDetails: () -> Unit, ) { val context = LocalContext.current var shouldShowInitialFilePick by rememberSaveable { mutableStateOf(shouldStartByPromptingUserForFiles) } @@ -195,7 +195,7 @@ private fun ImportFilesScreen( humanReadableSize = { humanReadableSize }, pickFiles = ::pickFiles, removeFileByUid = removeFileByUid, - navigateToFilesDetails = { navigateToFilesDetails(null) } + navigateToFilesDetails = { navigateToFilesDetails() } ) ImportTextFields(transferMessage, selectedTransferType.get) ImportFilesTitle(Modifier.padding(vertical = Margin.Medium), titleRes = R.string.transferTypeTitle) @@ -384,7 +384,7 @@ private fun Preview(@PreviewParameter(FileUiListPreviewParameter::class) files: closeActivity = {}, shouldStartByPromptingUserForFiles = false, sendTransfer = {}, - navigateToFilesDetails = { _ -> }, + navigateToFilesDetails = {}, ) } }