You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to add any kind of validation to EditTextPref to make sure invalid data doesn't make its way into the data store? For example, I want to make sure only positive integers are added. I also want to validate one value against another (one must always be greater than the other).
What's the best way to show the current value of an EditTextPref? I want to make sure the current value is visible without having to click into the edit dialog.
Is it possible to separate the DataStore connection so that the library can provide UI only and allow for a custom ViewModel?
Thanks - great work on this!!
The text was updated successfully, but these errors were encountered:
I don't think it would be too difficult to add validation. There is a callback called onValueChange which fires every time the value changes. You could possibly do some validation based on that? Not 100% sure though. I'd have to look into it a bit more.
Something like this would probably work although I haven't tested it:
var current by remember { mutableStateOf("") }
...
EditTextPref(
key = "et1",
title = "EditText example",
summary = current,
onValueChange = {newVal -> current= newVal}
)
Yes it would be possible but probably a fair bit of work. I urge you to give it a try though. I'm very open to PRs.
As it's probably quite clear I am not actively working on ComposePrefs anymore. The library works for what it was meant for and I don't have the time to actively maintain it. I would be glad to see more external contributions though.
Three questions:
Is it possible to add any kind of validation to EditTextPref to make sure invalid data doesn't make its way into the data store? For example, I want to make sure only positive integers are added. I also want to validate one value against another (one must always be greater than the other).
What's the best way to show the current value of an EditTextPref? I want to make sure the current value is visible without having to click into the edit dialog.
Is it possible to separate the DataStore connection so that the library can provide UI only and allow for a custom ViewModel?
Thanks - great work on this!!
The text was updated successfully, but these errors were encountered: