Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add transfer message #181

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading