浏览代码

Worked on searching of countries on driver license and passport screen and filter search countries on viewmodel

Khubaib 4 月之前
父节点
当前提交
28e7885a29

+ 21 - 4
app/src/main/java/com/fastest/pass/home/presentation/ui/components/AddDriverLicenseFormScreen.kt

@@ -58,9 +58,13 @@ import androidx.compose.ui.text.style.TextAlign
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
 import com.fastest.pass.R
+import com.fastest.pass.home.domain.model.CountryInfo
 
 @Composable
-fun AddDriverLicenseFormScreen() {
+fun AddDriverLicenseFormScreen(
+    onCountryList: (List<CountryInfo>, String) -> Unit,
+    countryListDisplayed: List<CountryInfo>
+) {
     val keyboardController = LocalSoftwareKeyboardController.current
     val focusManager = LocalFocusManager.current
     val gender = listOf("Please Select", "Male", "Female", "Other")
@@ -104,7 +108,15 @@ fun AddDriverLicenseFormScreen() {
             Spacer(modifier = Modifier.height(20.dp))
             NameTextFieldADLFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.zip_postal_code)
             Spacer(modifier = Modifier.height(20.dp))
-            SelectCountryInfoDS(labelText = R.string.country, keyboardController = keyboardController, focusManager = focusManager)
+            SelectCountryInfoDS(
+                labelText = R.string.country,
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                onCountryList = { list, text ->
+                    onCountryList.invoke(list, text)
+                },
+                countryListDisplayed = countryListDisplayed
+            )
 //            NameTextFieldADLFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.country)
 
             Spacer(modifier = Modifier.height(20.dp))
@@ -578,7 +590,9 @@ fun ColumnScope.DropDownFieldADLFS(
 fun ColumnScope.SelectCountryInfoDS(
     labelText: Int,
     keyboardController: SoftwareKeyboardController?,
-    focusManager: FocusManager
+    focusManager: FocusManager,
+    onCountryList: (List<CountryInfo>, String) -> Unit,
+    countryListDisplayed: List<CountryInfo>
 ) {
     var selectedCountry by remember { mutableStateOf("Please Select") }
     var isSheetOpened by remember { mutableStateOf(false) }
@@ -638,7 +652,10 @@ fun ColumnScope.SelectCountryInfoDS(
                 selectedCountry = countryName
             },
             onSearchTextChanged = {},
-            onCountryList = { t , c -> }
+            onCountryList = { list , text ->
+                onCountryList.invoke(list, text)
+            },
+            countryListDisplayed = countryListDisplayed
         )
     }
 }

+ 21 - 4
app/src/main/java/com/fastest/pass/home/presentation/ui/components/AddPassportFormScreen.kt

@@ -58,9 +58,13 @@ import androidx.compose.ui.text.style.TextAlign
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
 import com.fastest.pass.R
+import com.fastest.pass.home.domain.model.CountryInfo
 
 @Composable
-fun AddPassportFormScreen() {
+fun AddPassportFormScreen(
+    onCountryList: (List<CountryInfo>, String) -> Unit,
+    countryListDisplayed: List<CountryInfo>
+) {
     val keyboardController = LocalSoftwareKeyboardController.current
     val focusManager = LocalFocusManager.current
     val gender = listOf("Please Select", "Male", "Female", "Other")
@@ -91,7 +95,15 @@ fun AddPassportFormScreen() {
             Spacer(modifier = Modifier.height(20.dp))
             NameTextFieldAPFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.name)
             Spacer(modifier = Modifier.height(20.dp))
-            SelectCountryInfoPassport(labelText = R.string.country, keyboardController = keyboardController, focusManager = focusManager)
+            SelectCountryInfoPassport(
+                labelText = R.string.country,
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                onCountryList = { list, text ->
+                    onCountryList.invoke(list, text)
+                },
+                countryListDisplayed = countryListDisplayed
+            )
 //            NameTextFieldAPFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.country)
 
             Spacer(modifier = Modifier.height(20.dp))
@@ -476,7 +488,9 @@ fun ColumnScope.NotesTextFieldAPFS(
 fun ColumnScope.SelectCountryInfoPassport(
     labelText: Int,
     keyboardController: SoftwareKeyboardController?,
-    focusManager: FocusManager
+    focusManager: FocusManager,
+    onCountryList: (List<CountryInfo>, String) -> Unit,
+    countryListDisplayed: List<CountryInfo>
 ) {
     var selectedCountry by remember { mutableStateOf("Please Select") }
     var isSheetOpened by remember { mutableStateOf(false) }
@@ -536,7 +550,10 @@ fun ColumnScope.SelectCountryInfoPassport(
                 selectedCountry = countryName
             },
             onSearchTextChanged = {},
-            onCountryList = { t , c -> }
+            onCountryList = { list , text ->
+                onCountryList.invoke(list, text)
+            },
+            countryListDisplayed = countryListDisplayed
         )
     }
 }

+ 12 - 2
app/src/main/java/com/fastest/pass/home/presentation/ui/components/NewItemFormScreen.kt

@@ -109,10 +109,20 @@ fun NewItemFormScreen(
                 )
             }
             ClickTypeAddNewItem.Driver -> {
-                AddDriverLicenseFormScreen()
+                AddDriverLicenseFormScreen(
+                    onCountryList = { list, text ->
+                        onCountryList.invoke(list, text)
+                    },
+                    countryListDisplayed = countryListDisplayed
+                )
             }
             ClickTypeAddNewItem.Passport -> {
-                AddPassportFormScreen()
+                AddPassportFormScreen(
+                    onCountryList = { list, text ->
+                        onCountryList.invoke(list, text)
+                    },
+                    countryListDisplayed = countryListDisplayed
+                )
             }
             ClickTypeAddNewItem.GOTO_HOME -> {}
         }