galoc vor 4 Tagen
Ursprung
Commit
b7b7df07bf

+ 1 - 0
app/build.gradle.kts

@@ -83,6 +83,7 @@ dependencies {
     implementation(libs.ktor.serialization.kotlinx.xml)
     implementation(libs.coil.compose)
     implementation(libs.coil3.coil.compose)
+    implementation (libs.datetime)
 
 
 }

+ 128 - 20
app/src/main/java/com/example/osnov_android/MainActivityViewModel.kt

@@ -7,7 +7,6 @@ import androidx.compose.runtime.mutableStateOf
 import androidx.compose.runtime.setValue
 import androidx.lifecycle.ViewModel
 import androidx.lifecycle.viewModelScope
-import androidx.test.espresso.util.filter
 import com.example.osnov_android.components.Constants
 import com.example.osnov_android.models.Dishes
 import com.example.osnov_android.models.UserState
@@ -20,7 +19,7 @@ import kotlinx.coroutines.launch
 
 class MainActivityViewModel : ViewModel() {
     private val _userState = mutableStateOf<UserState>(UserState.Loading)
-    val userState:State<UserState> = _userState
+    val userState: State<UserState> = _userState
     private val _users = mutableStateOf(listOf<Users>())
     val users: State<List<Users>> = _users
 
@@ -28,11 +27,13 @@ class MainActivityViewModel : ViewModel() {
     val cookings: State<List<Dishes>> = _cookings
     var cooking by mutableStateOf<Dishes?>(null)
     val dish by mutableStateOf<Dishes?>(null)
+    private val _user = mutableStateOf(listOf<Users>())
+    val user: State<List<Users>> = _user
 
     fun SignIn(emailUser: String, userPassword: String) {
         viewModelScope.launch {
             try {
-                Log.d("начало","${emailUser} ${userPassword}")
+                Log.d("начало", "${emailUser} ${userPassword}")
                 _userState.value = UserState.Loading
                 Constants.supabase.auth.signInWith(Email) {
                     email = emailUser
@@ -44,42 +45,69 @@ class MainActivityViewModel : ViewModel() {
                     }
                 }.decodeList()
                 Log.d("Mytag", "${users.value.last().id_role}")
-                Log.d("Конец","закончили")
+                Log.d("Конец", "закончили")
                 _userState.value = UserState.Success("Signin is suc!")
-            }
-            catch (e: Exception) {
+            } catch (e: Exception) {
                 _userState.value = UserState.Error("Error: ${e.message}")
             }
         }
     }
 
-    fun SignUp(emailUser: String, passwordUsers: String, nameUser: String)
-    {
+    fun SignUp(emailUser: String,nameUsers: String, gender: Int, passwordUsers: String) {
         viewModelScope.launch {
-            try{
+            try {
                 _userState.value = UserState.Loading
                 Constants.supabase.auth.signUpWith(Email)
                 {
                     email = emailUser
                     password = passwordUsers
                 }
-                Constants.supabase.from("Users").insert(Users(
+                Constants.supabase.from("Users").insert(
+                    Users(
                         login = emailUser,
-                        name = nameUser,
-                        password = passwordUsers,
+                        name = nameUsers,
+                        password = Constants.supabase.auth.currentUserOrNull()!!.id,
                         id_role = 2,
-                ))
-                Log.d("начало","${_userState}")
+                        id_gender = gender,
+                        image = "https://unmeiceifhurzmiokboh.supabase.co/storage/v1/object/public/Users_ava/zaglushka.jpg"
+                    )
+                )
+                Log.d("добавили", "Пользователь добавлен")
                 _userState.value = UserState.Success("SignUp in suc!")
-            }
-            catch (e: Exception)
-            {
+            } catch (e: Exception) {
                 _userState.value = UserState.Error("Error: ${e.message}")
             }
         }
     }
-    fun allDishes()
+
+    fun UpdateUser(nameUsers: String) {
+        viewModelScope.launch {
+            try {
+            _userState.value = UserState.Loading
+             Constants.supabase.from("Users").insert(
+                Users(
+                    login = "saddasd",
+                    name = nameUsers,
+                    password = Constants.supabase.auth.currentUserOrNull()!!.id,
+                    id_role = 2,
+                )
+            )
+            _userState.value = UserState.Success("SignUpUpdate in suc!")
+            }
+        catch (e: Exception) {
+            _userState.value = UserState.Error("Error: ${e.message}")
+        }
+        }
+    }
+
+    fun DishesBlogUser()
     {
+        viewModelScope.launch {
+
+        }
+    }
+
+    fun allDishes() {
         viewModelScope.launch {
             try {
                 Log.d("начали еда", "Поехали еда")
@@ -90,11 +118,91 @@ class MainActivityViewModel : ViewModel() {
                 _userState.value =
                     UserState.Success("select dishes suc!")
                 Log.d("my_tag", "select dishes suc!")
+            } catch (e: Exception) {
+                _userState.value = UserState.Error("Error:  ${e.message}")
+                Log.e("error", e.message!!)
+            }
+        }
+    }
+
+    fun UsersProfile()
+    {
+        viewModelScope.launch {
+            _userState.value = UserState.Loading
+            _users.value = Constants.supabase.from("Users").select {
+                filter {
+                    Users::password eq Constants.supabase.auth.currentUserOrNull()!!.id
+                }
+            }.decodeList()
+        }
+    }
+
+    fun profileData() {
+        viewModelScope.launch {
+            try {
+                _userState.value = UserState.Loading
+                _user.value = Constants.supabase.from("Users").select {
+                    filter {
+                        Users::password eq Constants.supabase.auth.currentUserOrNull()!!.id
+                    }
+                }.decodeList<Users>()
+                Log.d("my_tag", "Профиль найден")
+                _userState.value = UserState.Success("Профиль найден")
+
+            } catch (e: Exception) {
+                _userState.value = UserState.Error("Профиль не найден")
+                Log.e("error", e.message!!)
+            }
+        }
+    }
+
+    fun updateUser(name: String, gender: Int) {
+        viewModelScope.launch {
+            try {
+                _userState.value = UserState.Loading
+                Constants.supabase.from("Users").update(
+                    {
+                        Users::name setTo name
+                        Users::id_gender setTo gender
+                    }
+                ) {
+                    filter {
+                        Users::password eq Constants.supabase.auth.currentUserOrNull()!!.id
+                    }
+                }
+                Log.d("my_tag", "Данные обновлены")
+                _userState.value = UserState.Success("Данные обновлены")
+
+            } catch (e: Exception) {
+                _userState.value = UserState.Error(e.message!!)
+                Log.e("error", e.message!!)
+            }
+        }
+
+    }
+
+    fun giveCooking(cooking: Dishes) {
+        this.cooking = cooking
+    }
+
+    fun deleteCooking(id: Int)
+    {
+        viewModelScope.launch {
+            try {
+                _userState.value = UserState.Loading
+
+                Constants.supabase.from("Dishes").delete{
+                    filter {
+                        Dishes::id eq id
+                    }
+                }
+                allDishes()
+                _userState.value = UserState.Success("the dish has deleted suc!")
+                Log.d("My tag dish", "deleted")
             }
             catch (e: Exception)
             {
-                _userState.value = UserState.Error("Error:  ${e.message}")
-                Log.e("error", e.message!!)
+                _userState.value = UserState.Error(e.message!!)
             }
         }
     }

+ 1 - 4
app/src/main/java/com/example/osnov_android/components/Constants.kt

@@ -3,15 +3,12 @@ package com.example.osnov_android.components
 import io.github.jan.supabase.auth.Auth
 import io.github.jan.supabase.createSupabaseClient
 import io.github.jan.supabase.postgrest.Postgrest
-import io.github.jan.supabase.postgrest.PropertyConversionMethod
 
 object Constants {
     val supabase = createSupabaseClient(
         supabaseUrl = "https://unmeiceifhurzmiokboh.supabase.co",
         supabaseKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InVubWVpY2VpZmh1cnptaW9rYm9oIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzA5MDU0MDUsImV4cCI6MjA0NjQ4MTQwNX0._7UneKbsr9O1DVE0OrlrRD5ZZlYrLWDOC1T-IJmJqvA") {
         install(Auth)
-        install(Postgrest){
-            propertyConversionMethod = PropertyConversionMethod.SERIAL_NAME
-        }
+        install(Postgrest)
         }
     }

+ 2 - 2
app/src/main/java/com/example/osnov_android/models/Users.kt

@@ -1,8 +1,7 @@
 package com.example.osnov_android.models
 
-import kotlinx.serialization.Serializable
-import androidx.room.Entity
 import androidx.room.PrimaryKey
+import kotlinx.serialization.Serializable
 
 
 @Serializable
@@ -13,4 +12,5 @@ data class Users(
     val name:String = "",
     val id_role:Int = 0,
     val id_gender:Int = 0,
+    val image:String = "",
 )

+ 10 - 0
app/src/main/java/com/example/osnov_android/navigation/Navigation.kt

@@ -7,9 +7,11 @@ import androidx.navigation.compose.NavHost
 import androidx.navigation.compose.composable
 import androidx.navigation.compose.rememberNavController
 import com.example.osnov_android.MainActivityViewModel
+import com.example.osnov_android.views.CookingsUpdate
 import com.example.osnov_android.views.SignIn
 import com.example.osnov_android.views.SignUp
 import com.example.osnov_android.views.Start
+import com.example.osnov_android.views.Updatedatauser
 import com.example.osnov_android.views.bottom_menu.AppNavigation
 import com.example.osnov_android.views.bottommenuAdmin.AppNavigationAdmin
 
@@ -39,6 +41,14 @@ fun Navigation(viewModelMain: MainActivityViewModel) {
         {
             AppNavigationAdmin(viewModelMain,navController)
         }
+        composable(Screen.UpdatedataUser.route)
+        {
+            Updatedatauser(viewModelMain,navController)
+        }
+        composable(Screen.CookingUpdate.route)
+        {
+            CookingsUpdate(viewModelMain,navController)
+        }
 
     }
 }

+ 2 - 0
app/src/main/java/com/example/osnov_android/navigation/Screen.kt

@@ -13,4 +13,6 @@ sealed class Screen (val route:String) {
     object BlogAdmin:Screen("blog_admin")
     object CookingAdmin:Screen("cooking_admin")
     object NavigationsAdmin:Screen("navigationsAdmin")
+    object UpdatedataUser:Screen("updatedatauser")
+    object CookingUpdate:Screen("cooking_update")
 }

+ 154 - 2
app/src/main/java/com/example/osnov_android/views/CookingAdmin.kt

@@ -1,11 +1,163 @@
 package com.example.osnov_android.views
 
+import androidx.compose.foundation.Image
+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.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.items
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonColors
+import androidx.compose.material3.Card
+import androidx.compose.material3.CircularProgressIndicator
+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.Color
+import androidx.compose.ui.layout.ContentScale
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
 import androidx.navigation.NavController
+import coil.compose.AsyncImagePainter
+import coil.compose.rememberAsyncImagePainter
+import coil.request.ImageRequest
 import com.example.osnov_android.MainActivityViewModel
+import com.example.osnov_android.navigation.Screen
 
 @Composable
-fun CookingAdmin(viewModel: MainActivityViewModel, navController: NavController)
-{
+fun CookingAdmin(viewModel: MainActivityViewModel, navController: NavController) {
+    val background = Color(0xFF1B1A20)
+    Column(Modifier.fillMaxSize().background(background)) {
+        val flag = remember { mutableStateOf(true) }
+        val cookings by viewModel.cookings
 
+        if (flag.value) {
+            viewModel.allDishes()
+            flag.value = false
+        }
+        if (cookings.isNotEmpty()) {
+            LazyColumn {
+                items(cookings) { cooking ->
+                    val image = rememberAsyncImagePainter(
+                        model = ImageRequest.Builder(LocalContext.current).data(cooking.Image)
+                            .size(200, 200).build()
+                    ).state
+                    Card(
+                        modifier = Modifier
+                            .fillMaxWidth()
+                            .padding(20.dp)
+
+
+                    ) {
+                        Column(
+                            Modifier.fillMaxSize(),
+                            verticalArrangement = Arrangement.Center,
+                            horizontalAlignment = Alignment.CenterHorizontally
+                        ) {
+                            if (image is AsyncImagePainter.State.Success) {
+                                Box(
+                                    modifier = Modifier
+                                        .height(200.dp)
+                                        .padding(10.dp),
+                                    contentAlignment = Alignment.Center
+                                ) {
+                                    Image(
+                                        modifier = Modifier
+                                            .fillMaxWidth()
+                                            .height(200.dp),
+                                        painter = image.painter,
+                                        contentDescription = "",
+                                        contentScale = ContentScale.Crop,
+                                        alignment = Alignment.Center
+                                    )
+                                }
+                            }
+                            if (image is AsyncImagePainter.State.Loading) {
+                                Box(
+                                    modifier = Modifier
+                                        .fillMaxWidth()
+                                        .height(250.dp),
+                                    contentAlignment = Alignment.Center
+                                ) {
+                                    CircularProgressIndicator()
+                                }
+                            }
+                        }
+                        Column(
+                            Modifier.fillMaxSize().padding(12.dp),
+                            horizontalAlignment = Alignment.Start
+                        ) {
+
+                            Text(
+                                text = cooking.Name,
+                                fontWeight = FontWeight.Medium,
+                                fontSize = 20.sp,
+                                color = Color.Black,
+                                modifier = Modifier.padding(5.dp)
+                            )
+                            Text(
+                                text = cooking.Descriptions,
+                                fontWeight = FontWeight.Light,
+                                fontSize = 14.sp,
+                                color = Color.Black,
+                                modifier = Modifier.padding(5.dp)
+                            )
+
+                            Column(Modifier, horizontalAlignment = Alignment.CenterHorizontally) {
+                                Button(
+                                    onClick = { viewModel.deleteCooking(cooking.id!!) },
+                                    modifier = Modifier
+                                        .fillMaxWidth(0.5f)
+                                        .padding(5.dp),
+                                    shape = RoundedCornerShape(20),
+                                    colors = ButtonColors(
+                                        contentColor = Color.White,
+                                        containerColor = Color(0xFF7DAD01),
+                                        disabledContentColor = Color.White,
+                                        disabledContainerColor = Color(0xFF7DAD01)
+                                    )
+                                ) {
+                                    Text("Удалить")
+                                }
+                                Button(
+                                    onClick = {
+                                        viewModel.giveCooking(cooking)
+                                        navController.navigate(Screen.CookingUpdate.route)
+                                    }, modifier = Modifier
+                                        .fillMaxWidth(0.5f)
+                                        .padding(5.dp),
+                                    shape = RoundedCornerShape(20),
+                                    colors = ButtonColors(
+                                        contentColor = Color.White,
+                                        containerColor = Color(0xFF7DAD01),
+                                        disabledContentColor = Color.White,
+                                        disabledContainerColor = Color(0xFF7DAD01)
+                                    )
+                                ) {
+                                    Text("Изменить")
+                                }
+                            }
+                        }
+                    }
+                }
+                    }
+                }
+        else {
+            Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
+                CircularProgressIndicator()
+            }
+        }
+    }
 }

+ 11 - 0
app/src/main/java/com/example/osnov_android/views/CookingUpdate.kt

@@ -0,0 +1,11 @@
+package com.example.osnov_android.views
+
+import androidx.compose.runtime.Composable
+import androidx.navigation.NavController
+import com.example.osnov_android.MainActivityViewModel
+
+@Composable
+fun CookingsUpdate(viewModel: MainActivityViewModel, navController: NavController)
+{
+
+}

+ 134 - 3
app/src/main/java/com/example/osnov_android/views/Profile.kt

@@ -1,19 +1,150 @@
 package com.example.osnov_android.views
 
+import androidx.compose.foundation.Image
 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.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.KeyboardArrowDown
+import androidx.compose.material.icons.filled.KeyboardArrowUp
+import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonColors
+import androidx.compose.material3.CircularProgressIndicator
+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.runtime.setValue
+import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.geometry.Size
 import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.layout.ContentScale
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
 import androidx.navigation.NavController
+import coil.compose.rememberAsyncImagePainter
 import com.example.osnov_android.MainActivityViewModel
+import com.example.osnov_android.navigation.Screen
 
 @Composable
-fun Profile(viewModel: MainActivityViewModel)
-{
+fun Profile(viewModel: MainActivityViewModel, navController: NavController) {
     val background = Color(0xFF1B1A20)
-    Column(Modifier.fillMaxSize().background(background)) {
+    val user by viewModel.user
+    val context = LocalContext.current
+    val flag1 = remember { mutableStateOf(false) }
+    val userState by viewModel.userState
+    val flag = remember { mutableStateOf(true) }
+    if (flag.value) {
+        viewModel.profileData()
+        flag.value = false
+    }
+
 
+    if (user.isNotEmpty()) {
+        val name = remember { mutableStateOf(user.last().name) }
+        var expanded by remember {
+            mutableStateOf(false)
+        }
+        val list = listOf("Мужской", "Женский")
+
+        var selectedItem by remember {
+            mutableStateOf(
+                if (user.last().id_gender == 1) {
+                    "Мужской"
+                } else {
+                    "Женский"
+                }
+            )
+        }
+        var textFiledSize by remember {
+            mutableStateOf(Size.Zero)
+        }
+        val icon = if (expanded) {
+            Icons.Filled.KeyboardArrowUp
+        } else {
+            Icons.Filled.KeyboardArrowDown
+        }
+        Column(
+            modifier = Modifier
+                .fillMaxSize()
+                .background(background)
+                .padding(top = 50.dp),
+            horizontalAlignment = Alignment.CenterHorizontally
+        ) {
+            Text(
+                text = "ПРОФИЛЬ",
+                fontWeight = FontWeight.Light,
+                fontSize = 24.sp,
+                color = Color(0xFFFFFFFF),
+                letterSpacing = 10.sp
+            )
+            Spacer(Modifier.height(30.dp))
+            Row {
+                Box(modifier = Modifier.height(200.dp).width(200.dp),)
+                {
+                    Column(
+                        Modifier.fillMaxSize(),
+                        verticalArrangement = Arrangement.Center,
+                    ) {
+                        Image(
+                            modifier = Modifier
+                                .fillMaxWidth()
+                                .size(200.dp)
+                                .clip(CircleShape),
+                            painter = rememberAsyncImagePainter(viewModel.users.value.last().image),
+                            contentDescription = "",
+                            contentScale = ContentScale.Crop,
+                            alignment = Alignment.Center
+                        )
+                    }
+                }
+                Spacer(Modifier.width(30.dp))
+                Box(modifier = Modifier.height(150.dp).width(105.dp))
+                {
+                    Text(text = viewModel.users.value.last().name,
+                        fontWeight = FontWeight.Medium,
+                        fontSize = 30.sp,
+                        color = Color.White,
+                        modifier = Modifier.padding(5.dp))
+                }
+                }
+            Spacer(Modifier.width(60.dp))
+            Button(onClick = {
+                navController.navigate(Screen.UpdatedataUser.route)
+            }, modifier = Modifier
+                .fillMaxWidth(0.5f)
+                .padding(top = 20.dp),
+                shape = RoundedCornerShape(20),
+                colors = ButtonColors(
+                    contentColor = Color.White,
+                    containerColor = Color(0xFF7DAD01),
+                    disabledContentColor = Color.White,
+                    disabledContainerColor = Color(0xFF7DAD01)
+                )
+            ) {
+                Text(text = "Изменить", fontSize = 24.sp, fontWeight = FontWeight.Light )
+            }
+        }
+    }
+    else {
+        Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
+            CircularProgressIndicator()
+        }
     }
 }

+ 34 - 19
app/src/main/java/com/example/osnov_android/views/SignUp.kt

@@ -1,10 +1,8 @@
 package com.example.osnov_android.views
 
 import android.util.Patterns
-import android.widget.Space
 import android.widget.Toast
 import androidx.compose.foundation.background
-import androidx.compose.foundation.border
 import androidx.compose.foundation.layout.Arrangement
 import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.Column
@@ -15,7 +13,6 @@ 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.foundation.text.KeyboardOptions
 import androidx.compose.material3.Button
 import androidx.compose.material3.ButtonColors
 import androidx.compose.material3.CircularProgressIndicator
@@ -35,7 +32,6 @@ import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.res.painterResource
 import androidx.compose.ui.text.TextStyle
 import androidx.compose.ui.text.font.FontWeight
-import androidx.compose.ui.text.input.KeyboardType
 import androidx.compose.ui.text.style.TextAlign
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
@@ -54,9 +50,14 @@ fun SignUp(navController: NavController, viewModel: MainActivityViewModel) {
     val email = remember { mutableStateOf("") }
     val name = remember { mutableStateOf("") }
     val password = remember { mutableStateOf("") }
+    val password2 = remember { mutableStateOf("") }
     val enable = remember { mutableStateOf(false)}
     val flag = remember { mutableStateOf(false)}
     val userState by viewModel.userState
+
+
+
+
     Column(
         modifier = Modifier
             .fillMaxSize()
@@ -108,17 +109,19 @@ fun SignUp(navController: NavController, viewModel: MainActivityViewModel) {
                     color = Color.Red,
                     textAlign = TextAlign.Center
                 )
-            }
-            else {
+            } else {
                 enable.value = true
             }
             Spacer(Modifier.height(20.dp))
-            Box(modifier = Modifier
-                .clip(RoundedCornerShape(10.dp))
-                .background(Color(0xFFAAABA7)))
+            Box(
+                modifier = Modifier
+                    .clip(RoundedCornerShape(10.dp))
+                    .background(Color(0xFFAAABA7))
+            )
             {
-                OutlinedTextField(value = name.value, onValueChange = { name.value = it },
-                    keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
+                OutlinedTextField(
+                    value = name.value,
+                    onValueChange = { name.value = it },
                     textStyle = TextStyle(
                         color = Color.Black,
                         fontSize = 15.sp
@@ -127,9 +130,10 @@ fun SignUp(navController: NavController, viewModel: MainActivityViewModel) {
                         focusedContainerColor = Color(0XFFF5F5F9),
                         focusedIndicatorColor = Color(0xFFEBEBEB),
                         focusedTextColor = Color(0XFF578FFF),
-                        disabledIndicatorColor = Color.Transparent,
-                        unfocusedIndicatorColor = Color.Transparent,
-                        cursorColor = Color(0XFF578FFF)
+                        disabledIndicatorColor = Color.White,
+                        unfocusedIndicatorColor = Color.White,
+                        cursorColor = Color(0XFF578FFF),
+                        focusedSupportingTextColor = Color(0xFF00000)
                     ),
                     modifier = Modifier
                         .fillMaxWidth(0.6f)
@@ -144,23 +148,33 @@ fun SignUp(navController: NavController, viewModel: MainActivityViewModel) {
                             color = Color(0XFF939396)
                         )
                     }
-
                 )
             }
             Column(
                 modifier = Modifier,
-                    horizontalAlignment = Alignment.CenterHorizontally
+                horizontalAlignment = Alignment.CenterHorizontally
             ) {
                 Spacer(Modifier.height(20.dp))
                 TextBlockPassword(
                     text = "Пароль",
                     search = password.value,
                     onValueChange = { password.value = it })
+                Spacer(Modifier.height(20.dp))
+                TextBlockPassword(
+                    text = "Повторите пароль",
+                    search = password2.value,
+                    onValueChange = { password2.value = it })
+
                 Spacer(Modifier.height(50.dp))
                 Button(
                     onClick = {
-                        viewModel.SignUp(email.value, password.value, name.value)
-                        flag.value = true
+                        if (password.value != password2.value) {
+                            Toast.makeText(context, "Пароли не совпадают", Toast.LENGTH_SHORT)
+                                .show()
+                        } else {
+                            viewModel.SignUp(email.value, name.value, 3, password.value)
+                            flag.value = true
+                        }
                     },
                     Modifier
                         .height(50.dp)
@@ -174,11 +188,12 @@ fun SignUp(navController: NavController, viewModel: MainActivityViewModel) {
                         disabledContainerColor = Color.LightGray
                     )
                 )
-                { Text(text = "Регистрация", fontSize = 24.sp, fontWeight = FontWeight.Light)}
+                { Text(text = "Регистрация", fontSize = 24.sp, fontWeight = FontWeight.Light) }
                 Spacer(modifier = Modifier.height(20.dp))
                 Button(
                     onClick = {
                         navController.navigate(Screen.Start.route)
+
                     },
                     Modifier
                         .height(50.dp)

+ 309 - 0
app/src/main/java/com/example/osnov_android/views/Updatedatauser.kt

@@ -0,0 +1,309 @@
+package com.example.osnov_android.views
+
+import android.widget.Toast
+import androidx.compose.foundation.BorderStroke
+import androidx.compose.foundation.Image
+import androidx.compose.foundation.background
+import androidx.compose.foundation.border
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxHeight
+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.size
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Face
+import androidx.compose.material.icons.filled.KeyboardArrowDown
+import androidx.compose.material.icons.filled.KeyboardArrowUp
+import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonColors
+import androidx.compose.material3.CircularProgressIndicator
+import androidx.compose.material3.DropdownMenu
+import androidx.compose.material3.DropdownMenuItem
+import androidx.compose.material3.Icon
+import androidx.compose.material3.OutlinedTextField
+import androidx.compose.material3.Text
+import androidx.compose.material3.TextFieldDefaults
+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.draw.clip
+import androidx.compose.ui.geometry.Size
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.layout.ContentScale
+import androidx.compose.ui.layout.onGloballyPositioned
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import androidx.compose.ui.unit.toSize
+import androidx.navigation.NavController
+import coil.compose.rememberAsyncImagePainter
+import com.example.osnov_android.MainActivityViewModel
+import com.example.osnov_android.models.UserState
+
+@Composable
+fun Updatedatauser(viewModel: MainActivityViewModel, navController: NavController) {
+    val background = Color(0xFF1B1A20)
+    val user by viewModel.user
+    val name = remember { mutableStateOf(user.last().name) }
+    val nameFlag = remember { mutableStateOf(true) }
+    val flag = remember { mutableStateOf(false) }
+    val userState by viewModel.userState
+    val context = LocalContext.current
+    var expanded by remember {
+        mutableStateOf(false)
+    }
+    val list = listOf("Мужской", "Женский")
+
+    var selectedItem by remember {
+        mutableStateOf(
+            if (user.last().id_gender == 1) {
+                "Мужской"
+            } else {
+                "Женский"
+            }
+        )
+    }
+    var textFiledSize by remember {
+        mutableStateOf(Size.Zero)
+    }
+    val icon = if (expanded) {
+        Icons.Filled.KeyboardArrowUp
+    } else {
+        Icons.Filled.KeyboardArrowDown
+    }
+
+    Column(
+        modifier = Modifier
+            .fillMaxSize()
+            .fillMaxHeight()
+            .background(background)
+            .padding(top = 50.dp),
+        horizontalAlignment = Alignment.CenterHorizontally
+    )
+    {
+        Text(
+            text = "ПРОФИЛЬ",
+            fontWeight = FontWeight.Light,
+            fontSize = 24.sp,
+            color = Color(0xFFFFFFFF),
+            letterSpacing = 10.sp
+        )
+        Spacer(Modifier.height(30.dp))
+        Box(modifier = Modifier.height(200.dp).width(200.dp),)
+        {
+            Image(
+                modifier = Modifier
+                    .fillMaxWidth()
+                    .size(200.dp)
+                    .clip(CircleShape),
+                painter = rememberAsyncImagePainter(viewModel.users.value.last().image),
+                contentDescription = "",
+                contentScale = ContentScale.Crop,
+                alignment = Alignment.Center
+            )
+        }
+        Spacer(Modifier.height(30.dp))
+        Column()
+        {
+            Text(
+                text = "Изменить имя",
+                fontWeight = FontWeight.Medium,
+                fontSize = 16.sp,
+                color = Color(0xFFFFFFFF),
+                letterSpacing = 2.sp
+            )
+            Box(
+                modifier = Modifier
+                    .clip(RoundedCornerShape(10.dp))
+                    .background(Color(0xFFAAABA7))
+            )
+            {
+                OutlinedTextField(
+                    value = name.value,
+                    onValueChange = { name.value = it },
+                    textStyle = TextStyle(
+                        color = Color.Black,
+                        fontSize = 15.sp
+                    ),
+                    colors = TextFieldDefaults.colors(
+                        focusedContainerColor = Color(0XFFF5F5F9),
+                        focusedIndicatorColor = Color(0xFFEBEBEB),
+                        focusedTextColor = Color(0XFF578FFF),
+                        disabledIndicatorColor = Color.White,
+                        unfocusedIndicatorColor = Color.White,
+                        cursorColor = Color(0XFF578FFF),
+                        focusedSupportingTextColor = Color(0xFF00000)
+                    ),
+                    isError = nameFlag.value,
+                    modifier = Modifier
+                        .background(Color(0XFFF5F5F9))
+                        .height(height = 50.dp)
+                        .fillMaxWidth(0.5f),
+                    placeholder = {
+                        Text(
+                            modifier = Modifier.fillMaxWidth(),
+                            text = "Имя",
+                            fontSize = 15.sp,
+                            color = Color(0XFF939396)
+                        )
+                    }
+                )
+            }
+            Spacer(Modifier.height(30.dp))
+            Column()
+            {
+                Text(
+                    text = "Изменить пол",
+                    fontWeight = FontWeight.Medium,
+                    fontSize = 16.sp,
+                    color = Color(0xFFFFFFFF),
+                    letterSpacing = 2.sp
+                )
+                Box(
+                    modifier = Modifier
+                        .clip(RoundedCornerShape(10.dp))
+                        .background(Color(0xFFAAABA7))
+                ) {
+
+                    OutlinedTextField(value = selectedItem,
+                        onValueChange = {
+                            selectedItem = it
+                        },
+                        leadingIcon = {
+                            Icon(
+                                Icons.Filled.Face,
+                                contentDescription = "Пол",
+                            )
+                        },
+                        colors = TextFieldDefaults.colors(
+                            unfocusedTextColor = Color.Black,
+                            focusedTextColor = Color.Black,
+                            disabledTextColor = Color.Black,
+                            disabledContainerColor = Color(0XffE4E4E7),
+                            focusedContainerColor = Color(0XffE4E4E7),
+                            unfocusedContainerColor = Color(0XffE4E4E7)
+
+                        ),
+                        enabled = false,
+                        modifier = Modifier
+                            .fillMaxWidth(0.5f)
+                            .height(height = 56.dp)
+                            .width(width = 320.dp)
+                            .clickable { expanded = !expanded }
+                            .onGloballyPositioned { coordinates ->
+                                textFiledSize = coordinates.size.toSize()
+                            }
+                            .border(BorderStroke(0.dp, Color.Transparent)),
+                        trailingIcon = {
+                            Icon(
+                                icon,
+                                contentDescription = ""
+                            )
+                        },
+                        placeholder = {
+                            Text(
+                                modifier = Modifier.fillMaxWidth(),
+                                text = "Пол",
+                                fontWeight = FontWeight.Normal,
+                                fontSize = 15.sp,
+                                color = Color.Black
+                            )
+                        }
+                    )
+
+
+                    DropdownMenu(
+                        expanded = expanded,
+                        onDismissRequest = { expanded = false },
+                        modifier = Modifier
+                            .width(with(LocalDensity.current) { textFiledSize.width.toDp() })
+                            .background(Color(0XffE4E4E7))
+                            .border(BorderStroke(0.dp, Color.Transparent))
+                    ) {
+                        list.forEach { label ->
+                            DropdownMenuItem(text = {
+                                Text(
+                                    text = label,
+                                    fontSize = 15.sp,
+                                    fontWeight = FontWeight.Normal,
+                                    color = Color.Black
+
+                                )
+                            }, onClick = {
+                                selectedItem = label
+                                expanded = false
+
+                            })
+                        }
+
+                    }
+                }
+            }
+        }
+        Spacer(Modifier.width(30.dp))
+
+        Button(
+            onClick = {
+                if (selectedItem == "Мужской") {
+                    viewModel.updateUser(name.value, 1)
+                } else {
+                    viewModel.updateUser(name.value, 2)
+                }
+                flag.value = true
+            },
+            Modifier
+                .height(100.dp)
+                .width(250.dp)
+                .padding(top = 20.dp),
+            shape = RoundedCornerShape(20),
+            colors = ButtonColors(
+                contentColor = Color.White,
+                containerColor = Color(0xFF7DAD01),
+                disabledContentColor = Color.White,
+                disabledContainerColor = Color.LightGray
+            )
+        )
+        {
+            Text(
+                text = "Изменить данные",
+                fontSize = 24.sp,
+                fontWeight = FontWeight.Light
+            )
+        }
+    }
+        if (flag.value) {
+            when (userState) {
+                is UserState.Loading -> {
+                    Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
+                        CircularProgressIndicator()
+                    }
+                }
+
+                is UserState.Success -> {
+                    Toast.makeText(context, "Данные изменены", Toast.LENGTH_SHORT).show()
+                    flag.value = false
+                }
+
+                is UserState.Error -> {
+                    val message = (userState as UserState.Error).message
+                    Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
+                    flag.value = false
+                }
+            }
+        }
+    }

+ 6 - 6
app/src/main/java/com/example/osnov_android/views/bottom_menu/BottomGraph.kt

@@ -4,21 +4,21 @@ import android.os.Build
 import androidx.annotation.RequiresApi
 import androidx.compose.runtime.Composable
 import androidx.navigation.NavController
+import androidx.navigation.NavHostController
 import androidx.navigation.compose.NavHost
+import androidx.navigation.compose.composable
 import com.example.osnov_android.MainActivityViewModel
 import com.example.osnov_android.navigation.Screen
-import com.example.osnov_android.views.Faq
+import com.example.osnov_android.views.Blog
 import com.example.osnov_android.views.Cookings
+import com.example.osnov_android.views.Faq
 import com.example.osnov_android.views.Profile
-import androidx.navigation.NavHostController
-import androidx.navigation.compose.composable
-import com.example.osnov_android.views.Blog
 
 @RequiresApi(Build.VERSION_CODES.O)
 @Composable
 fun BottomGraph(viewModel: MainActivityViewModel, navController: NavHostController, mainNavController: NavController) {
     NavHost(navController = navController,
-        startDestination = Screen.Blog.route,)
+        startDestination = Screen.Profile.route,)
     {
         composable(Screen.Blog.route)
         {
@@ -34,7 +34,7 @@ fun BottomGraph(viewModel: MainActivityViewModel, navController: NavHostControll
         }
         composable(Screen.Profile.route)
         {
-            Profile(viewModel )
+            Profile(viewModel, mainNavController )
         }
     }
 

+ 6 - 8
app/src/main/java/com/example/osnov_android/views/bottommenuAdmin/BottomGraphAdmin.kt

@@ -4,23 +4,21 @@ import android.os.Build
 import androidx.annotation.RequiresApi
 import androidx.compose.runtime.Composable
 import androidx.navigation.NavController
+import androidx.navigation.NavHostController
 import androidx.navigation.compose.NavHost
+import androidx.navigation.compose.composable
 import com.example.osnov_android.MainActivityViewModel
 import com.example.osnov_android.navigation.Screen
-import com.example.osnov_android.views.Faq
-import com.example.osnov_android.views.Cookings
-import com.example.osnov_android.views.Profile
-import androidx.navigation.NavHostController
-import androidx.navigation.compose.composable
-import com.example.osnov_android.views.Blog
 import com.example.osnov_android.views.BlogAdmin
 import com.example.osnov_android.views.CookingAdmin
+import com.example.osnov_android.views.Faq
+import com.example.osnov_android.views.Profile
 
 @RequiresApi(Build.VERSION_CODES.O)
 @Composable
 fun BottomGraphAdmin(viewModel: MainActivityViewModel, navController: NavHostController, mainNavController: NavController) {
     NavHost(navController = navController,
-        startDestination = Screen.BlogAdmin.route,)
+        startDestination = Screen.Profile.route,)
     {
         composable(Screen.BlogAdmin.route)
         {
@@ -36,7 +34,7 @@ fun BottomGraphAdmin(viewModel: MainActivityViewModel, navController: NavHostCon
         }
         composable(Screen.Profile.route)
         {
-            Profile(viewModel )
+            Profile(viewModel, mainNavController )
         }
     }
 

+ 2 - 0
gradle/libs.versions.toml

@@ -3,6 +3,7 @@ agp = "8.5.1"
 bom = "3.0.2"
 coilCompose = "2.4.0"
 coilComposeVersion = "3.0.3"
+datetime = "0.9.0"
 kotlin = "2.0.20"
 coreKtx = "1.10.1"
 junit = "4.13.2"
@@ -25,6 +26,7 @@ auth-kt = { module = "io.github.jan-tennert.supabase:auth-kt" }
 bom = { module = "io.github.jan-tennert.supabase:bom", version.ref = "bom" }
 coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coilCompose" }
 coil3-coil-compose = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coilComposeVersion" }
+datetime = { module = "io.github.vanpra.compose-material-dialogs:datetime", version.ref = "datetime" }
 junit = { group = "junit", name = "junit", version.ref = "junit" }
 androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
 androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }