Status Update
Comments
ha...@google.com <ha...@google.com>
ph...@gmail.com <ph...@gmail.com> #2
Thanks for your ticket.
-
colors (custom bg colors)" - you could use
backgroundColor
parameter to change it -
borders (no border) - yes, we've been considering the possibility to have optional or even customisable bottom indicator for TextField.
-
shape (already possible)
-
animation/position of label (disable animation, could be done by empty label and composition) - this might create unnecessary complexity for the TextField API. Alternatively, since the label parameter has become optional, you can leave it null and have your own label placed on top (depending on the animation of that label in your design).
-
leading/ending text (already possible, property name misleading (leadingIcon)) - these are named to be consistent with the Material Design terminology so should not be misleading (
https://material.io/components/text-fields ). I wouldn't expect developers to put text inside the 'leadingIcon' as its baseline won't be aligned with the input's baseline.
Please also keep in mind that you can use the BaseTextField or CoreTextField that provide basic edit text functionality to create any custom text field on top of them.
ha...@google.com <ha...@google.com>
ph...@gmail.com <ph...@gmail.com> #3
Branch: androidx-master-dev
commit 87bdc09422bd32c063a93efc0078ba5b788497af
Author: Anastasia Soboleva <soboleva@google.com>
Date: Tue Sep 08 10:47:53 2020
Do not apply alpha to background color
Before this change: when developer passes some color to the background color parameter, we would apply 0.12 transparency alpha to it. This behaviour is not expected and made customisation harder
Test: TextFieldTest
Relnote: "Textfield's background color does not implicitly apply transparency alpha anymore. Instead, any color provided through the backgroundColor parameter will be applied directly."
Bug: 167951441
Change-Id: Iecee9f535b699acf684948fa99ec64217ea3f249
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/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldTest.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextField.kt
ha...@google.com <ha...@google.com> #4
I'm ok with writing my own styled implementation, but currently using BaseTextField without published TextFieldScroller is really cumbersome. Could you please make that class public?
Also IconsWithTextFieldLayout could be somehow decomposed and published, since it takes care of a lot internals of text field.
Description
Jetpack Compose component(s) used: BasicTextField, contentReceiver() Modifier
Android Studio Build: Android Studio Koala | 2024.1.1 Patch 1
Kotlin version: 2.0.0
Steps to Reproduce or Code Sample to Reproduce:
1. Add a BasicTextField with a contentReceiver() Modifier.
2. On a Samsung device (my example is Samsung SM-F926U1, API 34) attempt to insert an Image/Gif from the stock Samsung keyboard.
3. The "Can't enter this content here." toast shows.
Here's the code for the BasicTextField used:
```
BasicTextField(
state = state,
enabled = enabled,
textStyle = baseTextStyle.copy(color = StudioTheme.colors.contentRegular),
lineLimits = TextFieldLineLimits.MultiLine(maxHeightInLines = 4),
cursorBrush = SolidColor(StudioTheme.colors.primaryAction),
keyboardOptions = KeyboardOptions(
capitalization = KeyboardCapitalization.Sentences,
keyboardType = KeyboardType.Text,
),
modifier = Modifier
.fillMaxWidth()
.focusRequester(focusRequester)
.contentReceiver { transferableContent ->
if (!transferableContent.hasMediaType(MediaType.Image)) {
return@contentReceiver transferableContent
}
transferableContent.consume {
it.uri?.let { uri ->
onMediaSelected(uri)
true
} ?: false
}
},
)
```
Other notes:
* This code works perfectly on a Pixel 6, API 34.
* The same Samsung device was inserting Images correctly when wrapping an AppCompatEditText with AndroidView (and overriding onCreateInputConnection)