Skip to content

Commit

Permalink
feat(TransferPasswordAlertDialog): Put advanced transfer option in sa…
Browse files Browse the repository at this point in the history
…vedStateHandle
  • Loading branch information
FabianDevel committed Nov 6, 2024
1 parent 890c5e1 commit 8c8d9e7
Showing 1 changed file with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,41 +144,53 @@ class NewTransferViewModel @Inject constructor(
}

//region Transfer Type
private val _selectedTransferType = MutableStateFlow(TransferType.LINK)
private val _selectedTransferType = MutableStateFlow(savedStateHandle[SELECTED_TRANSFER_TYPE] ?: TransferType.LINK)
val selectedTransferType: StateFlow<TransferType> = _selectedTransferType

fun selectTransferType(type: TransferType) {
_selectedTransferType.value = type
savedStateHandle[SELECTED_TRANSFER_TYPE] = type
}
//endregion

//region Transfer Advanced Options
private val _selectedValidityPeriodOption = MutableStateFlow<ValidityPeriodOption?>(null)

private val _selectedValidityPeriodOption = MutableStateFlow<ValidityPeriodOption?>(
savedStateHandle[SELECTED_VALIDITY_PERIOD_KEY]
)
val selectedValidityPeriodOption: StateFlow<ValidityPeriodOption?> = _selectedValidityPeriodOption.asStateFlow()

private val _selectedDownloadLimitOption = MutableStateFlow<DownloadLimitOption?>(null)
private val _selectedDownloadLimitOption = MutableStateFlow<DownloadLimitOption?>(
savedStateHandle[SELECTED_DOWNLOAD_LIMIT_KEY]
)
val selectedDownloadLimitOption: StateFlow<DownloadLimitOption?> = _selectedDownloadLimitOption.asStateFlow()

private val _selectedPasswordOption = MutableStateFlow(PasswordTransferOption.NONE)
private val _selectedPasswordOption = MutableStateFlow<PasswordTransferOption?>(
savedStateHandle[SELECTED_PASSWORD_OPTION_KEY] ?: PasswordTransferOption.NONE
)
val selectedPasswordOption: StateFlow<PasswordTransferOption?> = _selectedPasswordOption.asStateFlow()

private val _selectedLanguageOption = MutableStateFlow<EmailLanguageOption?>(null)
private val _selectedLanguageOption = MutableStateFlow<EmailLanguageOption?>(savedStateHandle[SELECTED_LANGUAGE_KEY])
val selectedLanguageOption: StateFlow<EmailLanguageOption?> = _selectedLanguageOption.asStateFlow()

fun selectTransferValidityPeriod(validityPeriodOption: ValidityPeriodOption) {
private fun selectTransferValidityPeriod(validityPeriodOption: ValidityPeriodOption) {
_selectedValidityPeriodOption.value = validityPeriodOption
savedStateHandle[SELECTED_VALIDITY_PERIOD_KEY] = validityPeriodOption
}

fun selectTransferDownloadLimit(downloadLimit: DownloadLimitOption) {
private fun selectTransferDownloadLimit(downloadLimit: DownloadLimitOption) {
_selectedDownloadLimitOption.value = downloadLimit
savedStateHandle[SELECTED_DOWNLOAD_LIMIT_KEY] = downloadLimit
}

fun selectTransferPasswordOption(passwordOption: PasswordTransferOption) {
private fun selectTransferPasswordOption(passwordOption: PasswordTransferOption) {
_selectedPasswordOption.value = passwordOption
savedStateHandle[SELECTED_PASSWORD_OPTION_KEY] = passwordOption
}

fun selectTransferLanguage(language: EmailLanguageOption) {
private fun selectTransferLanguage(language: EmailLanguageOption) {
_selectedLanguageOption.value = language
savedStateHandle[SELECTED_LANGUAGE_KEY] = language
}

fun initTransferAdvancedOptionsValues(safeAppSettings: AppSettings) {
Expand Down Expand Up @@ -250,5 +262,10 @@ class NewTransferViewModel @Inject constructor(
companion object {
private val TAG = NewTransferViewModel::class.java.simpleName
private const val IS_VIEW_MODEL_RESTORED_KEY = "IS_VIEW_MODEL_RESTORED_KEY"
private const val SELECTED_TRANSFER_TYPE = "SELECTED_TRANSFER_TYPE"
private const val SELECTED_VALIDITY_PERIOD_KEY = "SELECTED_VALIDITY_PERIOD_KEY"
private const val SELECTED_DOWNLOAD_LIMIT_KEY = "SELECTED_DOWNLOAD_LIMIT_KEY"
private const val SELECTED_PASSWORD_OPTION_KEY = "SELECTED_PASSWORD_OPTION_KEY"
private const val SELECTED_LANGUAGE_KEY = "SELECTED_TRANSFER_LANGUAGE_KEY"
}
}

0 comments on commit 8c8d9e7

Please sign in to comment.