Open KarolCieslar opened 2 months ago
The preferences take composables for title and subtitle so you can style them in there freely...
Regarding dialogs, I don't provide a dialog here just a simple composable... so what do you mean here in particular?
Thanks for reply. I want to customize this dialog
I do use my ComposeDialogs library for the internal dialogs - I do not expose a lot of customisation options for the dialogs to keep this library simple and independent from the the dialogs library.
You have 2 options:
Option 1
Create a custom preference based on the PreferenceInputText
and adjust the underlying ComposeDialogs
directly.
E.g. like following:
val showDialog = rememberDialogState()
if (showDialog.showing) {
val value = rememberDialogInput(value)
DialogInput(
state = showDialog,
input = value,
title = title, // <= provide a custom title composable here...
icon = icon
) {
if (it.isPositiveButton) {
onValueChange(value.value)
}
}
}
BasePreference(
enabled = enabled,
visible = visible,
title = title,
subtitle = subtitle,
icon = icon,
preferenceStyle = preferenceStyle,
itemSetup = itemSetup,
onClick = {
showDialog.show()
}
) {
PreferenceContentText(value, itemSetup)
}
Option 2 - create a custom preference and provide your own dialog
BasePreference(
enabled = enabled,
visible = visible,
title = title,
subtitle = subtitle,
icon = icon,
preferenceStyle = preferenceStyle,
itemSetup = itemSetup,
onClick = {
// show a dialog
}
) {
PreferenceContentText(value, itemSetup)
}
// TODO: show a fully custom dialog
Because of the simplicity of any dialog based preference I do not plan to offer more customisation for the dialogs currently.
In my opinion ComposeDialogs should had simple customization for example Title (as @Composable function) Description (as @Composable function) Enable/Disable icon Background color Cornders shape Buttons (as @Composable funciton)
These configuration give simple things to customize dialog and repository is still langweight
Check out the dialog code here:
There is a lot to customise... BUT I could offer a parameter that will allow you to provide your dialog directly, with a default implementation that you can overwrite, something like following:
@Composable
fun PreferenceScope.PreferenceInputText(
// Special
value: String,
onValueChange: (value: String) -> Unit,
// Base Preference
title: @Composable () -> Unit,
enabled: Dependency = Dependency.Enabled,
visible: Dependency = Dependency.Enabled,
subtitle: @Composable (() -> Unit)? = null,
icon: (@Composable () -> Unit)? = null,
preferenceStyle: PreferenceStyle = LocalPreferenceSettings.current.itemStyle,
itemSetup: PreferenceItemSetup = PreferenceBoolDefaults.itemSetup(),
// Dialog
dialog: @Composable (dialogState: DialogState) -> Unit = { dialogState ->
val value = rememberDialogInput(value)
DialogInput(
state = dialogState,
input = value,
title = title,
icon = icon
) {
if (it.isPositiveButton) {
onValueChange(value.value)
}
}
}
)
This way you could use all of the customisation options of my dialog libraries directly...
These configuration give simple things to customize dialog and repository is still langweight
What I meant here is that I do not want to copy the configuration options from my dialog library into this library and make the composable functions even more overloaded than they already are. Above suggestion would be an option though.
Sounds good. I will be grateful if You could make these changes.
When can i expect update?
How i can change default dialogs colors, title, description for specific preferences?