diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportFilesViewModel.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportFilesViewModel.kt index 31dd5f00c..68b60e063 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportFilesViewModel.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportFilesViewModel.kt @@ -139,7 +139,7 @@ class ImportFilesViewModel @Inject constructor( duration = selectedValidityPeriodOption.value.apiValue, authorEmail = "", password = if (selectedPasswordOption.value == PasswordTransferOption.ACTIVATED) transferPassword else NO_PASSWORD, - message = "sisi test", + message = _transferMessage, numberOfDownload = selectedDownloadLimitOption.value.apiValue, language = selectedLanguageOption.value.apiValue, recipientsEmails = emptyList(), @@ -245,6 +245,12 @@ class ImportFilesViewModel @Inject constructor( private val isPasswordValid by derivedStateOf { transferPassword.length in PASSWORD_MIN_LENGTH..PASSWORD_MAX_LENGTH } //endregion + + //region Transfer Message + private var _transferMessage by mutableStateOf("") + val transferMessage = GetSetCallbacks(get = { _transferMessage }, set = { _transferMessage = it }) + //endregion + sealed class SendActionResult { data class Success(val totalSize: Long) : SendActionResult() data object Failure : SendActionResult() 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 ed0b95a5a..c003f8e7e 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 @@ -104,6 +104,7 @@ fun ImportFilesScreen( files = { files }, filesToImportCount = { filesToImportCount }, currentSessionFilesCount = { currentSessionFilesCount }, + transferMessage = importFilesViewModel.transferMessage, selectedTransferType = GetSetCallbacks( get = { selectedTransferType }, set = importFilesViewModel::selectTransferType, @@ -137,6 +138,7 @@ private fun ImportFilesScreen( files: () -> List, filesToImportCount: () -> Int, currentSessionFilesCount: () -> Int, + transferMessage: GetSetCallbacks, selectedTransferType: GetSetCallbacks, transferOptionsCallbacks: TransferOptionsCallbacks, removeFileByUid: (uid: String) -> Unit, @@ -191,7 +193,7 @@ private fun ImportFilesScreen( showUploadSourceChoiceBottomSheet = { showUploadSourceChoiceBottomSheet = true }, removeFileByUid = removeFileByUid, ) - ImportTextFields(selectedTransferType.get) + ImportTextFields(transferMessage, selectedTransferType.get) ImportFilesTitle(Modifier.padding(vertical = Margin.Medium), titleRes = R.string.transferTypeTitle) TransferTypeButtons(selectedTransferType) ImportFilesTitle(Modifier.padding(vertical = Margin.Medium), titleRes = R.string.advancedSettingsTitle) @@ -213,7 +215,7 @@ private fun ImportFilesScreen( } @Composable -private fun ColumnScope.ImportTextFields(selectedTransferType: () -> TransferTypeUi) { +private fun ColumnScope.ImportTextFields(transferMessage: GetSetCallbacks, selectedTransferType: () -> TransferTypeUi) { EmailAddressesTextFields(selectedTransferType) @@ -222,6 +224,7 @@ private fun ColumnScope.ImportTextFields(selectedTransferType: () -> TransferTyp label = stringResource(R.string.transferMessagePlaceholder), isRequired = false, minLineNumber = 3, + onValueChange = transferMessage.set, ) } @@ -375,6 +378,7 @@ private fun Preview(@PreviewParameter(FileUiListPreviewParameter::class) files: files = { files }, filesToImportCount = { 0 }, currentSessionFilesCount = { 0 }, + transferMessage = GetSetCallbacks(get = { "" }, set = {}), selectedTransferType = GetSetCallbacks(get = { TransferTypeUi.QR_CODE }, set = {}), transferOptionsCallbacks = transferOptionsCallbacks, removeFileByUid = {},