Maybe I need more sleep... but how do I make sure ...
# compose
c
Maybe I need more sleep... but how do I make sure that I use the default capitalization EXCEPT when I declare the type to be a NAME?
Copy code
KeyboardOptions.Default.copy(
    capitalization = when (textFieldType) {
        MyCustomInputFieldType.EMAIL -> "How do I use the default here?"
        MyCustomInputFieldType.NAME -> KeyboardCapitalization.Sentences
        MyCustomInputFieldType.NUMBER -> "and here?"
    }
j
You should really invert the two constructs so as to only copy when needed, but you can use
KeyboardOptions.Default.capitalization
to get the default
l
If you look here, you can also see the default’s value, which is
KeyboardCapitalization.None
c
@ jw I'm only showing a snippet here, but in general it looks like this. so inverting the two constructs woulnd't make sense (i think) in my actual case. just my snippet
Copy code
KeyboardOptions.Default.copy(
    capitalization = when (textFieldType) {
        MyCustomInputFieldType.EMAIL -> "How do I use the default here?"
        MyCustomInputFieldType.NAME -> KeyboardCapitalization.Sentences
        MyCustomInputFieldType.NUMBER -> "and here?"
    }
    keyboardType =
        when (textFieldType) {
          MyInputFieldType.EMAIL -> KeyboardType.Email
          MyInputFieldType.PASSWORD -> KeyboardType.Password
          MyInputFieldType.NAME -> KeyboardType.Text
          MyInputFieldType.NUMBER -> KeyboardType.Number
        },
   ),
But cool. KeyboardOptions.Default.capitalization should work. thanks