Browse Source

feat: Добавлена странциа профиля пользователя

http://gogs.ngknn.local:3000/K1rakato/MobileStore.git 1 week ago
parent
commit
aef656b21e
17 changed files with 674 additions and 90 deletions
  1. 1 1
      ProjectApp/TomatoAndPotatoAPP/app/build.gradle.kts
  2. 9 20
      ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/MainActivity.kt
  3. 54 14
      ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/Screens/AuthorizationScreen.kt
  4. 32 17
      ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/Screens/ChoiceScreen.kt
  5. 14 0
      ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/Screens/PLantsCatalogScreen.kt
  6. 157 0
      ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/Screens/ProfileScreen.kt
  7. 49 15
      ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/Screens/RegistrationScreen.kt
  8. 26 9
      ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/Screens/StartScreen.kt
  9. 55 2
      ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/ViewModelsPack/SupabaseAuthViewModel.kt
  10. 116 3
      ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/navigationPack/AppNavigation.kt
  11. 28 0
      ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/navigationPack/BottomGraph.kt
  12. 15 0
      ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/navigationPack/NavItem.kt
  13. 47 0
      ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/navigationPack/Navigation.kt
  14. 22 0
      ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/navigationPack/Screens.kt
  15. 48 2
      ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/utils/ProfileString.kt
  16. 1 1
      ProjectApp/TomatoAndPotatoAPP/build.gradle.kts
  17. 0 6
      ProjectApp/TomatoAndPotatoAPP/gradle/libs.versions.toml

+ 1 - 1
ProjectApp/TomatoAndPotatoAPP/app/build.gradle.kts

@@ -75,7 +75,7 @@ dependencies {
 
     implementation(libs.ktor.client.android)
 
+    implementation(libs.androidx.navigation.compose)
 
-    implementation (libs.androidx.navigation.compose.v282)
 
 }

+ 9 - 20
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/MainActivity.kt

@@ -6,11 +6,15 @@ import androidx.activity.compose.setContent
 import androidx.activity.enableEdgeToEdge
 import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.MaterialTheme
 import androidx.compose.material3.Scaffold
+import androidx.compose.material3.Surface
 import androidx.compose.material3.Text
 import androidx.compose.runtime.Composable
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.tooling.preview.Preview
+import com.example.tomatoandpotatoapp.ViewModelsPack.SupabaseAuthViewModel
+import com.example.tomatoandpotatoapp.navigationPack.Navigation
 import com.example.tomatoandpotatoapp.ui.theme.TomatoAndPotatoAPPTheme
 
 class MainActivity : ComponentActivity() {
@@ -19,29 +23,14 @@ class MainActivity : ComponentActivity() {
         enableEdgeToEdge()
         setContent {
             TomatoAndPotatoAPPTheme {
-                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
-                    Greeting(
-                        name = "Android",
-                        modifier = Modifier.padding(innerPadding)
-                    )
+                Surface(
+                    modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background
+                ) {
+                    val viewModel = SupabaseAuthViewModel()
+                    Navigation(viewModel)
                 }
             }
         }
     }
 }
 
-@Composable
-fun Greeting(name: String, modifier: Modifier = Modifier) {
-    Text(
-        text = "Hello $name!",
-        modifier = modifier
-    )
-}
-
-@Preview(showBackground = true)
-@Composable
-fun GreetingPreview() {
-    TomatoAndPotatoAPPTheme {
-        Greeting("Android")
-    }
-}

+ 54 - 14
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/Screens/AuthorizationScreen.kt

@@ -16,38 +16,56 @@ import androidx.compose.foundation.shape.RoundedCornerShape
 import androidx.compose.material.icons.Icons
 import androidx.compose.material.icons.filled.KeyboardArrowLeft
 import androidx.compose.material3.Button
-import androidx.compose.material3.ButtonColors
 import androidx.compose.material3.ButtonDefaults
+import androidx.compose.material3.CircularProgressIndicator
 import androidx.compose.material3.Icon
 import androidx.compose.material3.MaterialTheme
 import androidx.compose.material3.Text
 import androidx.compose.material3.TextField
 import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
 import androidx.compose.runtime.mutableStateOf
 import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
 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.input.pointer.pointerInput
+import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.platform.LocalFocusManager
 import androidx.compose.ui.platform.LocalSoftwareKeyboardController
 import androidx.compose.ui.text.font.FontWeight
 import androidx.compose.ui.text.style.TextAlign
-import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
+import com.example.tomatoandpotatoapp.ViewModelsPack.SupabaseAuthViewModel
+import androidx.lifecycle.viewmodel.compose.viewModel
+import androidx.navigation.NavController
+import com.example.tomatoandpotatoapp.data.models.UserState
+import com.example.tomatoandpotatoapp.navigationPack.Screens
 
