|
@@ -1,54 +1,29 @@
|
|
|
package com.example.projectonsupabase.ui.theme.ui
|
|
|
|
|
|
-<<<<<<< HEAD
|
|
|
-import androidx.compose.foundation.layout.*
|
|
|
-=======
|
|
|
import android.content.Context
|
|
|
->>>>>>> 4b996b6ae37db5a6b523a676a040d21205bf6226
|
|
|
+import androidx.compose.foundation.layout.*
|
|
|
import androidx.compose.material3.*
|
|
|
import androidx.compose.runtime.*
|
|
|
-import androidx.compose.runtime.Composable
|
|
|
+import androidx.compose.ui.Alignment
|
|
|
import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
-<<<<<<< HEAD
|
|
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
|
-import com.example.projectonsupabase.MainActivity
|
|
|
-import com.example.projectonsupabase.ViewModels.LoginViewModel
|
|
|
-import com.example.projectonsupabase.ViewModels.LoginViewModelFactory
|
|
|
-
|
|
|
-@Composable
|
|
|
-fun LoginScreen(context: MainActivity)
|
|
|
-{
|
|
|
- //Используем фабрику для создания LoginViewModel с параметром context
|
|
|
- val viewModel : LoginViewModel = viewModel(
|
|
|
-=======
|
|
|
-import androidx.lifecycle.ViewModelProvider
|
|
|
-import androidx.lifecycle.viewmodel.
|
|
|
import com.example.projectonsupabase.ViewModels.LoginViewModel
|
|
|
import com.example.projectonsupabase.ViewModels.LoginViewModelFactory
|
|
|
|
|
|
-
|
|
|
@Composable
|
|
|
-fun LoginScreen(context: Context)
|
|
|
-{
|
|
|
- val viewModel: LoginViewModel = viewModel(
|
|
|
->>>>>>> 4b996b6ae37db5a6b523a676a040d21205bf6226
|
|
|
- factory = LoginViewModelFactory(context)
|
|
|
- )
|
|
|
+fun LoginScreen(context: Context) {
|
|
|
+ val viewModel: LoginViewModel = viewModel(factory = LoginViewModelFactory(context))
|
|
|
|
|
|
- var email by remember { mutableStateOf("")}
|
|
|
- var password by remember{ mutableStateOf("")}
|
|
|
-<<<<<<< HEAD
|
|
|
+ var email by remember { mutableStateOf("") }
|
|
|
+ var password by remember { mutableStateOf("") }
|
|
|
|
|
|
+ // Теперь Compose отслеживает изменения в loginSuccess и loginError
|
|
|
val loginSuccess = viewModel.loginSuccess
|
|
|
val loginError = viewModel.loginError
|
|
|
-=======
|
|
|
- val loginSuccess by remember { mutableStateOf(viewModel.loginSuccess)}
|
|
|
- val loginError by remember { mutableStateOf(viewModel.loginError)}
|
|
|
->>>>>>> 4b996b6ae37db5a6b523a676a040d21205bf6226
|
|
|
|
|
|
- Column (
|
|
|
+ Column(
|
|
|
modifier = Modifier
|
|
|
.fillMaxSize()
|
|
|
.padding(16.dp),
|
|
@@ -65,28 +40,26 @@ fun LoginScreen(context: Context)
|
|
|
label = { Text("Email") },
|
|
|
modifier = Modifier.fillMaxWidth()
|
|
|
)
|
|
|
-
|
|
|
- Spacer(modifier =
|
|
|
- Modifier.height(16.dp))
|
|
|
+
|
|
|
+ Spacer(modifier = Modifier.height(16.dp))
|
|
|
|
|
|
OutlinedTextField(
|
|
|
value = password,
|
|
|
- onValueChange ={ password = it },
|
|
|
- label = { Text("Password")},
|
|
|
+ onValueChange = { password = it },
|
|
|
+ label = { Text("Password") },
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
|
visualTransformation = PasswordVisualTransformation()
|
|
|
)
|
|
|
|
|
|
- Spacer(modifier =
|
|
|
- Modifier.height(16.dp))
|
|
|
+ Spacer(modifier = Modifier.height(16.dp))
|
|
|
|
|
|
Button(
|
|
|
- onClick = {
|
|
|
- viewModel.login(email, password) //Вызываем коллбек при клике на кнопку
|
|
|
+ onClick = {
|
|
|
+ viewModel.login(email, password)
|
|
|
},
|
|
|
modifier = Modifier.fillMaxWidth()
|
|
|
) {
|
|
|
- Text("Login")
|
|
|
+ Text("Login")
|
|
|
}
|
|
|
|
|
|
Spacer(modifier = Modifier.height(16.dp))
|
|
@@ -97,4 +70,4 @@ fun LoginScreen(context: Context)
|
|
|
Text("Error: $loginError", color = MaterialTheme.colorScheme.error)
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+}
|