Skip to content

Commit

Permalink
refactor(TransferSettings): Use multiplatform enum values instead of …
Browse files Browse the repository at this point in the history
…hardcoded ones
  • Loading branch information
FabianDevel committed Oct 23, 2024
1 parent 78884aa commit 44be74d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ enum class DownloadLimitOption(
override val imageVector: ImageVector? = null,
override val imageVectorResId: Int? = null,
) : SettingOption {
TWO_HUNDRED_FIFTY({ "250" }),
ONE_HUNDRED({ "100" }),
TWENTY({ "20" }),
ONE({ "1" }),
TWO_HUNDRED_FIFTY({ DownloadLimit.TWO_HUNDRED_FIFTY.value }),
ONE_HUNDRED({ DownloadLimit.ONE_HUNDRED.value }),
TWENTY({ DownloadLimit.TWENTY.value }),
ONE({ DownloadLimit.ONE.value }),
}

@PreviewAllWindows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,16 @@ enum class ValidityPeriodOption(
override val imageVector: ImageVector? = null,
override val imageVectorResId: Int? = null,
) : SettingOption {
THIRTY({ pluralStringResource(R.plurals.settingsValidityPeriodValue, 30, 30) }),
FIFTEEN({ pluralStringResource(R.plurals.settingsValidityPeriodValue, 15, 15) }),
SEVEN({ pluralStringResource(R.plurals.settingsValidityPeriodValue, 7, 7) }),
ONE({ pluralStringResource(R.plurals.settingsValidityPeriodValue, 1, 1) }),
THIRTY({ getValidityPeriodTitle(ValidityPeriod.THIRTY) }),
FIFTEEN({ getValidityPeriodTitle(ValidityPeriod.FIFTEEN) }),
SEVEN({ getValidityPeriodTitle(ValidityPeriod.SEVEN) }),
ONE({ getValidityPeriodTitle(ValidityPeriod.ONE) });
}

@Composable
private fun getValidityPeriodTitle(validityPeriod: ValidityPeriod): String {
val count = validityPeriod.value.toInt()
return pluralStringResource(R.plurals.settingsValidityPeriodValue, count, count)
}

@PreviewAllWindows
Expand Down

0 comments on commit 44be74d

Please sign in to comment.