|
@@ -42,6 +42,8 @@ import androidx.compose.material3.CircularProgressIndicator
|
|
|
import androidx.compose.material3.Icon
|
|
|
import androidx.compose.material3.IconButton
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
+import androidx.compose.material3.Scaffold
|
|
|
+import androidx.compose.material3.SnackbarHostState
|
|
|
import androidx.compose.material3.Text
|
|
|
import androidx.compose.material3.TextField
|
|
|
import androidx.compose.material3.TextFieldDefaults
|
|
@@ -52,6 +54,7 @@ import androidx.compose.runtime.livedata.observeAsState
|
|
|
import androidx.compose.runtime.mutableFloatStateOf
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
import androidx.compose.runtime.remember
|
|
|
+import androidx.compose.runtime.rememberCoroutineScope
|
|
|
import androidx.compose.runtime.setValue
|
|
|
import androidx.compose.ui.Alignment
|
|
|
import androidx.compose.ui.ExperimentalComposeUiApi
|
|
@@ -91,7 +94,9 @@ import com.vpn.fastestvpnservice.ui.theme.outfitFontFamily
|
|
|
import com.vpn.fastestvpnservice.viewmodels.LoginViewModel
|
|
|
import com.vpn.fastestvpnservice.viewmodels.SignUpViewModel
|
|
|
import com.vpn.fastestvpnservice.views.CustomValidation
|
|
|
+import com.vpn.fastestvpnservice.views.ShowCustomSnackBar
|
|
|
import kotlinx.coroutines.delay
|
|
|
+import kotlinx.coroutines.launch
|
|
|
|
|
|
@OptIn(ExperimentalComposeUiApi::class)
|
|
|
@Composable
|
|
@@ -109,123 +114,128 @@ fun SignUp(navHostController: NavHostController) {
|
|
|
var showErrorEmail2 by remember { mutableStateOf(false) }
|
|
|
var showErrorPass1 by remember { mutableStateOf(false) }
|
|
|
var showErrorPass2 by remember { mutableStateOf(false) }
|
|
|
+ val snackBarState = remember { SnackbarHostState() }
|
|
|
|
|
|
- Box(
|
|
|
- modifier = Modifier
|
|
|
- .paint(
|
|
|
- painter = painterResource(id = R.drawable.bg_img3),
|
|
|
- contentScale = ContentScale.FillBounds
|
|
|
- )
|
|
|
- .alpha(if (isSignUpEnabled!!) 0.6F else 1F)
|
|
|
+ Scaffold(
|
|
|
+ content = { padding ->
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .paint(
|
|
|
+ painter = painterResource(id = 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()
|
|
|
- }
|
|
|
- },
|
|
|
- ) {
|
|
|
- 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),
|
|
|
+ .fillMaxSize()
|
|
|
+ .pointerInput(Unit) {
|
|
|
+ detectTapGestures {
|
|
|
+ focusManager.clearFocus()
|
|
|
+ keyboardController?.hide()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ) {
|
|
|
+ ShowCustomSnackBar(snackBarState)
|
|
|
+
|
|
|
+ Column (
|
|
|
modifier = Modifier
|
|
|
- .height(36.dp)
|
|
|
- .width(36.dp)
|
|
|
- .align(Alignment.Start),
|
|
|
- )
|
|
|
- }
|
|
|
- Spacer(modifier = Modifier.height(44.dp))
|
|
|
+ .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),
|
|
|
- style = TextStyle(
|
|
|
- fontSize = 14.sp,
|
|
|
- fontFamily = outfitFontFamily,
|
|
|
- fontWeight = FontWeight.Normal,
|
|
|
- lineHeight = 30.sp
|
|
|
- ),
|
|
|
- text = "Please register your account.",
|
|
|
- color = colorResource(id = R.color.light_grey),
|
|
|
- )
|
|
|
- Spacer(modifier = Modifier.height(20.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),
|
|
|
+ style = TextStyle(
|
|
|
+ fontSize = 14.sp,
|
|
|
+ fontFamily = outfitFontFamily,
|
|
|
+ fontWeight = FontWeight.Normal,
|
|
|
+ lineHeight = 30.sp
|
|
|
+ ),
|
|
|
+ text = "Please register your account.",
|
|
|
+ color = colorResource(id = R.color.light_grey),
|
|
|
+ )
|
|
|
+ Spacer(modifier = Modifier.height(20.dp))
|
|
|
|
|
|
- val colorEmail = if (showErrorEmail || showErrorEmail2) {
|
|
|
- colorResource(id = R.color.red)
|
|
|
- } else {
|
|
|
- colorResource(id = R.color.white)
|
|
|
- }
|
|
|
+ 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 = TextStyle(
|
|
|
- color = colorResource(id = R.color.white),
|
|
|
- fontFamily = outfitFontFamily,
|
|
|
- fontWeight = FontWeight.Normal,
|
|
|
- fontSize = 14.sp,
|
|
|
- lineHeight = 22.sp,
|
|
|
- letterSpacing = 0.21.sp
|
|
|
- ),
|
|
|
- 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)
|
|
|
- ),
|
|
|
+ TextField(
|
|
|
+ value = textChanged,
|
|
|
+ onValueChange = {
|
|
|
+ textChanged = it
|
|
|
+ },
|
|
|
+ readOnly = isSignUpEnabled,
|
|
|
+ textStyle = TextStyle(
|
|
|
+ color = colorResource(id = R.color.white),
|
|
|
+ fontFamily = outfitFontFamily,
|
|
|
+ fontWeight = FontWeight.Normal,
|
|
|
+ fontSize = 14.sp,
|
|
|
+ lineHeight = 22.sp,
|
|
|
+ letterSpacing = 0.21.sp
|
|
|
+ ),
|
|
|
+ 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",
|
|
@@ -233,319 +243,326 @@ fun SignUp(navHostController: NavHostController) {
|
|
|
// fontSize = 14.sp,
|
|
|
// )
|
|
|
// },
|
|
|
- label = {
|
|
|
- Text(text = "Email",
|
|
|
- style = TextStyle(
|
|
|
- colorResource(id = R.color.white),
|
|
|
- fontFamily = outfitFontFamily,
|
|
|
- fontWeight = FontWeight.Medium,
|
|
|
- fontSize = 12.sp,
|
|
|
- )
|
|
|
- )
|
|
|
- },
|
|
|
- leadingIcon = {
|
|
|
- Icon(
|
|
|
- painter = painterResource(id = R.drawable.sms3x),
|
|
|
- contentDescription = "Email Logo",
|
|
|
- tint = colorResource(id = R.color.white),
|
|
|
- modifier = Modifier
|
|
|
- .size(24.dp, 24.dp)
|
|
|
+ label = {
|
|
|
+ Text(text = "Email",
|
|
|
+ style = TextStyle(
|
|
|
+ colorResource(id = R.color.white),
|
|
|
+ fontFamily = outfitFontFamily,
|
|
|
+ fontWeight = FontWeight.Medium,
|
|
|
+ fontSize = 12.sp,
|
|
|
+ )
|
|
|
+ )
|
|
|
+ },
|
|
|
+ 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()
|
|
|
+ }
|
|
|
+ ),
|
|
|
)
|
|
|
- },
|
|
|
- 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")
|
|
|
- }
|
|
|
+ if (showErrorEmail) {
|
|
|
+ ShowErrorRow(errorText = "Email is Empty")
|
|
|
+ }
|
|
|
+ else if (showErrorEmail2) {
|
|
|
+ ShowErrorRow(errorText = "Email format incorrect")
|
|
|
+ }
|
|
|
|
|
|
- Spacer(modifier = Modifier.height(20.dp))
|
|
|
+ Spacer(modifier = Modifier.height(20.dp))
|
|
|
|
|
|
- val colorPass = if (showErrorPass1 || showErrorPass2) {
|
|
|
- colorResource(id = R.color.red)
|
|
|
- } else {
|
|
|
- colorResource(id = R.color.grey_password_field)
|
|
|
- }
|
|
|
+ val colorPass = if (showErrorPass1 || showErrorPass2) {
|
|
|
+ colorResource(id = R.color.red)
|
|
|
+ } else {
|
|
|
+ colorResource(id = R.color.grey_password_field)
|
|
|
+ }
|
|
|
|
|
|
- TextField(
|
|
|
- value = passwordChanged,
|
|
|
- onValueChange = {
|
|
|
- Log.d("onClick_test", "onValueChange -> ")
|
|
|
- passwordChanged = it
|
|
|
- },
|
|
|
- readOnly = isSignUpEnabled,
|
|
|
- textStyle = TextStyle(
|
|
|
- color = colorResource(id = R.color.white),
|
|
|
- fontFamily = outfitFontFamily,
|
|
|
- fontWeight = FontWeight.Normal,
|
|
|
- fontSize = 14.sp,
|
|
|
- lineHeight = 22.sp,
|
|
|
- letterSpacing = 0.21.sp
|
|
|
- ),
|
|
|
- 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)),
|
|
|
+ TextField(
|
|
|
+ value = passwordChanged,
|
|
|
+ onValueChange = {
|
|
|
+ Log.d("onClick_test", "onValueChange -> ")
|
|
|
+ passwordChanged = it
|
|
|
+ },
|
|
|
+ readOnly = isSignUpEnabled,
|
|
|
+ textStyle = TextStyle(
|
|
|
+ color = colorResource(id = R.color.white),
|
|
|
+ fontFamily = outfitFontFamily,
|
|
|
+ fontWeight = FontWeight.Normal,
|
|
|
+ fontSize = 14.sp,
|
|
|
+ lineHeight = 22.sp,
|
|
|
+ letterSpacing = 0.21.sp
|
|
|
+ ),
|
|
|
+ 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),
|
|
|
+ shape = RoundedCornerShape(15.dp),
|
|
|
// placeholder = {
|
|
|
// Text(text = "Enter password",
|
|
|
// color = colorResource(id = R.color.white))
|
|
|
// },
|
|
|
- label = {
|
|
|
- Text(text = "Password",
|
|
|
- style = TextStyle(
|
|
|
- colorResource(id = R.color.white),
|
|
|
- fontFamily = outfitFontFamily,
|
|
|
- fontWeight = FontWeight.Normal,
|
|
|
- fontSize = 16.sp
|
|
|
- )
|
|
|
- )
|
|
|
- },
|
|
|
- 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 = colorResource(id = R.color.grey_password_field),
|
|
|
- focusedContainerColor = colorResource(id = R.color.grey_password_field),
|
|
|
- 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 -> ")
|
|
|
+ label = {
|
|
|
+ Text(text = "Password",
|
|
|
+ style = TextStyle(
|
|
|
+ colorResource(id = R.color.white),
|
|
|
+ fontFamily = outfitFontFamily,
|
|
|
+ fontWeight = FontWeight.Normal,
|
|
|
+ fontSize = 16.sp
|
|
|
+ )
|
|
|
+ )
|
|
|
+ },
|
|
|
+ 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 = colorResource(id = R.color.grey_password_field),
|
|
|
+ focusedContainerColor = colorResource(id = R.color.grey_password_field),
|
|
|
+ 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)
|
|
|
- )
|
|
|
+ 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!")
|
|
|
}
|
|
|
- }
|
|
|
- )
|
|
|
-
|
|
|
- if (showErrorPass1) {
|
|
|
- ShowErrorRow(errorText = "Password is Empty")
|
|
|
- }
|
|
|
- else if (showErrorPass2) {
|
|
|
- ShowErrorRow(errorText = "Should be 3 or more!")
|
|
|
- }
|
|
|
|
|
|
- Spacer(modifier = Modifier.height(15.dp))
|
|
|
+ Spacer(modifier = Modifier.height(15.dp))
|
|
|
|
|
|
- Row (
|
|
|
- modifier = Modifier
|
|
|
- .padding(start = 15.dp, top = 16.dp)
|
|
|
- .fillMaxWidth(),
|
|
|
- ){
|
|
|
-
|
|
|
- Icon(
|
|
|
- painter = painterResource(id = R.drawable.tick_square3x),
|
|
|
- contentDescription = "Logo",
|
|
|
- tint = colorResource(id = R.color.white),
|
|
|
- modifier = Modifier.size(24.dp, 24.dp)
|
|
|
- )
|
|
|
- Text(
|
|
|
- modifier = Modifier
|
|
|
- .padding(start = 15.dp),
|
|
|
- style = TextStyle(
|
|
|
- fontFamily = outfitFontFamily,
|
|
|
- fontWeight = FontWeight.Normal,
|
|
|
- fontSize = 16.sp,
|
|
|
- ),
|
|
|
- text = "By creating your account, you agree to",
|
|
|
- color = colorResource(id = R.color.white),
|
|
|
- )
|
|
|
- }
|
|
|
+ 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 = TextStyle(
|
|
|
+ fontFamily = outfitFontFamily,
|
|
|
+ fontWeight = FontWeight.Normal,
|
|
|
+ fontSize = 16.sp,
|
|
|
+ ),
|
|
|
+ text = "By creating your account, you agree to",
|
|
|
+ color = colorResource(id = R.color.white),
|
|
|
+ )
|
|
|
+ }
|
|
|
|
|
|
- Spacer(modifier = Modifier.height(0.dp))
|
|
|
+ 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
|
|
|
+ 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 = TextStyle(
|
|
|
+ fontFamily = outfitFontFamily,
|
|
|
+ fontWeight = FontWeight.Normal,
|
|
|
+ fontSize = 16.sp,
|
|
|
+ color = colorResource(id = R.color.yellow_text)
|
|
|
)
|
|
|
- }
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ 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
|
|
|
- .padding(start = 15.dp),
|
|
|
- text = AnnotatedString("Terms & Conditions"),
|
|
|
- style = TextStyle(
|
|
|
- fontFamily = outfitFontFamily,
|
|
|
- fontWeight = FontWeight.Normal,
|
|
|
- fontSize = 16.sp,
|
|
|
- color = colorResource(id = R.color.yellow_text)
|
|
|
+ .align(Alignment.BottomCenter)
|
|
|
+ .padding(40.dp),
|
|
|
+ ){
|
|
|
+ Text(
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(0.dp),
|
|
|
+ style = TextStyle(
|
|
|
+ fontFamily = outfitFontFamily,
|
|
|
+ fontWeight = FontWeight.Normal,
|
|
|
+ fontSize = 14.sp,
|
|
|
+ textAlign = TextAlign.Right,
|
|
|
+ lineHeight = 30.sp
|
|
|
+ ),
|
|
|
+ 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 = TextStyle(
|
|
|
+ fontFamily = outfitFontFamily,
|
|
|
+ fontWeight = FontWeight.Normal,
|
|
|
+ fontSize = 14.sp,
|
|
|
+ textAlign = TextAlign.Right,
|
|
|
+ lineHeight = 30.sp,
|
|
|
+ color = colorResource(id = R.color.yellow),
|
|
|
+ ),
|
|
|
+ text = AnnotatedString(" Sign In"),
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- SignUpButton(
|
|
|
- signUpViewModel,
|
|
|
- textChanged,
|
|
|
- passwordChanged,
|
|
|
- navHostController,
|
|
|
- showErrorEmail1 = {
|
|
|
- showErrorEmail = it
|
|
|
- },
|
|
|
- showErrorEmail,
|
|
|
- showErrorPass1 = {
|
|
|
- showErrorPass1 = it
|
|
|
- },
|
|
|
- showErrorPass1,
|
|
|
- showErrorPass2 = {
|
|
|
- showErrorPass2 = it
|
|
|
- },
|
|
|
- showErrorPass2,
|
|
|
- showErrorEmail2 = {
|
|
|
- showErrorEmail2 = it
|
|
|
- },
|
|
|
- showErrorEmail2
|
|
|
- )
|
|
|
-
|
|
|
- Row (
|
|
|
- modifier = Modifier
|
|
|
- .align(Alignment.BottomCenter)
|
|
|
- .padding(40.dp),
|
|
|
- ){
|
|
|
- Text(
|
|
|
- modifier = Modifier
|
|
|
- .padding(0.dp),
|
|
|
- style = TextStyle(
|
|
|
- fontFamily = outfitFontFamily,
|
|
|
- fontWeight = FontWeight.Normal,
|
|
|
- fontSize = 14.sp,
|
|
|
- textAlign = TextAlign.Right,
|
|
|
- lineHeight = 30.sp
|
|
|
- ),
|
|
|
- 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 = TextStyle(
|
|
|
- fontFamily = outfitFontFamily,
|
|
|
- fontWeight = FontWeight.Normal,
|
|
|
- fontSize = 14.sp,
|
|
|
- textAlign = TextAlign.Right,
|
|
|
- lineHeight = 30.sp,
|
|
|
- color = colorResource(id = R.color.yellow),
|
|
|
- ),
|
|
|
- text = AnnotatedString(" Sign In"),
|
|
|
- )
|
|
|
}
|
|
|
- }
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
@@ -588,19 +605,20 @@ fun BoxScope.SignUpButton(
|
|
|
showErrorPass2: (Boolean) -> Unit,
|
|
|
isErrorPass2: Boolean,
|
|
|
showErrorEmail2: (Boolean) -> Unit,
|
|
|
- isErrorEmail2: Boolean
|
|
|
+ isErrorEmail2: Boolean,
|
|
|
+ snackBarState: SnackbarHostState
|
|
|
) {
|
|
|
val loginViewModel: LoginViewModel = viewModel()
|
|
|
val context = LocalContext.current
|
|
|
val prefHelper = BasePreferenceHelper(context)
|
|
|
val customValidation = CustomValidation()
|
|
|
+ val coroutineScope = rememberCoroutineScope()
|
|
|
|
|
|
if (isErrorEmail1) {
|
|
|
if (email.isNotEmpty()) {
|
|
|
showErrorEmail1(false)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if (isErrorEmail2) {
|
|
|
if (email.isNotEmpty()) {
|
|
|
val emailFormat = customValidation.isValidEmail(email)
|
|
@@ -609,13 +627,11 @@ fun BoxScope.SignUpButton(
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if (isErrorPass1) {
|
|
|
if (password.isNotEmpty()) {
|
|
|
showErrorPass1(false)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if (isErrorPass2) {
|
|
|
if (password.isNotEmpty()) {
|
|
|
val isErrorPassSize = customValidation.isValidPassword(password)
|
|
@@ -625,7 +641,6 @@ fun BoxScope.SignUpButton(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if (signUpViewModel.liveDataSignUpStatus.value == true) {
|
|
|
var progress by remember { mutableFloatStateOf(0.1F) }
|
|
|
|
|
@@ -715,7 +730,12 @@ fun BoxScope.SignUpButton(
|
|
|
email, password, "android", "11", "3.2.4"
|
|
|
)
|
|
|
} else {
|
|
|
- Toast.makeText(context, response.message, Toast.LENGTH_SHORT).show()
|
|
|
+ response.message?.let {
|
|
|
+ coroutineScope.launch {
|
|
|
+ snackBarState.showSnackbar(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+// Toast.makeText(context, response.message, Toast.LENGTH_SHORT).show()
|
|
|
}
|
|
|
signUpViewModel.mutableLiveData.value = null
|
|
|
}
|