|
|
|
@ -47,7 +47,12 @@ import com.example.what_the_fantasy.ui.theme.gradienBox
|
|
|
|
|
import com.example.what_the_fantasy.ui.viewModels.AuthUserViewModel
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun LoginPage(navControllerSignUp: () -> Unit, navControllerProfil: (Int) -> Unit, authUserVM : AuthUserViewModel, authState : AuthUserState) {
|
|
|
|
|
fun LoginPage(navControllerSignUp: () -> Unit,
|
|
|
|
|
navControllerProfil: (Int) -> Unit,
|
|
|
|
|
authUserVM : AuthUserViewModel,
|
|
|
|
|
authState : AuthUserState,
|
|
|
|
|
initialierCurrentUser : (Int) -> Unit) {
|
|
|
|
|
|
|
|
|
|
// val authUserVM : AuthUserViewModel = viewModel()
|
|
|
|
|
// val authState by authUserVM.userState.collectAsState()
|
|
|
|
|
|
|
|
|
@ -69,11 +74,15 @@ fun LoginPage(navControllerSignUp: () -> Unit, navControllerProfil: (Int) -> Uni
|
|
|
|
|
|
|
|
|
|
TitlePageComponent(R.string.titleLogin, MaterialTheme.colorScheme.primary)
|
|
|
|
|
SpaceHeightComponent(20)
|
|
|
|
|
ConnexionButtonLogin(authUserVM,IdentifiantTextField(R.string.IdentifiantLogin, authState.username){
|
|
|
|
|
|
|
|
|
|
ConnexionButtonLogin(authUserVM,
|
|
|
|
|
IdentifiantTextField(R.string.IdentifiantLogin, authState.username){
|
|
|
|
|
authUserVM.setUsername(it)
|
|
|
|
|
}, PassWdTextField(R.string.PasswdLogin, authState.password){
|
|
|
|
|
authUserVM.setPassword(it)
|
|
|
|
|
}, R.string.ButtonLogin,18,navControllerProfil)
|
|
|
|
|
}, R.string.ButtonLogin,18,navControllerProfil){
|
|
|
|
|
initialierCurrentUser(it)
|
|
|
|
|
}
|
|
|
|
|
SpaceHeightComponent(16)
|
|
|
|
|
CreateAccountButton(R.string.ButtonCreateLogin,12, MaterialTheme.colorScheme.primary, navControllerSignUp)
|
|
|
|
|
}
|
|
|
|
@ -130,11 +139,11 @@ fun PassWdTextField(textpasswdResId : Int, password : String, onValueChange: (St
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun ConnexionButtonLogin(authUserVM : AuthUserViewModel, username : String, passwd : String, titleResId : Int, size : Int, navController: (Int) -> Unit){
|
|
|
|
|
fun ConnexionButtonLogin(authUserVM : AuthUserViewModel, username : String, passwd : String, titleResId : Int, size : Int, navController: (Int) -> Unit, initialierCurrentUser : (Int) -> Unit){
|
|
|
|
|
val title = stringResource(id = titleResId)
|
|
|
|
|
var showError by remember { mutableStateOf(false) }
|
|
|
|
|
Button(
|
|
|
|
|
onClick = { showError = !authUserVM.validLogin(username, passwd, navController)
|
|
|
|
|
onClick = { showError = !authUserVM.validLogin(username, passwd, navController, initialierCurrentUser)
|
|
|
|
|
},
|
|
|
|
|
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.background),
|
|
|
|
|
modifier = Modifier
|
|
|
|
|