Skip to content

Commit

Permalink
chore(TransferPasswordAlertDialog): Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianDevel committed Nov 5, 2024
1 parent c821503 commit 33453b7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,7 @@ fun BasicAlertDialogContent(
shouldEnableConfirmButton: () -> Boolean = { true },
) {
Column(modifier.padding(Margin.Large)) {
Text(
stringResource(titleRes),
style = SwissTransferTheme.typography.bodyMedium,
color = SwissTransferTheme.colors.primaryTextColor,
)
Spacer(Modifier.height(Margin.Large))
Text(
stringResource(descriptionRes),
style = SwissTransferTheme.typography.bodyRegular,
color = SwissTransferTheme.colors.secondaryTextColor,
)
Spacer(Modifier.height(Margin.Large))
TitleAndDescription(titleRes, descriptionRes)
additionalContent?.let {
it()
Spacer(Modifier.height(Margin.Large))
Expand All @@ -92,6 +81,22 @@ fun BasicAlertDialogContent(
}
}

@Composable
private fun TitleAndDescription(titleRes: Int, descriptionRes: Int) {
Text(
text = stringResource(titleRes),
style = SwissTransferTheme.typography.bodyMedium,
color = SwissTransferTheme.colors.primaryTextColor,
)
Spacer(Modifier.height(Margin.Large))
Text(
text = stringResource(descriptionRes),
style = SwissTransferTheme.typography.bodyRegular,
color = SwissTransferTheme.colors.secondaryTextColor,
)
Spacer(Modifier.height(Margin.Large))
}

@Composable
private fun ActionButtons(onDismissRequest: () -> Unit, onConfirmation: () -> Unit, shouldEnable: () -> Boolean) {
Row(
Expand Down Expand Up @@ -127,4 +132,3 @@ private fun PreviewAlertDialog() {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fun ImportFilesScreen(
get = { newTransferViewModel.transferPassword },
set = { newTransferViewModel.transferPassword = it },
),
isPasswordValid = { newTransferViewModel.isPasswordValid }
isPasswordValid = { newTransferViewModel.isPasswordValid },
)

ImportFilesScreen(
Expand Down Expand Up @@ -337,27 +337,27 @@ enum class PasswordTransferOption(
@PreviewAllWindows
@Composable
private fun ImportFilesScreenPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List<FileUi>) {
SwissTransferTheme {
val advancedOptionsCallbacks = AdvancedOptionsCallbacks(
initialValues = SettingsViewModel.AppSettingsData(
validityPeriod = ValidityPeriod.THIRTY,
downloadLimit = DownloadLimit.ONE,
passwordOption = PasswordTransferOption.NONE,
emailLanguage = EmailLanguage.FRENCH,
),
advancedOptionsStates = {
listOf(
ValidityPeriodOption.THIRTY,
DownloadLimitOption.TWO_HUNDRED_FIFTY,
PasswordTransferOption.NONE,
EmailLanguageOption.FRENCH,
)
},
onAdvancedOptionsValueSelected = {},
password = GetSetCallbacks(get = { "password" }, set = {}),
isPasswordValid = { true },
)
val advancedOptionsCallbacks = AdvancedOptionsCallbacks(
initialValues = SettingsViewModel.AppSettingsData(
validityPeriod = ValidityPeriod.THIRTY,
downloadLimit = DownloadLimit.ONE,
passwordOption = PasswordTransferOption.NONE,
emailLanguage = EmailLanguage.FRENCH,
),
advancedOptionsStates = {
listOf(
ValidityPeriodOption.THIRTY,
DownloadLimitOption.TWO_HUNDRED_FIFTY,
PasswordTransferOption.NONE,
EmailLanguageOption.FRENCH,
)
},
onAdvancedOptionsValueSelected = {},
password = GetSetCallbacks(get = { "password" }, set = {}),
isPasswordValid = { true },
)

SwissTransferTheme {
ImportFilesScreen(
files = { files },
filesToImportCount = { 0 },
Expand Down

0 comments on commit 33453b7

Please sign in to comment.