|
|
|
@ -45,6 +45,7 @@ import com.example.what_the_fantasy.data.services.hashPassword
|
|
|
|
|
import com.example.what_the_fantasy.ui.components.VisibleIconPasswordComponent
|
|
|
|
|
import com.example.what_the_fantasy.ui.states.AuthUserState
|
|
|
|
|
import com.example.what_the_fantasy.ui.viewModels.AuthUserViewModel
|
|
|
|
|
import com.example.what_the_fantasy.ui.viewModels.CurrentUserViewModel
|
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
@ -52,6 +53,7 @@ fun LoginPage(navControllerSignUp: () -> Unit,
|
|
|
|
|
navControllerProfil: (Int) -> Unit,
|
|
|
|
|
authUserVM : AuthUserViewModel,
|
|
|
|
|
authState : AuthUserState,
|
|
|
|
|
currentUserViewModel : CurrentUserViewModel,
|
|
|
|
|
initialierCurrentUser : (Int) -> Unit) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -79,7 +81,7 @@ fun LoginPage(navControllerSignUp: () -> Unit,
|
|
|
|
|
authUserVM.setUsername(it)
|
|
|
|
|
}, PassWdTextField(R.string.PasswdLogin, authState.password){
|
|
|
|
|
authUserVM.setPassword(it)
|
|
|
|
|
}, R.string.ButtonLogin,18,navControllerProfil){
|
|
|
|
|
}, R.string.ButtonLogin,18,currentUserViewModel,navControllerProfil){
|
|
|
|
|
initialierCurrentUser(it)
|
|
|
|
|
}
|
|
|
|
|
SpaceHeightComponent(16)
|
|
|
|
@ -138,14 +140,21 @@ fun PassWdTextField(textpasswdResId : Int, password : String, onValueChange: (St
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun ConnexionButtonLogin(authUserVM : AuthUserViewModel, username : String, passwd : String, titleResId : Int, size : Int, navController: (Int) -> Unit, initialierCurrentUser : (Int) -> Unit){
|
|
|
|
|
fun ConnexionButtonLogin(authUserVM : AuthUserViewModel,
|
|
|
|
|
username : String,
|
|
|
|
|
passwd : String,
|
|
|
|
|
titleResId : Int,
|
|
|
|
|
size : Int,
|
|
|
|
|
currentUserViewModel: CurrentUserViewModel,
|
|
|
|
|
navController: (Int) -> Unit,
|
|
|
|
|
initialierCurrentUser : (Int) -> Unit){
|
|
|
|
|
val title = stringResource(id = titleResId)
|
|
|
|
|
var showError by remember { mutableStateOf(false) }
|
|
|
|
|
val coroutineScope = rememberCoroutineScope()
|
|
|
|
|
Button(
|
|
|
|
|
onClick = {
|
|
|
|
|
coroutineScope.launch {
|
|
|
|
|
val result = authUserVM.validLogin(username, passwd, navController, initialierCurrentUser)
|
|
|
|
|
val result = authUserVM.validLogin(username, passwd, navController, initialierCurrentUser, currentUserViewModel)
|
|
|
|
|
showError = !result
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|