https://kotlinlang.org logo
k

Ketan

09/04/2020, 6:36 AM
Lot of things missing in
TextField
compare to
EditText
Material. Some basic things should be provided to style the look and feel.
🤔 1
z

Zach Klippenstein (he/him) [MOD]

09/04/2020, 1:20 PM
Well it is still in alpha.
n

Neil

09/04/2020, 1:26 PM
Maybe take a look at the Jetsurvey sample app.
k

Ketan

09/04/2020, 5:09 PM
So in on-going development, at later stage can we expect some stying features for
TextField
? Is it in roadmap? @Zach Klippenstein (he/him) [MOD]
z

Zach Klippenstein (he/him) [MOD]

09/04/2020, 5:36 PM
I don’t know what the roadmap is, but
TextField
(text editing in general) is probably one of the most complicated parts of any UI framework and it’s been under very heavy development for months, and i expect will continue to be until it reaches feature parity with the existing text input stuff. https://lord.io/blog/2019/text-editing-hates-you-too/
👍 1
s

Sean McQuillan [G]

09/06/2020, 9:06 PM
The TextField APIs are something that we know are not fitting every use case now and as Zach said it's definitely the hardest part of the UI toolkit (UI toolkit by loc: 95% text 5% everything else 🙂 ). I'd love to hear more about what you expected to find.
k

Ketan

09/07/2020, 9:06 AM
@Sean McQuillan [G] Basic things like to set the color of the line, If error text component is provided then to set the color of the error [I know we can specify the
Error
and
onError
colors in Theme but what if the error color in particular use case is different from that theme color. Like in Material EditText, we have everything, we just need to pass correct reference [color] to customise the experience as per our need… I hope this will help you…
s

Sean McQuillan [G]

09/08/2020, 10:52 PM
cc @Siyamed ^
s

Siyamed

09/09/2020, 12:19 AM
@Ketan if you can set the error colors in theme, you can wrap the textfield and use the same structure for that specific TextField
Same structure meaning ambients
Does material edit text provide setters getters for those colors?
One of the challenges is the number of co configuration options for each of our ui components gets really really big which ends up functions with far too mamy parameters
For the material text field component styling cc: @Anastasia [G]
k

Ketan

09/09/2020, 4:46 AM
@Siyamed I am setting the error color as stated here: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1599469564125200?thread_ts=1599201388.495500&cid=CJLTWPH7S but I am asking that in one of the use case if I need to use different color for error so in that case how can I set? I can understand on https://kotlinlang.slack.com/archives/CJLTWPH7S/p1599610863263100?thread_ts=1599201388.495500&cid=CJLTWPH7S Thanks @Zach Klippenstein (he/him) [MOD] @Sean McQuillan [G] @Siyamed for the inputs
a

Anastasia [G]

09/10/2020, 6:52 PM
I might have misunderstood your use case but TF has an ‘errorColor’ parameter. As for the bottom indicator, we’re looking towards making it more customisable. Please feel free to file a feature request. Such requests definitely help us understand which use cases we haven’t covered
k

Ketan

09/11/2020, 4:43 AM
@Anastasia [G] I am glad you guys are considering the
TextField
bottom line color customisation… I hope it turns out well Thank you so much P.S: Here you can check the dark theme screenshot https://kotlinlang.slack.com/archives/CJLTWPH7S/p1599201216493500 to refer why I asked for that customisation? [Bottom line is not visible]
c

coolchandrakumar

09/16/2020, 5:43 AM
In another perspective, I am trying to put EditText using AndroidView. In that case may I reuse the Compose color palate to the EditText widget. Any possibility of setting style/color using compose color palate @Zach Klippenstein (he/him) [MOD] @Andrey Kulikov
z

Zach Klippenstein (he/him) [MOD]

09/16/2020, 5:46 AM
Sure, just read the colors from the
MaterialTheme
, convert the colors to Android color ints, and set the appropriate color values on the
EditText
.
c

coolchandrakumar

09/16/2020, 5:49 AM
Though MaterialTheme.colors is a composable, I can not it use it directly. Do I need to write a separate parser, prepare the colors and then use it. In my understanding default theme/style attributes doesn’t override the compose color right.
If i use CheckBox widget, i need to set all color list programatically then
z

Zach Klippenstein (he/him) [MOD]

09/16/2020, 5:53 AM
Though MaterialTheme.colors is a composable, I can not it use it directly.
What do you mean by “use it directly”? There’s no automatic wiring of android theme colors to compose theme colors or vice versa, no.
c

coolchandrakumar

09/16/2020, 5:53 AM
Copy code
@Composable
    private fun androidViewColor() {
        MaterialTheme(colors = themeColor) {
            AndroidView(viewBlock = { context ->
                android.widget.EditText(context).apply {
                    layoutParams = LinearLayout.LayoutParams(
                        LinearLayout.LayoutParams.MATCH_PARENT,
                        LinearLayout.LayoutParams.WRAP_CONTENT
                    )
                    setText("HelloWorld")
                    //setBackgroundColor(android.graphics.Color.BLUE)
                    //ThisPart
                    //setBackgroundColor(android.graphics.Color.parseColor("#${MaterialTheme.colors.background.value}"))
                }
            })
        }}
z

Zach Klippenstein (he/him) [MOD]

09/16/2020, 6:03 AM
First of all, you shouldn’t be setting any properties of your android view in
viewBlock
that are derived from data in the composition that could change. That’s what the
update
block is for. The
update
block will be re-invoked when the composable needs to be recomposed, e.g. if the theme changes, where as the
viewBlock
will only be executed once to create the view.
👍 1
I think Compose’s
Color.toArgb()
returns a color int in the same format that Android’s
Color
class expects, you don’t need to do the intermediate string.
You also don’t need the
MaterialTheme {}
wrapper, since you’re not using any components that read the theme ambient.
So i think this might work:
Copy code
@Composable fun androidViewColor() {
  val themeColors = MaterialTheme.colors
  AndroidView({ EditText(it).apply {
    layoutParams = … 
    setText("HelloWorld")
  }}) {
    setText("HelloWorld")
    setBackgroundColor(themeColors.background.toArgb())
  }
}
c

coolchandrakumar

09/16/2020, 6:13 AM
I have custom color set, so used material theme wrapper whether android classic views will use or not. That is clarified now.
Using EditText getting trouble in Huawei P30 lite device. also crash happens when delete text
z

Zach Klippenstein (he/him) [MOD]

09/16/2020, 4:14 PM
I don't see a crash there, although the view doesn't seem to be updating. Can you post a stacktrace?
c

coolchandrakumar

09/17/2020, 4:39 AM
>the view doesn't seem to be updating. That is the issue. Check attachment for crash
>the view doesn’t seem to be updating. It might be device specific. edit text gets updated in emulator 2020-09-17 100513.328 23364-23364/com.chan.composetryout E/AndroidRuntime: FATAL EXCEPTION: main Process: com.chan.composetryout, PID: 23364 java.lang.IllegalStateException: KeyEvent can’t be processed because this key input node is not active. at androidx.compose.ui.input.key.KeyInputModifier.processKeyInput(KeyInputModifier.kt:62) at androidx.compose.ui.platform.AndroidComposeView.sendKeyEvent(AndroidComposeView.kt:192) at androidx.compose.ui.platform.AndroidComposeView.dispatchKeyEvent(AndroidComposeView.kt:196)