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