Jelajahi Sumber

Коммит для помощи

k1rakato 1 Minggu lalu
induk
melakukan
f0811a711a

+ 3 - 0
ProjectApp/TomatoAndPotatoAPP/.idea/deploymentTargetSelector.xml

@@ -13,6 +13,9 @@
         </DropdownSelection>
         <DialogSelection />
       </SelectionState>
+      <SelectionState runConfigName="MyProfile">
+        <option name="selectionMode" value="DROPDOWN" />
+      </SelectionState>
     </selectionStates>
   </component>
 </project>

+ 1 - 1
ProjectApp/TomatoAndPotatoAPP/.idea/gradle.xml

@@ -5,7 +5,7 @@
     <option name="linkedExternalProjectsSettings">
       <GradleProjectSettings>
         <option name="externalProjectPath" value="$PROJECT_DIR$" />
-        <option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
+        <option name="gradleJvm" value="jbr-17" />
         <option name="modules">
           <set>
             <option value="$PROJECT_DIR$" />

+ 28 - 0
ProjectApp/TomatoAndPotatoAPP/.idea/inspectionProfiles/Project_Default.xml

@@ -1,6 +1,34 @@
 <component name="InspectionProjectProfileManager">
   <profile version="1.0">
     <option name="myName" value="Project Default" />
+    <inspection_tool class="ComposePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
+      <option name="composableFile" value="true" />
+      <option name="previewFile" value="true" />
+    </inspection_tool>
+    <inspection_tool class="ComposePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
+      <option name="composableFile" value="true" />
+      <option name="previewFile" value="true" />
+    </inspection_tool>
+    <inspection_tool class="ComposePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
+      <option name="composableFile" value="true" />
+      <option name="previewFile" value="true" />
+    </inspection_tool>
+    <inspection_tool class="ComposePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
+      <option name="composableFile" value="true" />
+      <option name="previewFile" value="true" />
+    </inspection_tool>
+    <inspection_tool class="GlancePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
+      <option name="composableFile" value="true" />
+    </inspection_tool>
+    <inspection_tool class="GlancePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
+      <option name="composableFile" value="true" />
+    </inspection_tool>
+    <inspection_tool class="GlancePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
+      <option name="composableFile" value="true" />
+    </inspection_tool>
+    <inspection_tool class="GlancePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
+      <option name="composableFile" value="true" />
+    </inspection_tool>
     <inspection_tool class="PreviewAnnotationInFunctionWithParameters" enabled="true" level="ERROR" enabled_by_default="true">
       <option name="composableFile" value="true" />
       <option name="previewFile" value="true" />

+ 0 - 329
ProjectApp/TomatoAndPotatoAPP/.idea/other.xml

