Browse Source

Showing country dial code on mobile & fax fields also

Khubaib 4 months ago
parent
commit
ab0119faf6

+ 11 - 0
app/src/main/java/com/fastest/pass/account/presentation/ui/components/AccountScreen.kt

@@ -80,6 +80,7 @@ import com.fastest.pass.R
 import com.fastest.pass.account.domain.model.SliderPasswordType
 import com.fastest.pass.account.domain.model.sliderPasswordTypeList
 import com.google.gson.annotations.SerializedName
+import java.security.MessageDigest
 import kotlin.math.roundToInt
 import kotlin.random.Random
 
@@ -180,6 +181,16 @@ fun AccountScreen(clickType: (ClickType) -> Unit) {
             }
         }
     }
+
+    val hash = sha256("FastestPass")
+    Log.d("hash_sha256", "input text: FastestPass")
+    Log.d("hash_sha256", "hash text: $hash")
+}
+
+
+fun sha256(input: String): String {
+    val bytes = MessageDigest.getInstance("SHA-256").digest(input.toByteArray())
+    return bytes.joinToString("") { "%02x".format(it) }
 }
 
 @Composable

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

@@ -199,9 +199,32 @@ fun AddContactInfoScreen(
                 countryListDisplayed = countryListDisplayed
             )
             Spacer(modifier = Modifier.height(20.dp))
-            NumberTextFieldACIFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.mobile, placeholder = R.string.mobile, ImeAction.Next)
+            SelectCountryInfoMobile(
+                keyboardController,
+                focusManager,
+                R.string.mobile,
+                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.fax, placeholder = R.string.fax, ImeAction.Done)
+            SelectCountryInfoMobile(
+                keyboardController,
+                focusManager,
+                R.string.fax,
+                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))
+//            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)
@@ -1110,7 +1133,96 @@ fun ColumnScope.SelectCountryInfoPhoneIcon(
 }
 
 @Composable
-fun ColumnScope.SelectCountryInfoPhoneCGPT(
+fun ColumnScope.SelectCountryInfoMobile(
+    keyboardController: SoftwareKeyboardController?,
+    focusManager: FocusManager,
+    labelText: Int,
+    extText: Int,
+    onCountryList: (List<CountryInfo>, String) -> Unit,
+    countryListDisplayed: List<CountryInfo>
+) {
+    var number by remember { mutableStateOf("") }
+    var extNumber by remember { mutableStateOf("") }
+    var selectedCountryCode by remember { mutableStateOf("+1") }
+    var isSheetOpened by remember { mutableStateOf(false) }
+
+    TextField(
+        value = number,
+        onValueChange = {
+            number = it
+        },
+        textStyle = MaterialTheme.typography.displayMedium.copy(
+            color = colorResource(id = R.color.gray_splash)
+        ),
+        leadingIcon = {
+            Text(
+                text = selectedCountryCode,
+                style = MaterialTheme.typography.displayMedium.copy(
+                    color = colorResource(id = R.color.gray_text)
+                ),
+                modifier = Modifier
+                    .padding(start = 5.dp, bottom = 4.dp)
+                    .clickable {
+                        isSheetOpened = true
+                    }
+            )
+        },
+        modifier = Modifier
+            .fillMaxWidth()
+            .height(60.dp)
+            .border(
+                1.dp,
+                color = colorResource(id = R.color.gray_border_textfield),
+                shape = RoundedCornerShape(16.dp)
+            )
+            .background(
+                color = colorResource(id = R.color.transparent),
+                shape = RoundedCornerShape(16.dp)
+            ),
+        placeholder = {
+            Text(text = stringResource(id = labelText),
+                style = MaterialTheme.typography.displayMedium.copy(
+                    color = colorResource(id = R.color.gray_text)
+                )
+            )
+        },
+        maxLines = 1,
+        colors = TextFieldDefaults.colors(
+            focusedLabelColor = colorResource(id = R.color.gray_splash),
+            unfocusedContainerColor = colorResource(id = R.color.transparent),
+            focusedContainerColor = colorResource(id = R.color.transparent),
+            focusedIndicatorColor = colorResource(id = R.color.transparent),
+            disabledIndicatorColor = colorResource(id = R.color.transparent),
+            unfocusedIndicatorColor = colorResource(id = R.color.transparent),
+            cursorColor = colorResource(id = R.color.gray_splash),
+        ),
+        keyboardOptions = KeyboardOptions(
+            keyboardType = KeyboardType.Number,
+            imeAction = ImeAction.Next
+        ),
+        keyboardActions = KeyboardActions(),
+    )
+
+    if (isSheetOpened) {
+        OpenModalBottomSheet(
+            keyboardController,
+            focusManager,
+            isSheetOpened = {isSheetOpened = false},
+            onSelectedCountry = { countryCode ->
+                selectedCountryCode = countryCode
+            },
+            isCountryList = false,
+            onSearchTextChanged = {},
+            onCountryList = { list , text ->
+                onCountryList.invoke(list, text)
+            },
+            countryListDisplayed = countryListDisplayed
+        )
+    }
+}
+
+@Composable
+fun ColumnScope.SelectCountryInfoPhonecgp(
     keyboardController: SoftwareKeyboardController?,
     focusManager: FocusManager,
     labelText: Int,