11package io.github.farhanroy.cccp.components
22
33import androidx.compose.foundation.background
4- import androidx.compose.foundation.layout.*
4+ import androidx.compose.foundation.layout.Box
5+ import androidx.compose.foundation.layout.padding
6+ import androidx.compose.foundation.layout.size
57import androidx.compose.foundation.lazy.LazyColumn
68import androidx.compose.runtime.Composable
79import androidx.compose.runtime.MutableState
@@ -12,20 +14,16 @@ import androidx.compose.ui.unit.dp
1214import androidx.compose.ui.window.Dialog
1315import androidx.lifecycle.viewmodel.compose.viewModel
1416import io.github.farhanroy.cccp.state.DialogState
15- import io.github.farhanroy.cccp.utils.CCPCountry
16- import io.github.farhanroy.cccp.utils.getLibraryMasterCountriesEnglish
17-
1817import java.util.*
1918import kotlin.collections.ArrayList
2019
21-
2220@Composable
2321fun CountryCodeDialog (
2422 state : MutableState <TextFieldValue >,
2523 dialogState : DialogState = viewModel()
2624) {
27- val countries = getLibraryMasterCountriesEnglish ()
28- var filteredCountries: List <CCPCountry >
25+ val countries = getListOfCountries ()
26+ var filteredCountries: List <String >
2927
3028 if (dialogState.getState()) {
3129 Dialog (onDismissRequest = { dialogState.setState(false ) }) {
@@ -40,9 +38,9 @@ fun CountryCodeDialog(
4038 filteredCountries = if (searchedText.isEmpty()) {
4139 countries
4240 } else {
43- val resultList = ArrayList <CCPCountry >()
41+ val resultList = ArrayList <String >()
4442 for (country in countries) {
45- if (country.name. lowercase(Locale .getDefault())
43+ if (country.lowercase(Locale .getDefault())
4644 .contains(searchedText.lowercase(Locale .getDefault()))
4745 ) {
4846 resultList.add(country)
@@ -56,11 +54,12 @@ fun CountryCodeDialog(
5654 }
5755 items(filteredCountries.size) { index ->
5856 CountryItem (
59- country = filteredCountries[index]
60- ) { selectedCountry ->
61- dialogState.setState(false )
62- dialogState.setCountry(selectedCountry)
63- }
57+ countryText = filteredCountries[index],
58+ onItemClick = { selectedCountry ->
59+ dialogState.setState(false )
60+ dialogState.setCountry(selectedCountry)
61+ }
62+ )
6463 }
6564 }
6665 }
0 commit comments