Sfoglia il codice sorgente

App: add models and auth

БезаеваАА 2 settimane fa
parent
commit
30da11db5c
19 ha cambiato i file con 275 aggiunte e 1 eliminazioni
  1. 7 0
      Project_exvesta/.idea/kotlinc.xml
  2. 52 1
      Project_exvesta/app/src/main/java/com/example/exvesta/Screans/Preloading.kt
  3. 18 0
      Project_exvesta/app/src/main/java/com/example/exvesta/Screans/auth.kt
  4. 10 0
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Bows.kt
  5. 8 0
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Consists_bows.kt
  6. 8 0
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Consists_wardrob.kt
  7. 74 0
      Project_exvesta/app/src/main/java/com/example/exvesta/model/MainViewModel.kt
  8. 12 0
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Publicthimgs.kt
  9. 7 0
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Season.kt
  10. 7 0
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Season_duplicate.kt
  11. 7 0
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Style.kt
  12. 7 0
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Style_duplicate.kt
  13. 13 0
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Things_user.kt
  14. 7 0
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Type.kt
  15. 7 0
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Type_dublicate.kt
  16. 8 0
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Type_subtype.kt
  17. 8 0
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Type_subtype_duplicate.kt
  18. 8 0
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Users.kt
  19. 7 0
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Wardob.kt

+ 7 - 0
Project_exvesta/.idea/kotlinc.xml

@@ -1,5 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
+  <component name="Kotlin2JvmCompilerArguments">
+    <option name="jvmTarget" value="1.8" />
+  </component>
+  <component name="KotlinCommonCompilerArguments">
+    <option name="apiVersion" value="1.9" />
+    <option name="languageVersion" value="1.9" />
+  </component>
   <component name="KotlinJpsPluginSettings">
     <option name="version" value="1.9.0" />
   </component>

+ 52 - 1
Project_exvesta/app/src/main/java/com/example/exvesta/Screans/Preloading.kt

@@ -1,10 +1,61 @@
 package com.example.exvesta.Screans
 
+import androidx.compose.foundation.layout.Column
 import androidx.compose.runtime.Composable
 import androidx.navigation.NavHost
 import androidx.navigation.NavHostController
+import androidx.activity.ComponentActivity
+import androidx.activity.compose.setContent
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.*
+import androidx.compose.material3.Text
 
+
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Brush
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.style.TextAlign
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
 @Composable
 fun Preloading(navHost: NavHostController){
-
+    Column(
+        modifier = Modifier
+            .fillMaxSize()
+            .background(
+                Brush.verticalGradient(
+                    colors = listOf(
+                        Color(0xFFF4F4F4),
+                        Color(0xFFD9D9D9),
+                        Color(0xFFB0A69B),
+                        Color(0xFFA08779)
+                    )
+                )
+            ),
+        horizontalAlignment = Alignment.CenterHorizontally,
+        verticalArrangement = Arrangement.Center
+    ) {
+        Box(
+            modifier = Modifier
+                .size(100.dp)
+                .background(Color.White),
+            contentAlignment = Alignment.Center
+        ) {
+            Text(
+                text = "👕",
+                fontSize = 48.sp,
+                color = Color(0xFFA08779)
+            )
+        }
+        Spacer(modifier = Modifier.height(16.dp))
+        Text(
+            text = "EXVESTA",
+            fontSize = 24.sp,
+            color = Color.White,
+            fontWeight = FontWeight.Bold,
+            textAlign = TextAlign.Center
+        )
+    }
 }

+ 18 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/Screans/auth.kt

@@ -0,0 +1,18 @@
+package com.example.exvesta.Screans
+
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.navigation.NavHostController
+import com.example.exvesta.model.MainViewModel
+
+@Composable
+fun auth(navHost: NavHostController){
+    val viewModel = MainViewModel()
+    val email = remember { mutableStateOf("") }
+    val password = remember { mutableStateOf("") }
+    var showError = remember { mutableStateOf(false) }
+
+
+
+}

+ 10 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/model/Bows.kt

@@ -0,0 +1,10 @@
+package com.example.exvesta.model
+import kotlinx.serialization.Serializable
+@Serializable
+public data class Bows (
+    val id: Int,
+    val title_bow: String,
+    val id_user: Int,
+    val status: Boolean
+
+)

+ 8 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/model/Consists_bows.kt

@@ -0,0 +1,8 @@
+package com.example.exvesta.model
+import kotlinx.serialization.Serializable
+@Serializable
+public data class Consists_bows (
+    val id: Int,
+    val id_components: Int,
+    val id_bow: Int
+)

+ 8 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/model/Consists_wardrob.kt

@@ -0,0 +1,8 @@
+package com.example.exvesta.model
+import kotlinx.serialization.Serializable
+@Serializable
+public data class Consists_wardrob (
+    val id: Int,
+    val id_wardrob: Int,
+    val id_thing: Int
+    )

+ 74 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/model/MainViewModel.kt

