|
@@ -56,6 +56,7 @@ import androidx.compose.material3.rememberDatePickerState
|
|
|
import androidx.compose.material3.rememberModalBottomSheetState
|
|
|
import androidx.compose.runtime.Composable
|
|
|
import androidx.compose.runtime.CompositionLocalProvider
|
|
|
+import androidx.compose.runtime.LaunchedEffect
|
|
|
import androidx.compose.runtime.getValue
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
import androidx.compose.runtime.remember
|
|
@@ -85,17 +86,22 @@ import com.fastest.pass.home.domain.model.CountryInfoCode
|
|
|
import com.fastest.pass.home.domain.model.countryInfoList
|
|
|
import com.fastest.pass.home.domain.model.countryInfoListCode
|
|
|
import com.fastest.pass.home.utils.GetDrawable
|
|
|
+import kotlinx.coroutines.delay
|
|
|
import java.text.SimpleDateFormat
|
|
|
import java.util.Date
|
|
|
import java.util.Locale
|
|
|
import java.util.TimeZone
|
|
|
|
|
|
@Composable
|
|
|
-fun AddContactInfoScreen() {
|
|
|
+fun AddContactInfoScreen(
|
|
|
+ onSearchTextChanged: (String) -> Unit,
|
|
|
+ onCountryList: (List<CountryInfo>, String) -> Unit,
|
|
|
+ countryListDisplayed: List<CountryInfo>
|
|
|
+) {
|
|
|
val keyboardController = LocalSoftwareKeyboardController.current
|
|
|
val focusManager = LocalFocusManager.current
|
|
|
|
|
|
- val titles = listOf("Please Select", "Mr", "Mrs", "Ms", "Dr")
|
|
|
+ val honorific = listOf("Please Select", "Mr", "Mrs", "Ms", "Dr")
|
|
|
val list = getAllCountriesList()
|
|
|
val countriesList = ArrayList<String>()
|
|
|
countriesList.addAll(list)
|
|
@@ -124,7 +130,7 @@ fun AddContactInfoScreen() {
|
|
|
NameTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.title)
|
|
|
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- DropDownFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.honorific, titles)
|
|
|
+ DropDownFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.honorific, honorific)
|
|
|
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
NameTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.first_name)
|
|
@@ -150,7 +156,19 @@ fun AddContactInfoScreen() {
|
|
|
NameTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.zip_postal_code)
|
|
|
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- SelectCountryInfo(labelText = R.string.country, keyboardController, focusManager)
|
|
|
+ SelectCountryInfo(
|
|
|
+ labelText = R.string.country,
|
|
|
+ keyboardController,
|
|
|
+ focusManager,
|
|
|
+ onSearchTextChanged = { searchText ->
|
|
|
+ onSearchTextChanged(searchText)
|
|
|
+ },
|
|
|
+ onCountryList = { list, text ->
|
|
|
+ onCountryList.invoke(list, text)
|
|
|
+ },
|
|
|
+ countryListDisplayed = countryListDisplayed
|
|
|
+ )
|
|
|
+
|
|
|
// DropDownFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.country, countriesList)
|
|
|
|
|
|
// Spacer(modifier = Modifier.height(20.dp))
|
|
@@ -170,7 +188,16 @@ fun AddContactInfoScreen() {
|
|
|
EmailFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, R.string.enter_email_address)
|
|
|
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- SelectCountryInfoPhoneIcon(keyboardController, focusManager, R.string.phone, R.string.ext)
|
|
|
+ SelectCountryInfoPhoneIcon(
|
|
|
+ keyboardController,
|
|
|
+ focusManager,
|
|
|
+ R.string.phone,
|
|
|
+ R.string.ext,
|
|
|
+ onCountryList = { list, text ->
|
|
|
+ onCountryList.invoke(list, text)
|
|
|
+ },
|
|
|
+ countryListDisplayed = countryListDisplayed
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
NumberTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.mobile, placeholder = R.string.mobile, ImeAction.Next)
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
@@ -740,7 +767,10 @@ fun ColumnScope.OpenModalBottomSheet(
|
|
|
focusManager: FocusManager,
|
|
|
isSheetOpened: () -> Unit,
|
|
|
onSelectedCountry: (String) -> Unit,
|
|
|
- isCountryList: Boolean = true
|
|
|
+ isCountryList: Boolean = true,
|
|
|
+ onSearchTextChanged: (String) -> Unit,
|
|
|
+ onCountryList: (List<CountryInfo>, String) -> Unit,
|
|
|
+ countryListDisplayed: List<CountryInfo> = emptyList()
|
|
|
) {
|
|
|
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
|
|
var isSheetOpen by remember { mutableStateOf(true) }
|
|
@@ -748,6 +778,12 @@ fun ColumnScope.OpenModalBottomSheet(
|
|
|
var searchText by remember { mutableStateOf("") }
|
|
|
val countryList = if (isCountryList) countryInfoList else countryInfoListCode
|
|
|
|
|
|
+ LaunchedEffect(key1 = searchText) {
|
|
|
+ val delay = if (searchText.isEmpty()) 0L else 300L
|
|
|
+ delay(delay)
|
|
|
+ onCountryList.invoke(countryList, searchText)
|
|
|
+ }
|
|
|
+
|
|
|
if (isSheetOpen) {
|
|
|
ModalBottomSheet(
|
|
|
onDismissRequest = {
|
|
@@ -784,6 +820,8 @@ fun ColumnScope.OpenModalBottomSheet(
|
|
|
query = searchText,
|
|
|
onQueryChange = {
|
|
|
searchText = it
|
|
|
+ Log.d("searchText", "ACIS => OMBS , searchText = $searchText")
|
|
|
+ onSearchTextChanged.invoke(searchText)
|
|
|
// scope.launch {
|
|
|
// searchListViewModelSplash.searchTextChange(it)
|
|
|
// }
|
|
@@ -835,7 +873,7 @@ fun ColumnScope.OpenModalBottomSheet(
|
|
|
.padding(top = 20.dp, bottom = 40.dp)
|
|
|
) {
|
|
|
Log.d("countryInfoList", "countryInfoList => ${countryInfoList.size}")
|
|
|
- items(countryList, itemContent = { item ->
|
|
|
+ items(countryListDisplayed, itemContent = { item ->
|
|
|
ShowCountryListItem(
|
|
|
item = item,
|
|
|
isSheetOpened = {
|
|
@@ -859,7 +897,10 @@ fun ColumnScope.OpenModalBottomSheet(
|
|
|
fun ColumnScope.SelectCountryInfo(
|
|
|
labelText: Int,
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
- focusManager: FocusManager
|
|
|
+ focusManager: FocusManager,
|
|
|
+ onSearchTextChanged: (String) -> Unit,
|
|
|
+ onCountryList: (List<CountryInfo>, String) -> Unit,
|
|
|
+ countryListDisplayed: List<CountryInfo>
|
|
|
) {
|
|
|
var selectedCountry by remember { mutableStateOf("Please Select") }
|
|
|
var isSheetOpened by remember { mutableStateOf(false) }
|
|
@@ -917,7 +958,14 @@ fun ColumnScope.SelectCountryInfo(
|
|
|
isSheetOpened = {isSheetOpened = false},
|
|
|
onSelectedCountry = { countryName ->
|
|
|
selectedCountry = countryName
|
|
|
- }
|
|
|
+ },
|
|
|
+ onSearchTextChanged = { searchText ->
|
|
|
+ onSearchTextChanged.invoke(searchText)
|
|
|
+ },
|
|
|
+ onCountryList = { list , text ->
|
|
|
+ onCountryList.invoke(list, text)
|
|
|
+ },
|
|
|
+ countryListDisplayed = countryListDisplayed
|
|
|
)
|
|
|
}
|
|
|
}
|
|
@@ -927,7 +975,9 @@ fun ColumnScope.SelectCountryInfoPhoneIcon(
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
focusManager: FocusManager,
|
|
|
labelText: Int,
|
|
|
- extText: Int
|
|
|
+ extText: Int,
|
|
|
+ onCountryList: (List<CountryInfo>, String) -> Unit,
|
|
|
+ countryListDisplayed: List<CountryInfo>
|
|
|
) {
|
|
|
var number by remember { mutableStateOf("") }
|
|
|
var extNumber by remember { mutableStateOf("") }
|
|
@@ -1049,7 +1099,12 @@ fun ColumnScope.SelectCountryInfoPhoneIcon(
|
|
|
onSelectedCountry = { countryCode ->
|
|
|
selectedCountryCode = countryCode
|
|
|
},
|
|
|
- isCountryList = false
|
|
|
+ isCountryList = false,
|
|
|
+ onSearchTextChanged = {},
|
|
|
+ onCountryList = { list , text ->
|
|
|
+ onCountryList.invoke(list, text)
|
|
|
+ },
|
|
|
+ countryListDisplayed = countryListDisplayed
|
|
|
)
|
|
|
}
|
|
|
}
|