1
0

2 Ревизии d9d94b5d34 ... 14ad4727df

Автор SHA1 Съобщение Дата
  k1rakato 14ad4727df feat: Добавлено обновление данных пользователя в профиле преди 3 дни
  k1rakato 0387186927 feat: Добавлено обновление данных пользователя в профиле преди 3 дни

+ 9 - 0
.idea/TomatoAndPotato.iml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 6 - 0
.idea/misc.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectRootManager">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+</project>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/TomatoAndPotato.iml" filepath="$PROJECT_DIR$/.idea/TomatoAndPotato.iml" />
+    </modules>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="Git" />
+  </component>
+</project>

+ 51 - 0
.idea/workspace.xml

@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="AutoImportSettings">
+    <option name="autoReloadType" value="NONE" />
+  </component>
+  <component name="ChangeListManager">
+    <list default="true" id="c34c075b-3556-450b-af90-7bfdf4c1994b" name="Changes" comment="" />
+    <option name="SHOW_DIALOG" value="false" />
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
+    <option name="LAST_RESOLUTION" value="IGNORE" />
+  </component>
+  <component name="ClangdSettings">
+    <option name="formatViaClangd" value="false" />
+  </component>
+  <component name="Git.Settings">
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
+  </component>
+  <component name="ProjectColorInfo"><![CDATA[{
+  "associatedIndex": 4
+}]]></component>
+  <component name="ProjectId" id="2pC8lS67Ppau0Jr28DH6HxJyQe5" />
+  <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
+  <component name="ProjectViewState">
+    <option name="hideEmptyMiddlePackages" value="true" />
+    <option name="showLibraryContents" value="true" />
+  </component>
+  <component name="PropertiesComponent"><![CDATA[{
+  "keyToString": {
+    "RunOnceActivity.ShowReadmeOnStart": "true",
+    "RunOnceActivity.cidr.known.project.marker": "true",
+    "RunOnceActivity.readMode.enableVisualFormatting": "true",
+    "cf.first.check.clang-format": "false",
+    "cidr.known.project.marker": "true",
+    "git-widget-placeholder": "master",
+    "kotlin-language-version-configured": "true",
+    "last_opened_file_path": "D:/41/TomatoAndPotato/ProjectApp"
+  }
+}]]></component>
+  <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
+  <component name="TaskManager">
+    <task active="true" id="Default" summary="Default task">
+      <changelist id="c34c075b-3556-450b-af90-7bfdf4c1994b" name="Changes" comment="" />
+      <created>1732258848027</created>
+      <option name="number" value="Default" />
+      <option name="presentableId" value="Default" />
+      <updated>1732258848027</updated>
+    </task>
+    <servers />
+  </component>
+</project>

+ 26 - 0
ProjectApp/.idea/deploymentTargetSelector.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="deploymentTargetSelector">
+    <selectionStates>
+      <SelectionState runConfigName="TomatoAndPotatoAPP.app">
+        <option name="selectionMode" value="DROPDOWN" />
+        <DropdownSelection timestamp="2024-11-22T08:15:46.464967400Z">
+          <Target type="DEFAULT_BOOT">
+            <handle>
+              <DeviceId pluginId="LocalEmulator" identifier="path=C:\AndroidSettings\.android\avd\Pixel_7_API_34.avd" />
+            </handle>
+          </Target>
+        </DropdownSelection>
+        <DialogSelection>
+          <targets>
+            <Target type="DEFAULT_BOOT">
+              <handle>
+                <DeviceId pluginId="LocalEmulator" identifier="path=C:\AndroidSettings\.android\avd\Pixel_8_API_34.avd" />
+              </handle>
+            </Target>
+          </targets>
+        </DialogSelection>
+      </SelectionState>
+    </selectionStates>
+  </component>
+</project>

+ 8 - 0
ProjectApp/.idea/gradle.xml

@@ -1,10 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
+  <component name="GradleMigrationSettings" migrationVersion="1" />
   <component name="GradleSettings">
     <option name="linkedExternalProjectsSettings">
       <GradleProjectSettings>
         <option name="externalProjectPath" value="$PROJECT_DIR$/TomatoAndPotatoAPP" />
+        <option name="gradleHome" value="C:/AndroidSettings/Gradle" />
         <option name="gradleJvm" value="#JAVA_HOME" />
