Skip to content

Commit 33ee3c9

Browse files
authored
feat/ allow client code to customize label for the input field (#28)
1 parent 38b5970 commit 33ee3c9

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,20 @@ See [MainActivity in the sample app](https://github.com/jump-sdk/jetpack_compose
4141
```
4242

4343

44-
| Parameter | Description |
45-
|-----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
46-
| onValueChange | Called when the text in the text field changes. The first parameter is string pair of (country code, phone number) and the second parameter is a boolean indicating whether the phone number is valid. |
47-
| modifier | Modifier to be applied to the inner OutlinedTextField. |
48-
| enabled | Boolean indicating whether the field is enabled. |
49-
| shape | Shape of the text field. |
50-
| showCountryCode | Whether to show the country code in the text field. |
51-
| showCountryFlag | Whether to show the country flag in the text field. |
52-
| colors | Colors to be used for the text field. |
44+
| Parameter | Description |
45+
|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
46+
| onValueChange | Called when the text in the text field changes. The first parameter is string pair of (country code, phone number) and the second parameter is a boolean indicating whether the phone number is valid. |
47+
| modifier | Modifier to be applied to the inner OutlinedTextField. |
48+
| enabled | Boolean indicating whether the field is enabled. |
49+
| shape | Shape of the text field. |
50+
| showCountryCode | Whether to show the country code in the text field. |
51+
| showCountryFlag | Whether to show the country flag in the text field. |
52+
| colors | Colors to be used for the text field. |
5353
| fallbackCountryCode | The country to be used as a fallback if the user's country cannot be determined. |
54-
| showPlaceholder | Whether to show the placeholder number in the text field. |
55-
| includeOnly | A set of 2 digit country codes to be included in the list of countries. Set to null to include all supported countries. |
56-
| clearIcon | The icon to be used for the clear button. Set to null to disable the clear button. |
54+
| showPlaceholder | Whether to show the placeholder number in the text field. |
55+
| includeOnly | A set of 2 digit country codes to be included in the list of countries. Set to null to include all supported countries. |
56+
| clearIcon | The icon to be used for the clear button. Set to null to disable the clear button. |
57+
| label | An optional composable to be used as a label for input field. |
5758

5859

5960
## How to add in your project

ccp/src/main/java/com/togitech/ccp/component/TogiCountryCodePicker.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ private val DEFAULT_TEXT_FIELD_SHAPE = RoundedCornerShape(24.dp)
7070
* @param includeOnly A set of 2 digit country codes to be included in the list of countries.
7171
* Set to null to include all supported countries.
7272
* @param clearIcon The icon to be used for the clear button. Set to null to disable the clear button.
73+
* @param label An optional composable to be used as a label for input field
7374
*/
7475
@OptIn(ExperimentalComposeUiApi::class)
7576
@Suppress("LongMethod")
@@ -86,6 +87,9 @@ fun TogiCountryCodePicker(
8687
showPlaceholder: Boolean = true,
8788
includeOnly: ImmutableSet<String>? = null,
8889
clearIcon: ImageVector? = Icons.Filled.Clear,
90+
label:
91+
@Composable()
92+
(() -> Unit)? = null,
8993
) {
9094
val context = LocalContext.current
9195
val focusRequester = remember { FocusRequester() }
@@ -124,6 +128,7 @@ fun TogiCountryCodePicker(
124128
)
125129
.focusRequester(focusRequester = focusRequester),
126130
enabled = enabled,
131+
label = label,
127132
placeholder = {
128133
if (showPlaceholder) {
129134
PlaceholderNumberHint(langAndCode, fallbackCountry)

0 commit comments

Comments
 (0)