|
|
|
@ -26,6 +26,7 @@ import androidx.compose.runtime.collectAsState
|
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
|
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.Modifier
|
|
|
|
@ -47,6 +48,7 @@ import com.example.what_the_fantasy.ui.components.ErrorMessageProfileComponent
|
|
|
|
|
import com.example.what_the_fantasy.ui.components.VisibleIconPasswordComponent
|
|
|
|
|
import com.example.what_the_fantasy.ui.states.SignInUserState
|
|
|
|
|
import com.example.what_the_fantasy.ui.viewModels.SignInUserViewModel
|
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun SignUpPage(navControllerLogin: () -> Unit, signInUserVM :SignInUserViewModel,signInState : SignInUserState) {
|
|
|
|
@ -91,7 +93,7 @@ fun SignUpPage(navControllerLogin: () -> Unit, signInUserVM :SignInUserViewModel
|
|
|
|
|
ConnexionButtonSign(R.string.ButtonSignUp,18, Color.White, Color.Black, signInState.username, signInState.email, signInState.password, signInState.confirmPassword, signInUserVM, navControllerLogin)
|
|
|
|
|
SpaceHeightComponent(16)
|
|
|
|
|
|
|
|
|
|
ReturnLogin(R.string.ButtonLogin,12, Color.White, navController = navControllerLogin)
|
|
|
|
|
ReturnLogin(R.string.ButtonLogin,12, MaterialTheme.colorScheme.onBackground, navController = navControllerLogin)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -219,17 +221,21 @@ fun ConnexionButtonSign(
|
|
|
|
|
|
|
|
|
|
val invalidRegex = """^[a-zA-Z0-9]*$""".toRegex()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val coroutineScope = rememberCoroutineScope()
|
|
|
|
|
Button(
|
|
|
|
|
onClick = {
|
|
|
|
|
emailError = !isValidEmail(email)
|
|
|
|
|
passwordError = !arePasswordsMatching(password, confirmPassword)
|
|
|
|
|
usernameError = username.isBlank() && !username.matches(invalidRegex)
|
|
|
|
|
passwordErrorEmpty = password.isBlank() || confirmPassword.isBlank()
|
|
|
|
|
|
|
|
|
|
if (!emailError && !passwordError && !usernameError && !passwordErrorEmpty) {
|
|
|
|
|
usernameErrorExist = !viewModel.createUser(username, email, password)
|
|
|
|
|
if(!usernameErrorExist){
|
|
|
|
|
navController() // retour à la page login
|
|
|
|
|
coroutineScope.launch {
|
|
|
|
|
emailError = !isValidEmail(email)
|
|
|
|
|
passwordError = !arePasswordsMatching(password, confirmPassword)
|
|
|
|
|
usernameError = username.isBlank() && !username.matches(invalidRegex)
|
|
|
|
|
passwordErrorEmpty = password.isBlank() || confirmPassword.isBlank()
|
|
|
|
|
|
|
|
|
|
if (!emailError && !passwordError && !usernameError && !passwordErrorEmpty) {
|
|
|
|
|
usernameErrorExist = !viewModel.createUser(username, email, password)
|
|
|
|
|
if (!usernameErrorExist) {
|
|
|
|
|
navController() // retour à la page login
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|