Skip to content

Commit

Permalink
Merge pull request #6 from canopas/fix_search_text_cut
Browse files Browse the repository at this point in the history
Fix Search text cut
  • Loading branch information
cp-luzi-p authored May 10, 2022
2 parents 87a8ca4 + e137031 commit 299f615
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fun countrySearchView(state: ModalBottomSheetState): String {
TextField(
modifier = Modifier
.fillMaxWidth()
.height(48.dp)
.height(52.dp)
.background(
Color.LightGray.copy(0.6f),
shape = RoundedCornerShape(10.dp)
Expand Down Expand Up @@ -87,13 +87,14 @@ fun countrySearchView(state: ModalBottomSheetState): String {
keyboardType = KeyboardType.Text,
imeAction = ImeAction.Search
),
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() })
keyboardActions = KeyboardActions(onSearch = { focusManager.clearFocus() })
)
if (searchValue.isEmpty()) {
Text(
text = stringResource(R.string.search_text),
style = MaterialTheme.typography.body1,
color = Color.Gray,
fontSize = 16.sp,
modifier = Modifier
.align(Alignment.CenterStart)
.padding(start = 52.dp)
Expand All @@ -106,7 +107,7 @@ fun countrySearchView(state: ModalBottomSheetState): String {


@OptIn(ExperimentalMaterialApi::class)
@Preview()
@Preview
@Composable
fun PreviewSearchView() {
countrySearchView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fun countryList(context: Context): MutableList<Country> {
return Gson().fromJson(jsonFileString, type)
}

fun localeToEmoji(countryCode: String): String {
fun localeToEmoji(countryCode: String): String {
val firstLetter = Character.codePointAt(countryCode, 0) - 0x41 + 0x1F1E6
val secondLetter = Character.codePointAt(countryCode, 1) - 0x41 + 0x1F1E6
return String(Character.toChars(firstLetter)) + String(Character.toChars(secondLetter))
Expand All @@ -32,7 +32,9 @@ fun getJsonDataFromAsset(context: Context, fileName: String): String? {
fun List<Country>.searchCountryList(countryName: String): MutableList<Country> {
val countryList = mutableListOf<Country>()
this.forEach {
if (it.name.lowercase().contains(countryName.lowercase())) {
if (it.name.lowercase().contains(countryName.lowercase()) ||
it.dial_code.contains(countryName.lowercase())
) {
countryList.add(it)
}
}
Expand Down

0 comments on commit 299f615

Please sign in to comment.