Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design a better approach to widget defaults #346

Open
bitspittle opened this issue Oct 12, 2023 · 0 comments
Open

Design a better approach to widget defaults #346

bitspittle opened this issue Oct 12, 2023 · 0 comments
Labels
enhancement New feature or request maybe For issues that may not be worth pursuing
Milestone

Comments

@bitspittle
Copy link
Member

Currently, we have code like this:

object InputDefaults {
    const val Valid = true
    const val Enabled = true
    const val ReadOnly = false
    const val Required = false
    const val SpellCheck = false
    val Size = InputSize.MD
    val Variant = OutlinedInputVariant
}

@Composable
private fun <T : Any> Input(
    type: InputType<T>,
    value: T,
    enabled: Boolean = InputDefaults.Enabled,
    valid: Boolean = InputDefaults.Valid,
    required: Boolean = InputDefaults.Required,
    readOnly: Boolean = InputDefaults.ReadOnly,
    spellCheck: Boolean = InputDefaults.SpellCheck,
) { ... }

This is inspired by Jetpack Compose and does the job -- but what if we want to allow users to change these defaults in their own applications?

We should consider a different approach here, either doing something like exposing mutable defaults that get frozen at silk initialization time, or by using composition local providers. The latter could be useful if it makes sense to change defaults for some subsection of your site; while the former if defaults should be set once everywhere.

@bitspittle bitspittle added the enhancement New feature or request label Oct 12, 2023
@bitspittle bitspittle added this to the 1.0 milestone Oct 12, 2023
@bitspittle bitspittle added the maybe For issues that may not be worth pursuing label Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request maybe For issues that may not be worth pursuing
Projects
None yet
Development

No branches or pull requests

1 participant