Skip to content

Commit

Permalink
refactor: Code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Dec 23, 2024
1 parent 05d949f commit 0c95325
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class ImportFilesViewModel @Inject constructor(
isRecipientEmailInvalid = { isRecipientEmailInvalid },
validatedRecipientsEmails = GetSetCallbacks(
get = { validatedRecipientsEmails },
set = { validatedRecipientsEmails = it }
set = { validatedRecipientsEmails = it },
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ private fun ImportFilesScreen(
) {

val shouldShowEmailAddressesFields by remember { derivedStateOf { selectedTransferType.get() == TransferTypeUi.MAIL } }
val areEmailsCorrect by remember {
val areEmailsCorrects by remember {
derivedStateOf {
with(emailTextFieldCallbacks) {
val areAuthorAndRecipientCorrect = transferAuthorEmail.get().isNotEmpty() && !isAuthorEmailInvalid()
val areAuthorAndRecipientsCorrects = transferAuthorEmail.get().isNotEmpty() && !isAuthorEmailInvalid()
&& validatedRecipientsEmails.get().isNotEmpty()
!shouldShowEmailAddressesFields || areAuthorAndRecipientCorrect
!shouldShowEmailAddressesFields || areAuthorAndRecipientsCorrects
}
}
}
Expand All @@ -222,7 +222,7 @@ private fun ImportFilesScreen(
filesToImportCount = filesToImportCount,
currentSessionFilesCount = currentSessionFilesCount,
importedFiles = files,
areEmailsCorrect = { areEmailsCorrect },
areEmailsCorrects = { areEmailsCorrects },
sendStatus = sendStatus,
sendTransfer = sendTransfer,
)
Expand Down Expand Up @@ -412,7 +412,7 @@ private fun SendButton(
filesToImportCount: () -> Int,
currentSessionFilesCount: () -> Int,
importedFiles: () -> List<FileUi>,
areEmailsCorrect: () -> Boolean,
areEmailsCorrects: () -> Boolean,
sendStatus: () -> SendStatus,
sendTransfer: () -> Unit,
) {
Expand All @@ -432,7 +432,7 @@ private fun SendButton(
title = stringResource(R.string.transferSendButton),
style = ButtonType.PRIMARY,
showIndeterminateProgress = { sendStatus() == SendStatus.Pending },
enabled = { importedFiles().isNotEmpty() && !isImporting && areEmailsCorrect() && sendStatus().canEnableButton() },
enabled = { importedFiles().isNotEmpty() && !isImporting && areEmailsCorrects() && sendStatus().canEnableButton() },
progress = progress,
onClick = { sendTransfer() },
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ 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
Expand Down Expand Up @@ -82,7 +81,7 @@ fun UploadSuccessEmailScreen(emails: List<String>, closeActivity: () -> Unit) {
private fun UploadSuccessEmailScreenPreview(@PreviewParameter(EmailsPreviewParameter::class) emails: List<String>) {
SwissTransferTheme {
Surface {
UploadSuccessEmailScreen(closeActivity = {}, emails = emails)
UploadSuccessEmailScreen(emails) {}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows
fun UploadSuccessScreen(
transferType: TransferTypeUi,
transferUrl: String,
closeActivity: () -> Unit,
recipients: List<String>,
closeActivity: () -> Unit,
) {
BackHandler(onBack = closeActivity)

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

0 comments on commit 0c95325

Please sign in to comment.