https://kotlinlang.org logo
#compose-android
Title
# compose-android
j

jonathan olds

09/20/2023, 7:06 AM
Is there a way to apply a VisualTransformation or something similar to BTF2 at this point?
s

Stylianos Gakis

09/20/2023, 8:22 AM
j

jonathan olds

09/20/2023, 8:26 AM
I've been using a visualTransformation with the original BTF, but I don't know how to apply it to BTF2. The original BTF takes it as a parameter, and I used it both there and on the decoration box. BTF2 doesn't have that parameter, but I still used it on the decoration box, but it doesn't show it.
s

Stylianos Gakis

09/20/2023, 8:30 AM
j

jonathan olds

09/20/2023, 8:31 AM
I'm not positive, but it looks like the decoration box just uses it to compute a state (it's just an enum), so I guess displaying the result in orig BTF happens from its visualtransform parameter
s

Stylianos Gakis

09/20/2023, 8:32 AM
Maybe take a step back here, what is it that you are trying to achieve in the first place?
j

jonathan olds

09/20/2023, 8:32 AM
InputTransform happens between user input and saving the field's value. I'm only trying to transform the visual output
basically adding a units superscript label to the main value displayed
I'll show you what it looks like on btf1, maybe i'm overthinking
s

Stylianos Gakis

09/20/2023, 8:36 AM
Aha, so something like this https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]rmation.allCaps&ss=androidx%2Fplatform%2Fframeworks%2Fsupport doesn’t just change the visuals, but translates the value you get out of it too then you say?
j

jonathan olds

09/20/2023, 8:36 AM
2023-09-20 03_36_05-.png
yeah, the state i care about tracking is the Double
s

Stylianos Gakis

09/20/2023, 8:38 AM
I’ve seen this the other day https://x.com/halilozercan/status/1700187684474438093 which makes me think there must be a way to edit the output UI without editing the text field state itself, but I haven’t played enough with BTF2 myself to know how it’s done 👀
👍 1
j

jonathan olds

09/20/2023, 8:40 AM
I think that's the codepointsTransform. it changes each character 1:1, so perf form hiding passwords
BTF2 seems great so far, but maybe the last step of changing the visual output isn't built in yet. You were probably right that I'll have to work out my own thing for now
thanks for looking!
a

Albert Chang

09/20/2023, 10:52 AM
It's not yet available but is planned. Zach talked about this

here

(starting from 12700).
👍 2
thank you color 2
j

jonathan olds

09/20/2023, 10:53 AM
awesome! thank you
z

Zach Klippenstein (he/him) [MOD]

09/21/2023, 5:52 PM
I just talked about this at droidcon NYC! We’re working on a new API for this: https://speakerdeck.com/zachklipp/reimagining-text-fields-in-compose-dcnyc-23?slide=44
It’s not out yet, you might not be surprised to hear it’s quite complicated to implement 😅
👍 2
I literally have the branch open right now working on it
🦜 3
🙏🏾 1
j

jonathan olds

09/22/2023, 2:01 AM
awesome! I'm a huge fan so far. Especially how it keeps outside updates separate during editing. To me, that solves a lot of tricky problems with keeping the data in sync, but also the cursor where the user expects it.
Can't wait for it to be the norm!