Skip to content

Commit

Permalink
Merge pull request #114 from Infomaniak/use-multiplateform-value-in-e…
Browse files Browse the repository at this point in the history
…nums

refactor(TransferSettings): Use multiplatform enum values instead of hardcoded ones
  • Loading branch information
FabianDevel authored Oct 23, 2024
2 parents 78884aa + 44be74d commit 4df093a
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 4df093a

Please sign in to comment.