Is there a sensible way to support a smaller `Text...
# compose
z
Is there a sensible way to support a smaller
TextField
(width) than the material design one? ๐Ÿงต๐Ÿ‘€
TextFieldDefaults has this comment:
The default min width applied for a TextField and OutlinedTextField. Note that you can override it by applying Modifier.widthIn directly on a text field.
That doesnt do anything for me ๐Ÿ˜ž
Copy code
modifier = Modifier.widthIn(
    min = TouchTargetSmall //48.dp
)
I can wrap it inside a `Box`with
Modifier.width(120.dp)
but then Id have to guess how small its going to be, Id like for it to just wrap its contents.
a
You want it to grow as someone types into it? Usually people report that kind of thing as a bug ๐Ÿ™ƒ
z
Almost! I just need it to be a bit smaller, the maxLength for my use-case is 5 characters; yet it takes up 280.dp and results in the input being "aligned" to the left rather than center, if that makes sense?
a
What if the user increased the system font scaling in system settings?
z
There's plenty of room for it to grow, I just dont want it to start off at 280.dp if the max width (5 characters) only requires something like 180.dp. With font scaling applied, the required width might instead be 260.dp in order to wrap those 5 characters, and that would be fine since it would remain centered.
I can share some screenshots of my use case when I get back home, perhaps it'll make sense? ๐Ÿ˜‡ It's basically an input field in the middle of the screen where you can input a short duration (mm:ss), since the field has a minimum width of 280, the text starts off to the left instead of being in the center, even if I have a placeholder to fill in 00:30, the remainder of the min width pushes it towards the left and it looks awkward/wrong.
Heres the screenshot ๐Ÿ™‚ Id like to make the text in the middle editable, but as I mentioned - the text is no longer centered due to the minWidth "offsetting" it to the left when using a TextField, and it just looks wrong. In the worst case scenario, I can just pop up a dialog when you tap the text, and include the TextField there instead - but editing it inline would be a much better user experience. If editing inline works, Ill naturally include a hint that you can tap it to edit (I feel like I have to mention that.. blob sweat smile)
a
I think what you'd ideally want here is a way to implement your own text entry from the soft keyboard relationship on up. Drawing the text at all is something you want to have full control over.
Cc @Sean McQuillan [G]
z
That could work, atlhough I obviously have no idea how Id make that happen - open to learn it though! ๐Ÿ‘€
a
BasicTextField is the place to start with the current API but I think we have some work to do in compose-ui itself to expose some lower level building blocks
๐Ÿ‘ 2
z
Alright ๐Ÿ™‚ Ill leave it alone for now, the material library has covered all my needs thus far and I think that if I dabble with BasicTextField in an attempt to mimic 99% of the TextField functionality/look, itll just crush my hopes & dreams in the long run with maintenance work. I appreciate the responses, thank you!