@@ -0,0 +1,74 @@
+package com.example.exvesta.model
+
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
+import com.example.exvesta.domain.utils.Constants
+import io.github.jan.supabase.auth.auth
+import io.github.jan.supabase.auth.providers.builtin.Email
+import io.github.jan.supabase.auth.providers.builtin.OTP
+
+import kotlinx.coroutines.launch
+
+class MainViewModel(): ViewModel() {
+    private val _loginResult = MutableLiveData<Boolean>()
+    val loginResult: LiveData<Boolean> = _loginResult
+
+    fun onSignInEmailCode(emailUser: String) {
+        viewModelScope.launch {
+            try {
+                Constants.supabase.auth.signInWith(OTP) {
+                    email = emailUser
+                    createUser = false
+                }
+
+            } catch (e: Exception) {
+                println(e.message.toString())
+
+            }
+
+        }
+    }
+
+    fun onSignInEmailPassword(emailUser: String, passwordUser: String): Boolean {
+        viewModelScope.launch {
+            try {
+                val user = Constants.supabase.auth.signInWith(Email) {
+                    email = emailUser
+                    password = passwordUser
+                }
+                println(user.toString())
+                println(Constants.supabase.auth.currentUserOrNull()!!.id)
+                println("Success")
+                _loginResult.postValue(true)
+            } catch (e: Exception) {
+                println("Error")
+                println(e.message.toString())
+                _loginResult.postValue(false)
+            }
+        }
+        return _loginResult.value ?: false
+    }
+    fun onSignUpEmail(emailUser: String, passwordUser: String): Boolean {
+        viewModelScope.launch {
+            try{
+                var  user =  Constants.supabase.auth.signUpWith(Email) {
+                    email = emailUser
+                    password = passwordUser
+                }
+                println(user.toString())
+                println(Constants.supabase.auth.currentUserOrNull()!!.id)
+                println("Success")
+                _loginResult.postValue(true)
+            }
+            catch (e: Exception) {
+                println("Error")
+                println(e.message.toString())
+                _loginResult.postValue(false)
+            }
+
+        }
+        return _loginResult.value ?: false
+    }
+}

+ 12 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/model/Publicthimgs.kt

@@ -0,0 +1,12 @@
+package com.example.exvesta.model
+import kotlinx.serialization.Serializable
+@Serializable
+public data class Publicthimgs(
+    val  id: Int,
+    val title: String,
+    val id_style: Int,
+    val id_subtype: Int,
+    val img: String?,
+    val rsting: Int,
+    val article: String
+)

+ 7 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/model/Season.kt

@@ -0,0 +1,7 @@
+package com.example.exvesta.model
+import kotlinx.serialization.Serializable
+@Serializable
+public data class Season(
+    val id: Int,
+    val title_season: String
+)

+ 7 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/model/Season_duplicate.kt

@@ -0,0 +1,7 @@
+package com.example.exvesta.model
+import kotlinx.serialization.Serializable
+@Serializable
+public data class Season_duplicate(
+    val id: Int,
+    val title_season: String
+)

+ 7 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/model/Style.kt

@@ -0,0 +1,7 @@
+package com.example.exvesta.model
+import kotlinx.serialization.Serializable
+@Serializable
+public data class Style(
+    val id: Int,
+    val title_style: String
+)

+ 7 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/model/Style_duplicate.kt

@@ -0,0 +1,7 @@
+package com.example.exvesta.model
+import kotlinx.serialization.Serializable
+@Serializable
+public data class Style_duplicate(
+    val id: Int,
+    val title_style: String
+)

+ 13 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/model/Things_user.kt

@@ -0,0 +1,13 @@
+package com.example.exvesta.model
+import kotlinx.serialization.Serializable
+@Serializable
+public data class Things_user (
+    val id: Int,
+    val style: Int,
+    val title: String,
+    val subtype: Int,
+    val img: String?,
+    val id_season: Int,
+    val no: Boolean,
+    val public_status: Boolean
+)

+ 7 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/model/Type.kt

@@ -0,0 +1,7 @@
+package com.example.exvesta.model
+import kotlinx.serialization.Serializable
+@Serializable
+public data class Type (
+    val id: Int,
+    val title_type: String
+)

+ 7 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/model/Type_dublicate.kt

@@ -0,0 +1,7 @@
+package com.example.exvesta.model
+import kotlinx.serialization.Serializable
+@Serializable
+public data class Type_dublicate (
+    val id: Int,
+    val title_type: String
+)

+ 8 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/model/Type_subtype.kt

@@ -0,0 +1,8 @@
+package com.example.exvesta.model
+import kotlinx.serialization.Serializable
+@Serializable
+public data class Type_subtype (
+    val id: Int,
+    val id_type: Int,
+    val sub_type: String
+)

+ 8 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/model/Type_subtype_duplicate.kt

@@ -0,0 +1,8 @@
+package com.example.exvesta.model
+import kotlinx.serialization.Serializable
+@Serializable
+public data class Type_subtype_duplicate (
+    val id: Int,
+    val id_type: Int,
+    val sub_type: String
+)

+ 8 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/model/Users.kt

@@ -0,0 +1,8 @@
+package com.example.exvesta.model
+import kotlinx.serialization.Serializable
+@Serializable
+public data class Users(
+    val id: Int,
+    val user: String?,
+    val Name: String
+)

+ 7 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/model/Wardob.kt

@@ -0,0 +1,7 @@
+package com.example.exvesta.model
+import kotlinx.serialization.Serializable
+@Serializable
+public data class Wardob(
+    val id: Int,
+    val id_user: Int
+)