Browse Source

added snackbar validation on onBoarding screens

Khubaib 1 year ago
parent
commit
91ae98abcb

+ 14 - 1
.idea/deploymentTargetDropDown.xml

@@ -6,7 +6,20 @@
         <State />
       </entry>
       <entry key="app">
-        <State />
+        <State>
+          <targetSelectedWithDropDown>
+            <Target>
+              <type value="QUICK_BOOT_TARGET" />
+              <deviceKey>
+                <Key>
+                  <type value="VIRTUAL_DEVICE_PATH" />
+                  <value value="$USER_HOME$/.android/avd/Small_Phone_API_27.avd" />
+                </Key>
+              </deviceKey>
+            </Target>
+          </targetSelectedWithDropDown>
+          <timeTargetWasSelectedWithDropDown value="2024-04-18T09:19:39.746048075Z" />
+        </State>
       </entry>
     </value>
   </component>

+ 35 - 321
app/src/main/java/com/vpn/fastestvpnservice/screens/LoginScreen.kt

@@ -112,6 +112,7 @@ fun Login(navHostController: NavHostController) {
     val context = LocalContext.current
     val basePreferenceHelper = BasePreferenceHelper(context)
     val snackBarState = remember { SnackbarHostState() }
+    val coroutineScope = rememberCoroutineScope()
 
     Scaffold(
         content = { padding ->
@@ -134,7 +135,7 @@ fun Login(navHostController: NavHostController) {
                         }
                     },
             ) {
-                ShowCustomSnackBar(snackBarState)
+                ShowCustomSnackBar(snackBarState, R.color.yellow_text, R.color.dark_blue_gray_text)
                 if (loginViewModel.liveDataLoginStatus.value == true) {
                     var progress by remember { mutableFloatStateOf(0.1F) }
 
@@ -158,6 +159,11 @@ fun Login(navHostController: NavHostController) {
                     )
                 }
 
+//                LaunchedEffect(key1 = Unit) {
+//                    Log.d("test_snackbar", "sb $showErrorEmail")
+//
+//                }
+
                 Image(
                     painter = painterResource(
                         id = R.drawable.fastestapp_logo3x),
@@ -251,9 +257,7 @@ fun Login(navHostController: NavHostController) {
                             ),
                             )
 
-//                        if (showErrorEmail) {
-//                            ShowErrorRow(errorText = "Email is Empty")
-//                        }
+
 
                         Spacer(modifier = Modifier.height(20.dp))
 
@@ -366,12 +370,7 @@ fun Login(navHostController: NavHostController) {
                             }
                         )
 
-//                        if (showErrorPass1) {
-//                            ShowErrorRow(errorText = "Password is Empty")
-//                        }
-//                        else if (showErrorPass2) {
-//                            ShowErrorRow(errorText = "Should be 3 or more!")
-//                        }
+
 
                         Spacer(modifier = Modifier.height(20.dp))
                         ClickableText(
@@ -426,316 +425,6 @@ fun Login(navHostController: NavHostController) {
 }
 
 @Composable
-fun Login2(navHostController: NavHostController) {
-    val keyboardController = LocalSoftwareKeyboardController.current
-    val focusManager = LocalFocusManager.current
-    val random = Random.nextInt(1,999)
-    val loginViewModel: LoginViewModel = viewModel()
-    val readOnly = loginViewModel.liveDataLoginStatus.observeAsState().value
-    var textChanged by remember { mutableStateOf("") }
-    var passwordChanged by remember { mutableStateOf("") }
-    var passwordVisible by remember { mutableStateOf(false) }
-    var showErrorEmail by remember { mutableStateOf(false) }
-    var showErrorPass1 by remember { mutableStateOf(false) }
-    var showErrorPass2 by remember { mutableStateOf(false) }
-    val context = LocalContext.current
-    val basePreferenceHelper = BasePreferenceHelper(context)
-    val snackBarState = remember { SnackbarHostState() }
-
-    Scaffold(
-        content = { padding ->
-            Box(
-                modifier = Modifier
-                    .fillMaxSize()
-                    .paint(
-                        painter = painterResource(id = if (isDarkTheme.value) R.drawable.bg_app else R.drawable.bg_img3),
-                        contentScale = ContentScale.FillBounds
-                    )
-                    .alpha(if (readOnly == true) 0.6F else 1F)
-//            .background(
-//                if (isSystemInDarkTheme()) Color.Black
-//                else Color.Transparent
-//            )
-                    .pointerInput(Unit) {
-                        detectTapGestures {
-                            focusManager.clearFocus()
-                            keyboardController?.hide()
-                        }
-                    },
-            ) {
-                ShowCustomSnackBar(snackBarState)
-
-                Column (
-                    modifier = Modifier
-                        .fillMaxHeight()
-                        .fillMaxWidth()
-                    ,
-                    verticalArrangement = Arrangement.Top,
-                    horizontalAlignment = Alignment.CenterHorizontally
-                ) {
-                    Spacer(modifier = Modifier.height(132.dp))
-                    Image(
-                        painter = painterResource(
-                            id = R.drawable.fastestapp_logo3x),
-                        contentDescription = "FastestVPN",
-                        modifier = Modifier
-                            .size(width = 75.dp, height = 102.dp)
-                            .background(Color.Transparent)
-                            .padding(top = 0.dp)
-                        ,
-                    )
-                    Spacer(modifier = Modifier.height(50.dp))
-
-                    TextMsg(
-                        text = "Welcome Back!",
-                        color = Color.White,
-                        style = MaterialTheme.typography.displayLarge
-                    )
-                    Spacer(modifier = Modifier.height(8.dp))
-                    TextMsg(
-                        text = "Please login to your account.",
-                        color = colorResource(id = R.color.white),
-                        style = MaterialTheme.typography.customTypography.labelLarge,
-                        alpha = 0.6F
-                    )
-
-                    Spacer(modifier = Modifier.height(20.dp))
-
-
-                    TextField(
-                        value = textChanged,
-                        onValueChange = {
-                            textChanged = it
-                        },
-                        readOnly = readOnly!!,
-                        textStyle = MaterialTheme.typography.customTypography.bodyMedium,
-                        modifier = Modifier
-                            .padding(start = 15.dp, end = 15.dp)
-                            .align(Alignment.Start)
-                            .fillMaxWidth()
-                            .height(60.dp)
-                            .border(
-                                1.dp,
-                                color = if (showErrorEmail) colorResource(id = R.color.red)
-                                else colorResource(id = R.color.white),
-                                shape = RoundedCornerShape(16.dp)
-                            )
-                            .clickable() { },
-
-//                placeholder = {
-//                    Text(text = "Enter email address",
-//                        color = colorResource(id = R.color.white))
-//                },
-                        label = {
-                            Text(text = "Email",
-                                style = MaterialTheme.typography.customTypography.bodySmall
-                            )
-                        },
-                        leadingIcon = {
-                            Icon(
-                                painter = painterResource(id = R.drawable.sms3x),
-                                contentDescription = "Email Logo",
-                                tint = colorResource(id = R.color.white),
-                                modifier = Modifier
-                                    .size(24.dp, 24.dp)
-                            )
-                        },
-                        maxLines = 1,
-                        colors = TextFieldDefaults.colors(
-                            focusedLabelColor = Color.Blue,
-                            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.white)
-                        ),
-                        keyboardOptions = KeyboardOptions(
-                            keyboardType = KeyboardType.Email,
-                            imeAction = ImeAction.Done
-                        ),
-                        keyboardActions = KeyboardActions(
-                            onDone = {
-                                focusManager.clearFocus()
-                                keyboardController?.hide()
-                            }
-                        ),
-
-                        )
-
-                    if (showErrorEmail) {
-                        ShowErrorRow(errorText = "Email is Empty")
-                    }
-
-                    Spacer(modifier = Modifier.height(20.dp))
-
-                    val color = if (showErrorPass1) {
-                        colorResource(id = R.color.red)
-                    }
-                    else if (showErrorPass2) {
-                        colorResource(id = R.color.red)
-                    }
-                    else {
-                        MaterialTheme.colorScheme.secondaryContainer
-                    }
-
-                    TextField(
-                        value = passwordChanged,
-                        onValueChange = {
-//                            Log.d("onClick_test", "onValueChange -> ")
-                            passwordChanged = it
-                        },
-                        readOnly = readOnly,
-
-                        textStyle = MaterialTheme.typography.customTypography.bodyLarge,
-                        modifier = Modifier
-                            .padding(start = 15.dp, end = 15.dp)
-                            .align(Alignment.Start)
-                            .fillMaxWidth()
-                            .height(60.dp)
-                            .border(
-                                1.dp,
-                                color = color,
-                                shape = RoundedCornerShape(16.dp)
-                            )
-                            .background(color = colorResource(id = R.color.transparent))
-                            .clickable() {},
-
-                        shape = RoundedCornerShape(15.dp),
-//                placeholder = {
-//                    Text(text = "Enter password",
-//                        color = colorResource(id = R.color.white))
-//                },
-                        label = {
-                            Text(text = "Password",
-                                style = MaterialTheme.typography.customTypography.bodyLarge
-                            )
-                        },
-                        leadingIcon = {
-                            Icon(
-                                painter = painterResource(id = R.drawable.lock3x),
-                                contentDescription = "Password Logo",
-                                tint = colorResource(id = R.color.white),
-                                modifier = Modifier
-                                    .size(24.dp, 24.dp)
-                            )
-                        },
-                        maxLines = 1,
-                        colors = TextFieldDefaults.colors(
-                            focusedLabelColor = Color.Blue,
-                            unfocusedContainerColor = MaterialTheme.colorScheme.secondaryContainer,
-                            focusedContainerColor = MaterialTheme.colorScheme.secondaryContainer,
-                            focusedIndicatorColor = colorResource(id = R.color.transparent),
-                            disabledIndicatorColor = colorResource(id = R.color.transparent),
-                            unfocusedIndicatorColor = colorResource(id = R.color.transparent),
-                            cursorColor = colorResource(id = R.color.white)
-                        ),
-                        keyboardOptions = KeyboardOptions(
-                            keyboardType = KeyboardType.Password,
-                            imeAction = ImeAction.Done
-                        ),
-                        keyboardActions = KeyboardActions(
-                            onDone = {
-                                focusManager.clearFocus()
-                                keyboardController?.hide()
-                            }
-                        ),
-                        visualTransformation =
-                        if (passwordVisible) VisualTransformation.Companion.None
-                        else PasswordVisualTransformation(),
-
-                        trailingIcon = {
-//                    val image
-//                            = if (passwordVisible) Icons.Filled.Visibility
-//                    else Icons.Filled.VisibilityOff
-
-                            val description = if (passwordVisible) "Hide Password"
-                            else "Show Password"
-
-                            IconButton(onClick = {
-                                if (!readOnly) {
-                                    passwordVisible = !passwordVisible
-                                }
-                            })
-                            {
-                                if (passwordVisible) {
-                                    Icon(
-                                        imageVector = Icons.Outlined.Visibility,
-                                        contentDescription = description,
-                                        tint = colorResource(id = R.color.white),
-                                        modifier = Modifier.size(24.dp)
-                                    )
-                                }
-                                else {
-                                    Icon(
-                                        painter = painterResource(id = R.drawable.eye_slash3x),
-                                        contentDescription = description,
-                                        tint = colorResource(id = R.color.white),
-                                        modifier = Modifier.size(24.dp)
-                                    )
-                                }
-                            }
-                        }
-                    )
-
-                    if (showErrorPass1) {
-                        ShowErrorRow(errorText = "Password is Empty")
-                    }
-                    else if (showErrorPass2) {
-                        ShowErrorRow(errorText = "Should be 3 or more!")
-                    }
-
-
-                    Spacer(modifier = Modifier.height(20.dp))
-                    ClickableText(
-                        onClick = {
-                            if (!readOnly) {
-//                                Log.d("onClick_test", "Forgot Password Clicked")
-                                navHostController.navigate(Screen.ForgotPassword.route)
-                            }
-                        },
-                        modifier = Modifier
-                            .padding(end = 15.dp)
-                            .align(Alignment.End),
-                        style = MaterialTheme.typography.customTypography.titleSmall,
-                        text = AnnotatedString("Forgot Password"),
-                    )
-
-                }
-
-//                SignInButton(
-//                    navHostController = navHostController,
-//                    textChanged,
-//                    passwordChanged,
-//                    loginViewModel = loginViewModel,
-//                    basePreferenceHelper,
-//                    showErrorEmail = {
-//                        showErrorEmail = it
-//                    },
-//                    showErrorEmail,
-//                    showErrorPass = {
-//                        showErrorPass1 = it
-//                    },
-//                    showErrorPass1,
-//                    showErrorPass2 = {
-//                        showErrorPass2 = it
-//                    },
-//                    showErrorPass2,
-//                    snackBarState
-//                )
-                Row (
-                    modifier = Modifier
-                        .align(Alignment.BottomCenter)
-                        .padding(57.dp),
-                ){
-                    TextMsgSignUp(navHostController = navHostController, loginViewModel, readOnly!!)
-                }
-            }
-        }
-    )
-}
-
-@Composable
 fun ColumnScope.ShowErrorRow(
     errorText: String
 ) {
@@ -830,6 +519,8 @@ fun ColumnScope.SignInButton(
         }
     }
 
+
+
     Button(
         modifier = Modifier
             .padding(
@@ -854,6 +545,28 @@ fun ColumnScope.SignInButton(
                 showErrorPass2(!isError2)
             }
 
+            Log.d("test_snackbar", "sb in = $isErrors")
+
+            if (!isErrors) {
+//                            ShowErrorRow(errorText = "Email is Empty")
+                coroutineScope.launch {
+                    snackBarState.showSnackbar("Email is Empty")
+                }
+            }
+            else if (!isError1) {
+//                            ShowErrorRow(errorText = "Password is Empty")
+                coroutineScope.launch {
+                    snackBarState.showSnackbar("Password is Empty")
+                }
+            }
+            else if (!isError2) {
+//                            ShowErrorRow(errorText = "Should be 3 or more!")
+                coroutineScope.launch {
+                    snackBarState.showSnackbar("Password should be 3 or more!")
+                }
+            }
+
+
 //            showLoader = true
             if (loginViewModel.liveDataLoginStatus.value == false) {
 //                Log.d("test_api_response live", "SignIn: $email $password")
@@ -874,7 +587,6 @@ fun ColumnScope.SignInButton(
                         )
                     }
                 }
-
             }
         },
         shape = RoundedCornerShape(15.dp),
@@ -996,6 +708,8 @@ fun ColumnScope.SignInButton(
             }
             loginViewModel.mutableLiveDataUserResponse.value = null
         }
+
+
     }
 }
 

+ 27 - 433
app/src/main/java/com/vpn/fastestvpnservice/screens/SignUpScreen.kt

@@ -130,7 +130,7 @@ fun SignUp(navHostController: NavHostController) {
                     }
                     ,
             ) {
-                ShowCustomSnackBar(snackBarState)
+                ShowCustomSnackBar(snackBarState, R.color.yellow_text, R.color.dark_blue_gray_text)
                 if (signUpViewModel.liveDataSignUpStatus.value == true) {
                     var progress by remember { mutableFloatStateOf(0.1F) }
 
@@ -306,13 +306,6 @@ fun SignUp(navHostController: NavHostController) {
                             ),
                         )
 
-//                        if (showErrorEmail) {
-//                            ShowErrorRow(errorText = "Email is Empty")
-//                        }
-//                        else if (showErrorEmail2) {
-//                            ShowErrorRow(errorText = "Email format incorrect")
-//                        }
-
                         Spacer(modifier = Modifier.height(20.dp))
 
                         val colorPass = if (showErrorPass1 || showErrorPass2) {
@@ -421,12 +414,7 @@ fun SignUp(navHostController: NavHostController) {
                             }
                         )
 
-//                        if (showErrorPass1) {
-//                            ShowErrorRow(errorText = "Password is Empty")
-//                        }
-//                        else if (showErrorPass2) {
-//                            ShowErrorRow(errorText = "Should be 3 or more!")
-//                        }
+
 
                         Spacer(modifier = Modifier.height(10.dp))
 
@@ -565,423 +553,6 @@ fun SignUp(navHostController: NavHostController) {
         }
     )
 }
-
-@Composable
-fun SignUp2(navHostController: NavHostController) {
-    val keyboardController = LocalSoftwareKeyboardController.current
-    val focusManager = LocalFocusManager.current
-
-    val signUpViewModel: SignUpViewModel = viewModel()
-    var isSignUpEnabled = signUpViewModel.liveDataSignUpStatus.observeAsState().value
-
-    var textChanged by remember { mutableStateOf("") }
-    var passwordChanged by remember { mutableStateOf("") }
-    var passwordVisible by remember { mutableStateOf(false) }
-    var showErrorEmail by remember { mutableStateOf(false) }
-    var showErrorEmail2 by remember { mutableStateOf(false) }
-    var showErrorPass1 by remember { mutableStateOf(false) }
-    var showErrorPass2 by remember { mutableStateOf(false) }
-    val snackBarState = remember { SnackbarHostState() }
-
-    Scaffold(
-        content = { padding ->
-            Box(
-                modifier = Modifier
-                    .paint(
-                        painter = painterResource(id = if (isDarkTheme.value) R.drawable.bg_app else R.drawable.bg_img3),
-                        contentScale = ContentScale.FillBounds
-                    )
-                    .alpha(if (isSignUpEnabled!!) 0.6F else 1F)
-//            .background(
-//                if (isSystemInDarkTheme()) Color.Black
-//                else Color.Transparent
-//            )
-                    .fillMaxSize()
-                    .pointerInput(Unit) {
-                        detectTapGestures {
-                            focusManager.clearFocus()
-                            keyboardController?.hide()
-                        }
-                    },
-            ) {
-                ShowCustomSnackBar(snackBarState)
-
-                Column (
-                    modifier = Modifier
-                        .fillMaxHeight()
-                        .fillMaxWidth()
-                    ,
-                    verticalArrangement = Arrangement.Top,
-                    horizontalAlignment = Alignment.CenterHorizontally
-                ) {
-
-                    Spacer(modifier = Modifier.height(50.dp))
-
-                    IconButton(
-                        onClick = {
-                            if (!isSignUpEnabled) {
-                                navHostController.popBackStack()
-                            }
-                        },
-                        modifier = Modifier
-                            .padding(start = 16.dp, top = 25.dp)
-                            .align(Alignment.Start)
-                    )
-                    {
-                        Icon(painter = painterResource(
-                            id = R.drawable.back_arrow3x),
-                            contentDescription = "Back Button",
-                            tint = colorResource(id = R.color.white),
-                            modifier = Modifier
-                                .height(36.dp)
-                                .width(36.dp)
-                                .align(Alignment.Start),
-                        )
-                    }
-                    Spacer(modifier = Modifier.height(44.dp))
-
-                    Image(
-                        painter = painterResource(id = R.drawable.fastestapp_logo3x),
-                        contentDescription = "FastestVPN",
-                        modifier = Modifier
-                            .size(75.dp, 102.dp)
-                            .background(Color.Transparent)
-                            .padding(top = 0.dp),
-                    )
-                    Spacer(modifier = Modifier.height(50.dp))
-                    Text(
-                        modifier = Modifier
-                            .padding(start = 15.dp)
-                            .align(Alignment.Start)
-                        ,
-                        style = MaterialTheme.typography.displayLarge,
-                        text = "Hello There!",
-                        color = Color.White,
-                    )
-                    Text(
-                        modifier = Modifier
-                            .padding(start = 15.dp)
-                            .align(Alignment.Start)
-                            .alpha(0.6F),
-                        style = MaterialTheme.typography.customTypography.labelLarge,
-                        text = "Please register your account.",
-                        color = colorResource(id = R.color.white),
-                    )
-                    Spacer(modifier = Modifier.height(20.dp))
-
-                    val colorEmail = if (showErrorEmail || showErrorEmail2) {
-                        colorResource(id = R.color.red)
-                    } else {
-                        colorResource(id = R.color.white)
-                    }
-
-                    TextField(
-                        value = textChanged,
-                        onValueChange = {
-                            textChanged = it
-                        },
-                        readOnly = isSignUpEnabled,
-                        textStyle = MaterialTheme.typography.customTypography.bodyMedium,
-                        modifier = Modifier
-                            .padding(start = 15.dp, end = 15.dp, top = 10.dp)
-                            .align(Alignment.Start)
-                            .fillMaxWidth()
-                            .height(60.dp)
-                            .border(
-                                1.dp,
-                                color = colorEmail,
-                                shape = RoundedCornerShape(16.dp)
-                            ),
-
-//                placeholder = {
-//                    Text(text = "Enter email address",
-//                        color = colorResource(id = R.color.white),
-//                        fontSize = 14.sp,
-//                    )
-//                },
-                        label = {
-                            Text(text = "Email",
-                                style = MaterialTheme.typography.customTypography.bodySmall
-                            )
-                        },
-                        leadingIcon = {
-                            Icon(
-                                painter = painterResource(id = R.drawable.sms3x),
-                                contentDescription = "Email Logo",
-                                tint = colorResource(id = R.color.white),
-                                modifier = Modifier
-                                    .size(24.dp, 24.dp)
-                            )
-                        },
-                        maxLines = 1,
-                        colors = TextFieldDefaults.colors(
-                            focusedLabelColor = Color.Blue,
-                            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.white)
-                        ),
-                        keyboardOptions = KeyboardOptions(
-                            keyboardType = KeyboardType.Email,
-                            imeAction = ImeAction.Done
-                        ),
-                        keyboardActions = KeyboardActions(
-                            onDone = {
-                                focusManager.clearFocus()
-                                keyboardController?.hide()
-                            }
-                        ),
-                    )
-
-                    if (showErrorEmail) {
-                        ShowErrorRow(errorText = "Email is Empty")
-                    }
-                    else if (showErrorEmail2) {
-                        ShowErrorRow(errorText = "Email format incorrect")
-                    }
-
-                    Spacer(modifier = Modifier.height(20.dp))
-
-                    val colorPass = if (showErrorPass1 || showErrorPass2) {
-                        colorResource(id = R.color.red)
-                    } else {
-                        MaterialTheme.colorScheme.secondaryContainer
-                    }
-
-                    TextField(
-                        value = passwordChanged,
-                        onValueChange = {
-                            Log.d("onClick_test", "onValueChange -> ")
-                            passwordChanged = it
-                        },
-                        readOnly = isSignUpEnabled,
-                        textStyle = MaterialTheme.typography.customTypography.bodyMedium,
-                        modifier = Modifier
-                            .padding(start = 15.dp, end = 15.dp)
-                            .align(Alignment.Start)
-                            .fillMaxWidth()
-                            .height(60.dp)
-                            .border(
-                                1.dp,
-                                color = colorPass,
-                                shape = RoundedCornerShape(16.dp)
-                            )
-                            .background(color = colorResource(id = R.color.transparent)),
-
-                        shape = RoundedCornerShape(15.dp),
-//                placeholder = {
-//                    Text(text = "Enter password",
-//                        color = colorResource(id = R.color.white))
-//                },
-                        label = {
-                            Text(text = "Password",
-                                style = MaterialTheme.typography.customTypography.bodyLarge
-                            )
-                        },
-                        leadingIcon = {
-                            Icon(
-                                painter = painterResource(id = R.drawable.lock3x),
-                                contentDescription = "Password Logo",
-                                tint = colorResource(id = R.color.white),
-                                modifier = Modifier
-                                    .size(24.dp, 24.dp)
-                            )
-                        },
-                        maxLines = 1,
-                        colors = TextFieldDefaults.colors(
-                            focusedLabelColor = Color.Blue,
-                            unfocusedContainerColor = MaterialTheme.colorScheme.secondaryContainer,
-                            focusedContainerColor = MaterialTheme.colorScheme.secondaryContainer,
-                            focusedIndicatorColor = colorResource(id = R.color.transparent),
-                            disabledIndicatorColor = colorResource(id = R.color.transparent),
-                            unfocusedIndicatorColor = colorResource(id = R.color.transparent),
-                            cursorColor = colorResource(id = R.color.white)
-                        ),
-                        keyboardOptions = KeyboardOptions(
-                            keyboardType = KeyboardType.Password,
-                            imeAction = ImeAction.Done
-                        ),
-                        keyboardActions = KeyboardActions(
-                            onDone = {
-                                focusManager.clearFocus()
-                                keyboardController?.hide()
-                            }
-                        ),
-                        visualTransformation =
-                        if (passwordVisible) VisualTransformation.None
-                        else PasswordVisualTransformation(),
-
-                        trailingIcon = {
-                            Log.d("onClick_test", "trailingIcon -> ")
-
-//                    val image
-//                            = if (passwordVisible) Icons.Filled.Visibility
-//                    else Icons.Filled.VisibilityOff
-
-                            val description = if (passwordVisible) "Hide Password"
-                            else "Show Password"
-
-                            IconButton(onClick = {
-                                if (!isSignUpEnabled) {
-                                    passwordVisible = !passwordVisible
-                                }
-                            })
-                            {
-                                if (passwordVisible) {
-                                    Icon(
-                                        imageVector = Icons.Outlined.Visibility,
-                                        contentDescription = description,
-                                        tint = colorResource(id = R.color.white),
-                                        modifier = Modifier.size(24.dp)
-                                    )
-                                }
-                                else {
-                                    Icon(
-                                        painter = painterResource(id = R.drawable.eye_slash3x),
-                                        contentDescription = description,
-                                        tint = colorResource(id = R.color.white),
-                                        modifier = Modifier.size(24.dp)
-                                    )
-                                }
-
-                            }
-                        }
-                    )
-
-                    if (showErrorPass1) {
-                        ShowErrorRow(errorText = "Password is Empty")
-                    }
-                    else if (showErrorPass2) {
-                        ShowErrorRow(errorText = "Should be 3 or more!")
-                    }
-
-                    Spacer(modifier = Modifier.height(15.dp))
-
-                    Row (
-                        modifier = Modifier
-                            .padding(start = 15.dp, top = 16.dp)
-                            .fillMaxWidth(),
-                    ){
-
-                        val colorLogo = if (showErrorEmail || showErrorEmail2 || showErrorPass1 || showErrorPass2) colorResource(
-                            id = R.color.red
-                        ) else colorResource(id = R.color.white)
-
-                        Icon(
-                            painter = painterResource(id = R.drawable.tick_square3x),
-                            contentDescription = "Logo",
-                            tint = colorLogo,
-                            modifier = Modifier.size(24.dp, 24.dp)
-                        )
-                        Text(
-                            modifier = Modifier
-                                .padding(start = 15.dp),
-                            style = MaterialTheme.typography.customTypography.bodyLarge,
-                            text = "By creating your account, you agree to",
-                            color = colorResource(id = R.color.white),
-                        )
-                    }
-
-                    Spacer(modifier = Modifier.height(0.dp))
-
-                    Row (
-                        modifier = Modifier
-                            .padding(start = 15.dp)
-                            .fillMaxWidth(),
-                    ){
-
-                        Icon(
-                            painter = painterResource(id = R.drawable.tick_square3x),
-                            contentDescription = "Logo",
-                            tint = colorResource(id = R.color.transparent),
-                            modifier = Modifier.size(24.dp),
-                        )
-                        ClickableText(
-                            onClick = {
-                                if (!isSignUpEnabled) {
-                                    navHostController.navigate(
-                                        Screen.TermsAndConditions.route
-                                    )
-                                }
-                            },
-                            modifier = Modifier
-                                .padding(start = 15.dp),
-                            text = AnnotatedString("Terms & Conditions"),
-                            style = MaterialTheme.typography.customTypography.titleLarge
-                        )
-                    }
-
-                }
-
-//                SignUpButton(
-//                    signUpViewModel,
-//                    textChanged,
-//                    passwordChanged,
-//                    navHostController,
-//                    showErrorEmail1 = {
-//                        showErrorEmail = it
-//                    },
-//                    showErrorEmail,
-//                    showErrorPass1 = {
-//                        showErrorPass1 = it
-//                    },
-//                    showErrorPass1,
-//                    showErrorPass2 = {
-//                        showErrorPass2 = it
-//                    },
-//                    showErrorPass2,
-//                    showErrorEmail2 = {
-//                        showErrorEmail2 = it
-//                    },
-//                    showErrorEmail2,
-//                    snackBarState
-//                )
-
-                Row (
-                    modifier = Modifier
-                        .align(Alignment.BottomCenter)
-                        .padding(40.dp),
-                ){
-                    Text(
-                        modifier = Modifier
-                            .padding(0.dp),
-                        style = MaterialTheme.typography.customTypography.labelLarge,
-                        text = "Already have an account? ",
-                        color = Color.White,
-                    )
-                    ClickableText(
-                        onClick = {
-                            if (!isSignUpEnabled) {
-                                navHostController.popBackStack()
-
-                                if (navHostController.currentDestination?.id != null &&
-                                    navHostController.currentDestination?.route != null){
-                                    Log.d("test_signup", "From Sign In -> id = " + navHostController.currentDestination?.id
-                                            + " route = " + navHostController.currentDestination?.route
-                                    )
-                                }
-                                else {
-                                    Log.d("test_signup", "From Sign Up -> id = " + navHostController.currentDestination?.id
-                                            + " route = " + navHostController.currentDestination?.route
-                                    )
-                                    navHostController.navigate(Screen.Login.route)
-                                }
-                            }
-
-                        },
-                        modifier = Modifier
-                            .padding(0.dp),
-                        style = MaterialTheme.typography.customTypography.titleMedium,
-                        text = AnnotatedString(" Sign In"),
-                    )
-                }
-            }
-        }
-    )
-}
-
 @Composable
 fun ColumnScope.ShowErrorRowSignUp(
     errorText: String
@@ -1058,8 +629,6 @@ fun ColumnScope.SignUpButton(
         }
     }
 
