|
@@ -59,10 +59,10 @@ import kotlinx.coroutines.launch
|
|
//@Preview
|
|
//@Preview
|
|
@Composable
|
|
@Composable
|
|
fun auth(navController: NavHostController) {
|
|
fun auth(navController: NavHostController) {
|
|
- val viewModel = MainViewModel()
|
|
|
|
|
|
+ val viewModel = MainViewModel() // Создаем экземпляр MainViewModel
|
|
val email = remember { mutableStateOf("") }
|
|
val email = remember { mutableStateOf("") }
|
|
val password = remember { mutableStateOf("") }
|
|
val password = remember { mutableStateOf("") }
|
|
- val scope = rememberCoroutineScope()
|
|
|
|
|
|
+ val scope = rememberCoroutineScope() //для асинхронного выполнения задач
|
|
|
|
|
|
Box(
|
|
Box(
|
|
modifier = Modifier
|
|
modifier = Modifier
|
|
@@ -124,7 +124,7 @@ fun auth(navController: NavHostController) {
|
|
)
|
|
)
|
|
TextField(
|
|
TextField(
|
|
value = email.value,
|
|
value = email.value,
|
|
- onValueChange = { newText -> email.value = newText },
|
|
|
|
|
|
+ onValueChange = { newText -> email.value = newText }, //обновление текста
|
|
shape = RoundedCornerShape(15.dp),
|
|
shape = RoundedCornerShape(15.dp),
|
|
colors = TextFieldDefaults.textFieldColors(
|
|
colors = TextFieldDefaults.textFieldColors(
|
|
containerColor = fon,
|
|
containerColor = fon,
|
|
@@ -154,7 +154,7 @@ fun auth(navController: NavHostController) {
|
|
//2
|
|
//2
|
|
Spacer(modifier = Modifier.height(15.dp))
|
|
Spacer(modifier = Modifier.height(15.dp))
|
|
|
|
|
|
- var passwordVisibility by remember { mutableStateOf(false) }
|
|
|
|
|
|
+ var passwordVisibility by remember { mutableStateOf(false) } // для упраления видимостью пароля
|
|
|
|
|
|
Text(
|
|
Text(
|
|
text = "Password",
|
|
text = "Password",
|
|
@@ -165,7 +165,7 @@ fun auth(navController: NavHostController) {
|
|
)
|
|
)
|
|
TextField(
|
|
TextField(
|
|
value = password.value,
|
|
value = password.value,
|
|
- visualTransformation = if (passwordVisibility) VisualTransformation.None else PasswordVisualTransformation(),
|
|
|
|
|
|
+ visualTransformation = if (passwordVisibility) VisualTransformation.None else PasswordVisualTransformation(), // если тру то обычный текст если фолс то скрыт
|
|
trailingIcon = {
|
|
trailingIcon = {
|
|
IconButton(onClick = {
|
|
IconButton(onClick = {
|
|
passwordVisibility = !passwordVisibility
|
|
passwordVisibility = !passwordVisibility
|
|
@@ -183,7 +183,7 @@ fun auth(navController: NavHostController) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- onValueChange = { newText -> password.value = newText },
|
|
|
|
|
|
+ onValueChange = { newText -> password.value = newText }, // обновляем значение пароля
|
|
shape = RoundedCornerShape(15.dp),
|
|
shape = RoundedCornerShape(15.dp),
|
|
colors = TextFieldDefaults.textFieldColors(
|
|
colors = TextFieldDefaults.textFieldColors(
|
|
containerColor = fon,
|
|
containerColor = fon,
|
|
@@ -210,14 +210,14 @@ fun auth(navController: NavHostController) {
|
|
)
|
|
)
|
|
Spacer(modifier = Modifier.height(30.dp))
|
|
Spacer(modifier = Modifier.height(30.dp))
|
|
|
|
|
|
- val context = LocalContext.current
|
|
|
|
|
|
+ val context = LocalContext.current //необходим для отображения сообщений
|
|
Button(
|
|
Button(
|
|
onClick = {
|
|
onClick = {
|
|
if (email.value.isNotEmpty() && password.value.isNotEmpty()) {
|
|
if (email.value.isNotEmpty() && password.value.isNotEmpty()) {
|
|
viewModel.onSignInEmailPassword(email.value, password.value)
|
|
viewModel.onSignInEmailPassword(email.value, password.value)
|
|
- scope.launch {
|
|
|
|
|
|
+ scope.launch { //запускаем асинхронную операцию
|
|
delay(2000)
|
|
delay(2000)
|
|
- if (Constant.supabase.auth.currentUserOrNull() != null) {
|
|
|
|
|
|
+ if (Constant.supabase.auth.currentUserOrNull() != null) { //если пользователь авториз то вход
|
|
println("Current User: ${Constant.supabase.auth.currentUserOrNull()!!.email}")
|
|
println("Current User: ${Constant.supabase.auth.currentUserOrNull()!!.email}")
|
|
Toast.makeText(
|
|
Toast.makeText(
|
|
context,
|
|
context,
|