Skip to content

Commit

Permalink
feat(TransferMessage): Add transfer message to the upload
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianDevel committed Nov 13, 2024
1 parent cb2975e commit 0a1f31e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ fun ImportFilesScreen(
files = { files },
filesToImportCount = { filesToImportCount },
currentSessionFilesCount = { currentSessionFilesCount },
transferMessage = importFilesViewModel.transferMessage,
selectedTransferType = GetSetCallbacks(
get = { selectedTransferType },
set = importFilesViewModel::selectTransferType,
Expand Down Expand Up @@ -137,6 +138,7 @@ private fun ImportFilesScreen(
files: () -> List<FileUi>,
filesToImportCount: () -> Int,
currentSessionFilesCount: () -> Int,
transferMessage: GetSetCallbacks<String>,
selectedTransferType: GetSetCallbacks<TransferTypeUi>,
transferOptionsCallbacks: TransferOptionsCallbacks,
removeFileByUid: (uid: String) -> Unit,
Expand Down Expand Up @@ -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)
Expand All @@ -213,7 +215,7 @@ private fun ImportFilesScreen(
}

@Composable
private fun ColumnScope.ImportTextFields(selectedTransferType: () -> TransferTypeUi) {
private fun ColumnScope.ImportTextFields(transferMessage: GetSetCallbacks<String>, selectedTransferType: () -> TransferTypeUi) {

EmailAddressesTextFields(selectedTransferType)

Expand All @@ -222,6 +224,7 @@ private fun ColumnScope.ImportTextFields(selectedTransferType: () -> TransferTyp
label = stringResource(R.string.transferMessagePlaceholder),
isRequired = false,
minLineNumber = 3,
onValueChange = transferMessage.set,
)
}

Expand Down Expand Up @@ -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 = {},
Expand Down

0 comments on commit 0a1f31e

Please sign in to comment.