Skip to content

Commit

Permalink
chore: Remove variable from FilesDetailsDestination for NewTransfer
Browse files Browse the repository at this point in the history
  • Loading branch information
tevincent committed Nov 27, 2024
1 parent 0f4fb38 commit 4b1f969
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ fun MainNavHost(
transferUuid = filesDetailsDestination.transferUuid,
fileUuid = filesDetailsDestination.fileUuid,
navigateBack = { navController.popBackStack() },
withFileSize = false,
withSpaceLeft = false,
withFileDelete = false,
onCloseClicked = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
)
}
Expand Down Expand Up @@ -75,14 +76,11 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un
UploadErrorScreen(navigateToImportFiles = { navController.navigate(ImportFilesDestination) })
}
composable<FilesDetailsDestination> {
val filesDetailsDestination: FilesDetailsDestination = it.toRoute()
val backStackEntry = remember(it) { navController.getBackStackEntry(ImportFilesDestination) }
FilesDetailsScreen(
importFilesViewModel = hiltViewModel<ImportFilesViewModel>(backStackEntry),
navigateToDetails = { transferUuid, fileId ->
navController.navigate(FilesDetailsDestination(transferUuid, fileId))
},
fileUuid = filesDetailsDestination.fileUuid,
navigateToDetails = { _, _ -> navController.navigate(FilesDetailsDestination) },
withFileSize = true,
withSpaceLeft = true,
withFileDelete = true,
onCloseClicked = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ fun FilesDetailsScreen(
transferUuid: String? = null,
fileUuid: String? = null,
navigateToDetails: (String?, String) -> Unit,
withFileSize: Boolean,
withSpaceLeft: Boolean,
withFileDelete: Boolean,
onCloseClicked: (() -> Unit),
Expand All @@ -58,6 +59,7 @@ fun FilesDetailsScreen(
transferUuid = transferUuid,
files = files ?: emptyList(),
navigateToDetails = navigateToDetails,
withFileSize = withFileSize,
withSpaceLeft = withSpaceLeft,
onFileRemoved = if (withFileDelete) {
{ importFilesViewModel.removeFileByUid(it) }
Expand All @@ -73,6 +75,7 @@ private fun FilesDetailsScreen(
transferUuid: String?,
files: List<FileUi>,
navigateToDetails: (String?, String) -> Unit,
withFileSize: Boolean,
withSpaceLeft: Boolean,
onFileRemoved: ((uuid: String) -> Unit)? = null,
onCloseClicked: (() -> Unit),
Expand All @@ -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,
Expand All @@ -112,6 +115,7 @@ private fun FilesDetailsScreenPreview(@PreviewParameter(FileUiListPreviewParamet
transferUuid = "",
files = files,
navigateToDetails = { _, _ -> },
withFileSize = true,
withSpaceLeft = true,
onCloseClicked = {},
onFileRemoved = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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) }
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -384,7 +384,7 @@ private fun Preview(@PreviewParameter(FileUiListPreviewParameter::class) files:
closeActivity = {},
shouldStartByPromptingUserForFiles = false,
sendTransfer = {},
navigateToFilesDetails = { _ -> },
navigateToFilesDetails = {},
)
}
}

0 comments on commit 4b1f969

Please sign in to comment.