Skip to content

Commit

Permalink
Feat/keyboard customization (#35)
Browse files Browse the repository at this point in the history
* feat/ allow client code to customize keyboard options

* feat/ allow client code to customize keyboard actions

* documentation/ allow client code to customize keyboard options and actions

* feat/ allow client code to customize keyboard options

* feat/ allow client code to customize keyboard actions

* feat/ allow client code to customize keyboard actions

* fix/ detekt
  • Loading branch information
itstanany authored Oct 11, 2023
1 parent 6adaded commit b278af7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ TogiCountryCodePicker(
| initialCountryPhoneCode | Optional country phone code to set the initially selected country. This takes precedence over initialCountryIsoCode. |
| label | An optional composable to be used as a label for input field. |
| textStyle | An optional [TextStyle](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/TextStyle) for customizing text style of phone number input field. Defaults to MaterialTheme.typography.body1 |
| keyboardOptions | An optional [KeyboardOptions](https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/KeyboardOptions) to customize keyboard options. |
| keyboardActions | An optional [KeyboardActions](https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/KeyboardActions) to customize keyboard actions. |



Expand Down Expand Up @@ -97,8 +99,7 @@ Step 2. Add the dependency

```kotlin
dependencies {
implementation("androidx.compose.material:material:1.5.3")
implementation("com.github.jump-sdk:jetpack_compose_country_code_picker_emoji:2.2.3")
implementation("com.github.jump-sdk:jetpack_compose_country_code_picker_emoji:2.2.0")
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ private const val TAG = "TogiCountryCodePicker"
* @param label An optional composable to be used as a label for input field
* @param textStyle An optional [TextStyle] for customizing text style of phone number input field.
* Defaults to MaterialTheme.typography.body1
* @param [keyboardOptions] An optional [KeyboardOptions] to customize keyboard options.
* @param [keyboardActions] An optional [KeyboardActions] to customize keyboard actions.
*/
@OptIn(ExperimentalComposeUiApi::class)
@Suppress("LongMethod")
@Suppress("LongMethod", "CyclomaticComplexMethod")
@Composable
fun TogiCountryCodePicker(
onValueChange: (Pair<PhoneCode, String>, Boolean) -> Unit,
Expand All @@ -108,6 +110,8 @@ fun TogiCountryCodePicker(
textStyle: TextStyle = MaterialTheme.typography.body1.copy(
color = MaterialTheme.colors.onSurface,
),
keyboardOptions: KeyboardOptions? = null,
keyboardActions: KeyboardActions? = null,
) {
val context = LocalContext.current
val focusRequester = remember { FocusRequester() }
Expand Down Expand Up @@ -244,12 +248,12 @@ fun TogiCountryCodePicker(
},
isError = !isNumberValid,
visualTransformation = phoneNumberTransformation,
keyboardOptions = KeyboardOptions.Default.copy(
keyboardOptions = keyboardOptions ?: KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Phone,
autoCorrect = true,
imeAction = ImeAction.Done,
),
keyboardActions = KeyboardActions(
keyboardActions = keyboardActions ?: KeyboardActions(
onDone = {
keyboardController?.hide()
focusRequester.freeFocus()
Expand Down

0 comments on commit b278af7

Please sign in to comment.