@@ -1,329 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="direct_access_persist.xml">
-    <option name="deviceSelectionList">
-      <list>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="27" />
-          <option name="brand" value="DOCOMO" />
-          <option name="codename" value="F01L" />
-          <option name="id" value="F01L" />
-          <option name="manufacturer" value="FUJITSU" />
-          <option name="name" value="F-01L" />
-          <option name="screenDensity" value="360" />
-          <option name="screenX" value="720" />
-          <option name="screenY" value="1280" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="28" />
-          <option name="brand" value="DOCOMO" />
-          <option name="codename" value="SH-01L" />
-          <option name="id" value="SH-01L" />
-          <option name="manufacturer" value="SHARP" />
-          <option name="name" value="AQUOS sense2 SH-01L" />
-          <option name="screenDensity" value="480" />
-          <option name="screenX" value="1080" />
-          <option name="screenY" value="2160" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="34" />
-          <option name="brand" value="Lenovo" />
-          <option name="codename" value="TB370FU" />
-          <option name="id" value="TB370FU" />
-          <option name="manufacturer" value="Lenovo" />
-          <option name="name" value="Tab P12" />
-          <option name="screenDensity" value="340" />
-          <option name="screenX" value="1840" />
-          <option name="screenY" value="2944" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="31" />
-          <option name="brand" value="samsung" />
-          <option name="codename" value="a51" />
-          <option name="id" value="a51" />
-          <option name="manufacturer" value="Samsung" />
-          <option name="name" value="Galaxy A51" />
-          <option name="screenDensity" value="420" />
-          <option name="screenX" value="1080" />
-          <option name="screenY" value="2400" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="34" />
-          <option name="brand" value="google" />
-          <option name="codename" value="akita" />
-          <option name="id" value="akita" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel 8a" />
-          <option name="screenDensity" value="420" />
-          <option name="screenX" value="1080" />
-          <option name="screenY" value="2400" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="33" />
-          <option name="brand" value="samsung" />
-          <option name="codename" value="b0q" />
-          <option name="id" value="b0q" />
-          <option name="manufacturer" value="Samsung" />
-          <option name="name" value="Galaxy S22 Ultra" />
-          <option name="screenDensity" value="600" />
-          <option name="screenX" value="1440" />
-          <option name="screenY" value="3088" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="32" />
-          <option name="brand" value="google" />
-          <option name="codename" value="bluejay" />
-          <option name="id" value="bluejay" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel 6a" />
-          <option name="screenDensity" value="420" />
-          <option name="screenX" value="1080" />
-          <option name="screenY" value="2400" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="34" />
-          <option name="brand" value="google" />
-          <option name="codename" value="caiman" />
-          <option name="id" value="caiman" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel 9 Pro" />
-          <option name="screenDensity" value="360" />
-          <option name="screenX" value="960" />
-          <option name="screenY" value="2142" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="34" />
-          <option name="brand" value="google" />
-          <option name="codename" value="comet" />
-          <option name="id" value="comet" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel 9 Pro Fold" />
-          <option name="screenDensity" value="390" />
-          <option name="screenX" value="2076" />
-          <option name="screenY" value="2152" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="29" />
-          <option name="brand" value="samsung" />
-          <option name="codename" value="crownqlteue" />
-          <option name="id" value="crownqlteue" />
-          <option name="manufacturer" value="Samsung" />
-          <option name="name" value="Galaxy Note9" />
-          <option name="screenDensity" value="420" />
-          <option name="screenX" value="2220" />
-          <option name="screenY" value="1080" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="34" />
-          <option name="brand" value="samsung" />
-          <option name="codename" value="dm3q" />
-          <option name="id" value="dm3q" />
-          <option name="manufacturer" value="Samsung" />
-          <option name="name" value="Galaxy S23 Ultra" />
-          <option name="screenDensity" value="600" />
-          <option name="screenX" value="1440" />
-          <option name="screenY" value="3088" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="34" />
-          <option name="brand" value="samsung" />
-          <option name="codename" value="e1q" />
-          <option name="id" value="e1q" />
-          <option name="manufacturer" value="Samsung" />
-          <option name="name" value="Galaxy S24" />
-          <option name="screenDensity" value="480" />
-          <option name="screenX" value="1080" />
-          <option name="screenY" value="2340" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="33" />
-          <option name="brand" value="google" />
-          <option name="codename" value="felix" />
-          <option name="id" value="felix" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel Fold" />
-          <option name="screenDensity" value="420" />
-          <option name="screenX" value="2208" />
-          <option name="screenY" value="1840" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="34" />
-          <option name="brand" value="google" />
-          <option name="codename" value="felix" />
-          <option name="id" value="felix" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel Fold" />
-          <option name="screenDensity" value="420" />
-          <option name="screenX" value="2208" />
-          <option name="screenY" value="1840" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="33" />
-          <option name="brand" value="google" />
-          <option name="codename" value="felix_camera" />
-          <option name="id" value="felix_camera" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel Fold (Camera-enabled)" />
-          <option name="screenDensity" value="420" />
-          <option name="screenX" value="2208" />
-          <option name="screenY" value="1840" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="33" />
-          <option name="brand" value="samsung" />
-          <option name="codename" value="gts8uwifi" />
-          <option name="id" value="gts8uwifi" />
-          <option name="manufacturer" value="Samsung" />
-          <option name="name" value="Galaxy Tab S8 Ultra" />
-          <option name="screenDensity" value="320" />
-          <option name="screenX" value="1848" />
-          <option name="screenY" value="2960" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="34" />
-          <option name="brand" value="google" />
-          <option name="codename" value="husky" />
-          <option name="id" value="husky" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel 8 Pro" />
-          <option name="screenDensity" value="390" />
-          <option name="screenX" value="1008" />
-          <option name="screenY" value="2244" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="30" />
-          <option name="brand" value="motorola" />
-          <option name="codename" value="java" />
-          <option name="id" value="java" />
-          <option name="manufacturer" value="Motorola" />
-          <option name="name" value="G20" />
-          <option name="screenDensity" value="280" />
-          <option name="screenX" value="720" />
-          <option name="screenY" value="1600" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="34" />
-          <option name="brand" value="google" />
-          <option name="codename" value="komodo" />
-          <option name="id" value="komodo" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel 9 Pro XL" />
-          <option name="screenDensity" value="360" />
-          <option name="screenX" value="1008" />
-          <option name="screenY" value="2244" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="33" />
-          <option name="brand" value="google" />
-          <option name="codename" value="lynx" />
-          <option name="id" value="lynx" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel 7a" />
-          <option name="screenDensity" value="420" />
-          <option name="screenX" value="1080" />
-          <option name="screenY" value="2400" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="31" />
-          <option name="brand" value="google" />
-          <option name="codename" value="oriole" />
-          <option name="id" value="oriole" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel 6" />
-          <option name="screenDensity" value="420" />
-          <option name="screenX" value="1080" />
-          <option name="screenY" value="2400" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="33" />
-          <option name="brand" value="google" />
-          <option name="codename" value="panther" />
-          <option name="id" value="panther" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel 7" />
-          <option name="screenDensity" value="420" />
-          <option name="screenX" value="1080" />
-          <option name="screenY" value="2400" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="34" />
-          <option name="brand" value="samsung" />
-          <option name="codename" value="q5q" />
-          <option name="id" value="q5q" />
-          <option name="manufacturer" value="Samsung" />
-          <option name="name" value="Galaxy Z Fold5" />
-          <option name="screenDensity" value="420" />
-          <option name="screenX" value="1812" />
-          <option name="screenY" value="2176" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="34" />
-          <option name="brand" value="samsung" />
-          <option name="codename" value="q6q" />
-          <option name="id" value="q6q" />
-          <option name="manufacturer" value="Samsung" />
-          <option name="name" value="Galaxy Z Fold6" />
-          <option name="screenDensity" value="420" />
-          <option name="screenX" value="1856" />
-          <option name="screenY" value="2160" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="30" />
-          <option name="brand" value="google" />
-          <option name="codename" value="r11" />
-          <option name="id" value="r11" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel Watch" />
-          <option name="screenDensity" value="320" />
-          <option name="screenX" value="384" />
-          <option name="screenY" value="384" />
-          <option name="type" value="WEAR_OS" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="30" />
-          <option name="brand" value="google" />
-          <option name="codename" value="redfin" />
-          <option name="id" value="redfin" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel 5" />
-          <option name="screenDensity" value="440" />
-          <option name="screenX" value="1080" />
-          <option name="screenY" value="2340" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="34" />
-          <option name="brand" value="google" />
-          <option name="codename" value="shiba" />
-          <option name="id" value="shiba" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel 8" />
-          <option name="screenDensity" value="420" />
-          <option name="screenX" value="1080" />
-          <option name="screenY" value="2400" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="33" />
-          <option name="brand" value="google" />
-          <option name="codename" value="tangorpro" />
-          <option name="id" value="tangorpro" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel Tablet" />
-          <option name="screenDensity" value="320" />
-          <option name="screenX" value="1600" />
-          <option name="screenY" value="2560" />
-        </PersistentDeviceSelectionData>
-        <PersistentDeviceSelectionData>
-          <option name="api" value="34" />
-          <option name="brand" value="google" />
-          <option name="codename" value="tokay" />
-          <option name="id" value="tokay" />
-          <option name="manufacturer" value="Google" />
-          <option name="name" value="Pixel 9" />
-          <option name="screenDensity" value="420" />
-          <option name="screenX" value="1080" />
-          <option name="screenY" value="2424" />
-        </PersistentDeviceSelectionData>
-      </list>
-    </option>
-  </component>
-</project>

+ 1 - 0
ProjectApp/TomatoAndPotatoAPP/app/src/main/AndroidManifest.xml

@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools">
+    <uses-permission android:name="android.permission.INTERNET"/>
 
     <application
         android:allowBackup="true"

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

@@ -89,7 +89,7 @@ fun Authorization(
                 Row(
                     modifier = Modifier
                         .fillMaxWidth()
-                        .height(75.dp),
+                        .height(95.dp),
                     horizontalArrangement = Arrangement.Start
                 ) {
                     Button(
@@ -97,7 +97,7 @@ fun Authorization(
                             navController.navigate(Screens.ChoiceScreen.route)
                         },
                         modifier = Modifier
-                            .padding(start = 13.dp, top = 34.dp)
+                            .padding(start = 23.dp, top = 54.dp)
                             .width(32.dp)
                             .height(32.dp),
                         colors = ButtonDefaults.buttonColors(
@@ -177,7 +177,8 @@ fun Authorization(
 
                     Button(
                         onClick =
-                        { /*TODO*/ },
+                        { viewModel.singIn(context,userEmail,userPassword)
+                        navController.navigate(Screens.ProfileScreen.route)},
                         modifier = Modifier
                             .width(278.dp)
                             .height(45.dp),

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

@@ -80,21 +80,21 @@ fun ShowPlants(
                         fontSize = 25.sp
                     )
 
-                    TextField(
-                        modifier = Modifier.width(320.dp),
-                        shape = RoundedCornerShape(20.dp),
-                        maxLines = 1,
-                        singleLine = true,
-                        placeholder = {
-                            Text(
-                                text = "Поиск", fontWeight = FontWeight.W800,
-                                color = Color.Black,
-                                fontSize = 25.sp
-                            )
-                        },
-                        value = Unit,
-                        onValueChange = {  }
-                    )
+//                    TextField(
+//                        modifier = Modifier.width(320.dp),
+//                        shape = RoundedCornerShape(20.dp),
+//                        maxLines = 1,
+//                        singleLine = true,
+//                        placeholder = {
+//                            Text(
+//                                text = "Поиск", fontWeight = FontWeight.W800,
+//                                color = Color.Black,
+//                                fontSize = 25.sp
+//                            )
+//                        },
+//                        value = Unit,
+//                        onValueChange = {  }
+//                    )
                 }
             }
 

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

@@ -87,7 +87,7 @@ fun MyProfile(
             Row(
                 modifier = Modifier
                     .fillMaxWidth()
-                    .height(75.dp)
+                    .height(95.dp)
                     .background(color = Color(0xffD9D9D9)),
                 horizontalArrangement = Arrangement.Center,
                 verticalAlignment = Alignment.CenterVertically
@@ -176,7 +176,7 @@ fun MyProfile(
 
             Row(modifier = Modifier
                 .fillMaxWidth()
-                .height(80.dp)
+                .height(95.dp)
                 .align(Alignment.End)
                 .background(color = Color(0xff718588)),
                 horizontalArrangement = Arrangement.SpaceEvenly

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

@@ -52,10 +52,10 @@ fun Registration(
     viewModel: SupabaseAuthViewModel = viewModel(),
     navController: NavController
 ) {
-    val context = LocalContext.current
     val userState by viewModel.userState
     val f = remember { mutableStateOf(false) }
 
+    val context = LocalContext.current
     var userEmail by remember { mutableStateOf("") }
     var userPassword by remember { mutableStateOf("") }
 
@@ -86,7 +86,7 @@ fun Registration(
             Row(
                 modifier = Modifier
                     .fillMaxWidth()
-                    .height(75.dp),
+                    .height(95.dp),
                 horizontalArrangement = Arrangement.Start
             ) {
                 Button(
@@ -94,7 +94,7 @@ fun Registration(
                         navController.navigate(Screens.ChoiceScreen.route)
                     },
                     modifier = Modifier
-                        .padding(start = 13.dp, top = 34.dp)
+                        .padding(start = 23.dp, top = 54.dp)
                         .width(32.dp)
                         .height(32.dp),
                     colors = ButtonDefaults.buttonColors(containerColor = Color(0xFF78EE99)),
@@ -111,7 +111,7 @@ fun Registration(
             Column(
                 modifier = Modifier
                     .fillMaxSize()
-                    .padding(vertical = 110.dp)
+                    .padding(vertical = 90.dp)
                     .pointerInput(Unit) {
                         detectTapGestures(onTap = {
                             keyboardController?.hide()
@@ -128,7 +128,7 @@ fun Registration(
                     fontSize = 40.sp
                 )
 
-                Spacer(modifier = Modifier.height(150.dp))
+                Spacer(modifier = Modifier.height(50.dp))
 
                 Row(
                     modifier = Modifier.fillMaxWidth(),
@@ -145,7 +145,7 @@ fun Registration(
                 }
                 TextField(
                     modifier = Modifier
-                        .width(320.dp),
+                        .width(320.dp).padding(top = 30.dp),
                     maxLines = 1,
                     singleLine = true,
                     shape = RoundedCornerShape(20.dp),
@@ -160,7 +160,7 @@ fun Registration(
                 )
 
                 TextField(
-                    modifier = Modifier.width(320.dp),
+                    modifier = Modifier.width(320.dp).padding(bottom = 110.dp),
                     shape = RoundedCornerShape(20.dp),
                     maxLines = 1,
                     singleLine = true,
@@ -171,12 +171,9 @@ fun Registration(
                     }
                 )
 
-                Spacer(modifier = Modifier.height(15.dp))
-
                 Button(
-                    onClick = {
-                        navController.navigate(Screens.ProfileScreen.route)
-                    },
+                    onClick = {viewModel.singUp(context,userEmail,userPassword)
+                        f.value = true},
                     modifier = Modifier
                         .width(278.dp)
                         .height(45.dp),

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

@@ -39,6 +39,20 @@ class SupabaseAuthViewModel : ViewModel() {
     private val _genders = mutableStateOf(listOf<GenderTable>())
     val genders: State<List<GenderTable>> = _genders
 
+
+    private fun saveToken(context: Context) {
+        viewModelScope.launch {
+            val accessToken = client.auth.currentAccessTokenOrNull() ?: ""
+            val sharedPref = SharedPreferenceHelper(context)
+            sharedPref.saveStringData("accessToken", accessToken)
+        }
+    }
+
+    private fun getToken(context: Context): String? {
+        val sharedPref = SharedPreferenceHelper(context)
+        return sharedPref.getStringData("accessToken")
+    }
+
     fun singUp(
         context: Context,
         userEmail: String,
@@ -59,19 +73,6 @@ class SupabaseAuthViewModel : ViewModel() {
 
     }
 
-    private fun saveToken(context: Context) {
-        viewModelScope.launch {
-            val accessToken = client.auth.currentAccessTokenOrNull() ?: ""
-            val sharedPref = SharedPreferenceHelper(context)
-            sharedPref.saveStringData("accessToken", accessToken)
-        }
-    }
-
-    private fun getToken(context: Context) {
-        val sharedPref = SharedPreferenceHelper(context)
-        sharedPref.getStringData("accessToken")
-    }
-
     fun singIn(
         context: Context,
         userEmail: String,
@@ -85,45 +86,47 @@ class SupabaseAuthViewModel : ViewModel() {
                 }
                 saveToken(context)
                 _userState.value = UserState.Success("Успешный вход!")
-            }catch (e:Exception){
+            } catch (e: Exception) {
                 _userState.value = UserState.Error("Error ${e.message}")
             }
         }
     }
 
-    fun singOut(context: Context){
-        val sharedPref =SharedPreferenceHelper(context)
+    fun singOut(context: Context) {
+        val sharedPref = SharedPreferenceHelper(context)
         viewModelScope.launch {
             try {
                 client.auth.signOut()
                 sharedPref.clearPreferences()
                 _userState.value = UserState.Success("Успешный выход!")
 
-            }catch (e:Exception){
-                _userState.value =UserState.Error("Error ${e.message}")
+            } catch (e: Exception) {
+                _userState.value = UserState.Error("Error ${e.message}")
             }
         }
     }
 
 
-    fun addPeople(){
+    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))
+                client.from("UsersTable").insert(
+                    UsersTable(
+                        idRole = 2,
+                        genderId = null,
+                        uid = client.auth.currentUserOrNull()!!.id
+                    )
+                )
 
 
-            }catch (e: Exception){
+            } catch (e: Exception) {
                 _userState.value = UserState.Error("Error ${e.message}")
             }
         }
     }
 
-    fun updatePeople(firstname: String, genderId:Int, birthDate:String)
-    {
+    fun updatePeople(firstname: String, genderId: Int, birthDate: String) {
         viewModelScope.launch {
             try {
                 _userState.value = UserState.Loading
@@ -137,25 +140,47 @@ class SupabaseAuthViewModel : ViewModel() {
                 }
 
 
-            }catch (e: Exception){
+            } catch (e: Exception) {
                 _userState.value = UserState.Error("Error ${e.message}")
             }
         }
     }
 
-    fun selectPeople(){
+    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>()
 
-                _user.value = client.from("Users").select { filter { UsersTable::uid eq
-                        client.auth.currentUserOrNull()!!.id } }.decodeList<UsersTable>()
-
-            }catch (e: Exception){
+            } catch (e: Exception) {
                 _userState.value = UserState.Error("Error ${e.message}")
             }
         }
     }
 
+    fun isUserLoggedIn(
+        context: Context
+    ) {
+        viewModelScope.launch {
+            try {
+                val token = getToken(context)
+                if (token.isNullOrEmpty()) {
+                    _userState.value = UserState.Error("Пользователь не вошёл в систему")
+                } else {
+                    client.auth.retrieveUser(token)
+                    client.auth.refreshCurrentSession()
+                    saveToken(context)
+                    _userState.value = UserState.Success("Пользователь уже вошёл в систему")
+                }
 
-}
+            } catch (e: Exception) {
+                _userState.value = UserState.Error("Error${e.message}")
+            }
+        }
+    }
+}

+ 1 - 1
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/data/models/UsersTable.kt

@@ -7,7 +7,7 @@ import java.sql.Date
 data class UsersTable (
     val id:Int? = null,
     val firstName:String = "",
-    val genderId:Int,
+    val genderId:Int? = null,
     val birthDate:String = "",
     val idRole:Int,
     val uid:String = ""

+ 2 - 2
ProjectApp/TomatoAndPotatoAPP/app/src/main/java/com/example/tomatoandpotatoapp/data/network/TomatAndPotatClient.kt

@@ -7,8 +7,8 @@ import io.github.jan.supabase.postgrest.PropertyConversionMethod
 
 object TomatAndPotatClient {
     val client = createSupabaseClient(
-        supabaseUrl = "https://frfcflbocgkxgzycevlz.supabase.co",
-        supabaseKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZyZmNmbGJvY2dreGd6eWNldmx6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjkyMzQ0NTEsImV4cCI6MjA0NDgxMDQ1MX0.eFxM98dUxzefAz5AwcZV-eWgYTkjuH4xEsuYiDHFX98"
+        supabaseUrl = "https://xjbpbyocknyxsmwdvlue.supabase.co",
+        supabaseKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhqYnBieW9ja255eHNtd2R2bHVlIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzE5NDY5MzQsImV4cCI6MjA0NzUyMjkzNH0.HesTDGPfqxlMuRqecMCxCyJHsPKuYBpUfgJh9Nc-_00"
     ){
         install(Auth)
         install(Postgrest){

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

@@ -19,10 +19,10 @@ fun BottomGraph (
         startDestination = Screens.ProfileScreen.route,
     ) {
         composable(Screens.ProfileScreen.route) {
-           MyProfile()
+           //MyProfile(viewModel,navController)
         }
         composable(Screens.PlantsCatalogScreen.route) {
-            ShowPlants(viewModel,navController)
+            //ShowPlants(viewModel,navController)
         }
     }
 }

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

@@ -40,7 +40,7 @@ fun Navigation(viewModel: SupabaseAuthViewModel) {
             //MyProfile(viewModel,navController)
         }
         composable(route = Screens.PlantsCatalogScreen.route) {
-            ShowPlants(viewModel,navController)
+            //ShowPlants(viewModel,navController)
         }
     }