update installation option getter

This commit is contained in:
X1nto 2021-12-04 18:36:22 +04:00
parent e9e4222014
commit 22ac84e448
1 changed files with 80 additions and 63 deletions

View File

@ -67,15 +67,17 @@ class AppDtoMapper(
appThemes: List<String>?,
appVersions: List<String>?,
appLanguages: List<String>?,
) = when (appName) {
VANCED_NAME -> listOf(
) : List<InstallationOption>? = when (appName) {
VANCED_NAME -> buildList {
if (appThemes != null) {
add(
InstallationOption.SingleSelect(
titleId = R.string.app_installation_options_theme,
getOption = { vancedThemePref },
setOption = {
vancedThemePref = it
},
items = appThemes?.map { theme ->
items = appThemes.map { theme ->
InstallationOptionItem(
displayText = {
theme.replaceFirstChar {
@ -84,21 +86,29 @@ class AppDtoMapper(
},
key = theme
)
} ?: emptyList(),
),
},
)
)
}
if (appVersions != null) {
add(
InstallationOption.SingleSelect(
titleId = R.string.app_installation_options_version,
getOption = { vancedVersionPref },
setOption = {
vancedVersionPref = it
},
items = appVersions?.map { version ->
items = (appVersions.map { version ->
InstallationOptionItem(
displayText = { "v$version" },
key = version
)
}?.plus(latestVersionRadioButton)?.reversed() ?: emptyList(),
),
} + latestVersionRadioButton).reversed(),
)
)
}
if (appLanguages != null) {
add(
InstallationOption.MultiSelect(
titleId = R.string.app_installation_options_language,
getOption = { vancedLanguagesPref },
@ -108,7 +118,7 @@ class AppDtoMapper(
removeOption = {
vancedLanguagesPref = vancedLanguagesPref - it
},
items = appLanguages?.map { language ->
items = appLanguages.map { language ->
InstallationOptionItem(
displayText = {
val locale = Locale(it)
@ -116,24 +126,31 @@ class AppDtoMapper(
},
key = language
)
} ?: emptyList(),
),
},
)
MUSIC_NAME -> listOf(
)
}
}
MUSIC_NAME -> buildList {
if (appVersions != null) {
add(
InstallationOption.SingleSelect(
titleId = R.string.app_installation_options_version,
getOption = { musicVersionPref },
setOption = {
musicVersionPref = it
},
items = appVersions?.map { version ->
items = (appVersions.map { version ->
InstallationOptionItem(
displayText = { version },
displayText = { "v$version" },
key = version
)
} ?: emptyList(),
} + latestVersionRadioButton).reversed(),
)
)
}
}
else -> null
}
}