https://kotlinlang.org logo
#compose
Title
# compose
g

Guy Bieber

06/03/2020, 10:29 PM
TextField with a Keyboard.password doesn’t work as expected to hide the password as it is typed. Is there something like this for text fields:
Copy code
//by default
edittext.setTransformationMethod(new PasswordTransformationMethod());
//You can make it custom
edittext.setTransformationMethod(new AsterPasswordTransformationMethod());
l

Leland Richardson [G]

06/04/2020, 12:05 AM
cc @Siyamed should this be easier? perhaps
visualTransformation
should have a default value that is a function of the keyboardType
s

Siyamed

06/04/2020, 12:09 AM
I dont think it would scale
The difference of how the outout will look like, what characters keyboard will show, is it a number password, ascii password, what the action would be, visible password, invisible password etc it far too complex
Things get too complicated too fast there, and we end up in a state where we cant support the need
I am assuming that this is not about the api of visual transformation which i find hard to use; but it is about having to add a visual transformation
l

Leland Richardson [G]

06/04/2020, 12:26 AM
yeah
you might be totally right, but i’m not sure i see the issue
s

Siyamed

06/04/2020, 12:27 AM
Hmm, even though keyboard type is password, the visual outout might be hidden
l

Leland Richardson [G]

06/04/2020, 12:27 AM
is visual output different from visualTransformation?
s

Siyamed

06/04/2020, 12:27 AM
Or keyboard type is numeric but not password, but still output (visuals) is password
Too many combinations
Will think how it can be better but adding signal to keyboard type wouldn't scale
l

Leland Richardson [G]

06/04/2020, 12:29 AM
i guess it seems like not a scalability issue to me. it’s taking advantage of the default value, so you can add as few “common cases” as you want
in this case we have the current common cases = 1
and only increasing to 2
no need to increase it further
s

Siyamed

06/04/2020, 12:30 AM
I dont agree with common cases especially when it is about text based on my experience :)
l

Leland Richardson [G]

06/04/2020, 12:30 AM
people could still specify any visual tranformation they wanted
s

Siyamed

06/04/2020, 12:30 AM
I will check it
l

Leland Richardson [G]

06/04/2020, 12:30 AM
(not trying to be pushy here, just trying to understand the scalability argument)
s

Siyamed

06/04/2020, 12:32 AM
I also dont understand the issue :) what is hard to say visual transformatuon is password transformation?
Keyboard type is specific to 'keyboard' not textfield
l

Leland Richardson [G]

06/04/2020, 12:33 AM
it doesn’t seem terribly difficult or anything
s

Siyamed

06/04/2020, 12:33 AM
It is possible that when we see that keyboard type is passowrd and visualtranformation is not defined, we attach one
l

Leland Richardson [G]

06/04/2020, 12:33 AM
that was what i was suggesting
s

Siyamed

06/04/2020, 12:34 AM
Sorry, i double checjed after i wrote :) i though you wanted a visual transformation api in keyboard type class
Makes sense :)
534pm effect :)
l

Leland Richardson [G]

06/04/2020, 12:35 AM
i was thinking something like
Copy code
visualTransformation: VisualTransformation = VisualTransformation.None
changed to
Copy code
visualTransformation: VisualTransformation = if (keyboardType == KeyboardType.Password) PasswordVisualTransformation() else VisualTransformation.None
s

Siyamed

06/04/2020, 12:35 AM
Makes sense
l

Leland Richardson [G]

06/04/2020, 12:35 AM
it just makes a common case a little easier to get to
but i don’t feel strongly 🙂
s

Siyamed

06/04/2020, 12:36 AM
We should guide community about the difference of keyboardtype vs visuals very well though
Sounds good
l

Leland Richardson [G]

06/04/2020, 12:39 AM
👍 also, thinking more about this, i can see the argument of trying to keep these separate. I was just thinking that it would be nice to have a common case “password” textfield be only one additional line of code
i also wish it was easier to not allocate a new PasswordVisualTransformation on each recompose if you pass it in
wonder if a
VisualTransformation.Password
makes sense
assuming its stateless, which i’m guessing it is
s

Siyamed

06/04/2020, 12:42 AM
That also makes sense
It is something very common. Password one itself does not have a state
Ok so i create two tickets :)
🙏 1
g

Guy Bieber

06/04/2020, 3:02 AM
Smile. Didn’t want to spawn a huge debate! Got it working with the API the way it is.
all good
Copy code
ui.TextFieldStyled(
    text = appModel.session.user.userPass,
    onDone = {
        appModel.session.user.userPass = it
    },
    keyboardType = KeyboardType.Password,
    visualTransformation = PasswordVisualTransformation()
)
s

Siyamed

06/04/2020, 11:56 PM
158247724 for default transformation
🤦
3 Views