|
@@ -34,11 +34,13 @@ import androidx.compose.ui.res.painterResource
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
+import androidx.core.text.isDigitsOnly
|
|
|
import androidx.navigation.NavController
|
|
|
import com.example.mystictale.R
|
|
|
import com.example.mystictale.ViewModels.AuthViewModel
|
|
|
import com.example.mystictale.navigation.Screens
|
|
|
import com.example.mystictale.resources.components.PasswordTextField
|
|
|
+import com.example.mystictale.resources.components.ValidationPassword
|
|
|
import com.example.mystictale.ui.theme.DarkPurple
|
|
|
import com.example.mystictale.ui.theme.Grey
|
|
|
import com.example.mystictale.ui.theme.OpenSans
|
|
@@ -53,6 +55,7 @@ fun RegistrationPassword(navController: NavController, viewModel: AuthViewModel)
|
|
|
val repeatedPassword = remember {
|
|
|
mutableStateOf("")
|
|
|
}
|
|
|
+ val passwordFlag = remember { mutableStateOf(false) }
|
|
|
Column(
|
|
|
Modifier
|
|
|
.fillMaxSize()
|
|
@@ -114,7 +117,11 @@ fun RegistrationPassword(navController: NavController, viewModel: AuthViewModel)
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
- Column(modifier = Modifier.padding(10.dp)) {
|
|
|
+ Column(
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(20.dp)
|
|
|
+ .padding(start = 15.dp, end = 5.dp)
|
|
|
+ ) {
|
|
|
Spacer(modifier = Modifier.height(30.dp))
|
|
|
Text(
|
|
|
text = "Придумайте пароль",
|
|
@@ -123,8 +130,7 @@ fun RegistrationPassword(navController: NavController, viewModel: AuthViewModel)
|
|
|
fontSize = 24.sp,
|
|
|
color = Color.White,
|
|
|
modifier = Modifier
|
|
|
- .fillMaxWidth(0.9f)
|
|
|
- .padding(start = 35.dp),
|
|
|
+ .fillMaxWidth(),
|
|
|
style = MaterialTheme.typography.headlineMedium
|
|
|
)
|
|
|
Spacer(modifier = Modifier.height(30.dp))
|
|
@@ -138,22 +144,71 @@ fun RegistrationPassword(navController: NavController, viewModel: AuthViewModel)
|
|
|
fontSize = 13.sp,
|
|
|
color = Color.White,
|
|
|
modifier = Modifier
|
|
|
- .fillMaxWidth(0.9f)
|
|
|
- .padding(start = 40.dp)
|
|
|
+ .fillMaxWidth()
|
|
|
)
|
|
|
|
|
|
|
|
|
Spacer(modifier = Modifier.height(30.dp))
|
|
|
|
|
|
- PasswordTextField(password.value, { password.value = it }, "Пароль")
|
|
|
+ PasswordTextField(
|
|
|
+ password.value, {
|
|
|
+ password.value = it
|
|
|
+ passwordFlag.value = false
|
|
|
+ }, "Пароль",
|
|
|
+ passwordFlag.value
|
|
|
+ )
|
|
|
|
|
|
Spacer(modifier = Modifier.height(30.dp))
|
|
|
|
|
|
PasswordTextField(
|
|
|
repeatedPassword.value,
|
|
|
{ repeatedPassword.value = it },
|
|
|
- "Повторный пароль"
|
|
|
+ "Повторный пароль",
|
|
|
+ passwordFlag.value
|
|
|
)
|
|
|
+ if (passwordFlag.value) {
|
|
|
+ if (password.value.isEmpty()) {
|
|
|
+ Text(
|
|
|
+ "Введите пароль",
|
|
|
+ fontWeight = FontWeight.Light,
|
|
|
+ fontFamily = OpenSans,
|
|
|
+ fontSize = 13.sp,
|
|
|
+ color = Color.Red
|
|
|
+ )
|
|
|
+ } else if (password.value.length < 6) {
|
|
|
+ Text(
|
|
|
+ "Пароль содержит меньше 6 символов",
|
|
|
+ fontWeight = FontWeight.Light,
|
|
|
+ fontFamily = OpenSans,
|
|
|
+ fontSize = 13.sp,
|
|
|
+ color = Color.Red
|
|
|
+ )
|
|
|
+ } else if (password.value.isDigitsOnly()) {
|
|
|
+ Text(
|
|
|
+ "Пароль не содержит букв",
|
|
|
+ fontWeight = FontWeight.Light,
|
|
|
+ fontFamily = OpenSans,
|
|
|
+ fontSize = 13.sp,
|
|
|
+ color = Color.Red
|
|
|
+ )
|
|
|
+ } else if (!password.value.any { it.isDigit() }) {
|
|
|
+ Text(
|
|
|
+ "Пароль не содержит цифр",
|
|
|
+ fontWeight = FontWeight.Light,
|
|
|
+ fontFamily = OpenSans,
|
|
|
+ fontSize = 13.sp,
|
|
|
+ color = Color.Red
|
|
|
+ )
|
|
|
+ } else if (password.value != repeatedPassword.value) {
|
|
|
+ Text(
|
|
|
+ "Пароли не совпадают",
|
|
|
+ fontWeight = FontWeight.Light,
|
|
|
+ fontFamily = OpenSans,
|
|
|
+ fontSize = 13.sp,
|
|
|
+ color = Color.Red
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -161,12 +216,17 @@ fun RegistrationPassword(navController: NavController, viewModel: AuthViewModel)
|
|
|
Box(Modifier.padding(bottom = 50.dp)) {
|
|
|
Button(
|
|
|
onClick = {
|
|
|
- viewModel.password = password.value
|
|
|
- navController.navigate(Screens.RegistrationName.route)
|
|
|
+ if (!ValidationPassword(password.value, repeatedPassword.value)) {
|
|
|
+ viewModel.passwordUser = password.value
|
|
|
+ navController.navigate(Screens.RegistrationName.route)
|
|
|
+ } else {
|
|
|
+ passwordFlag.value = true
|
|
|
+ }
|
|
|
},
|
|
|
modifier = Modifier
|
|
|
- .width(310.dp)
|
|
|
- .height(48.dp),
|
|
|
+ .fillMaxWidth()
|
|
|
+ .height(48.dp)
|
|
|
+ .padding(horizontal = 30.dp),
|
|
|
shape = RoundedCornerShape(12.dp),
|
|
|
colors = ButtonColors(
|
|
|
containerColor = DarkPurple,
|