Created
October 8, 2022 11:28
-
-
Save MohitGupta121/6ece10630a5f90220b122d483a3de34e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun CountryPickerSheet() { | |
Box { | |
var expanded by remember { mutableStateOf(false) } | |
var selectedCountry by remember { mutableStateOf<Country?>(null) } | |
val focusManager = LocalFocusManager.current | |
CountryPickerBottomSheet( | |
title = { | |
Text( | |
modifier = Modifier | |
.fillMaxWidth() | |
.padding(16.dp), | |
text = stringResource(R.string.select_country_text), | |
textAlign = TextAlign.Center, | |
fontWeight = FontWeight.Bold, | |
fontSize = 20.sp | |
) | |
}, | |
expanded, | |
onDismissRequest = { | |
expanded = false | |
}, | |
onItemSelected = { | |
selectedCountry = it | |
expanded = false | |
focusManager.clearFocus() | |
} | |
) { | |
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" } | |
) { | |
expanded = !expanded | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment