Преглед на файлове

Add item API implemented for Contact Info form list

Khubaib преди 1 седмица
родител
ревизия
06a63f5c38

+ 268 - 38
app/src/main/java/com/fastest/pass/home/presentation/ui/components/AddContactInfoScreen.kt

@@ -3,6 +3,7 @@ package com.fastest.pass.home.presentation.ui.components
 import android.util.Log
 import androidx.compose.foundation.BorderStroke
 import androidx.compose.foundation.ExperimentalFoundationApi
+import androidx.compose.foundation.Image
 import androidx.compose.foundation.LocalOverscrollConfiguration
 import androidx.compose.foundation.background
 import androidx.compose.foundation.border
@@ -81,6 +82,8 @@ 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.helpers.BasePreferenceHelper
+import com.fastest.pass.home.data.model.NewItemFormField
 import com.fastest.pass.home.domain.model.CountryInfo
 import com.fastest.pass.home.domain.model.CountryInfoCode
 import com.fastest.pass.home.domain.model.countryInfoList
@@ -96,11 +99,51 @@ import java.util.TimeZone
 fun AddContactInfoScreen(
     onSearchTextChanged: (String) -> Unit,
     onCountryList: (List<CountryInfo>, String) -> Unit,
-    countryListDisplayed: List<CountryInfo>
+    countryListDisplayed: List<CountryInfo>,
+    basePreferenceHelper: BasePreferenceHelper,
+    onContactInfoFormList: (ArrayList<NewItemFormField>, Boolean) -> Unit
 ) {
     val keyboardController = LocalSoftwareKeyboardController.current
     val focusManager = LocalFocusManager.current
 
+    var address_title by remember { mutableStateOf("") }
+    var address_honorific by remember { mutableStateOf("") }
+    var address_first_name by remember { mutableStateOf("") }
+    var address_middle_name by remember { mutableStateOf("") }
+    var address_last_Name by remember { mutableStateOf("") }
+    var address_address_1 by remember { mutableStateOf("") }
+    var address_address_2 by remember { mutableStateOf("") }
+    var address_address_3 by remember { mutableStateOf("") }
+    var address_city_town by remember { mutableStateOf("") }
+    var address_state by remember { mutableStateOf("") }
+    var address_zip_postalcode by remember { mutableStateOf("") }
+    var address_country by remember { mutableStateOf("") }
+    var address_company by remember { mutableStateOf("") }
+    var address_gender by remember { mutableStateOf("") }
+    var address_birthday by remember { mutableStateOf("") }
+    var address_email_address by remember { mutableStateOf("") }
+    var address_phone by remember { mutableStateOf("") }
+    var address_mobile_phone by remember { mutableStateOf("") }
+    var address_fax by remember { mutableStateOf("") }
+    var address_username by remember { mutableStateOf("") }
+    var address_notes by remember { mutableStateOf("") }
+
+    var phone_country_code by remember { mutableStateOf("+1") }
+    var phone_number by remember { mutableStateOf("") }
+    var phone_ext by remember { mutableStateOf("") }
+    val phone_values = listOf(phone_country_code, phone_number, phone_ext).joinToString(", ")
+    address_phone = phone_values
+
+    var mobile_country_code by remember { mutableStateOf("+1") }
+    var mobile_number by remember { mutableStateOf("") }
+    val mobile_values = listOf(mobile_country_code, mobile_number).joinToString(", ")
+    address_mobile_phone = mobile_values
+
+    var fax_country_code by remember { mutableStateOf("+1") }
+    var fax_number by remember { mutableStateOf("") }
+    val fax_values = listOf(fax_country_code, fax_number).joinToString(", ")
+    address_fax = fax_values
+
     val honorific = listOf("Please Select", "Mr", "Mrs", "Ms", "Dr")
     val list = getAllCountriesList()
     val countriesList = ArrayList<String>()
@@ -116,7 +159,61 @@ fun AddContactInfoScreen(
             .background(Color.Transparent)
             .imePadding(),
     ) {
-        SaveButtonACIFS(buttonText = R.string.save)
+        SaveButtonACIFS(
+            buttonText = R.string.save,
+            onSaveButtonClick = {
+                val contactInfoFormList = ArrayList<NewItemFormField>()
+                val saltKey = basePreferenceHelper.getCustomSaltKey()
+                val secretKey = basePreferenceHelper.getCustomSecretKey()
+                val isTitleEmpty = address_title.isEmpty()
+
+                address_title = encryptIfNotEmpty(address_title, secretKey, saltKey)
+                address_honorific = encryptIfNotEmpty(address_honorific, secretKey, saltKey)
+                address_first_name = encryptIfNotEmpty(address_first_name, secretKey, saltKey)
+                address_middle_name = encryptIfNotEmpty(address_middle_name, secretKey, saltKey)
+                address_last_Name = encryptIfNotEmpty(address_last_Name, secretKey, saltKey)
+                address_address_1 = encryptIfNotEmpty(address_address_1, secretKey, saltKey)
+                address_address_2 = encryptIfNotEmpty(address_address_2, secretKey, saltKey)
+                address_address_3 = encryptIfNotEmpty(address_address_3, secretKey, saltKey)
+                address_city_town = encryptIfNotEmpty(address_city_town, secretKey, saltKey)
+                address_state = encryptIfNotEmpty(address_state, secretKey, saltKey)
+                address_zip_postalcode = encryptIfNotEmpty(address_zip_postalcode, secretKey, saltKey)
+                address_country = encryptIfNotEmpty(address_country, secretKey, saltKey)
+                address_company = encryptIfNotEmpty(address_company, secretKey, saltKey)
+                address_gender = encryptIfNotEmpty(address_gender, secretKey, saltKey)
+                address_birthday = encryptIfNotEmpty(address_birthday, secretKey, saltKey)
+                address_email_address = encryptIfNotEmpty(address_email_address, secretKey, saltKey)
+                address_phone = encryptIfNotEmpty(address_phone, secretKey, saltKey)
+                address_mobile_phone = encryptIfNotEmpty(address_mobile_phone, secretKey, saltKey)
+                address_fax = encryptIfNotEmpty(address_fax, secretKey, saltKey)
+                address_username = encryptIfNotEmpty(address_username, secretKey, saltKey)
+                address_notes = encryptIfNotEmpty(address_notes, secretKey, saltKey)
+
+                contactInfoFormList.add(NewItemFormField("address_title", address_title))
+                contactInfoFormList.add(NewItemFormField("address_honorific", address_honorific))
+                contactInfoFormList.add(NewItemFormField("address_first_name", address_first_name))
+                contactInfoFormList.add(NewItemFormField("address_middle_name", address_middle_name))
+                contactInfoFormList.add(NewItemFormField("address_last_Name", address_last_Name))
+                contactInfoFormList.add(NewItemFormField("address_address_1", address_address_1))
+                contactInfoFormList.add(NewItemFormField("address_address_2", address_address_2))
+                contactInfoFormList.add(NewItemFormField("address_address_3", address_address_3))
+                contactInfoFormList.add(NewItemFormField("address_city_town", address_city_town))
+                contactInfoFormList.add(NewItemFormField("address_state", address_state))
+                contactInfoFormList.add(NewItemFormField("address_zip_postalcode", address_zip_postalcode))
+                contactInfoFormList.add(NewItemFormField("address_country", address_country))
+                contactInfoFormList.add(NewItemFormField("address_company", address_company))
+                contactInfoFormList.add(NewItemFormField("address_gender", address_gender))
+                contactInfoFormList.add(NewItemFormField("address_birthday", address_birthday))
+                contactInfoFormList.add(NewItemFormField("address_email_address", address_email_address))
+                contactInfoFormList.add(NewItemFormField("address_phone", address_phone))
+                contactInfoFormList.add(NewItemFormField("address_mobile_phone", address_mobile_phone))
+                contactInfoFormList.add(NewItemFormField("address_fax", address_fax))
+                contactInfoFormList.add(NewItemFormField("address_username", address_username))
+                contactInfoFormList.add(NewItemFormField("address_notes", address_notes))
+
+                onContactInfoFormList.invoke(contactInfoFormList, isTitleEmpty)
+            }
+        )
 
         Column(
             modifier = Modifier
@@ -127,33 +224,89 @@ fun AddContactInfoScreen(
                 .verticalScroll(rememberScrollState())
         ) {
             Spacer(modifier = Modifier.height(20.dp))
-            NameTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.title)
+            NameTextFieldACIFS(
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                labelText = R.string.title,
+                onText = { address_title = it }
+            )
 
             Spacer(modifier = Modifier.height(20.dp))
-            DropDownFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.honorific, honorific)
+            DropDownFieldACIFS(
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                labelText = R.string.honorific,
+                honorific,
+                onText = { address_honorific = it }
+            )
 
             Spacer(modifier = Modifier.height(20.dp))
-            NameTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.first_name)
+            NameTextFieldACIFS(
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                labelText = R.string.first_name,
+                onText = { address_first_name = it }
+            )
             Spacer(modifier = Modifier.height(20.dp))
-            NameTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.middle_name)
+            NameTextFieldACIFS(
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                labelText = R.string.middle_name,
+                onText = { address_middle_name = it }
+            )
             Spacer(modifier = Modifier.height(20.dp))
-            NameTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.last_name)
+            NameTextFieldACIFS(
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                labelText = R.string.last_name,
+                onText = { address_last_Name = it }
+            )
 
             Spacer(modifier = Modifier.height(20.dp))
-            NameTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.address1)
+            NameTextFieldACIFS(
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                labelText = R.string.address1,
+                onText = { address_address_1 = it }
+            )
             Spacer(modifier = Modifier.height(20.dp))
-            NameTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.address2)
+            NameTextFieldACIFS(
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                labelText = R.string.address2,
+                onText = { address_address_2 = it }
+            )
             Spacer(modifier = Modifier.height(20.dp))
-            NameTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.address3)
+            NameTextFieldACIFS(
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                labelText = R.string.address3,
+                onText = { address_address_3 = it }
+            )
 
             Spacer(modifier = Modifier.height(20.dp))
-            NameTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.city_town)
+            NameTextFieldACIFS(
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                labelText = R.string.city_town,
+                onText = { address_city_town = it }
+            )
 //            Spacer(modifier = Modifier.height(20.dp))
 //            NameTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.country)
             Spacer(modifier = Modifier.height(20.dp))
-            NameTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.state)
+            NameTextFieldACIFS(
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                labelText = R.string.state,
+                onText = { address_state = it }
+            )
             Spacer(modifier = Modifier.height(20.dp))
-            NameTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.zip_postal_code)
+            NameTextFieldACIFS(
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                labelText = R.string.zip_postal_code,
+                onText = { address_zip_postalcode = it }
+            )
 
             Spacer(modifier = Modifier.height(20.dp))
             SelectCountryInfo(
@@ -166,7 +319,8 @@ fun AddContactInfoScreen(
                 onCountryList = { list, text ->
                     onCountryList.invoke(list, text)
                 },
-                countryListDisplayed = countryListDisplayed
+                countryListDisplayed = countryListDisplayed,
+                onText = { address_country = it }
             )
 
 //        DropDownFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.country, countriesList)
@@ -175,20 +329,37 @@ fun AddContactInfoScreen(
 //        DropDownFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.time_zone, timezoneList, topPadding = 10)
 
             Spacer(modifier = Modifier.height(20.dp))
-            NameTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.company)
+            NameTextFieldACIFS(
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                labelText = R.string.company,
+                onText = { address_company = it }
+            )
             Spacer(modifier = Modifier.height(20.dp))
-            DropDownFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.gender, gender)
+            DropDownFieldACIFS(
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                labelText = R.string.gender,
+                gender,
+                onText = { address_gender = it }
+            )
 
             Spacer(modifier = Modifier.height(20.dp))
-            DatePickerACIFS(labelText = R.string.birthday) { selectedDate ->
-
-            }
+            DatePickerACIFS(
+                labelText = R.string.birthday,
+                onDateSelected = { address_birthday = it }
+                )
 
             Spacer(modifier = Modifier.height(20.dp))
-            EmailFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, R.string.enter_email_address)
+            EmailFieldACIFS(
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                R.string.enter_email_address,
+                onText = { address_email_address = it }
+            )
 
             Spacer(modifier = Modifier.height(20.dp))
-            SelectCountryInfoPhoneIcon(
+            SelectCountryInfoPhoneIcon( // Phone Field
                 keyboardController,
                 focusManager,
                 R.string.phone,
@@ -196,10 +367,13 @@ fun AddContactInfoScreen(
                 onCountryList = { list, text ->
                     onCountryList.invoke(list, text)
                 },
-                countryListDisplayed = countryListDisplayed
+                countryListDisplayed = countryListDisplayed,
+                onCountryCode = { phone_country_code = it },
+                onNumber = { phone_number = it },
+                onExt = { phone_ext = it }
             )
             Spacer(modifier = Modifier.height(20.dp))
-            SelectCountryInfoMobile(
+            SelectCountryInfoMobile(    // Mobile Field
                 keyboardController,
                 focusManager,
                 R.string.mobile,
@@ -207,10 +381,12 @@ fun AddContactInfoScreen(
                 onCountryList = { list, text ->
                     onCountryList.invoke(list, text)
                 },
-                countryListDisplayed = countryListDisplayed
+                countryListDisplayed = countryListDisplayed,
+                onCountryCode = { mobile_country_code = it },
+                onNumber = { mobile_number = it }
             )
             Spacer(modifier = Modifier.height(20.dp))
-            SelectCountryInfoMobile(
+            SelectCountryInfoMobile(    // Fax Field
                 keyboardController,
                 focusManager,
                 R.string.fax,
@@ -218,7 +394,9 @@ fun AddContactInfoScreen(
                 onCountryList = { list, text ->
                     onCountryList.invoke(list, text)
                 },
-                countryListDisplayed = countryListDisplayed
+                countryListDisplayed = countryListDisplayed,
+                onCountryCode = { fax_country_code = it },
+                onNumber = { fax_number = it }
             )
 
 //            Spacer(modifier = Modifier.height(20.dp))
@@ -227,10 +405,19 @@ fun AddContactInfoScreen(
 //            NumberTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.fax, placeholder = R.string.fax, ImeAction.Done)
 
             Spacer(modifier = Modifier.height(20.dp))
-            NameTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.username)
+            NameTextFieldACIFS(
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                labelText = R.string.username,
+                onText = { address_username = it }
+            )
 
             Spacer(modifier = Modifier.height(20.dp))
-            NotesTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager)
+            NotesTextFieldACIFS(
+                keyboardController = keyboardController,
+                focusManager = focusManager,
+                onText = { address_notes = it }
+            )
         }
     }
 }
@@ -239,7 +426,8 @@ fun AddContactInfoScreen(
 fun ColumnScope.NameTextFieldACIFS(
     keyboardController: SoftwareKeyboardController?,
     focusManager: FocusManager,
-    labelText: Int
+    labelText: Int,
+    onText: (String) -> Unit
 ) {
     var text by remember { mutableStateOf("") }
 
@@ -247,6 +435,7 @@ fun ColumnScope.NameTextFieldACIFS(
         value = text,
         onValueChange = {
             text = it
+            onText.invoke(text)
         },
         textStyle = MaterialTheme.typography.displayMedium,
         modifier = Modifier
@@ -312,7 +501,8 @@ fun ColumnScope.DropDownFieldACIFS(
     focusManager: FocusManager,
     labelText: Int,
     titles: List<String>,
-    topPadding: Int = 0
+    topPadding: Int = 0,
+    onText: (String) -> Unit
 ) {
     var isExpanded by remember { mutableStateOf(false) }
     var selectedText by remember { mutableStateOf(titles[0]) }
@@ -395,6 +585,7 @@ fun ColumnScope.DropDownFieldACIFS(
                            onClick = {
                                selectedText = s
                                isExpanded = false
+                               onText.invoke(selectedText)
                            },
                            modifier = Modifier
                                .background(colorResource(id = R.color.white))
@@ -417,6 +608,8 @@ fun ColumnScope.DatePickerACIFS(
     var selectedDateMillis by remember { mutableStateOf<Long?>(null) }
     var showDatePicker by remember { mutableStateOf(false) }
 
+    Log.d("selectedDate", "selectedDate = $selectedDate")
+
     Column(
         modifier = Modifier
             .fillMaxWidth()
@@ -442,6 +635,14 @@ fun ColumnScope.DatePickerACIFS(
                     tint = colorResource(id = R.color.gray_text)
                     )
             },
+            trailingIcon = {
+                Icon(
+                    painter = painterResource(id = R.drawable.arrow_right),
+                    contentDescription = "description",
+                    modifier = Modifier.size(24.dp),
+                    tint = colorResource(id = R.color.gray_text)
+                )
+            },
             modifier = Modifier
                 .align(Alignment.Start)
                 .fillMaxWidth()
@@ -488,7 +689,7 @@ fun ColumnScope.DatePickerACIFS(
                         if (selectedMillis != null) {
                             val formattedDate = convertMillisToFormattedDate(selectedMillis)
                             selectedDate = formattedDate
-                            onDateSelected(selectedDate)
+                            onDateSelected.invoke(selectedDate)
                             selectedDateMillis = selectedMillis
                             showDatePicker = false
                         }
@@ -517,7 +718,8 @@ fun ColumnScope.DatePickerACIFS(
 fun ColumnScope.EmailFieldACIFS(
     keyboardController: SoftwareKeyboardController?,
     focusManager: FocusManager,
-    labelText: Int
+    labelText: Int,
+    onText: (String) -> Unit
 ) {
     var emailText by remember { mutableStateOf("") }
 
@@ -525,6 +727,7 @@ fun ColumnScope.EmailFieldACIFS(
         value = emailText,
         onValueChange = {
             emailText = it
+            onText.invoke(emailText)
         },
         textStyle = MaterialTheme.typography.displayMedium,
         modifier = Modifier
@@ -923,7 +1126,8 @@ fun ColumnScope.SelectCountryInfo(
     focusManager: FocusManager,
     onSearchTextChanged: (String) -> Unit,
     onCountryList: (List<CountryInfo>, String) -> Unit,
-    countryListDisplayed: List<CountryInfo>
+    countryListDisplayed: List<CountryInfo>,
+    onText: (String) -> Unit
 ) {
     var selectedCountry by remember { mutableStateOf("Please Select") }
     var isSheetOpened by remember { mutableStateOf(false) }
@@ -958,6 +1162,14 @@ fun ColumnScope.SelectCountryInfo(
                 isSheetOpened = true
             },
         shape = RoundedCornerShape(16.dp),
+        trailingIcon = {
+            Icon(
+                painter = painterResource(id = R.drawable.arrow_right),
+                contentDescription = "description",
+                modifier = Modifier.size(24.dp),
+                tint = colorResource(id = R.color.gray_text)
+            )
+        },
         enabled = false,
         colors = TextFieldDefaults.colors(
             disabledContainerColor = colorResource(id = R.color.transparent),
@@ -981,6 +1193,7 @@ fun ColumnScope.SelectCountryInfo(
             isSheetOpened = {isSheetOpened = false},
             onSelectedCountry = { countryName ->
                 selectedCountry = countryName
+                onText.invoke(selectedCountry)
             },
             onSearchTextChanged = { searchText ->
                 onSearchTextChanged.invoke(searchText)
@@ -1000,7 +1213,10 @@ fun ColumnScope.SelectCountryInfoPhoneIcon(
     labelText: Int,
     extText: Int,
     onCountryList: (List<CountryInfo>, String) -> Unit,
-    countryListDisplayed: List<CountryInfo>
+    countryListDisplayed: List<CountryInfo>,
+    onCountryCode: (String) -> Unit,
+    onNumber: (String) -> Unit,
+    onExt: (String) -> Unit
 ) {
     var number by remember { mutableStateOf("") }
     var extNumber by remember { mutableStateOf("") }
@@ -1016,6 +1232,7 @@ fun ColumnScope.SelectCountryInfoPhoneIcon(
             value = number,
             onValueChange = {
                 number = it
+                onNumber.invoke(number)
             },
             textStyle = MaterialTheme.typography.displayMedium.copy(
                 color = colorResource(id = R.color.gray_splash)
@@ -1077,6 +1294,7 @@ fun ColumnScope.SelectCountryInfoPhoneIcon(
             value = extNumber,
             onValueChange = {
                 extNumber = it
+                onExt.invoke(extNumber)
             },
             textStyle = MaterialTheme.typography.displayMedium,
             modifier = Modifier
@@ -1121,6 +1339,7 @@ fun ColumnScope.SelectCountryInfoPhoneIcon(
             isSheetOpened = {isSheetOpened = false},
             onSelectedCountry = { countryCode ->
                 selectedCountryCode = countryCode
+                onCountryCode.invoke(selectedCountryCode)
             },
             isCountryList = false,
             onSearchTextChanged = {},
@@ -1139,7 +1358,9 @@ fun ColumnScope.SelectCountryInfoMobile(
     labelText: Int,
     extText: Int,
     onCountryList: (List<CountryInfo>, String) -> Unit,
-    countryListDisplayed: List<CountryInfo>
+    countryListDisplayed: List<CountryInfo>,
+    onCountryCode: (String) -> Unit,
+    onNumber: (String) -> Unit
 ) {
     var number by remember { mutableStateOf("") }
     var extNumber by remember { mutableStateOf("") }
@@ -1150,6 +1371,7 @@ fun ColumnScope.SelectCountryInfoMobile(
         value = number,
         onValueChange = {
             number = it
+            onNumber.invoke(number)
         },
         textStyle = MaterialTheme.typography.displayMedium.copy(
             color = colorResource(id = R.color.gray_splash)
@@ -1210,6 +1432,7 @@ fun ColumnScope.SelectCountryInfoMobile(
             isSheetOpened = {isSheetOpened = false},
             onSelectedCountry = { countryCode ->
                 selectedCountryCode = countryCode
+                onCountryCode.invoke(selectedCountryCode)
             },
             isCountryList = false,
             onSearchTextChanged = {},
@@ -1523,7 +1746,10 @@ fun ColumnScope.NumberTextFieldACIFS(
 }
 
 @Composable
-fun BoxScope.SaveButtonACIFS(buttonText: Int) {
+fun BoxScope.SaveButtonACIFS(
+    buttonText: Int,
+    onSaveButtonClick: () -> Unit
+    ) {
     Button(
         modifier = Modifier
             .background(colorResource(id = R.color.transparent))
@@ -1531,7 +1757,9 @@ fun BoxScope.SaveButtonACIFS(buttonText: Int) {
             .height(60.dp)
             .align(Alignment.BottomCenter)
             .clickable() { },
-        onClick = {},
+        onClick = {
+            onSaveButtonClick.invoke()
+        },
         shape = RoundedCornerShape(15.dp),
 //            border = BorderStroke(25.dp, colorResource(id = R.color.black)),
         colors = ButtonDefaults.buttonColors(
@@ -1554,7 +1782,8 @@ fun BoxScope.SaveButtonACIFS(buttonText: Int) {
 @Composable
 fun ColumnScope.NotesTextFieldACIFS(
     keyboardController: SoftwareKeyboardController?,
-    focusManager: FocusManager
+    focusManager: FocusManager,
+    onText: (String) -> Unit
 ) {
     var notesText by remember { mutableStateOf("") }
 
@@ -1562,6 +1791,7 @@ fun ColumnScope.NotesTextFieldACIFS(
         value = notesText,
         onValueChange = {
             notesText = it
+            onText.invoke(notesText)
         },
         textStyle = MaterialTheme.typography.displayMedium,
         modifier = Modifier

+ 0 - 1
app/src/main/java/com/fastest/pass/home/presentation/ui/components/AddPasswordFormScreen.kt

@@ -95,7 +95,6 @@ fun AddPasswordFormScreen(
                 val passwordsFormList = ArrayList<NewItemFormField>()
                 val saltKey = basePreferenceHelper.getCustomSaltKey()
                 val secretKey = basePreferenceHelper.getCustomSecretKey()
-
                 val isTitleEmpty = passwords_title.isEmpty()
                 val isPasswordEmpty = passwords_password.isEmpty()
 

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

@@ -56,6 +56,7 @@ fun NewItemFormScreen(
     onPaymentCardFormList: (ArrayList<NewItemFormField>, Boolean) -> Unit,
     onWifiPasswordFormList: (ArrayList<NewItemFormField>, Boolean) -> Unit,
     onSecureNoteFormList: (ArrayList<NewItemFormField>, Boolean) -> Unit,
+    onContactInfoFormList: (ArrayList<NewItemFormField>, Boolean) -> Unit,
 ) {
     val keyboardController = LocalSoftwareKeyboardController.current
     val focusManager = LocalFocusManager.current
@@ -132,14 +133,16 @@ fun NewItemFormScreen(
             ClickTypeAddNewItem.Contact -> {
                 AddContactInfoScreen(
                     onSearchTextChanged = { searchText ->
-                        Log.d("searchText", "NIFS => searchText = $searchText")
                         onSearchTextChanged.invoke(searchText)
                     },
                     onCountryList = { list, text ->
-                        Log.d("searchText", "NIFS => list = ${list.size}")
                         onCountryList.invoke(list, text)
                     },
-                    countryListDisplayed = countryListDisplayed
+                    countryListDisplayed = countryListDisplayed,
+                    basePreferenceHelper = basePreferenceHelper,
+                    onContactInfoFormList = { data, boolean ->
+                        onContactInfoFormList.invoke(data, boolean)
+                    }
                 )
             }
             ClickTypeAddNewItem.Driver -> {

+ 13 - 0
app/src/main/java/com/fastest/pass/home/presentation/ui/fragment/NewItemFormFragment.kt

@@ -178,6 +178,19 @@ class NewItemFormFragment : BaseFragment() {
                                     else {
                                         viewmodel.addItems("notes", secureNoteFormData)
                                     }
+                                },
+                                onContactInfoFormList = { contactInfoFormData, isTitleEmpty ->
+                                    contactInfoFormData.forEachIndexed { i, data ->
+                                        Log.d("contactInfoFormData", "data = ${data.key} , ${data.value}")
+                                    }
+                                    if (isTitleEmpty) {
+                                        coroutineScope.launch {
+                                            snackBarStateRed.showSnackbar("Title field is empty.")
+                                        }
+                                    }
+                                    else {
+                                        viewmodel.addItems("address", contactInfoFormData)
+                                    }
                                 }
                             )