-
-
     Button(
         onClick = {
 //            navHostController.popBackStack()
@@ -1080,6 +649,31 @@ fun ColumnScope.SignUpButton(
                 showErrorPass2(!isError3)
             }
 
+            if (!isErrors) {
+//                            ShowErrorRow(errorText = "Email is Empty")
+                coroutineScope.launch {
+                    snackBarState.showSnackbar("Email is Empty")
+                }
+            }
+            else if (!isErrors4) {
+//                            ShowErrorRow(errorText = "Email format incorrect")
+                coroutineScope.launch {
+                    snackBarState.showSnackbar("Email format incorrect")
+                }
+            }
+            else if (!isErrors2) {
+//                            ShowErrorRow(errorText = "Password is Empty")
+                coroutineScope.launch {
+                    snackBarState.showSnackbar("Password is Empty")
+                }
+            }
+            else if (!isError3) {
+//                            ShowErrorRow(errorText = "Should be 3 or more!")
+                coroutineScope.launch {
+                    snackBarState.showSnackbar("Password should be 3 or more!")
+                }
+            }
+
             if (signUpViewModel.liveDataSignUpStatus.value == false) {
                 Log.d("test_button", "onClick")
 

+ 3 - 3
app/src/main/java/com/vpn/fastestvpnservice/views/CustomSnackBar.kt

@@ -23,14 +23,14 @@ import com.vpn.fastestvpnservice.R
 import com.vpn.fastestvpnservice.ui.theme.outfitFontFamily
 
 @Composable
-fun ShowCustomSnackBar(snackBarState: SnackbarHostState) {
+fun ShowCustomSnackBar(snackBarState: SnackbarHostState, color: Int, textColor: Int) {
     SnackbarHost(
         hostState = snackBarState,
         modifier = Modifier.padding(10.dp)
     ) {data ->
         Snackbar(
             elevation = 0.dp,
-            backgroundColor = colorResource(id = R.color.yellow_text)
+            backgroundColor = colorResource(id = color)
         ) {
             Box(
                 modifier = Modifier
@@ -49,7 +49,7 @@ fun ShowCustomSnackBar(snackBarState: SnackbarHostState) {
                             fontFamily = outfitFontFamily,
                             fontWeight = FontWeight.Medium,
                             fontSize = 16.sp,
-                            color = colorResource(id = R.color.dark_blue_gray_text)
+                            color = colorResource(id = textColor)
                         ),
                         modifier = Modifier.padding(start = 10.dp)
                     )