Skip to content

Commit

Permalink
feat(RecipientEmail): Display real recipients of the transfer instead…
Browse files Browse the repository at this point in the history
… of hardcoded data
  • Loading branch information
FabianDevel committed Dec 20, 2024
1 parent cf3dae5 commit 29a0cc5
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
) : NewTransferNavigation()
@Serializable
data class UploadSuccessDestination(val transferType: TransferTypeUi, val transferUrl: String) : NewTransferNavigation()
data class UploadSuccessDestination(
val transferType: TransferTypeUi,
val transferUrl: String,
val recipients: List<String>,
) : NewTransferNavigation()
@Serializable
data object UploadErrorDestination : NewTransferNavigation()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un
composable<ImportFilesDestination> {
ImportFilesScreen(
closeActivity = closeActivity,
navigateToUploadProgress = { transferType, totalSize ->
navController.navigate(UploadProgressDestination(transferType, totalSize))
navigateToUploadProgress = { transferType, totalSize, recipients ->
navController.navigate(UploadProgressDestination(transferType, totalSize, recipients))
},
)
}
Expand All @@ -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) },
closeActivity = closeActivity,
Expand All @@ -61,6 +61,7 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un
UploadSuccessScreen(
transferType = args.transferType,
transferUrl = args.transferUrl,
recipients = args.recipients,
closeActivity = closeActivity,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private val HORIZONTAL_PADDING = Margin.Medium
fun ImportFilesScreen(
importFilesViewModel: ImportFilesViewModel = hiltViewModel<ImportFilesViewModel>(),
closeActivity: () -> Unit,
navigateToUploadProgress: (transferType: TransferTypeUi, totalSize: Long) -> Unit,
navigateToUploadProgress: (transferType: TransferTypeUi, totalSize: Long, recipients: List<String>) -> Unit,
) {

val files by importFilesViewModel.importedFilesDebounced.collectAsStateWithLifecycle()
Expand All @@ -79,6 +79,8 @@ fun ImportFilesScreen(

val snackbarHostState = remember { SnackbarHostState() }

val emailTextFieldCallbacks = importFilesViewModel.getEmailTextFieldCallbacks()

HandleIntegrityCheckResult(
snackbarHostState = snackbarHostState,
integrityCheckResult = { integrityCheckResult },
Expand All @@ -88,8 +90,13 @@ fun ImportFilesScreen(
HandleSendActionResult(
snackbarHostState = snackbarHostState,
getSendActionResult = { sendActionResult },
transferType = { selectedTransferType },
navigateToUploadProgress = navigateToUploadProgress,
navigateToUploadProgress = { totalSize ->
navigateToUploadProgress(
selectedTransferType,
totalSize,
emailTextFieldCallbacks.validatedRecipientsEmails.get().toList(),
)
},
resetSendActionResult = importFilesViewModel::resetSendActionResult,
)

Expand Down Expand Up @@ -133,7 +140,7 @@ fun ImportFilesScreen(
files = { files },
filesToImportCount = { filesToImportCount },
currentSessionFilesCount = { currentSessionFilesCount },
emailTextFieldCallbacks = importFilesViewModel.getEmailTextFieldCallbacks(),
emailTextFieldCallbacks = emailTextFieldCallbacks,
transferMessageCallbacks = importFilesViewModel.transferMessageCallbacks,
selectedTransferType = GetSetCallbacks(
get = { selectedTransferType },
Expand All @@ -154,14 +161,13 @@ fun ImportFilesScreen(
private fun HandleSendActionResult(
snackbarHostState: SnackbarHostState,
getSendActionResult: () -> SendActionResult?,
transferType: () -> TransferTypeUi,
navigateToUploadProgress: (transferType: TransferTypeUi, totalSize: Long) -> Unit,
navigateToUploadProgress: (totalSize: Long) -> Unit,
resetSendActionResult: () -> Unit,
) {
val errorMessage = stringResource(R.string.errorUnknown)
LaunchedEffect(getSendActionResult()) {
when (val actionResult = getSendActionResult()) {
is SendActionResult.Success -> navigateToUploadProgress(transferType(), actionResult.totalSize)
is SendActionResult.Success -> navigateToUploadProgress(actionResult.totalSize)
is SendActionResult.Failure -> {
snackbarHostState.showSnackbar(errorMessage)
resetSendActionResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,21 @@ 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
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows

@Composable
fun UploadSuccessEmailScreen(
emails: List<String> = emailsPreviewData, // TODO: Use real data
closeActivity: () -> Unit,
) {
fun UploadSuccessEmailScreen(emails: List<String>, closeActivity: () -> Unit) {
BottomStickyButtonScaffold(
topBar = { BrandTopAppBar() },
bottomButton = {
Expand Down Expand Up @@ -80,10 +79,10 @@ fun UploadSuccessEmailScreen(

@PreviewAllWindows
@Composable
private fun UploadSuccessEmailScreenPreview() {
private fun UploadSuccessEmailScreenPreview(@PreviewParameter(EmailsPreviewParameter::class) emails: List<String>) {
SwissTransferTheme {
Surface {
UploadSuccessEmailScreen(closeActivity = {})
UploadSuccessEmailScreen(closeActivity = {}, emails = emails)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ fun UploadSuccessScreen(
transferType: TransferTypeUi,
transferUrl: String,
closeActivity: () -> Unit,
recipients: List<String>,
) {
BackHandler(onBack = closeActivity)

if (transferType == TransferTypeUi.MAIL) {
UploadSuccessEmailScreen(closeActivity = closeActivity)
UploadSuccessEmailScreen(closeActivity = closeActivity, emails = recipients)
} else {
UploadSuccessQrScreen(transferType, transferUrl, closeActivity)
}
Expand All @@ -47,7 +48,8 @@ private fun UploadSuccessScreenPreview() {
UploadSuccessScreen(
transferType = TransferTypeUi.QR_CODE,
transferUrl = "https://chk.me/83azQOl",
closeActivity = {}
closeActivity = {},
recipients = emptyList(),
)
}
}
Expand Down

0 comments on commit 29a0cc5

Please sign in to comment.