joelkanyi / kompose-country-code-picker

Kompose Country Code Picker is a Jetpack Compose library based on Material 3 (M3) that provides a country code picker for Android apps.
https://joelkanyi.github.io/kompose-country-code-picker/
Apache License 2.0
114 stars 13 forks source link

Allow listening to different interactions i.e focused by passing a MutableInteractionSource parameter #31

Closed Breens-Mbaka closed 5 months ago

Breens-Mbaka commented 5 months ago

This is to observe interactions in the text field i.e focused

joelkanyi commented 5 months ago

You can add onFocusChanged and listen when the textfield's focus changes:

val context = LocalContext.current

DPhoneNumberTextField(
      modifier = Modifier
                  .fillMaxWidth()
                   .onFocusChanged {
                        if (it.isFocused) {
                              Toast.makeText(context, "Focused", Toast.LENGTH_SHORT).show()
                         }
                   }
Breens-Mbaka commented 5 months ago

You can add onFocusChanged and listen when the textfield's focus changes:

val context = LocalContext.current

DPhoneNumberTextField(
      modifier = Modifier
                  .fillMaxWidth()
                   .onFocusChanged {
                        if (it.isFocused) {
                              Toast.makeText(context, "Focused", Toast.LENGTH_SHORT).show()
                         }
                   }

This works great ✅

joelkanyi commented 5 months ago

Closing this as there is nothing that needs to change on the lib