From f528770a546ccfdbd519844454038a6545dd777a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=92=AA=E1=97=A9=E1=99=AD=E1=97=B0=E1=8E=A5=20=E1=9B=95?= =?UTF-8?q?=E1=97=A9=E1=91=8E=E4=B8=85?= <54760870+codewith-fun@users.noreply.github.com> Date: Thu, 22 Dec 2022 03:20:30 +0530 Subject: [PATCH] Update README.md --- README.md | 98 ++++++++++++++++++++++++------------------------------- 1 file changed, 43 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 825075e..30f7729 100644 --- a/README.md +++ b/README.md @@ -36,19 +36,17 @@ Languages: ```kotlin @Composable -fun MCodeCountryCodePicker( - modifier: Modifier = Modifier, - text: String, - onValueChange: (String) -> Unit, - shape: Shape = RoundedCornerShape(24.dp), - color: Color = MaterialTheme.colors.background, - showCountryCode: Boolean = true, - showCountryFlag: Boolean = true, - focusedBorderColor: Color = MaterialTheme.colors.primary, - unfocusedBorderColor: Color = MaterialTheme.colors.onSecondary, - cursorColor: Color = MaterialTheme.colors.primary, - bottomStyle: Boolean = false -) + CountryTextField( + label = stringResource(R.string.select_country_text), + modifier = Modifier + .padding(top = 50.dp) + .align(Alignment.TopCenter), + expanded = expanded, + selectedCountry = selectedCountry, + defaultSelectedCountry = countryList(LocalContext.current).single { it.code == "IN" } + ) { + + } ``` @@ -56,52 +54,42 @@ fun MCodeCountryCodePicker( ```kotlin - -@Composable -fun CountryCodePick() { - Column( - modifier = Modifier - .verticalScroll(rememberScrollState()) - .fillMaxSize(), - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally - ) { - - val phoneNumber = rememberSaveable { mutableStateOf("") } - val fullPhoneNumber = rememberSaveable { mutableStateOf("") } - val onlyPhoneNumber = rememberSaveable { mutableStateOf("") } - - MCodeCountryCodePicker( - text = phoneNumber.value, - onValueChange = { phoneNumber.value = it }, - unfocusedBorderColor = MaterialTheme.colors.primary, - bottomStyle =false, - shape = RoundedCornerShape(24.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Button(onClick = { - if (!isPhoneNumber()) { - fullPhoneNumber.value = getFullPhoneNumber() - onlyPhoneNumber.value = getOnlyPhoneNumber() - } else { - fullPhoneNumber.value = "Error" - onlyPhoneNumber.value = "Error" - } + Box { + var expanded by remember { mutableStateOf(false) } + var selectedCountry by remember { mutableStateOf(null) } + val focusManager = LocalFocusManager.current + + CountryPickerBottomSheet(title = { + Text( + modifier = Modifier + .fillMaxWidth() + .padding(16.dp), + text = "Select Country", textAlign = TextAlign.Center, + fontWeight = FontWeight.Bold, + fontSize = 20.sp + ) + }, expanded, onDismissRequest = { + expanded = false + }, onItemSelected = { + selectedCountry = it + expanded = false + focusManager.clearFocus() }) { - Text(text = "Check") - } + CountryTextField( + label = "Select country", + modifier = Modifier + .padding(top = 50.dp) + .align(Alignment.TopCenter), + expanded, + defaultSelectedCountry = countryList(LocalContext.current).single { it.code == "IN" }, + selectedCountry + ) { + expanded = !expanded + } - Text( - text = "Full Phone Number: ${fullPhoneNumber.value}", - color = if (getErrorStatus()) Color.Red else Color.Green - ) + } - Text( - text = "Only Phone Number: ${onlyPhoneNumber.value}", - color = if (getErrorStatus()) Color.Red else Color.Green - ) } -} ```