+        <option name="modules">
+          <set>
+            <option value="$PROJECT_DIR$/TomatoAndPotatoAPP" />
+            <option value="$PROJECT_DIR$/TomatoAndPotatoAPP/app" />
+          </set>
+        </option>
         <option name="resolveExternalAnnotations" value="false" />
       </GradleProjectSettings>
     </option>

+ 6 - 0
ProjectApp/.idea/kotlinc.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="KotlinJpsPluginSettings">
+    <option name="version" value="1.9.0" />
+  </component>
+</project>

+ 1 - 1
ProjectApp/.idea/misc.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ExternalStorageConfigurationManager" enabled="true" />
-  <component name="ProjectRootManager">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="temurin-21" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/out" />
   </component>
 </project>

+ 1 - 1
ProjectApp/.idea/other.xml

@@ -262,7 +262,7 @@
           <option name="codename" value="q6q" />
           <option name="id" value="q6q" />
           <option name="manufacturer" value="Samsung" />
-          <option name="name" value="SM-F956B" />
+          <option name="name" value="Galaxy Z Fold6" />
           <option name="screenDensity" value="420" />
           <option name="screenX" value="1856" />
           <option name="screenY" value="2160" />

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

@@ -1,6 +1,7 @@
 package com.example.tomatoandpotatoapp.Screens
 
 import android.widget.ImageButton
+import android.widget.Toast
 import androidx.compose.foundation.background
 import androidx.compose.foundation.clickable
 import androidx.compose.foundation.layout.Arrangement
@@ -19,6 +20,7 @@ import androidx.compose.material.icons.filled.KeyboardArrowDown
 import androidx.compose.material.icons.filled.KeyboardArrowUp
 import androidx.compose.material3.Button
 import androidx.compose.material3.ButtonDefaults
+import androidx.compose.material3.CircularProgressIndicator
 import androidx.compose.material3.DropdownMenu
 import androidx.compose.material3.DropdownMenuItem
 import androidx.compose.material3.Icon
@@ -52,138 +54,160 @@ import com.example.tomatoandpotatoapp.ViewModelsPack.SupabaseAuthViewModel
 import androidx.lifecycle.viewmodel.compose.viewModel
 import androidx.navigation.NavController
 import com.example.tomatoandpotatoapp.R
+import com.example.tomatoandpotatoapp.data.models.UserState
+import com.example.tomatoandpotatoapp.navigationPack.Screens
 import com.example.tomatoandpotatoapp.utils.EditProfileString
 
 
-@Preview
+//@Preview
 @Composable
 fun MyProfile(
     viewModel: SupabaseAuthViewModel = viewModel(),
-    //navController: NavController
+    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)
-//        }
+    val userState by viewModel.userState
+    val people by viewModel.user
+    val f = remember { mutableStateOf(false) }
+    val context = LocalContext.current
+    val f2 = remember { mutableStateOf(true) }
+    val out = remember { mutableStateOf(false) }
     var mSelectedText by remember { mutableStateOf("") }
     var expanded by remember { mutableStateOf(false) }
     var mTextFieldSize by remember { mutableStateOf(Size.Zero) }
-    val genders = listOf("Мужской", "Женский")
+
+    val genders = viewModel.genders
 
     val icon = if (expanded)
         Icons.Filled.KeyboardArrowUp
     else
         Icons.Filled.KeyboardArrowDown
 
-    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(
+    if (f2.value) {
+        viewModel.selectPeople()
+        f2.value = false
+    }
+
+    if (people.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
-                    .fillMaxWidth()
-                    .height(95.dp)
-                    .background(color = Color(0xffD9D9D9)),
-                horizontalArrangement = Arrangement.Center,
-                verticalAlignment = Alignment.CenterVertically
-            ) {
-                Text(
-                    text = "Профиль",
-                    fontWeight = FontWeight.W800,
-                    color = Color.Black,
-                    fontSize = 25.sp
-                )
-            }
+                    .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(95.dp)
+                        .background(color = Color(0xffD9D9D9)),
+                    horizontalArrangement = Arrangement.Center,
+                    verticalAlignment = Alignment.CenterVertically
+                ) {
+                    Text(
+                        text = "Профиль",
+                        fontWeight = FontWeight.W800,
+                        color = Color.Black,
+                        fontSize = 25.sp
+                    )
+                }
 
-            Spacer(modifier = Modifier.height(60.dp))
-            Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
+                Spacer(modifier = Modifier.height(60.dp))
+                Row(
+                    modifier = Modifier.fillMaxWidth(),
+                    horizontalArrangement = Arrangement.Center
+                ) {
 
-                EditProfileString(search = "", onValueChange = {}, enabled = true)
-            }
+                    EditProfileString(search = firstName.value,
+                        onValueChange = {firstName.value = it}, enabled = true)
+                }
 
-            Spacer(modifier = Modifier.height(30.dp))
+                Spacer(modifier = Modifier.height(30.dp))
 
-            Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
+                Row(
+                    modifier = Modifier.fillMaxWidth(),
+                    horizontalArrangement = Arrangement.Center
+                ) {
 
-                EditProfileString(search = "", onValueChange = {}, enabled = true)
-            }
+                    EditProfileString(search = birthDate.value,
+                        onValueChange = {birthDate.value = it}, enabled = true)
+                }
 
-            Spacer(modifier = Modifier.height(30.dp))
+                Spacer(modifier = Modifier.height(30.dp))
 
-            Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
+                Row(
+                    modifier = Modifier.fillMaxWidth(),
+                    horizontalArrangement = Arrangement.Center
+                ) {
 
-                OutlinedTextField(
-                    value = mSelectedText,
-                    onValueChange = { mSelectedText = it },
-                    modifier = Modifier
-                        .height(50.dp)
-                        .width(316.dp)
-                        .onGloballyPositioned { coordinates ->
-                            mTextFieldSize = coordinates.size.toSize()
+                    OutlinedTextField(
+                        value = mSelectedText,
+                        onValueChange = {  },
+                        modifier = Modifier
+                            .height(50.dp)
+                            .width(316.dp)
+                            .onGloballyPositioned { coordinates ->
+                                mTextFieldSize = coordinates.size.toSize()
+                            },
+                        shape = RoundedCornerShape(20),
+                        colors = TextFieldDefaults.colors(
+                            focusedContainerColor = Color(0xFFF2D6FA),
+                            focusedIndicatorColor = Color(0xFF4C2259),
+                            focusedTextColor = Color.Black,
+                            disabledIndicatorColor = Color.Transparent,
+                            unfocusedIndicatorColor = Color.Transparent,
+                            cursorColor = Color.Black,
+                            focusedSupportingTextColor = Color.Black
+                        ),
+                        label = {
+                            Text(
+                                "Пол",
+                                fontWeight = FontWeight.W600,
+                                color = Color.Black
+                            )
                         },
-                    shape = RoundedCornerShape(20),
-                    colors = TextFieldDefaults.colors(
-                        focusedContainerColor = Color(0xFFF2D6FA),
-                        focusedIndicatorColor = Color(0xFF4C2259),
-                        focusedTextColor = Color.Black,
-                        disabledIndicatorColor = Color.Transparent,
-                        unfocusedIndicatorColor = Color.Transparent,
-                        cursorColor = Color.Black,
-                        focusedSupportingTextColor = Color.Black
-                    ),
-                    label = {
-                        Text(
-                            "Пол",
-                            fontWeight = FontWeight.W600,
-                            color = Color.Black
-                        )
-                    },
-                    trailingIcon = {
-                        Icon(icon, "contentDescription",
-                            Modifier.clickable { expanded = !expanded })
-                    }
-                )
-                DropdownMenu(
-                    expanded = expanded,
-                    onDismissRequest = { expanded = false },
-                    modifier = Modifier
-                        .width(with(LocalDensity.current) { mTextFieldSize.width.toDp() })
-                ) {
-                    genders.forEach { label ->
-                        DropdownMenuItem(onClick = {
-                            mSelectedText = label
-                            expanded = false
-                        }) {
-                            Text(text = label)
+                        trailingIcon = {
+                            Icon(icon, "contentDescription",
+                                Modifier.clickable { expanded = !expanded })
+                        }
+                    )
+                    DropdownMenu(
+                        expanded = expanded,
+                        onDismissRequest = { expanded = false },
+                        modifier = Modifier
+                            .width(with(LocalDensity.current) { mTextFieldSize.width.toDp() })
+                    ) {
+                        genders.value.forEach { label ->
+                            DropdownMenuItem(text = {
+                                Text(
+                                    text = label.genderTitle,
+                                    fontSize = 15.sp, fontWeight = FontWeight.Normal
+                                )
+                            },
+                                onClick = {
+                                    mSelectedText = label.genderTitle
+                                    genderId.value = label.id
+                                    expanded = false
+                                }
+                            )
                         }
                     }
                 }
@@ -213,8 +237,6 @@ fun MyProfile(
                     }
                 }
 
-
-
                 Spacer(modifier = Modifier.height(110.dp))
 
                 Row(
@@ -228,7 +250,8 @@ fun MyProfile(
                             .width(278.dp)
                             .height(45.dp),
                         shape = RoundedCornerShape(20),
-                        colors = ButtonDefaults.buttonColors(containerColor = Color(0xff78EE99))
+                        colors = ButtonDefaults
+                            .buttonColors(containerColor = Color(0xff78EE99))
                     )
                     {
                         Text(
@@ -248,12 +271,13 @@ fun MyProfile(
                     verticalAlignment = Alignment.CenterVertically
                 ) {
                     Button(
-                        onClick = { },
+                        onClick = {viewModel.singOut(context) },
                         modifier = Modifier
                             .width(278.dp)
                             .height(45.dp),
                         shape = RoundedCornerShape(20),
-                        colors = ButtonDefaults.buttonColors(containerColor = Color(0xffFC5050))
+                        colors = ButtonDefaults
+                            .buttonColors(containerColor = Color(0xffFC5050))
                     )
                     {
                         Text(
@@ -271,12 +295,11 @@ fun MyProfile(
                     modifier = Modifier
                         .fillMaxWidth()
                         .height(95.dp)
-                        //.align(Alignment.End)
                         .background(color = Color(0xff718588)),
                     horizontalArrangement = Arrangement.SpaceEvenly
                 ) {
                     IconButton(
-                        onClick = { /*TODO*/ },
+                        onClick = { },
                         modifier = Modifier.size(120.dp)
                     ) {
                         Icon(
@@ -286,7 +309,7 @@ fun MyProfile(
                         )
                     }
                     IconButton(
-                        onClick = { /*TODO*/ },
+                        onClick = { navController.navigate(Screens.PlantsCatalogScreen.route) },
                         modifier = Modifier.size(120.dp)
                     ) {
                         Icon(
@@ -296,7 +319,7 @@ fun MyProfile(
                         )
                     }
                     IconButton(
-                        onClick = { /*TODO*/ },
+                        onClick = { navController.navigate(Screens.ProfileScreen.route) },
                         modifier = Modifier.size(120.dp)
                     ) {
                         Icon(
@@ -310,4 +333,41 @@ fun MyProfile(
             }
         }
     }
-}
+    if (f.value) {
+        when (userState) {
+            is UserState.Loading -> {
+                CircularProgressIndicator()
+            }
+
+            is UserState.Success -> {
+                val message = (userState as UserState.Success).message
+                Toast.makeText(context, "Данные успещно сохранены!", Toast.LENGTH_SHORT).show()
+                f.value = false
+            }
+
+            is UserState.Error -> {
+                val message = (userState as UserState.Error).message
+                f.value = false
+            }
+        }
+    }
+
+    if (out.value) {
+        when (userState) {
+            is UserState.Loading -> {
+                CircularProgressIndicator()
+            }
+
+            is UserState.Success -> {
+                navController.navigate(Screens.ChoiceScreen.route)
+                out.value = false
+            }
+
+            is UserState.Error -> {
+                val message = (userState as UserState.Error).message
+                Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
+                out.value = false
+            }
+        }
+    }
+}

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

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

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

@@ -4,11 +4,12 @@ sealed class NavItem(
     val label: String,
     val rote: String
 ) {
-object Profile: NavItem(
-    label = "Профиль",
-    rote = Screens.ProfileScreen.route
-)
-    object PlantsCatalog: NavItem(
+    object Profile : NavItem(
+        label = "Профиль",
+        rote = Screens.ProfileScreen.route
+    )
+
+    object PlantsCatalog : NavItem(
         label = "Каталог растений",
         rote = Screens.PlantsCatalogScreen.route
     )

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

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