From 05d949f0f75874b623c9ff6dfc50bf3b43d81426 Mon Sep 17 00:00:00 2001 From: Fabian Devel Date: Fri, 20 Dec 2024 13:59:27 +0100 Subject: [PATCH] feat(RecipientEmail): Display real recipients of the transfer instead of hardcoded data --- .../ui/navigation/NavigationDestination.kt | 12 +++++++++-- .../screen/newtransfer/NewTransferNavHost.kt | 7 ++++--- .../importfiles/ImportFilesScreen.kt | 20 ++++++++++++------- .../upload/UploadSuccessEmailScreen.kt | 11 +++++----- .../newtransfer/upload/UploadSuccessScreen.kt | 6 ++++-- 5 files changed, 36 insertions(+), 20 deletions(-) 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 d2a9bd678..fd56edace 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 @@ -99,9 +99,17 @@ sealed class NewTransferNavigation : NavigationDestination() { @Serializable data object ValidateUserEmailDestination : NewTransferNavigation() @Serializable - data class UploadProgressDestination(val transferType: TransferTypeUi, val totalSize: Long) : NewTransferNavigation() + data class UploadProgressDestination( + val transferType: TransferTypeUi, + val totalSize: Long, + val recipients: List, + ) : NewTransferNavigation() @Serializable - data class UploadSuccessDestination(val transferType: TransferTypeUi, val transferUrl: String) : NewTransferNavigation() + data class UploadSuccessDestination( + val transferType: TransferTypeUi, + val transferUrl: String, + val recipients: List, + ) : NewTransferNavigation() @Serializable data object UploadErrorDestination : NewTransferNavigation() 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 8a25375cb..764a77020 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 @@ -37,8 +37,8 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un composable { ImportFilesScreen( closeActivity = closeActivity, - navigateToUploadProgress = { transferType, totalSize -> - navController.navigate(UploadProgressDestination(transferType, totalSize)) + navigateToUploadProgress = { transferType, totalSize, recipients -> + navController.navigate(UploadProgressDestination(transferType, totalSize, recipients)) }, ) } @@ -50,7 +50,7 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un UploadProgressScreen( totalSizeInBytes = args.totalSize, navigateToUploadSuccess = { transferUrl -> - navController.navigate(UploadSuccessDestination(args.transferType, transferUrl)) + navController.navigate(UploadSuccessDestination(args.transferType, transferUrl, args.recipients)) }, navigateToUploadError = { navController.navigate(UploadErrorDestination) }, navigateBackToImportFiles = { navController.popBackStack(route = ImportFilesDestination, inclusive = false) }, @@ -61,6 +61,7 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un UploadSuccessScreen( transferType = args.transferType, transferUrl = args.transferUrl, + recipients = args.recipients, closeActivity = closeActivity, ) } 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 78941fe11..2791799e7 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 @@ -60,7 +60,7 @@ private val HORIZONTAL_PADDING = Margin.Medium fun ImportFilesScreen( importFilesViewModel: ImportFilesViewModel = hiltViewModel(), closeActivity: () -> Unit, - navigateToUploadProgress: (transferType: TransferTypeUi, totalSize: Long) -> Unit, + navigateToUploadProgress: (transferType: TransferTypeUi, totalSize: Long, recipients: List) -> Unit, ) { val files by importFilesViewModel.importedFilesDebounced.collectAsStateWithLifecycle() @@ -78,11 +78,18 @@ fun ImportFilesScreen( val snackbarHostState = remember { SnackbarHostState() } + val emailTextFieldCallbacks = importFilesViewModel.getEmailTextFieldCallbacks() + HandleSendActionResult( snackbarHostState = snackbarHostState, sendStatus = { sendStatus }, - transferType = { selectedTransferType }, - navigateToUploadProgress = navigateToUploadProgress, + navigateToUploadProgress = { totalSize -> + navigateToUploadProgress( + selectedTransferType, + totalSize, + emailTextFieldCallbacks.validatedRecipientsEmails.get().toList(), + ) + }, resetSendActionResult = importFilesViewModel::resetSendActionResult, ) @@ -126,7 +133,7 @@ fun ImportFilesScreen( files = { files }, filesToImportCount = { filesToImportCount }, currentSessionFilesCount = { currentSessionFilesCount }, - emailTextFieldCallbacks = importFilesViewModel.getEmailTextFieldCallbacks(), + emailTextFieldCallbacks = emailTextFieldCallbacks, transferMessageCallbacks = importFilesViewModel.transferMessageCallbacks, selectedTransferType = GetSetCallbacks( get = { selectedTransferType }, @@ -146,8 +153,7 @@ fun ImportFilesScreen( private fun HandleSendActionResult( snackbarHostState: SnackbarHostState, sendStatus: () -> SendStatus, - transferType: () -> TransferTypeUi, - navigateToUploadProgress: (transferType: TransferTypeUi, totalSize: Long) -> Unit, + navigateToUploadProgress: (totalSize: Long) -> Unit, resetSendActionResult: () -> Unit, ) { val context = LocalContext.current @@ -159,7 +165,7 @@ private fun HandleSendActionResult( // If we don't reset the ImportFiles state machine, we'll automatically navigate-back to UploadProgress again. // So, before leaving ImportFiles to go to UploadProgress, we need to reset the ImportFiles state machine. resetSendActionResult() - navigateToUploadProgress(transferType(), actionResult.totalSize) + navigateToUploadProgress(actionResult.totalSize) } is SendStatus.Refused -> { snackbarHostState.showSnackbar(context.getString(R.string.errorAppIntegrity)) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessEmailScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessEmailScreen.kt index 44a1ff4d4..e87ffb7a9 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessEmailScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessEmailScreen.kt @@ -26,11 +26,13 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.* import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus import com.infomaniak.swisstransfer.ui.images.illus.beers.Beers +import com.infomaniak.swisstransfer.ui.previewparameter.EmailsPreviewParameter import com.infomaniak.swisstransfer.ui.previewparameter.emailsPreviewData import com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.components.TransferTypeUi import com.infomaniak.swisstransfer.ui.theme.Margin @@ -38,10 +40,7 @@ import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable -fun UploadSuccessEmailScreen( - emails: List = emailsPreviewData, // TODO: Use real data - closeActivity: () -> Unit, -) { +fun UploadSuccessEmailScreen(emails: List, closeActivity: () -> Unit) { BottomStickyButtonScaffold( topBar = { BrandTopAppBar() }, bottomButton = { @@ -80,10 +79,10 @@ fun UploadSuccessEmailScreen( @PreviewAllWindows @Composable -private fun UploadSuccessEmailScreenPreview() { +private fun UploadSuccessEmailScreenPreview(@PreviewParameter(EmailsPreviewParameter::class) emails: List) { SwissTransferTheme { Surface { - UploadSuccessEmailScreen(closeActivity = {}) + UploadSuccessEmailScreen(closeActivity = {}, emails = emails) } } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessScreen.kt index e13f36aca..8c872c524 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessScreen.kt @@ -29,11 +29,12 @@ fun UploadSuccessScreen( transferType: TransferTypeUi, transferUrl: String, closeActivity: () -> Unit, + recipients: List, ) { BackHandler(onBack = closeActivity) if (transferType == TransferTypeUi.MAIL) { - UploadSuccessEmailScreen(closeActivity = closeActivity) + UploadSuccessEmailScreen(closeActivity = closeActivity, emails = recipients) } else { UploadSuccessQrScreen(transferType, transferUrl, closeActivity) } @@ -47,7 +48,8 @@ private fun UploadSuccessScreenPreview() { UploadSuccessScreen( transferType = TransferTypeUi.QR_CODE, transferUrl = "https://chk.me/83azQOl", - closeActivity = {} + closeActivity = {}, + recipients = emptyList(), ) } }