-@Preview(showBackground = true)
+//@Preview(showBackground = true)
 @Composable
-fun Authorization() {
+fun Authorization(
+    viewModel: SupabaseAuthViewModel = viewModel(),
+    navController: NavController
+) {
+
+    val context = LocalContext.current
+    val userState by viewModel.userState
+    val f = remember { mutableStateOf(false) }
+
+    var userEmail by remember { mutableStateOf("") }
+    var userPassword by remember { mutableStateOf("") }
+
+    var currentUserState by remember { mutableStateOf("") }
 
     val keyboardController = LocalSoftwareKeyboardController.current
     val focusManager = LocalFocusManager.current
-    val userEmail = remember { mutableStateOf("") }
-    val userPassword = remember { mutableStateOf("") }
-
-    val emailFlag = remember { mutableStateOf(false) }
+    val emailFlag = remember {
+        mutableStateOf(false)
+    }
 
     Box(modifier = Modifier.fillMaxSize()) {
 
@@ -76,7 +94,7 @@ fun Authorization() {
                 ) {
                     Button(
                         onClick = {
-                            /*TODO*/
+                            navController.navigate(Screens.ChoiceScreen.route)
                         },
                         modifier = Modifier
                             .padding(start = 13.dp, top = 34.dp)
@@ -139,8 +157,8 @@ fun Authorization() {
                         placeholder = {
                             Text(text = "Введите логин")
                         },
-                        value = userEmail.value,
-                        onValueChange = { userEmail.value = it }
+                        value = userEmail,
+                        onValueChange = { userEmail = it }
                     )
 
                     TextField(
@@ -151,8 +169,8 @@ fun Authorization() {
                         placeholder = {
                             Text(text = "Введите пароль")
                         },
-                        value = userPassword.value,
-                        onValueChange = {userPassword.value = it}
+                        value = userPassword,
+                        onValueChange = { userPassword = it }
                     )
 
                     Spacer(modifier = Modifier.height(15.dp))
@@ -172,7 +190,8 @@ fun Authorization() {
                             text = "Вход",
                             fontSize = 20.sp,
                             fontWeight = FontWeight.W700,
-                            color = Color.White)
+                            color = Color.White
+                        )
                     }
 
 
@@ -182,5 +201,26 @@ fun Authorization() {
 
         }
     }
+    if (f.value) {
+        when (userState) {
+            is UserState.Loading -> {
+                CircularProgressIndicator()
+            }
+
+            is UserState.Success -> {
+                val message = (userState as UserState.Success).message
+                currentUserState = message
+                viewModel.selectPeople()
+                navController.navigate(Screens.AppNavigation.route)
+                f.value = false
+            }
+
+            is UserState.Error -> {
+                val message = (userState as UserState.Error).message
+                currentUserState = message
+                f.value = false
+            }
+        }
+    }
 }
 

+ 32 - 17
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/Screens/ChoiceScreen.kt

@@ -14,7 +14,6 @@ import androidx.compose.foundation.layout.size
 import androidx.compose.foundation.layout.width
 import androidx.compose.foundation.shape.RoundedCornerShape
 import androidx.compose.material3.Button
-import androidx.compose.material3.ButtonColors
 import androidx.compose.material3.ButtonDefaults
 import androidx.compose.material3.Text
 import androidx.compose.runtime.Composable
@@ -26,33 +25,38 @@ import androidx.compose.ui.layout.ContentScale
 import androidx.compose.ui.res.painterResource
 import androidx.compose.ui.text.font.FontWeight
 import androidx.compose.ui.text.style.TextAlign
-import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
 import com.example.tomatoandpotatoapp.R
-import io.github.jan.supabase.realtime.Column
-import io.ktor.websocket.Frame
+import androidx.navigation.NavController
+import com.example.tomatoandpotatoapp.navigationPack.Screens
 
 
-@Preview()
 @Composable
-fun ChoiceScr() {
+fun ChoiceScr(
+    navController: NavController
+) {
     Box(
         modifier = Modifier.fillMaxSize()
     ) {
-        Image(painter = painterResource(
-            id = R.drawable.fon),
+        Image(
+            painter = painterResource(
+                id = R.drawable.fon
+            ),
             contentDescription = "Фон",
             modifier = Modifier.fillMaxSize(),
-            contentScale = ContentScale.Crop)
+            contentScale = ContentScale.Crop
+        )
 
         Box(
             modifier = Modifier
                 .fillMaxSize()
                 .background(
                     brush = Brush.verticalGradient(
-                        colors = listOf(Color(0xFFFFFFFF).copy(alpha = 0.4f),
-                    Color(0xFF000000).copy(alpha = 0.65f)),
+                        colors = listOf(
+                            Color(0xFFFFFFFF).copy(alpha = 0.4f),
+                            Color(0xFF000000).copy(alpha = 0.65f)
+                        ),
                         startY = 0.0f,
                         endY = 1500.0f
                     )
@@ -75,9 +79,18 @@ fun ChoiceScr() {
                 Image(
                     painter = painterResource(id = R.drawable.logo),
                     contentDescription = "Логотип",
-                    modifier = Modifier.size(120.dp))
+                    modifier = Modifier.size(120.dp)
+                )
+                Text(
+                    text = "Добро пожаловать в",
+                    fontWeight = FontWeight.W700,
+                    fontSize = 27.sp,
+                    color = Color.White,
+                    textAlign = TextAlign.Center
+                )
+                Spacer(modifier = Modifier.height(10.dp))
                 Text(
-                    text = "Добро пожаловать в TomatoAndPotato",
+                    text = "TomatoAndPotato",
                     fontWeight = FontWeight.W700,
                     fontSize = 27.sp,
                     color = Color.White,
@@ -93,12 +106,13 @@ fun ChoiceScr() {
                 verticalArrangement = Arrangement.Center
             ) {
                 Button(
-                    onClick = { /*TODO*/ },
+                    onClick = { navController.navigate(Screens.AuthorizationScreen.route) },
                     modifier = Modifier
                         .width(278.dp)
                         .height(45.dp),
                     shape = RoundedCornerShape(30),
-                    colors = ButtonDefaults.buttonColors(containerColor = Color(0xFFBCBD76)
+                    colors = ButtonDefaults.buttonColors(
+                        containerColor = Color(0xFFBCBD76)
                     )
                 )
                 {
@@ -113,12 +127,13 @@ fun ChoiceScr() {
                 Spacer(modifier = Modifier.height(30.dp))
 
                 Button(
-                    onClick = { /*TODO*/ },
+                    onClick = { navController.navigate(Screens.RegistrationScreen.route) },
                     modifier = Modifier
                         .width(278.dp)
                         .height(45.dp),
                     shape = RoundedCornerShape(30),
-                    colors = ButtonDefaults.buttonColors(containerColor = Color(0xFF78EE99)
+                    colors = ButtonDefaults.buttonColors(
+                        containerColor = Color(0xFF78EE99)
                     )
                 ) {
                     Text(

+ 14 - 0
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/Screens/PLantsCatalogScreen.kt

@@ -0,0 +1,14 @@
+package com.example.tomatoandpotatoapp.Screens
+
+import androidx.compose.runtime.Composable
+import androidx.navigation.NavController
+import com.example.tomatoandpotatoapp.ViewModelsPack.SupabaseAuthViewModel
+import androidx.lifecycle.viewmodel.compose.viewModel
+
+@Composable
+fun ShowPlants(
+    viewModel: SupabaseAuthViewModel = viewModel(),
+    navController: NavController,
+) {
+
+}

+ 157 - 0
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/Screens/ProfileScreen.kt

@@ -0,0 +1,157 @@
+package com.example.tomatoandpotatoapp.Screens
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonDefaults
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+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.platform.LocalContext
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.tooling.preview.Preview
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import com.example.tomatoandpotatoapp.ViewModelsPack.SupabaseAuthViewModel
+import androidx.lifecycle.viewmodel.compose.viewModel
+import androidx.navigation.NavController
+import com.example.tomatoandpotatoapp.utils.EditProfileString
+
+@Preview
+@Composable
+fun MyProfile(
+    //viewModel: SupabaseAuthViewModel = viewModel(),
+    //navController: NavController
+) {
+//    val userState by viewModel.userState
+//    val people by viewModel.user
+//    val f = remember { mutableStateOf(false) }
+//    val context = LocalContext.current
+//    val f2 = remember { mutableStateOf(true) }
+//
+//    if (f2.value) {
+//        viewModel.selectPeople()
+//        f2.value = false
+//    }
+
+//    if (viewModel.user.value.isNotEmpty()){
+//        val firstName = remember {
+//            mutableStateOf(people.last().firstName)
+//        }
+//        val genderId = remember {
+//            mutableStateOf(people.last().genderId)
+//        }
+//        val birthDate = remember {
+//            mutableStateOf(people.last().birthDate)
+//        }
+
+    Box(modifier = Modifier.fillMaxSize()) {
+        Box(
+            modifier = Modifier
+                .fillMaxSize()
+                .background(
+                    brush = Brush.verticalGradient(
+                        colors = listOf(
+                            Color(0xFF666666).copy(alpha = 0.85f),
+                            Color(0xFF666666).copy(alpha = 0.1f)
+                        ),
+                        startY = 0.0f,
+                        endY = 1500.0f
+                    )
+                )
+        )
+        Column(modifier = Modifier.fillMaxSize()) {
+            Row(
+                modifier = Modifier
+                    .fillMaxWidth()
+                    .height(75.dp),
+                horizontalArrangement = Arrangement.Center,
+                verticalAlignment = Alignment.CenterVertically
+            ) {
+                Text(
+                    text = "Профиль",
+                    fontWeight = FontWeight.W700,
+                    color = Color.White,
+                    fontSize = 25.sp
+                )
+            }
+
+            Spacer(modifier = Modifier.height(60.dp))
+
+            EditProfileString(search = "", onValueChange = {}, enabled = true)
+
+            Spacer(modifier = Modifier.height(30.dp))
+
+            EditProfileString(search = "", onValueChange = {}, enabled = true)
+
+            Spacer(modifier = Modifier.height(30.dp))
+
+            EditProfileString(search = "", onValueChange = {}, enabled = true)
+
+            Spacer(modifier = Modifier.height(110.dp))
+
+            Row(
+                modifier = Modifier.fillMaxWidth(),
+                horizontalArrangement = Arrangement.Center,
+                verticalAlignment = Alignment.CenterVertically
+            ) {
+                Button(
+                    onClick = { },
+                    modifier = Modifier
+                        .width(278.dp)
+                        .height(45.dp),
+                    shape = RoundedCornerShape(20),
+                    colors = ButtonDefaults.buttonColors(containerColor = Color(0xff78EE99))
+                )
+                {
+                    Text(
+                        text = "Сохранить",
+                        fontSize = 20.sp,
+                        fontWeight = FontWeight.W700,
+                        color = Color.White
+                    )
+                }
+            }
+
+            Spacer(modifier = Modifier.height(25.dp))
+
+            Row(
+                modifier = Modifier.fillMaxWidth(),
+                horizontalArrangement = Arrangement.Center,
+                verticalAlignment = Alignment.CenterVertically
+            ) {
+                Button(
+                    onClick = { },
+                    modifier = Modifier
+                        .width(278.dp)
+                        .height(45.dp),
+                    shape = RoundedCornerShape(20),
+                    colors = ButtonDefaults.buttonColors(containerColor = Color(0xffFC5050))
+                )
+                {
+                    Text(
+                        text = "Выход",
+                        fontSize = 20.sp,
+                        fontWeight = FontWeight.W700,
+                        color = Color.White
+                    )
+                }
+            }
+        }
+    }
+}

+ 49 - 15
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/Screens/RegistrationScreen.kt

@@ -18,6 +18,7 @@ import androidx.compose.material.icons.Icons
 import androidx.compose.material.icons.filled.KeyboardArrowLeft
 import androidx.compose.material3.Button
 import androidx.compose.material3.ButtonDefaults
+import androidx.compose.material3.CircularProgressIndicator
 import androidx.compose.material3.Icon
 import androidx.compose.material3.MaterialTheme
 import androidx.compose.material3.Text
@@ -26,30 +27,42 @@ import androidx.compose.runtime.Composable
 import androidx.compose.runtime.getValue
 import androidx.compose.runtime.mutableStateOf
 import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
 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.input.pointer.pointerInput
+import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.platform.LocalFocusManager
 import androidx.compose.ui.platform.LocalSoftwareKeyboardController
 import androidx.compose.ui.text.font.FontWeight
 import androidx.compose.ui.text.style.TextAlign
-import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
+import androidx.navigation.NavController
+import com.example.tomatoandpotatoapp.ViewModelsPack.SupabaseAuthViewModel
+import com.example.tomatoandpotatoapp.navigationPack.Screens
+import androidx.lifecycle.viewmodel.compose.viewModel
+import com.example.tomatoandpotatoapp.data.models.UserState
 
 
-@Preview(showBackground = true)
 @Composable
-fun Registration() {
+fun Registration(
+    viewModel: SupabaseAuthViewModel = viewModel(),
+    navController: NavController
+) {
+    val context = LocalContext.current
+    val userState by viewModel.userState
+    val f = remember { mutableStateOf(false) }
 
-    val keyboardController = LocalSoftwareKeyboardController.current
-    val focusManager = LocalFocusManager.current
+    var userEmail by remember { mutableStateOf("") }
+    var userPassword by remember { mutableStateOf("") }
 
-    val userEmail = remember { mutableStateOf("") }
-    val userPassword = remember { mutableStateOf("") }
+    var currentUserState by remember { mutableStateOf("") }
 
+    val keyboardController = LocalSoftwareKeyboardController.current
+    val focusManager = LocalFocusManager.current
     val emailFlag = remember {
         mutableStateOf(false)
     }
@@ -78,7 +91,7 @@ fun Registration() {
             ) {
                 Button(
                     onClick = {
-                        /*TODO*/
+                        navController.navigate(Screens.ChoiceScreen.route)
                     },
                     modifier = Modifier
                         .padding(start = 13.dp, top = 34.dp)
@@ -139,10 +152,10 @@ fun Registration() {
                     placeholder = {
                         Text(text = "Введите логин")
                     },
-                    value = userEmail.value,
+                    value = userEmail,
 
                     onValueChange = {
-                        userEmail.value = it
+                        userEmail = it
                     }
                 )
 
@@ -152,9 +165,9 @@ fun Registration() {
                     maxLines = 1,
                     singleLine = true,
                     placeholder = { Text(text = "Введите пароль") },
-                    value = userPassword.value,
+                    value = userPassword,
                     onValueChange = {
-                        userPassword.value = it
+                        userPassword = it
                     }
                 )
 
@@ -162,7 +175,7 @@ fun Registration() {
 
                 Button(
                     onClick = {
-                        /*TODO*/
+                        navController.navigate(Screens.ProfileScreen.route)
                     },
                     modifier = Modifier
                         .width(278.dp)
@@ -173,7 +186,8 @@ fun Registration() {
                     )
                 )
                 {
-                    Text(text = "Регистрация",
+                    Text(
+                        text = "Регистрация",
                         fontWeight = FontWeight.W700,
                         fontSize = 20.sp,
                         color = Color.White
@@ -181,7 +195,27 @@ fun Registration() {
                 }
             }
         }
-    }
+        if (f.value) {
+            when (userState) {
+                is UserState.Loading -> {
+                    CircularProgressIndicator()
+                }
 
+                is UserState.Success -> {
+                    val message = (userState as UserState.Success).message
+                    currentUserState = message
+                    viewModel.addPeople()
+                    viewModel.selectPeople()
+                    navController.navigate(Screens.AppNavigation.route)
+                    f.value = false
+                }
 
+                is UserState.Error -> {
+                    val message = (userState as UserState.Error).message
+                    currentUserState = message
+                    f.value = false
+                }
+            }
+        }
+    }
 }

+ 26 - 9
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/Screens/StartScreen.kt

@@ -1,6 +1,7 @@
 package com.example.tomatoandpotatoapp.Screens
 
 
+import android.content.res.Configuration
 import androidx.compose.foundation.Image
 import androidx.compose.foundation.background
 import androidx.compose.foundation.layout.Arrangement
@@ -10,6 +11,7 @@ import androidx.compose.foundation.layout.Row
 import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.material3.Text
 import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.geometry.Size
@@ -19,36 +21,51 @@ import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.graphics.ImageBitmap
 import androidx.compose.ui.graphics.RadialGradientShader
 import androidx.compose.ui.graphics.ShaderBrush
+import androidx.compose.ui.platform.LocalConfiguration
 import androidx.compose.ui.res.imageResource
 import androidx.compose.ui.tooling.preview.Preview
+import androidx.navigation.NavController
 import com.example.tomatoandpotatoapp.R
+import com.example.tomatoandpotatoapp.navigationPack.Screens
+import kotlinx.coroutines.delay
 import java.security.KeyStore.TrustedCertificateEntry
 
 
-@Preview(showBackground = true)
 @Composable
-fun Welcome()
-{
+fun Welcome(navController: NavController) {
+    val configuration = LocalConfiguration.current
+    if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
+        LaunchedEffect(key1 = true) {
+            delay(1500L)
+            navController.navigate(Screens.ChoiceScreen.route)
+        }
+    }
 
     Box(
         modifier = Modifier
             .fillMaxSize()
             .background(
                 brush = Brush.verticalGradient(
-                    colors = listOf(Color(0xFF666666).copy(alpha = 0.8f),
-                        Color(0xFF000000).copy(alpha = 0.75f)),
+                    colors = listOf(
+                        Color(0xFF666666).copy(alpha = 0.8f),
+                        Color(0xFF000000).copy(alpha = 0.75f)
+                    ),
                     startY = 0.0f,
                     endY = 1500.0f
                 )
             )
     )
 
-    Column(modifier = Modifier
-        .fillMaxSize())
+    Column(
+        modifier = Modifier
+            .fillMaxSize()
+    )
     {
-        Row(modifier = Modifier.fillMaxSize(),
+        Row(
+            modifier = Modifier.fillMaxSize(),
             horizontalArrangement = Arrangement.Center,
-            verticalAlignment = Alignment.CenterVertically) {
+            verticalAlignment = Alignment.CenterVertically
+        ) {
             Image(bitmap = ImageBitmap.imageResource(R.drawable.logo), contentDescription = "")
 
         }

+ 55 - 2
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/ViewModelsPack/SupabaseAuthViewModel.kt

@@ -17,14 +17,15 @@ import com.example.tomatoandpotatoapp.utils.SharedPreferenceHelper
 import io.github.jan.supabase.auth.admin.AdminUserBuilder
 import io.github.jan.supabase.auth.auth
 import io.github.jan.supabase.auth.providers.builtin.Email
+import io.github.jan.supabase.postgrest.from
 import kotlinx.coroutines.launch
 
 class SupabaseAuthViewModel : ViewModel() {
     private val _userState = mutableStateOf<UserState>(UserState.Loading)
     val userState: State<UserState> = _userState
 
-    private val _users = mutableStateOf(listOf<UsersTable>())
-    val users: State<List<UsersTable>> = _users
+    private val _user = mutableStateOf(listOf<UsersTable>())
+    val user: State<List<UsersTable>> = _user
 
     private val _plants = mutableStateOf(listOf<Plants>())
     val plants: State<List<Plants>> = _plants
@@ -105,4 +106,56 @@ class SupabaseAuthViewModel : ViewModel() {
     }
 
 
+    fun addPeople(){
+        viewModelScope.launch {
+            try {
+                _userState.value = UserState.Loading
+                client.from("UsersTable").insert(UsersTable(
+                    idRole = 2,
+                    genderId = client.auth.currentAccessTokenOrNull()!!.length,
+                    uid = client.auth.currentUserOrNull()!!.id))
+
+
+            }catch (e: Exception){
+                _userState.value = UserState.Error("Error ${e.message}")
+            }
+        }
+    }
+
+    fun updatePeople(firstname: String, genderId:Int, birthDate:String)
+    {
+        viewModelScope.launch {
+            try {
+                _userState.value = UserState.Loading
+                client.from("Users").update({
+                    UsersTable::firstName setTo firstname
+                    UsersTable::genderId setTo genderId
+                    UsersTable::birthDate setTo birthDate
+                })
+                {
+                    filter { UsersTable::uid eq client.auth.currentUserOrNull()!!.id }
+                }
+
+
+            }catch (e: Exception){
+                _userState.value = UserState.Error("Error ${e.message}")
+            }
+        }
+    }
+
+    fun selectPeople(){
+        viewModelScope.launch {
+            try {
+                _userState.value = UserState.Loading
+
+                _user.value = client.from("Users").select { filter { UsersTable::uid eq
+                        client.auth.currentUserOrNull()!!.id } }.decodeList<UsersTable>()
+
+            }catch (e: Exception){
+                _userState.value = UserState.Error("Error ${e.message}")
+            }
+        }
+    }
+
+
 }

+ 116 - 3
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/navigationPack/AppNavigation.kt

@@ -1,11 +1,124 @@
 package com.example.tomatoandpotatoapp.navigationPack
 
+import androidx.compose.foundation.background
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.Scaffold
+import androidx.compose.material3.Text
 import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import androidx.navigation.NavDestination
+import androidx.navigation.NavDestination.Companion.hierarchy
+import androidx.navigation.NavGraph.Companion.findStartDestination
+import androidx.navigation.NavHostController
+import androidx.navigation.compose.currentBackStackEntryAsState
+import androidx.navigation.compose.rememberNavController
 import com.example.tomatoandpotatoapp.ViewModelsPack.SupabaseAuthViewModel
 
 @Composable
-fun AppNavigation(viewModel: SupabaseAuthViewModel){
+fun AppNavigation(viewModel: SupabaseAuthViewModel) {
+    val navController = rememberNavController()
+    Scaffold(modifier = Modifier
+        .fillMaxSize()
+        .background(Color.Transparent),
+        bottomBar = { BottomBar(navController) }
+    ) {
+        Column(
+            modifier = Modifier
+                .fillMaxSize()
+                .padding(it)
+        ) {
+            BottomGraph(navController = navController, viewModel)
+        }
+    }
 
-    
+}
 
-}
+@Composable
+fun BottomBar(navController: NavHostController) {
+    val screens = listOf(
+        NavItem.Profile,
+        NavItem.PlantsCatalog
+    )
+
+    val navStackBackEntry by navController.currentBackStackEntryAsState()
+    val currentDestination = navStackBackEntry?.destination
+
+    Row(
+        modifier = Modifier
+            .height(60.dp)
+            .background(Color(0xFF5178FF))
+            .fillMaxWidth(),
+        horizontalArrangement = Arrangement.SpaceEvenly,
+        verticalAlignment = Alignment.CenterVertically
+    ) {
+        screens.forEach { screen ->
+            AddItem(
+                screen = screen,
+                currentDestination = currentDestination,
+                navController = navController
+            )
+        }
+    }
+}
+
+@Composable
+fun AddItem(
+    screen: NavItem,
+    currentDestination: NavDestination?,
+    navController: NavHostController
+) {
+    val selected = currentDestination?.hierarchy?.any { it.route == screen.rote } == true
+
+    val background =
+        if (selected) Color(0x5944589F) else Color.Transparent
+
+    val contentColor =
+        if (selected) Color.White else Color.White
+
+    Box(
+        modifier = Modifier
+            .width(85.dp)
+            .clip(RoundedCornerShape(10.dp))
+            .background(background)
+            .clickable(onClick = {
+                navController.navigate(screen.rote) {
+                    popUpTo(navController.graph.findStartDestination().id)
+                    launchSingleTop = true
+                }
+            })
+    ) {
+        Column(
+            modifier = Modifier
+                .height(60.dp)
+                .align(Alignment.Center),
+            verticalArrangement = Arrangement.Center,
+            horizontalAlignment = Alignment.CenterHorizontally
+        ) {
+
+            Text(
+                text = screen.label,
+                color = contentColor,
+                fontSize = 12.sp,
+                fontWeight = FontWeight.Normal
+
+            )
+        }
+    }
+}

+ 28 - 0
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/navigationPack/BottomGraph.kt

@@ -0,0 +1,28 @@
+package com.example.tomatoandpotatoapp.navigationPack
+
+import androidx.compose.runtime.Composable
+import androidx.navigation.NavController
+import androidx.navigation.NavHostController
+import com.example.tomatoandpotatoapp.ViewModelsPack.SupabaseAuthViewModel
+import androidx.navigation.compose.NavHost
+import androidx.navigation.compose.composable
+import com.example.tomatoandpotatoapp.Screens.MyProfile
+import com.example.tomatoandpotatoapp.Screens.ShowPlants
+
+@Composable
+fun BottomGraph (
+    navController: NavHostController,
+    viewModel: SupabaseAuthViewModel,
+) {
+    NavHost(
+        navController = navController,
+        startDestination = Screens.ProfileScreen.route,
+    ) {
+        composable(Screens.ProfileScreen.route) {
+           MyProfile()
+        }
+        composable(Screens.PlantsCatalogScreen.route) {
+            ShowPlants(viewModel,navController)
+        }
+    }
+}

+ 15 - 0
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/navigationPack/NavItem.kt

@@ -0,0 +1,15 @@
+package com.example.tomatoandpotatoapp.navigationPack
+
+sealed class NavItem(
+    val label: String,
+    val rote: String
+) {
+object Profile: NavItem(
+    label = "Профиль",
+    rote = Screens.ProfileScreen.route
+)
+    object PlantsCatalog: NavItem(
+        label = "Каталог растений",
+        rote = Screens.PlantsCatalogScreen.route
+    )
+}

+ 47 - 0
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/navigationPack/Navigation.kt

@@ -0,0 +1,47 @@
+package com.example.tomatoandpotatoapp.navigationPack
+
+import androidx.compose.runtime.Composable
+import androidx.navigation.compose.NavHost
+import androidx.navigation.compose.composable
+import androidx.navigation.compose.rememberNavController
+import com.example.tomatoandpotatoapp.Screens.Authorization
+import com.example.tomatoandpotatoapp.Screens.ChoiceScr
+import com.example.tomatoandpotatoapp.Screens.MyProfile
+import com.example.tomatoandpotatoapp.Screens.Registration
+import com.example.tomatoandpotatoapp.Screens.ShowPlants
+import com.example.tomatoandpotatoapp.Screens.Welcome
+import com.example.tomatoandpotatoapp.ViewModelsPack.SupabaseAuthViewModel
+
+@Composable
+
+fun Navigation(viewModel: SupabaseAuthViewModel) {
+    val navController = rememberNavController()
+    NavHost(
+        navController = navController,
+        startDestination = Screens.StartScreen.route
+    ) {
+        composable(route = Screens.StartScreen.route) {
+            Welcome(navController)
+        }
+        composable(route = Screens.ChoiceScreen.route) {
+            ChoiceScr(navController)
+        }
+        composable(route = Screens.AuthorizationScreen.route  ) {
+            Authorization(viewModel,navController)
+        }
+        composable(route = Screens.RegistrationScreen.route) {
+            Registration(viewModel,navController)
+        }
+        composable(route = Screens.AppNavigation.route)
+        {
+            AppNavigation(viewModel)
+        }
+        composable(route = Screens.ProfileScreen.route) {
+            //MyProfile(viewModel,navController)
+        }
+        composable(route = Screens.PlantsCatalogScreen.route) {
+            ShowPlants(viewModel,navController)
+        }
+    }
+
+}

+ 22 - 0
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/navigationPack/Screens.kt

@@ -0,0 +1,22 @@
+package com.example.tomatoandpotatoapp.navigationPack
+
+import androidx.navigation.NavArgs
+
+sealed class Screens(val route: String) {
+    object AuthorizationScreen : Screens("author_screen")
+    object ChoiceScreen : Screens("choice_screen")
+    object StartScreen : Screens("start_screen")
+    object RegistrationScreen : Screens("registration_screen")
+    object ProfileScreen : Screens("profile_screen")
+    object PlantsCatalogScreen : Screens("plants_catalog_screen")
+    object AppNavigation: Screens("app_navigation")
+
+    fun withArgs(vararg args: String): String {
+        return buildString {
+            append(route)
+            args.forEach { arg ->
+                append("/$arg")
+            }
+        }
+    }
+}

+ 48 - 2
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/utils/ProfileString.kt

@@ -1,8 +1,54 @@
 package com.example.tomatoandpotatoapp.utils
 
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.OutlinedTextField
+import androidx.compose.material3.TextFieldDefaults
 import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
 
 @Composable
-fun EditProfileString(){
-
+fun EditProfileString(
+    search: String,
+    onValueChange: (String) -> Unit,
+    enabled: Boolean
+) {
+    Box(
+        modifier = Modifier
+            .clip(RoundedCornerShape(10.dp))
+            .background(Color(0XFFE8EFFF))
+    ) {
+        OutlinedTextField(
+            value = search,
+            onValueChange = onValueChange,
+            textStyle = TextStyle(
+                color = Color.Black,
+                fontSize = 15.sp
+            ),
+            colors = TextFieldDefaults.colors(
+                focusedContainerColor = Color(0xFFF2D6FA),
+                focusedIndicatorColor = Color(0xFF4C2259),
+                focusedTextColor = Color.Black,
+                disabledIndicatorColor = Color.Transparent,
+                unfocusedIndicatorColor = Color.Transparent,
+                cursorColor = Color.Black,
+                focusedSupportingTextColor = Color.Black
+            ),
+            modifier = Modifier
+                .fillMaxWidth(1f)
+                .background(Color(0XFFF5F5F9))
+                .height(height = 50.dp)
+                .width(width = 316.dp),
+            enabled = enabled
+        )
+    }
 }

+ 1 - 1
ProjectApp/TomatoAndPotatoAPP/build.gradle.kts

@@ -2,5 +2,5 @@
 plugins {
     alias(libs.plugins.android.application) apply false
     alias(libs.plugins.jetbrains.kotlin.android) apply false
-    kotlin("plugin.serialization") version "1.6.21"
+    kotlin("plugin.serialization") version "1.9.0"
 }

+ 0 - 6
ProjectApp/TomatoAndPotatoAPP/gradle/libs.versions.toml

@@ -6,19 +6,15 @@ coreKtx = "1.13.1"
 junit = "4.13.2"
 junitVersion = "1.2.1"
 espressoCore = "3.6.1"
-kotlinSerialization = "1.9.0"
-kotlinxSerializationJson = "1.9.0"
 ktorClientAndroid = "3.0.0"
 lifecycleRuntimeKtx = "2.8.6"
 activityCompose = "1.9.2"
 composeBom = "2024.04.01"
 navigationCompose = "2.8.1"
-navigationComposeVersion = "2.8.2"
 
 [libraries]
 androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
 androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationCompose" }
-androidx-navigation-compose-v282 = { module = "androidx.navigation:navigation-compose", version.ref = "navigationComposeVersion" }
 auth-kt = { module = "io.github.jan-tennert.supabase:auth-kt" }
 bom = { module = "io.github.jan-tennert.supabase:bom", version.ref = "bom" }
 junit = { group = "junit", name = "junit", version.ref = "junit" }
@@ -34,8 +30,6 @@ androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-toolin
 androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
 androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
 androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
-kotlin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlinSerialization" }
-kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" }
 ktor-client-android = { module = "io.ktor:ktor-client-android", version.ref = "ktorClientAndroid" }
 postgrest-kt = { module = "io.github.jan-tennert.supabase:postgrest-kt" }
 realtime-kt = { module = "io.github.jan-tennert.supabase:realtime-kt" }