Status Update
Comments
so...@google.com <so...@google.com> #2
Branch: androidx-master-dev
commit 23a7d960caf43390a554700d3c56ada189a9d10e
Author: Louis Pullen-Freilich <lpf@google.com>
Date: Mon Aug 10 15:11:36 2020
IconButton / IconToggleButton API scrub
Test: ./gradlew updateApi
Bug:
Bug:
Relnote: "Adds enabled parameter to IconButton, and reorders parameters in IconToggleButton"
Change-Id: I0a9419b1a631cadad451395302ad87b7f9214f96
M ui/ui-material/api/current.txt
M ui/ui-material/api/public_plus_experimental_current.txt
M ui/ui-material/api/restricted_current.txt
M ui/ui-material/src/commonMain/kotlin/androidx/compose/material/IconButton.kt
ma...@google.com <ma...@google.com> #3
do we want to have the primitive override in a single 'core' text field
I don't think so. This whole bug is a side effect of the naming problem we've already fixed. I would suggest to close this bug as fixed because of renaming and original problem being infeasible anymore.
If someone is reimplementing their TextField for their design need, I expect them to be ok with TextFieldValue hoisting or them be able to wrap this API with their string overload.
It seems reasonable to separate selection range and value long term, but maybe I'm missing some cases there where this might not work. Over to Siyamed to give some input here
se...@google.com <se...@google.com> #4
I'm not actually sure that the Material TextFields fully replace this API – it's pretty common to need text input in various contexts that aren't well supported by the styling of a material TextField.
In particular, the label is often undesired in interactive inputs (search fields / inline data entry) and typical applications will need to use BaseTextField in typical application coding.
se...@google.com <se...@google.com> #5
I'm currently working on a TODO sample app and am copy/pasting the code from TextField to manage state into the sample. I can't use either of the material text fields in this UI location.
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun TodoTextField(value: String, onValueChange: (String) -> Unit, modifier: Modifier = Modifier) {
// this code is used to manage the selection and composition state of the BaseTextField
var textFieldValue by state { TextFieldValue() }
if (textFieldValue.text != value) {
@OptIn(InternalTextApi::class)
textFieldValue = TextFieldValue(
text = value,
selection = textFieldValue.selection.constrain(0, value.length)
)
}
BaseTextField(
value = textFieldValue,
onValueChange = {
val previousValue = textFieldValue.text
textFieldValue = it
if (previousValue != it.text) {
onValueChange(it.text)
}
},
modifier = modifier
)
}
It seems in general if we find that a material component requires an API like this for usability the core equivalent should be exposed similarly.
so...@google.com <so...@google.com> #6
One thought is that maybe the label parameter should be optional in material text fields? Even though you can do label = {}
, but label parameter being non-optional maybe makes it confusing.
ap...@google.com <ap...@google.com> #7
Branch: androidx-master-dev
commit 9e43642ea25a9c3f3a63cc7ddd6ef7eafc6348f0
Author: Anastasia Soboleva <soboleva@google.com>
Date: Wed Aug 12 10:10:17 2020
Make placeholder animated and label optional
Before this change label was a required slot API. But often label is not needed, and having it non-optional sends a wrong signal. With this change label is optional similar to other slots inside material text fields.
Placeholder animates on focus/unfocus as per MD specs.
Test: material tests passed + checked the demo
Fixes: 161519460
Bug: 162234081
Relnote: "Label became an optional parameter inside TextField and OutlinedTextField"
Change-Id: I267f6ada96a3371aaa99bdaa4007229ab7efddab
M compose/material/material/api/current.txt
M compose/material/material/api/public_plus_experimental_current.txt
M compose/material/material/api/restricted_current.txt
M compose/material/material/samples/src/main/java/androidx/compose/material/samples/TextFieldSamples.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/OutlinedTextField.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextField.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextFieldImpl.kt
ma...@google.com <ma...@google.com> #8
Assigning to Anastasia for future work or to close
so...@google.com <so...@google.com> #9
We now provide both String
and TextFieldValue
overrides in both material and foundation text fields.
Description
Compose: dev14
The current API of
TextField
requiring aTextFieldValue
promotes developers duplicating state inside a composable.The common code is something similar to this:
Developers have express that they don't feel like the selection state (etc) of the TextField is appropriate state to hoist to a parent (e.g. a ViewModel).
We should provide primitives overrides for
TextField
similar to the Material TextField options to allow developers to express this more simply: