mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-25 20:55:12 +00:00
dialog adjustments
This commit is contained in:
parent
bc69bd4a9d
commit
3a0cbc6174
4 changed files with 18 additions and 30 deletions
|
@ -21,6 +21,7 @@ import com.vanced.manager.ui.preferences.holder.vancedVersionPref
|
|||
import com.vanced.manager.ui.widgets.home.installation.CheckboxInstallationOption
|
||||
import com.vanced.manager.ui.widgets.home.installation.InstallationOption
|
||||
import com.vanced.manager.ui.widgets.home.installation.RadiobuttonInstallationOption
|
||||
import java.util.*
|
||||
|
||||
class AppDtoMapper(
|
||||
private val packageInformationDataSource: PackageInformationDataSource,
|
||||
|
@ -81,10 +82,10 @@ class AppDtoMapper(
|
|||
RadiobuttonInstallationOption(
|
||||
titleId = R.string.app_installation_options_theme,
|
||||
preference = vancedThemePref,
|
||||
buttons = app.versions?.map {
|
||||
buttons = app.versions?.map { version ->
|
||||
RadioButtonPreference(
|
||||
title = it,
|
||||
key = it
|
||||
title = version.replaceFirstChar { it.titlecase(Locale.getDefault()) },
|
||||
key = version
|
||||
)
|
||||
} ?: emptyList()
|
||||
),
|
||||
|
@ -103,7 +104,7 @@ class AppDtoMapper(
|
|||
preference = vancedLanguagesPref,
|
||||
buttons = app.versions?.map {
|
||||
CheckboxPreference(
|
||||
title = it,
|
||||
title = Locale(it).displayName,
|
||||
key = it
|
||||
)
|
||||
} ?: emptyList()
|
||||
|
|
|
@ -19,7 +19,6 @@ import kotlinx.coroutines.launch
|
|||
@Composable
|
||||
fun CheckboxDialogPreference(
|
||||
preferenceTitle: String,
|
||||
preferenceDescriptionConverter: (values: List<String>) -> String = { it.joinToString(separator = ", ") },
|
||||
preference: ManagerPreference<Set<String>>,
|
||||
trailing: @Composable () -> Unit = {},
|
||||
buttons: List<CheckboxPreference>,
|
||||
|
@ -30,7 +29,11 @@ fun CheckboxDialogPreference(
|
|||
val coroutineScope = rememberCoroutineScope()
|
||||
DialogPreference(
|
||||
preferenceTitle = preferenceTitle,
|
||||
preferenceDescription = preferenceDescriptionConverter(selectedButtons),
|
||||
preferenceDescription = buttons.filter { button ->
|
||||
selectedButtons.any { selectedButton ->
|
||||
button.key == selectedButton
|
||||
}
|
||||
}.joinToString(separator = ", ") { it.title },
|
||||
trailing = trailing,
|
||||
buttons = { isShown ->
|
||||
ManagerThemedTextButton(
|
||||
|
|
|
@ -15,7 +15,6 @@ import kotlinx.coroutines.launch
|
|||
@Composable
|
||||
fun RadiobuttonDialogPreference(
|
||||
preferenceTitle: String,
|
||||
preferenceDescriptionConverter: (value: String) -> String = { it },
|
||||
preference: ManagerPreference<String>,
|
||||
trailing: @Composable () -> Unit = {},
|
||||
buttons: List<RadioButtonPreference>,
|
||||
|
@ -25,7 +24,7 @@ fun RadiobuttonDialogPreference(
|
|||
var currentSelection by remember { mutableStateOf(preference.value.value) }
|
||||
DialogPreference(
|
||||
preferenceTitle = preferenceTitle,
|
||||
preferenceDescription = preferenceDescriptionConverter(currentSelection),
|
||||
preferenceDescription = buttons.find { it.key == currentSelection }?.title,
|
||||
trailing = trailing,
|
||||
buttons = { isShown ->
|
||||
ManagerSaveButton {
|
||||
|
|
|
@ -9,37 +9,22 @@ import com.vanced.manager.ui.resources.managerString
|
|||
|
||||
@Composable
|
||||
fun ThemeSettingsItem() {
|
||||
val lightTheme = managerString(stringId = R.string.settings_preference_theme_light)
|
||||
val darkTheme = managerString(stringId = R.string.settings_preference_theme_dark)
|
||||
val sysDefTheme = managerString(stringId = R.string.settings_option_system_default)
|
||||
|
||||
val lightKey = "Light"
|
||||
val darkKey = "Dark"
|
||||
val sysDefKey = "System Default"
|
||||
|
||||
RadiobuttonDialogPreference(
|
||||
preferenceTitle = managerString(stringId = R.string.settings_preference_theme_title),
|
||||
preference = managerThemePref,
|
||||
buttons = listOf(
|
||||
RadioButtonPreference(
|
||||
title = lightTheme,
|
||||
key = lightKey
|
||||
title = managerString(stringId = R.string.settings_preference_theme_light),
|
||||
key = "Light"
|
||||
),
|
||||
RadioButtonPreference(
|
||||
title = darkTheme,
|
||||
key = darkKey
|
||||
title = managerString(stringId = R.string.settings_preference_theme_dark),
|
||||
key = "Dark"
|
||||
),
|
||||
RadioButtonPreference(
|
||||
title = sysDefTheme,
|
||||
key = sysDefKey
|
||||
title = managerString(stringId = R.string.settings_option_system_default),
|
||||
key = "System Default"
|
||||
)
|
||||
),
|
||||
preferenceDescriptionConverter = {
|
||||
when (it) {
|
||||
lightKey -> lightTheme
|
||||
darkKey -> darkTheme
|
||||
else -> sysDefTheme
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue