Denis Pavlov 1 месяц назад
Родитель
Сommit
81fa876632

+ 1 - 17
app/build.gradle.kts

@@ -53,11 +53,7 @@ android {
 dependencies {
     implementation(libs.androidx.core.ktx)
     implementation(libs.androidx.lifecycle.runtime.ktx)
-<<<<<<< HEAD
     implementation (libs.androidx.lifecycle.viewmodel.compose)
-=======
-    implementation(libs.androidx.lifecycle.viewmodel.compose)
->>>>>>> 4b996b6ae37db5a6b523a676a040d21205bf6226
     implementation(libs.androidx.activity.compose)
     implementation(platform(libs.androidx.compose.bom))
     implementation(libs.androidx.ui)
@@ -69,13 +65,10 @@ dependencies {
 //    implementation(libs.androidx.runtime.android)
     testImplementation(libs.junit)
     androidTestImplementation(libs.androidx.junit)
-    androidTestImplementation(libs.androidx.espresso.core)
-    androidTestImplementation(platform(libs.androidx.compose.bom))
     androidTestImplementation(libs.androidx.ui.test.junit4)
     debugImplementation(libs.androidx.ui.tooling)
     debugImplementation(libs.androidx.ui.test.manifest)
 
-<<<<<<< HEAD
     implementation(libs.bom)
     implementation(libs.postgrest.kt)
     implementation(libs.gotrue.kt)
@@ -83,27 +76,18 @@ dependencies {
     implementation(libs.storage.kt)
     //noinspection UseTomlInstead
     implementation("io.ktor:ktor-client-android:2.3.12")
-=======
-    implementation(platform(libs.bom))
+
 //    implementation(platform(libs.androidx.compose.bom))
-    implementation(libs.gotrue.kt)
-    implementation(libs.realtime.kt)
-    implementation(libs.storage.kt)
     implementation(libs.ktor.client.android)
->>>>>>> 4b996b6ae37db5a6b523a676a040d21205bf6226
     implementation (libs.ktor.client.core)
     implementation (libs.ktor.client.content.negotiation)
     implementation (libs.ktor.serialization.kotlinx.json)
     implementation (libs.ktor.client.serialization)
     implementation (libs.ktor.client.logging)
 
-<<<<<<< HEAD
     //noinspection UseTomlInstead
     implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-core:2.3.12")
-=======
     implementation (libs.kotlinx.coroutines.core)
->>>>>>> 4b996b6ae37db5a6b523a676a040d21205bf6226
-
     implementation (libs.ui)
     implementation (libs.material3)
     implementation (libs.ui.tooling.preview)

+ 3 - 11
app/src/main/java/com/example/projectonsupabase/ViewModels/LoginViewModelFactory.kt

@@ -4,22 +4,14 @@ import android.content.Context
 import androidx.lifecycle.ViewModel
 import androidx.lifecycle.ViewModelProvider
 
-class LoginViewModelFactory (private val context: Context) : ViewModelProvider.Factory {
-<<<<<<< HEAD
-    override fun <T : ViewModel> create (modelClass: Class<T>) : T {
-=======
-    override fun <T : ViewModel>
-    create(modelClass: Class<T>): T {
->>>>>>> 4b996b6ae37db5a6b523a676a040d21205bf6226
+class LoginViewModelFactory(private val context: Context) : ViewModelProvider.Factory {
+    override fun <T : ViewModel> create(modelClass: Class<T>): T {
         if (modelClass.isAssignableFrom(LoginViewModel::class.java)) {
             return LoginViewModel(context) as T
         }
         throw IllegalArgumentException("Unknown ViewModel class")
     }
-<<<<<<< HEAD
 }
 
 
-=======
-}
->>>>>>> 4b996b6ae37db5a6b523a676a040d21205bf6226
+

+ 17 - 44
app/src/main/java/com/example/projectonsupabase/ui/theme/ui/LoginScreen.kt

@@ -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)
         }
     }
-}
+}

+ 5 - 31
gradle/libs.versions.toml

@@ -1,59 +1,39 @@
 [versions]
-<<<<<<< HEAD
+
 agp = "8.6.1"
 bom = "2.6.1"
-=======
-agp = "8.5.1"
-bom = "2.6.1"
 composeBomVersion = "2024.09.03"
->>>>>>> 4b996b6ae37db5a6b523a676a040d21205bf6226
 kotlin = "1.9.0"
 coreKtx = "1.13.1"
 junit = "4.13.2"
-<<<<<<< HEAD
 junitVersion = "1.2.1"
 espressoCore = "3.6.1"
-=======
-junitVersion = "1.1.5"
-espressoCore = "3.5.1"
 kotlinxCoroutinesCore = "2.3.12"
 ktorClientAndroid = "2.3.12"
->>>>>>> 4b996b6ae37db5a6b523a676a040d21205bf6226
 ktorClientCio = "2.3.12"
 ktorClientContentNegotiation = "2.3.12"
 ktorClientCore = "2.3.12"
 ktorClientLogging = "2.3.12"
 ktorClientSerialization = "2.3.12"
 ktorSerializationKotlinxJson = "2.3.12"
-<<<<<<< HEAD
+
 lifecycleRuntimeKtx = "2.8.6"
 activityCompose = "1.9.3"
 composeBom = "2024.10.00"
 lifecycleViewmodelCompose = "2.8.6"
 storageKt = "2.6.1"
 volley = "1.2.1"
-=======
-lifecycleRuntimeKtx = "2.6.1"
-activityCompose = "1.8.0"
-composeBom = "2024.04.01"
-lifecycleViewmodelCompose = "2.8.6"
 material3 = "1.3.0"
 navigationCompose = "2.8.2"
-storageKt = "2.6.1"
 ui = "1.7.3"
 uiToolingPreview = "1.7.3"
-volley = "1.2.1"
 runtimeAndroid = "1.7.3"
->>>>>>> 4b996b6ae37db5a6b523a676a040d21205bf6226
-
 [libraries]
 androidx-compose-bom-v20240903 = { module = "androidx.compose:compose-bom", version.ref = "composeBomVersion" }
 androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
 androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycleViewmodelCompose" }
-<<<<<<< HEAD
-=======
+
 androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationCompose" }
->>>>>>> 4b996b6ae37db5a6b523a676a040d21205bf6226
 bom = { module = "io.github.jan-tennert.supabase:bom", version.ref = "bom" }
 gotrue-kt = { module = "io.github.jan-tennert.supabase:gotrue-kt" }
 junit = { group = "junit", name = "junit", version.ref = "junit" }
@@ -77,22 +57,16 @@ ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktorCli
 ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktorClientLogging" }
 ktor-client-serialization = { module = "io.ktor:ktor-client-serialization", version.ref = "ktorClientSerialization" }
 ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktorSerializationKotlinxJson" }
-<<<<<<< HEAD
+
 realtime-kt = { module = "io.github.jan-tennert.supabase:realtime-kt" }
 postgrest-kt = { module = "io.github.jan-tennert.supabase:postgrest-kt" }
 storage-kt = { module = "io.github.jan-tennert.supabase:storage-kt", version.ref = "storageKt" }
 volley = { module = "com.android.volley:volley", version.ref = "volley" }
-=======
+
 material3 = { module = "androidx.compose.material3:material3", version.ref = "material3" }
-postgrest-kt = { module = "io.github.jan-tennert.supabase:postgrest-kt" }
-realtime-kt = { module = "io.github.jan-tennert.supabase:realtime-kt" }
-storage-kt = { module = "io.github.jan-tennert.supabase:storage-kt", version.ref = "storageKt" }
 ui = { module = "androidx.compose.ui:ui", version.ref = "ui" }
 ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "uiToolingPreview" }
-volley = { module = "com.android.volley:volley", version.ref = "volley" }
 androidx-runtime-android = { group = "androidx.compose.runtime", name = "runtime-android", version.ref = "runtimeAndroid" }
->>>>>>> 4b996b6ae37db5a6b523a676a040d21205bf6226
-
 [plugins]
 android-application = { id = "com.android.application", version.ref = "agp" }
 jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }