فهرست منبع

App: add functions

Anna 19 ساعت پیش
والد
کامیت
c7cbcc13f2
20فایلهای تغییر یافته به همراه2561 افزوده شده و 105 حذف شده
  1. 4 1
      Project_exvesta/app/build.gradle.kts
  2. 15 0
      Project_exvesta/app/src/main/AndroidManifest.xml
  3. 2 0
      Project_exvesta/app/src/main/java/com/example/exvesta/Screans/AddUser.kt
  4. 151 17
      Project_exvesta/app/src/main/java/com/example/exvesta/Screans/Auth.kt
  5. 582 0
      Project_exvesta/app/src/main/java/com/example/exvesta/Screans/Bows.kt
  6. 27 23
      Project_exvesta/app/src/main/java/com/example/exvesta/Screans/Filters.kt
  7. 2 2
      Project_exvesta/app/src/main/java/com/example/exvesta/Screans/Home.kt
  8. 6 1
      Project_exvesta/app/src/main/java/com/example/exvesta/Screans/Login.kt
  9. 64 1
      Project_exvesta/app/src/main/java/com/example/exvesta/Screans/MainActivity.kt
  10. 1 1
      Project_exvesta/app/src/main/java/com/example/exvesta/Screans/MainViewModel.kt
  11. 486 0
      Project_exvesta/app/src/main/java/com/example/exvesta/Screans/MyBows.kt
  12. 523 54
      Project_exvesta/app/src/main/java/com/example/exvesta/Screans/Wardrob.kt
  13. 674 0
      Project_exvesta/app/src/main/java/com/example/exvesta/Screans/addBow.kt
  14. 2 1
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Bows.kt
  15. 1 1
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Consists_wardrob.kt
  16. 2 2
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Things_user.kt
  17. 1 1
      Project_exvesta/app/src/main/java/com/example/exvesta/model/Wardob.kt
  18. 12 0
      Project_exvesta/app/src/main/java/com/example/exvesta/navigation/Navigation.kt
  19. 4 0
      Project_exvesta/app/src/main/res/xml/file_paths.xml
  20. 2 0
      Project_exvesta/gradle/libs.versions.toml

+ 4 - 1
Project_exvesta/app/build.gradle.kts

@@ -67,6 +67,7 @@ dependencies {
     implementation(libs.androidx.espresso.core)
     implementation(libs.androidx.tools.core)
     implementation(libs.androidx.appcompat)
+    implementation(libs.androidx.runtime.livedata)
     testImplementation(libs.junit)
     androidTestImplementation(libs.androidx.junit)
     androidTestImplementation(libs.androidx.espresso.core)
@@ -76,7 +77,9 @@ dependencies {
     debugImplementation(libs.androidx.ui.test.manifest)
     implementation(libs.androidx.material)
 
-
+    // Другие зависимости
+    debugImplementation(libs.androidx.ui.tooling)
+    debugImplementation(libs.androidx.ui.test.manifest)
     implementation(platform(libs.bom.v261))
     implementation(libs.io.github.jan.tennert.supabase.postgrest.kt2)
     implementation(libs.io.github.jan.tennert.supabase.postgrest.kt)

+ 15 - 0
Project_exvesta/app/src/main/AndroidManifest.xml

@@ -1,17 +1,23 @@
 <?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" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
     <application
         android:allowBackup="true"
         android:dataExtractionRules="@xml/data_extraction_rules"
         android:fullBackupContent="@xml/backup_rules"
         android:icon="@mipmap/ic_launcher"
         android:label="@string/app_name"
+        android:requestLegacyExternalStorage="true"
         android:roundIcon="@mipmap/ic_launcher_round"
         android:supportsRtl="true"
         android:theme="@style/Theme.Exvesta"
         tools:targetApi="31">
+
+
         <activity
             android:name=".Screans.MainActivity"
             android:exported="true"
@@ -23,6 +29,15 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
+        <provider
+            android:name="androidx.core.content.FileProvider"
+            android:authorities="your.package.name.fileprovider"
+            android:exported="false"
+            android:grantUriPermissions="true">
+            <meta-data
+                android:name="android.support.FILE_PROVIDER_PATHS"
+                android:resource="@xml/file_paths" />
+        </provider>
     </application>
 
 </manifest>

+ 2 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/Screans/AddUser.kt

@@ -0,0 +1,2 @@
+package com.example.exvesta.Screans
+

+ 151 - 17
Project_exvesta/app/src/main/java/com/example/exvesta/Screans/Auth.kt

@@ -1,23 +1,57 @@
 package com.example.exvesta.Screans
 
+import android.content.Intent
+import android.net.Uri
+import android.provider.MediaStore
+import android.util.Log
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.core.app.ActivityCompat.startActivityForResult
 import androidx.lifecycle.ViewModel
 import androidx.lifecycle.viewModelScope
 import androidx.navigation.NavController
 import androidx.navigation.NavHostController
 
 import com.example.exvesta.domain.utils.Constants
+import com.example.exvesta.domain.utils.Constants.supabase
 import com.example.exvesta.model.Consists_wardrob
+import com.example.exvesta.model.Publicthings
+import com.example.exvesta.model.Season
+import com.example.exvesta.model.Style
 import com.example.exvesta.model.Things_user
+import com.example.exvesta.model.Type_subtype
 import io.github.jan.supabase.gotrue.providers.builtin.OTP
 import kotlinx.coroutines.launch
 
-
+import android.content.Context
+import androidx.compose.foundation.layout.Column
+import androidx.compose.runtime.mutableStateListOf
 import io.github.jan.supabase.gotrue.auth
 import io.github.jan.supabase.gotrue.providers.builtin.Email
 import io.github.jan.supabase.postgrest.from
+import io.github.jan.supabase.storage.storage
+import okhttp3.MediaType
+import okhttp3.OkHttpClient
+import okhttp3.RequestBody
+
+import androidx.core.content.ContextCompat
+import io.github.jan.supabase.postgrest.query.Columns
+import io.github.jan.supabase.postgrest.query.Order
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+
+import okhttp3.*
+import okhttp3.MediaType.Companion.toMediaTypeOrNull
+import java.io.File
+import java.sql.DriverManager
+import java.sql.PreparedStatement
 
 
-class  Auth(): ViewModel(){
+class  Auth(private val context: Context): ViewModel() {
+    private val _userThingsState = MutableStateFlow<List<Things_user>>(listOf())
+    val userThingsState: StateFlow<List<Things_user>> = _userThingsState
     fun onSignInEmailCode(emailUser: String) {
         viewModelScope.launch {
             try {
@@ -51,18 +85,18 @@ class  Auth(): ViewModel(){
             }
         }
     }
+
     fun onSignUpEmail(emailUser: String, passwordUser: String) {
         viewModelScope.launch {
-            try{
-                var  user =  Constants.supabase.auth.signUpWith(Email) {
+            try {
+                var user = Constants.supabase.auth.signUpWith(Email) {
                     email = emailUser
                     password = passwordUser
                 }
                 println(user.toString())
                 println(Constants.supabase.auth.currentUserOrNull()!!.id)
                 println("Success")
-            }
-            catch (e: Exception) {
+            } catch (e: Exception) {
                 println("Error")
                 println(e.message.toString())
             }
@@ -70,22 +104,122 @@ class  Auth(): ViewModel(){
         }
     }
 
-fun deleteItem(userthing: Consists_wardrob){
-    viewModelScope.launch {
+    fun deleteItem(userthing: Things_user) {
+        var response: List<Things_user>
+        response = ArrayList()
+        viewModelScope.launch {
 
-        try {
-            val del = Constants.supabase.from("Things_user").delete() {
+            try {
+                Constants.supabase.from("Things_user").delete {
 
-                filter{
-                    Things_user::id eq userthing.id
+                    filter {
+                        Things_user::id eq userthing.id
+                    }
                 }
-            }.decodeList<Things_user>()
+
+            } catch (e: Exception) {
+                println("Error")
+                println(e.message.toString())
+            }
         }
-        catch (e: Exception){
-            println("Error")
-            println(e.message.toString())
+
+    }
+
+    fun insertItem(season: Int, styles: Int, title: String, subtype: Int, imgUri: Uri?) {
+        viewModelScope.launch {
+            try {
+                imgUri?.let { imageUri ->
+                    val inputStream = context.contentResolver.openInputStream(imageUri)
+                    inputStream?.use { stream ->
+                        val byteArray =
+                            stream.readBytes() // Читаем содержимое файла в массив байтов
+                        val bucket =
+                            Constants.supabase.storage.from("exvesta") // Укажите имя вашего бакета
+
+                        val fileName = imageUri.lastPathSegment
+                            ?: "default_image_name.jpg" // Получаем имя файла из Uri
+                        val imageUrl =
+                            "https://vkxcxcimqqswxqxncmof.supabase.co/storage/v1/object/public/exvesta/$fileName"
+
+                        // Загружаем файл в бакет
+                        val uploadResponse =
+                            bucket.upload(fileName, byteArray) // Используем имя файла
+                        Log.d("UploadResponse", uploadResponse.toString())
+
+                        // Создаем объект Things_user
+                        val thing = Things_user(
+                            id = null,
+                            style = styles,
+                            title = title,
+                            subtype = subtype,
+                            img = imageUrl,
+                            id_season = season,
+                            no = false,
+                            public_status = false
+                        )
+
+                        // Вставка элемента в базу данных
+                        val insertResponse = Constants.supabase.from("Things_user").insert(thing)
+                        Log.d("InsertResponse1", insertResponse.toString())
+
+                    }
+
+
+                }
+                refreshUserThings()
+            } catch (e: Exception) {
+                println("Error during insertion: ${e.message}")
+            }
+        }
+    }
+
+    fun refreshUserThings() {
+        viewModelScope.launch {
+            try {
+                val refreshedThings = Constants.supabase.from("Things_user")
+                    .select()
+                    .decodeList<Things_user>()
+                // Здесь вы можете использовать LiveData или StateFlow, чтобы обновить UI
+                // Например, если вы используете StateFlow:
+                _userThingsState.value = refreshedThings
+            } catch (e: Exception) {
+                println("Error refreshing user things: ${e.message}")
+            }
+        }
+    }
+
+    fun addc(
+        idWardrob: Int,
+        firstId: Int
+    ) {
+
+        Log.d("firstId", firstId.toString())
+        viewModelScope.launch {
+            try {
+
+                val conw = Consists_wardrob(
+                    id = null,
+                    id_thing = firstId,
+                    id_wardrob = idWardrob
+                )
+                val insertRespons = Constants.supabase.from("Consists_wardrob").insert(conw)
+                refreshUserThings()
+            } catch (e: Exception) {
+                println("Error during insertion: ${e.message}")
+            }
         }
     }
-}
+    private var _filteredSortedThings = mutableStateListOf<Things_user>()
+    val filteredSortedThings: List<Things_user> get() = _filteredSortedThings
 
+    fun FilterAndSortThings(  userthings: List<Things_user>,   newThingName: String,){
+        _filteredSortedThings.clear()
+       _filteredSortedThings.addAll(
+           userthings
+               .filter { thing ->
+                   // Фильтрация по имени
+                   newThingName.isEmpty() || thing.title.contains(newThingName, ignoreCase = true)
+               }
+       )
+     }
 }

+ 582 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/Screans/Bows.kt

@@ -0,0 +1,582 @@
+package com.example.exvesta.Screans
+
+import android.util.Log
+import androidx.compose.foundation.BorderStroke
+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.fillMaxHeight
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.offset
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.sizeIn
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.wrapContentSize
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.LazyRow
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonDefaults
+import androidx.compose.material3.CircularProgressIndicator
+import androidx.compose.material3.Text
+import androidx.compose.foundation.lazy.items
+import androidx.compose.material.DrawerValue
+import androidx.compose.material.ModalDrawer
+import androidx.compose.material.rememberDrawerState
+import androidx.compose.material3.Divider
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.rememberCoroutineScope
+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.draw.shadow
+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.NavHostController
+import coil.compose.AsyncImagePainter
+import coil.compose.rememberAsyncImagePainter
+import coil.request.ImageRequest
+import coil.size.Size
+
+import com.example.exvesta.domain.utils.Constants
+import com.example.exvesta.model.Publicthings
+import com.example.exvesta.model.Season_dublicate
+import com.example.exvesta.model.Style_dublicate
+import com.example.exvesta.model.Type_dublicate
+import com.example.exvesta.model.Type_subtype_dublicate
+import io.github.jan.supabase.postgrest.from
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Menu
+import androidx.compose.material.*
+import androidx.compose.ui.graphics.Brush
+import androidx.navigation.NavHost
+import com.example.exvesta.model.Bows
+import com.example.exvesta.model.Consists_bows
+import com.example.exvesta.model.Things_user
+import com.example.exvesta.model.Wardob
+import io.github.jan.supabase.gotrue.auth
+import kotlinx.coroutines.launch
+
+
+@OptIn(ExperimentalMaterialApi::class)
+@Composable
+fun Bows(navHost: NavHostController) {
+    var subdubtype by remember { mutableStateOf<List<Type_subtype_dublicate>>(listOf()) }
+    var dubtype by remember { mutableStateOf<List<Type_dublicate>>(listOf()) }
+    var bows by remember { mutableStateOf<List<Bows>>(listOf()) }
+    var conbows by remember { mutableStateOf<List<Consists_bows>>(listOf()) }
+    var seasondub by remember { mutableStateOf<List<Season_dublicate>>(listOf()) }
+    var publicthings by remember { mutableStateOf<List<Publicthings>>(listOf()) }
+    var styledub by remember { mutableStateOf<List<Style_dublicate>>(listOf()) }
+    var recpubthingsList by remember { mutableStateOf<List<Publicthings>>(listOf()) }
+    var filteredPublicThings by remember { mutableStateOf<List<Publicthings>>(listOf()) }
+    var selectedBow by remember { mutableStateOf<Bows?>(null) }
+
+    var showDialog by remember { mutableStateOf(false) }
+    val viewModel = MainViewModel()
+    var userthings by remember { mutableStateOf<List<Things_user>>(listOf()) }
+    LaunchedEffect(Unit) {
+        withContext(Dispatchers.IO) {
+            userthings  = Constants.supabase.from("Things_user")
+               .select().decodeList<Things_user>()
+            publicthings = Constants.supabase.from("Publicthings")
+                .select().decodeList<Publicthings>()
+            bows  = Constants.supabase.from("Bows")
+                .select().decodeList<Bows>()
+            conbows  = Constants.supabase.from("Consists_bows")
+                .select().decodeList<Consists_bows>()
+            subdubtype = Constants.supabase.from("Type_subtype_dublicate")
+                .select().decodeList<Type_subtype_dublicate>()
+            dubtype = Constants.supabase.from("Type_dublicate")
+                .select().decodeList<Type_dublicate>()
+            seasondub = Constants.supabase.from("Season_dublicate")
+                .select().decodeList<Season_dublicate>()
+            styledub = Constants.supabase.from("Style_dublicate")
+                .select().decodeList<Style_dublicate>()
+            publicthings.forEach { it ->
+                Log.d("ts", it.title)
+            }
+        }
+        filteredPublicThings = publicthings
+
+    }
+    var filtersApplied by remember { mutableStateOf(false) }
+    var isFilterSheetVisible by remember { mutableStateOf(false) }
+    var drawerState = rememberDrawerState(DrawerValue.Closed)
+    val scope = rememberCoroutineScope()
+
+    ModalDrawer(
+        drawerState = drawerState,
+        drawerContent = {
+            DrawerContent(navHost)
+
+        },
+    ) {
+        Column(
+            modifier = Modifier
+
+                .fillMaxSize()
+                .background(Color.White)
+                .padding(16.dp),
+            horizontalAlignment = Alignment.CenterHorizontally
+        ) {
+            Spacer(modifier = Modifier.height(20.dp))
+            Row(
+                modifier = Modifier
+                    .fillMaxWidth()
+                    .padding(vertical = 16.dp)
+                ,
+                verticalAlignment = Alignment.CenterVertically,
+                horizontalArrangement = Arrangement.Start
+            ) {
+                IconButton(onClick = {
+                    scope.launch { drawerState.open() }
+                }) {
+                    Icon(imageVector = Icons.Filled.Menu, contentDescription = "Menu")
+                }
+
+                Button(
+                    onClick = {
+                        isFilterSheetVisible = true
+                    },
+                    border = BorderStroke(1.dp, Color(0xFF92A2B0)),
+                    modifier = Modifier
+                        .fillMaxWidth()
+                        .padding(vertical = 8.dp),
+                    colors = ButtonDefaults.buttonColors(Color(0xFFF1F1F3))
+                ) {
+                    Text(text = "+ добавить фильтр", color = Color(0xFF92A2B0))
+
+                }
+
+            }
+            if (filtersApplied) {
+                Button(
+                    onClick = {
+                        filteredPublicThings = publicthings
+                        filtersApplied = false
+                    },
+                    border = BorderStroke(1.dp, Color(0xFF92A2B0)),
+                    modifier = Modifier
+                        .fillMaxWidth()
+                        .padding(vertical = 8.dp),
+                    colors = ButtonDefaults.buttonColors(Color(0xFFF1F1F3))
+                ) {
+                    Text(text = "сбросить фильтры", color = Color(0xFF92A2B0))
+                }
+            }
+            Spacer(modifier = Modifier.height(10.dp))
+
+
+
+
+            Row(
+                modifier = Modifier.fillMaxWidth(),
+                horizontalArrangement = Arrangement.SpaceAround
+            ) {
+                // Кнопка "вещи"
+                Box(
+                    modifier = Modifier
+                        .weight(1f)
+                        .padding(bottom = 4.dp) // Паддинг для отступа от нижней тени
+                        .clip(RoundedCornerShape(16.dp))
+                ) {
+                    // Тень
+                    Box(
+                        modifier = Modifier
+                            .shadow(8.dp, RoundedCornerShape(30.dp))
+
+
+                    )
+
+                    // Кнопка
+                    Button(
+                        onClick = { navHost.navigate("Home")  },
+                        modifier = Modifier
+                            .fillMaxWidth()
+
+                            .shadow(
+                                0.dp,
+                                shape = CircleShape,
+                                clip = false
+                            )// Убираем тень у кнопки
+                            .background(
+                                brush = Brush.horizontalGradient(
+                                    colors = listOf(
+                                        Color(0xFFF1F1F3),
+                                        Color(0xFFFFFFFF),
+                                    )
+                                ), shape = ButtonDefaults.shape
+                            ), // Убираем тень у кнопки
+                        colors = ButtonDefaults.buttonColors(containerColor = Color.Transparent)
+
+                    ) {
+                        Text(text = "вещи", color = Color(0xFF92A2B0))
+                    }
+                }
+
+                Spacer(modifier = Modifier.width(16.dp))
+
+                // Кнопка "образы"
+                Box(
+                    modifier = Modifier
+                        .weight(1f)
+                        .padding(bottom = 4.dp) // Паддинг для отступа от нижней тени
+                        .clip(RoundedCornerShape(16.dp))
+                ) {
+                    // Тень
+                    Box(
+                        modifier = Modifier
+                            .shadow(8.dp, RoundedCornerShape(30.dp))
+                    )
+
+                    // Кнопка
+                    Button(
+                        onClick = { /*TODO*/ },
+                        modifier = Modifier
+                            .fillMaxWidth()
+
+                            .background(
+                                brush = Brush.horizontalGradient(
+                                    colors = listOf(
+                                        Color(0xFFF1F1F3),
+                                        Color(0xFFFFFFFF),
+                                    )
+                                ), shape = ButtonDefaults.shape
+                            ), // Убираем тень у кнопки
+                        colors = ButtonDefaults.buttonColors(containerColor = Color.Transparent),
+
+                        ) {
+                        Text(text = "образы", color = Color(0xFF92A2B0))
+                    }
+                }
+            }
+
+            Spacer(modifier = Modifier.height(10.dp))
+
+            LazyColumn(
+
+                modifier = Modifier
+                    .fillMaxSize(1f)
+                    .padding(10.dp)
+            ) {
+
+                items(
+                bows
+                ) { bow->
+                    val iconb = bow.id
+                    val cobow = conbows.filter { it.id_bow ==bow.id }
+                    if(cobow!=null && bow.status==true){
+                        val imageState = rememberAsyncImagePainter(
+                            model = ImageRequest.Builder(LocalContext.current).data(bow.img)
+                                .size(Size.ORIGINAL).build()
+                        ).state
+
+                        Box(
+                            modifier = Modifier
+                                .shadow(8.dp, RoundedCornerShape(30.dp))
+                        ) {
+                            Box(
+                                modifier = Modifier
+                                    .background(
+
+                                        Color.White,
+
+                                        shape = RoundedCornerShape(30.dp)
+                                    )
+                                    .padding(8.dp)
+                                    .wrapContentSize(Alignment.Center)
+
+                            ) {
+
+                                Column(
+                                )
+                                {
+                                    if (imageState is AsyncImagePainter.State.Error) {
+                                        Box(
+                                            modifier = Modifier
+                                                .fillMaxWidth()
+
+                                                .height(250.dp),
+                                            contentAlignment = Alignment.Center
+                                        ) {
+                                            LazyRow {
+                                                items(cobow){
+                                                        conbo ->
+                                                    val thingid = conbo.id_components
+                                                    val thing = userthings.find { it.id == thingid }
+                                                    if(thing!=null){
+
+                                                            val imageState = rememberAsyncImagePainter(
+                                                                model = ImageRequest.Builder(LocalContext.current)
+                                                                    .data(thing.img)
+                                                                    .size(Size.ORIGINAL).build()
+                                                            ).state
+                                                            if (imageState is AsyncImagePainter.State.Error) {
+                                                                Box(
+                                                                    modifier = Modifier
+                                                                        .fillMaxWidth()
+
+                                                                        .height(250.dp),
+                                                                    contentAlignment = Alignment.Center
+                                                                ) {
+                                                                    CircularProgressIndicator()
+                                                                }
+                                                            }
+
+                                                            if (imageState is AsyncImagePainter.State.Success) {
+                                                                Image(
+                                                                    modifier = Modifier
+                                                                        .fillMaxWidth()
+                                                                        .height(250.dp)
+//                                    .clip(RoundedCornerShape(8.dp))
+                                                                    ,
+                                                                    painter = imageState.painter,
+                                                                    contentDescription = "",
+                                                                    contentScale = ContentScale.Crop
+
+
+                                                                )
+                                                            }
+
+
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }
+
+                                    if (imageState is AsyncImagePainter.State.Success) {
+                                        Image(
+                                            modifier = Modifier
+                                                .fillMaxWidth()
+                                                .height(250.dp)
+//                                    .clip(RoundedCornerShape(8.dp))
+                                            ,
+                                            painter = imageState.painter,
+                                            contentDescription = "",
+                                            contentScale = ContentScale.Crop
+
+
+                                        )
+                                    }
+                                    Divider(
+                                        modifier = Modifier.padding(vertical = 8.dp),
+                                        color = Color.LightGray,
+                                        thickness = 1.dp
+                                    )
+                                    Spacer(modifier = Modifier.height(8.dp))
+                                    Text(
+                                        "Название: ${bow.title_bow}",
+                                        fontSize = 18.sp,
+                                        modifier = Modifier.padding(start = 8.dp),
+                                        color = Color(0xFF92A2B0)
+                                    )
+
+
+                                    Spacer(modifier = Modifier.height(8.dp))
+                                    Row(
+                                        horizontalArrangement = Arrangement.SpaceAround
+                                    )
+                                    {
+
+
+                                        Button(
+                                            onClick = {
+                                                selectedBow = bow
+                                                showDialog = true // Показываем диалог
+                                                 },
+                                            modifier = Modifier
+                                                .width(200.dp)
+                                                .height(50.dp)
+                                                .padding(start = 50.dp),
+                                            colors = ButtonDefaults.buttonColors(
+                                                Color(0xFF6F4A48),
+                                                contentColor = Color.White
+                                            ),
+                                            shape = ButtonDefaults.shape
+                                        ) {
+                                            Text(
+                                                text = "подробности",
+                                                fontSize = 16.sp,
+                                                fontWeight = FontWeight.Medium
+                                            )
+                                        }
+
+
+                                    }
+
+                                }
+
+                            }
+
+                            Spacer(modifier = Modifier.height(16.dp))
+
+
+                        }
+                        Spacer(modifier = Modifier.height(20.dp))
+                    }
+
+                }
+
+            }
+
+
+        }
+
+    }
+    if (isFilterSheetVisible) {
+        Column {
+            Filters(
+                onApplyFilters = { selectedSubtype, selectedSeason, selectedStyle ->
+                    // Применяем фильтры и обновляем отображение
+                    filteredPublicThings = publicthings.filter { publicThing ->
+                        (selectedSubtype == null || publicThing.id_subtype == selectedSubtype.id) &&
+                                (selectedSeason == null || publicThing.seson_id == selectedSeason.id)&&
+                                (selectedStyle == null || publicThing.id_style == selectedStyle.id)
+                    }
+
+                    isFilterSheetVisible = false // Закрываем окно фильтров
+                    filtersApplied = true;
+                },
+                onDismiss = { isFilterSheetVisible = false })
+
+        }
+    }
+    if (showDialog && selectedBow != null) {
+        ThingsListScreen(bow = selectedBow!!, things=userthings , conb = conbows, onDismiss = { showDialog = false })
+    }
+}
+
+
+
+@Composable
+public fun ThingsListScreen(bow: Bows, things: List<Things_user>, conb: List<Consists_bows>,onDismiss: () -> Unit) {
+    Column(  modifier = Modifier
+        .fillMaxSize()
+
+        .background(
+            Brush.verticalGradient(
+                colors = listOf(
+                    Color(0xFFF4F4F4),
+                    Color(0xFFE7D2A9),
+                    Color(0xFFC1A88B),
+                    Color(0xFF6F4A48)
+                )
+            )
+        ),
+        horizontalAlignment = Alignment.CenterHorizontally,) {
+
+        Spacer(modifier = Modifier.height(50.dp))
+
+                LazyColumn (  modifier = Modifier.padding(16.dp)){
+                    val cobow = conb.filter { it.id_bow == bow.id }
+                    if (cobow != null && bow.status==true) {
+                        items(cobow) { conbo ->
+                            Box(
+                                modifier = Modifier
+                                    .shadow(8.dp, RoundedCornerShape(30.dp))
+                            ) {
+                                Box(
+                                    modifier = Modifier
+                                        .background(
+
+                                            Color.White,
+
+                                            shape = RoundedCornerShape(30.dp)
+                                        )
+                                        .padding(8.dp)
+                                        .wrapContentSize(Alignment.Center)
+
+                                ){
+                                    Column(
+                                    )
+                                    {
+                                    val thingid = conbo.id_components
+                                    val thing = things.find { it.id == thingid }
+                                    if (thing != null) {
+
+                                        if (thing.id == conbo.id_components) {
+                                            val imageState = rememberAsyncImagePainter(
+                                                model = ImageRequest.Builder(LocalContext.current)
+                                                    .data(thing.img)
+                                                    .size(Size.ORIGINAL).build()
+                                            ).state
+                                            if (imageState is AsyncImagePainter.State.Error) {
+                                                Box(
+                                                    modifier = Modifier
+                                                        .fillMaxWidth()
+
+                                                        .height(250.dp),
+                                                    contentAlignment = Alignment.Center
+                                                ) {
+                                                    CircularProgressIndicator()
+                                                }
+                                            }
+
+                                            if (imageState is AsyncImagePainter.State.Success) {
+                                                Image(
+                                                    modifier = Modifier
+                                                        .fillMaxWidth()
+                                                        .height(250.dp)
+//                                    .clip(RoundedCornerShape(8.dp))
+                                                    ,
+                                                    painter = imageState.painter,
+                                                    contentDescription = "",
+                                                    contentScale = ContentScale.Crop
+
+
+                                                )
+                                            }
+                                            Divider(
+                                                modifier = Modifier.padding(vertical = 8.dp),
+                                                color = Color.LightGray,
+                                                thickness = 1.dp
+                                            )
+                                            Spacer(modifier = Modifier.height(8.dp))
+                                            Text(
+                                                "Название: ${thing.title}",
+                                                fontSize = 18.sp,
+                                                modifier = Modifier.padding(start = 8.dp),
+                                                color = Color(0xFF92A2B0)
+                                            )
+                                        }
+                                    }
+                                    }
+
+
+
+
+                        }
+                    }
+                            Spacer(modifier = Modifier.height(16.dp))
+                }
+
+            }
+        }
+        Spacer(modifier = Modifier.height(16.dp))
+        Button(onClick = onDismiss) {
+            Text("Закрыть")
+        }
+    }
+}

+ 27 - 23
Project_exvesta/app/src/main/java/com/example/exvesta/Screans/Filters.kt

@@ -54,6 +54,10 @@ import androidx.compose.foundation.layout.*
 import androidx.compose.material.*
 import androidx.compose.runtime.*
 import androidx.lifecycle.viewmodel.compose.viewModel
+import com.example.exvesta.model.Season
+import com.example.exvesta.model.Style
+import com.example.exvesta.model.Type
+import com.example.exvesta.model.Type_subtype
 
 @OptIn(ExperimentalLayoutApi::class)
 @Composable
@@ -358,33 +362,33 @@ public  fun Filters(   onApplyFilters: (Type_subtype_dublicate?, Season_dublicat
 
 @OptIn(ExperimentalLayoutApi::class)
 @Composable
-public  fun FiltersUser(   onApplyFilters: (Type_subtype_dublicate?, Season_dublicate?,  Style_dublicate?) -> Unit,
+public  fun FiltersUser(   onApplyFilter: (Type_subtype?, Season?,  Style?) -> Unit,
                        onDismiss: () -> Unit) {
-    var styledubs by remember { mutableStateOf<List<Style_dublicate>>(listOf()) }
-    var subdubtypes by remember { mutableStateOf<List<Type_subtype_dublicate>>(listOf()) }
-    var typedubs by remember { mutableStateOf<List<Type_dublicate>>(listOf()) }
-    var seasondubs by remember { mutableStateOf<List<Season_dublicate>>(listOf()) }
-    var selectedStyle by remember { mutableStateOf<Style_dublicate?>(null) }
-    var selectedSubtype by remember { mutableStateOf<Type_subtype_dublicate?>(null) }
-    var selectedSeason by remember { mutableStateOf<Season_dublicate?>(null) }
+    var style by remember { mutableStateOf<List<Style>>(listOf()) }
+    var subdubtype by remember { mutableStateOf<List<Type_subtype>>(listOf()) }
+    var types by remember { mutableStateOf<List<Type>>(listOf()) }
+    var season by remember { mutableStateOf<List<Season>>(listOf()) }
+    var selectedStyle by remember { mutableStateOf<Style?>(null) }
+    var selectedSubtype by remember { mutableStateOf<Type_subtype?>(null) }
+    var selectedSeason by remember { mutableStateOf<Season?>(null) }
 
     var selectedsubId by remember { mutableStateOf(0) }
     var selectedseasonId by remember { mutableStateOf(0) }
     val viewModel = MainViewModel()
     LaunchedEffect(Unit) {
         withContext(Dispatchers.IO) {
-            subdubtypes = Constants.supabase.from("Type_subtype_dublicate")
-                .select().decodeList<Type_subtype_dublicate>()
-            typedubs = Constants.supabase.from("Type_dublicate")
-                .select().decodeList<Type_dublicate>()
-            seasondubs = Constants.supabase.from("Season_dublicate")
-                .select().decodeList<Season_dublicate>()
-            styledubs = Constants.supabase.from("Style_dublicate")
-                .select().decodeList<Style_dublicate>()
-            seasondubs.forEach { it ->
+            subdubtype = Constants.supabase.from("Type_subtype")
+                .select().decodeList<Type_subtype>()
+            types = Constants.supabase.from("Type_dublicate")
+                .select().decodeList<Type>()
+            season = Constants.supabase.from("Season")
+                .select().decodeList<Season>()
+            style = Constants.supabase.from("Style")
+                .select().decodeList<Style>()
+            season.forEach { it ->
                 Log.d("ts", it.title_season)
             }
-            typedubs.forEach { it ->
+            types.forEach { it ->
                 Log.d("ts", it.title_type)
             }
         }
@@ -464,7 +468,7 @@ public  fun FiltersUser(   onApplyFilters: (Type_subtype_dublicate?, Season_dubl
                                 .fillMaxWidth()
                                 .padding(10.dp)
                         ) {
-                            seasondubs.forEach { seasondub ->
+                            season.forEach { seasondub ->
                                 Row(
                                     verticalAlignment = Alignment.CenterVertically,
                                     modifier = Modifier
@@ -510,7 +514,7 @@ public  fun FiltersUser(   onApplyFilters: (Type_subtype_dublicate?, Season_dubl
                                 .fillMaxWidth()
                                 .padding(10.dp)
                         ) {
-                            styledubs.forEach { styledub ->
+                            style.forEach { styledub ->
                                 Box(
                                     modifier = Modifier
                                         .padding(4.dp) // Отступы между элементами
@@ -561,7 +565,7 @@ public  fun FiltersUser(   onApplyFilters: (Type_subtype_dublicate?, Season_dubl
                             .padding(10.dp)
                     )
                     {
-                        typedubs.forEach { typedub ->
+                        types.forEach { typedub ->
 
                             Box(
                                 modifier = Modifier
@@ -580,7 +584,7 @@ public  fun FiltersUser(   onApplyFilters: (Type_subtype_dublicate?, Season_dubl
 
                                 LazyColumn {
                                     items(
-                                        subdubtypes,
+                                        subdubtype,
                                         key = { subdubtype -> subdubtype.id },
                                     ) { subtypedub ->
                                         if (subtypedub.id_type == typedub.id) {
@@ -627,7 +631,7 @@ public  fun FiltersUser(   onApplyFilters: (Type_subtype_dublicate?, Season_dubl
             }
 
             Button(
-                onClick = {  onApplyFilters(selectedSubtype, selectedSeason, selectedStyle) },
+                onClick = {  onApplyFilter(selectedSubtype, selectedSeason, selectedStyle) },
                 modifier = Modifier
                     .align(Alignment.BottomCenter)
                     .fillMaxWidth() // Занять всю ширину

+ 2 - 2
Project_exvesta/app/src/main/java/com/example/exvesta/Screans/Home.kt

@@ -235,7 +235,7 @@ fun Home(navHost: NavHostController) {
 
                     // Кнопка
                     Button(
-                        onClick = { /*TODO*/ },
+                        onClick = { navHost.navigate("Bows")  },
                         modifier = Modifier
                             .fillMaxWidth()
 
@@ -495,7 +495,7 @@ fun Home(navHost: NavHostController) {
             Spacer(modifier = Modifier.height(32.dp))
             // Кнопки
             Button(
-                onClick = { /* TODO: Открыть "Мои образы" */ },
+                onClick = { navHost.navigate("MyBows")  },
                 modifier = Modifier
                     .fillMaxWidth()
                     .height(48.dp),

+ 6 - 1
Project_exvesta/app/src/main/java/com/example/exvesta/Screans/Login.kt

@@ -31,6 +31,7 @@ import androidx.compose.ui.draw.clip
 import androidx.compose.ui.geometry.Offset
 import androidx.compose.ui.graphics.Brush
 import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.platform.LocalContext
 
 import androidx.compose.ui.res.painterResource
 import androidx.compose.ui.text.TextStyle
@@ -45,7 +46,11 @@ import com.example.exvesta.R
 
 @Composable
 fun Login(navHost: NavHostController) {
-    val viewModel = Auth()
+
+    val context = LocalContext.current
+
+    // Создаем экземпляр Auth ViewModel
+    val viewModel  = remember { Auth(context) }
     val email = remember { mutableStateOf("") }
     val password = remember { mutableStateOf("")}
     val gradientButton = Brush.linearGradient(

+ 64 - 1
Project_exvesta/app/src/main/java/com/example/exvesta/Screans/MainActivity.kt

@@ -1,6 +1,12 @@
 package com.example.exvesta.Screans
-
+import android.Manifest
+import android.app.Activity
+import android.content.Intent
+import android.content.pm.PackageManager
+import android.net.Uri
 import android.os.Bundle
+import android.provider.MediaStore
+import android.util.Log
 import androidx.activity.ComponentActivity
 import androidx.activity.compose.setContent
 import androidx.activity.enableEdgeToEdge
@@ -8,10 +14,24 @@ import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.material3.MaterialTheme
 import androidx.compose.material3.Surface
 import androidx.compose.ui.Modifier
+import androidx.core.app.ActivityCompat
+import androidx.core.content.ContextCompat
+import com.example.exvesta.domain.utils.Constants.supabase
 import com.example.exvesta.navigation.Navigation
 import com.example.exvesta.ui.theme.ExvestaTheme
+import io.github.jan.supabase.storage.storage
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+
+import androidx.compose.foundation.layout.*
+
+import androidx.compose.runtime.*
 
 class MainActivity : ComponentActivity() {
+
+    private val IMAGE_PICK_CODE = 1000
+    private val PERMISSION_REQUEST_CODE = 1001
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         enableEdgeToEdge()
@@ -27,5 +47,48 @@ class MainActivity : ComponentActivity() {
             }
         }
     }
+    private fun checkPermission() {
+        if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
+            ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), PERMISSION_REQUEST_CODE)
+        } else {
+            openGallery()
+        }
+    }
+
+    private fun openGallery() {
+        val intent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
+        startActivityForResult(intent, IMAGE_PICK_CODE)
+    }
+    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
+        super.onActivityResult(requestCode, resultCode, data)
+        if (requestCode == IMAGE_PICK_CODE && resultCode == Activity.RESULT_OK) {
+            val imageUri: Uri? = data?.data
+            imageUri?.let {
+                // Загрузите изображение в Supabase
+                uploadImage(it)
+            }
+        }
+    }
+    private fun uploadImage(uri: Uri) {
+        val imageBytes = getImageBytes(uri)
+        if (imageBytes != null) {
+            CoroutineScope(Dispatchers.IO).launch {
+                uploadImageToSupabase(imageBytes)
+            }
+        }
+    }
+    private suspend fun uploadImageToSupabase(imageBytes: ByteArray) {
+        val response = supabase.storage.from("exvesta").upload("path/to/image.jpg", imageBytes)
+
+    }
+    private fun getImageBytes(uri: Uri): ByteArray? {
+        return try {
+            val inputStream = contentResolver.openInputStream(uri)
+            inputStream?.readBytes()
+        } catch (e: Exception) {
+            e.printStackTrace()
+            null
+        }
+    }
 }
 

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

@@ -121,7 +121,7 @@ class MainViewModel(): ViewModel() {
 
 
         }
-        return recpubthingsList;
+        return recpubthingsList
     }
 
 

+ 486 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/Screans/MyBows.kt

@@ -0,0 +1,486 @@
+package com.example.exvesta.Screans
+
+import android.util.Log
+import androidx.compose.foundation.BorderStroke
+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.width
+import androidx.compose.foundation.layout.wrapContentSize
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.LazyRow
+import androidx.compose.foundation.lazy.items
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material.DrawerValue
+import androidx.compose.material.Icon
+import androidx.compose.material.IconButton
+import androidx.compose.material.ModalDrawer
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Menu
+import androidx.compose.material.rememberDrawerState
+import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonDefaults
+import androidx.compose.material3.CircularProgressIndicator
+import androidx.compose.material3.Divider
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.rememberCoroutineScope
+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.draw.shadow
+import androidx.compose.ui.graphics.Brush
+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.NavHostController
+import coil.compose.AsyncImagePainter
+import coil.compose.rememberAsyncImagePainter
+import coil.request.ImageRequest
+import coil.size.Size
+import com.example.exvesta.domain.utils.Constants
+import com.example.exvesta.model.Bows
+import com.example.exvesta.model.Consists_bows
+import com.example.exvesta.model.Publicthings
+import com.example.exvesta.model.Season_dublicate
+import com.example.exvesta.model.Style_dublicate
+import com.example.exvesta.model.Things_user
+import com.example.exvesta.model.Type_dublicate
+import com.example.exvesta.model.Type_subtype_dublicate
+import com.example.exvesta.model.Users
+import io.github.jan.supabase.gotrue.auth
+import io.github.jan.supabase.postgrest.from
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+
+@Composable
+fun MyBows(navHost: NavHostController) {
+    var subdubtype by remember { mutableStateOf<List<Type_subtype_dublicate>>(listOf()) }
+    var dubtype by remember { mutableStateOf<List<Type_dublicate>>(listOf()) }
+    var bows by remember { mutableStateOf<List<Bows>>(listOf()) }
+    var conbows by remember { mutableStateOf<List<Consists_bows>>(listOf()) }
+    var seasondub by remember { mutableStateOf<List<Season_dublicate>>(listOf()) }
+    var publicthings by remember { mutableStateOf<List<Publicthings>>(listOf()) }
+    var styledub by remember { mutableStateOf<List<Style_dublicate>>(listOf()) }
+    var recpubthingsList by remember { mutableStateOf<List<Publicthings>>(listOf()) }
+    var filteredPublicThings by remember { mutableStateOf<List<Publicthings>>(listOf()) }
+    var selectedBow by remember { mutableStateOf<Bows?>(null) }
+    var users by remember { mutableStateOf<List<Users>>(listOf()) }
+    var showDialog by remember { mutableStateOf(false) }
+    val viewModel = MainViewModel()
+    var userthings by remember { mutableStateOf<List<Things_user>>(listOf()) }
+    LaunchedEffect(Unit) {
+        withContext(Dispatchers.IO) {
+            userthings  = Constants.supabase.from("Things_user")
+                .select().decodeList<Things_user>()
+            publicthings = Constants.supabase.from("Publicthings")
+                .select().decodeList<Publicthings>()
+            bows  = Constants.supabase.from("Bows")
+                .select().decodeList<Bows>()
+            conbows  = Constants.supabase.from("Consists_bows")
+                .select().decodeList<Consists_bows>()
+            subdubtype = Constants.supabase.from("Type_subtype_dublicate")
+                .select().decodeList<Type_subtype_dublicate>()
+            dubtype = Constants.supabase.from("Type_dublicate")
+                .select().decodeList<Type_dublicate>()
+            seasondub = Constants.supabase.from("Season_dublicate")
+                .select().decodeList<Season_dublicate>()
+            styledub = Constants.supabase.from("Style_dublicate")
+                .select().decodeList<Style_dublicate>()
+            publicthings.forEach { it ->
+                Log.d("ts", it.title)
+                users = Constants.supabase.from("Users")
+                    .select().decodeList<Users>()
+            }
+        }
+        filteredPublicThings = publicthings
+
+    }
+    var filtersApplied by remember { mutableStateOf(false) }
+    var isFilterSheetVisible by remember { mutableStateOf(false) }
+    var drawerState = rememberDrawerState(DrawerValue.Closed)
+    val scope = rememberCoroutineScope()
+
+    ModalDrawer(
+        drawerState = drawerState,
+        drawerContent = {
+            DrawerContent(navHost)
+
+        },
+    ) {
+        Column(
+            modifier = Modifier
+
+                .fillMaxSize()
+                .background(Color.White)
+                .padding(16.dp),
+            horizontalAlignment = Alignment.CenterHorizontally
+        ) {
+            Spacer(modifier = Modifier.height(20.dp))
+            Row(
+                modifier = Modifier
+                    .fillMaxWidth()
+                    .padding(vertical = 16.dp)
+                ,
+                verticalAlignment = Alignment.CenterVertically,
+                horizontalArrangement = Arrangement.Start
+            ) {
+                IconButton(onClick = {
+                    scope.launch { drawerState.open() }
+                }) {
+                    Icon(imageVector = Icons.Filled.Menu, contentDescription = "Menu")
+                }
+
+                Button(
+                    onClick = {
+                        navHost.navigate("addBow")
+                    },
+                    border = BorderStroke(1.dp, Color(0xFF92A2B0)),
+                    modifier = Modifier
+                        .fillMaxWidth()
+                        .padding(vertical = 8.dp),
+                    colors = ButtonDefaults.buttonColors(Color(0xFFF1F1F3))
+                ) {
+                    Text(text = "+ образ", color = Color(0xFF92A2B0))
+
+                }
+
+            }
+
+            Spacer(modifier = Modifier.height(10.dp))
+
+
+
+
+            Spacer(modifier = Modifier.height(10.dp))
+            val userId = Constants.supabase.auth.currentUserOrNull()?.id
+            val authorizedUser  = users.find { it.user == userId }
+
+
+            if (authorizedUser  != null) {
+                LazyColumn(
+
+                    modifier = Modifier
+                        .fillMaxSize(1f)
+                        .padding(10.dp)
+                ) {
+
+                    items(
+                        bows
+                    ) { bow ->
+                        val iconb = bow.id
+                        val cobow = conbows.filter { it.id_bow == bow.id }
+                        if (cobow != null && bow.id_user ==authorizedUser.id) {
+                            val imageState = rememberAsyncImagePainter(
+                                model = ImageRequest.Builder(LocalContext.current).data(bow.img)
+                                    .size(Size.ORIGINAL).build()
+                            ).state
+
+                            Box(
+                                modifier = Modifier
+                                    .shadow(8.dp, RoundedCornerShape(30.dp))
+                            ) {
+                                Box(
+                                    modifier = Modifier
+                                        .background(
+
+                                            Color.White,
+
+                                            shape = RoundedCornerShape(30.dp)
+                                        )
+                                        .padding(8.dp)
+                                        .wrapContentSize(Alignment.Center)
+
+                                ) {
+
+                                    Column(
+                                    )
+                                    {
+                                        if (imageState is AsyncImagePainter.State.Error) {
+                                            Box(
+                                                modifier = Modifier
+                                                    .fillMaxWidth()
+
+                                                    .height(250.dp),
+                                                contentAlignment = Alignment.Center
+                                            ) {
+                                                LazyRow {
+                                                    items(cobow) { conbo ->
+                                                        val thingid = conbo.id_components
+                                                        val thing =
+                                                            userthings.find { it.id == thingid }
+                                                        if (thing != null) {
+
+                                                            val imageState =
+                                                                rememberAsyncImagePainter(
+                                                                    model = ImageRequest.Builder(
+                                                                        LocalContext.current
+                                                                    )
+                                                                        .data(thing.img)
+                                                                        .size(Size.ORIGINAL).build()
+                                                                ).state
+                                                            if (imageState is AsyncImagePainter.State.Error) {
+                                                                Box(
+                                                                    modifier = Modifier
+                                                                        .fillMaxWidth()
+
+                                                                        .height(250.dp),
+                                                                    contentAlignment = Alignment.Center
+                                                                ) {
+                                                                    CircularProgressIndicator()
+                                                                }
+                                                            }
+
+                                                            if (imageState is AsyncImagePainter.State.Success) {
+                                                                Image(
+                                                                    modifier = Modifier
+                                                                        .fillMaxWidth()
+                                                                        .height(250.dp)
+//                                    .clip(RoundedCornerShape(8.dp))
+                                                                    ,
+                                                                    painter = imageState.painter,
+                                                                    contentDescription = "",
+                                                                    contentScale = ContentScale.Crop
+
+
+                                                                )
+                                                            }
+
+
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+
+                                        if (imageState is AsyncImagePainter.State.Success) {
+                                            Image(
+                                                modifier = Modifier
+                                                    .fillMaxWidth()
+                                                    .height(250.dp)
+//                                    .clip(RoundedCornerShape(8.dp))
+                                                ,
+                                                painter = imageState.painter,
+                                                contentDescription = "",
+                                                contentScale = ContentScale.Crop
+
+
+                                            )
+                                        }
+                                        Divider(
+                                            modifier = Modifier.padding(vertical = 8.dp),
+                                            color = Color.LightGray,
+                                            thickness = 1.dp
+                                        )
+                                        Spacer(modifier = Modifier.height(8.dp))
+                                        Text(
+                                            "Название: ${bow.title_bow}",
+                                            fontSize = 18.sp,
+                                            modifier = Modifier.padding(start = 8.dp),
+                                            color = Color(0xFF92A2B0)
+                                        )
+
+
+                                        Spacer(modifier = Modifier.height(8.dp))
+                                        Row(
+                                            horizontalArrangement = Arrangement.SpaceAround
+                                        )
+                                        {
+
+
+                                            Button(
+                                                onClick = {
+                                                    selectedBow = bow
+                                                    showDialog = true // Показываем диалог
+                                                },
+                                                modifier = Modifier
+                                                    .width(200.dp)
+                                                    .height(50.dp)
+                                                    .padding(start = 50.dp),
+                                                colors = ButtonDefaults.buttonColors(
+                                                    Color(0xFF6F4A48),
+                                                    contentColor = Color.White
+                                                ),
+                                                shape = ButtonDefaults.shape
+                                            ) {
+                                                Text(
+                                                    text = "подробности",
+                                                    fontSize = 16.sp,
+                                                    fontWeight = FontWeight.Medium
+                                                )
+                                            }
+
+
+                                        }
+
+                                    }
+
+                                }
+
+                                Spacer(modifier = Modifier.height(16.dp))
+
+
+                            }
+                            Spacer(modifier = Modifier.height(20.dp))
+                        }
+
+                    }
+
+                }
+            }
+
+        }
+
+    }
+    if (isFilterSheetVisible) {
+        Column {
+            Filters(
+                onApplyFilters = { selectedSubtype, selectedSeason, selectedStyle ->
+                    // Применяем фильтры и обновляем отображение
+                    filteredPublicThings = publicthings.filter { publicThing ->
+                        (selectedSubtype == null || publicThing.id_subtype == selectedSubtype.id) &&
+                                (selectedSeason == null || publicThing.seson_id == selectedSeason.id)&&
+                                (selectedStyle == null || publicThing.id_style == selectedStyle.id)
+                    }
+
+                    isFilterSheetVisible = false // Закрываем окно фильтров
+                    filtersApplied = true;
+                },
+                onDismiss = { isFilterSheetVisible = false })
+
+        }
+    }
+    if (showDialog && selectedBow != null) {
+        ThingListScreen(bow = selectedBow!!, things=userthings , conb = conbows, onDismiss = { showDialog = false })
+    }
+}
+
+
+@Composable
+public fun ThingListScreen(bow: Bows, things: List<Things_user>, conb: List<Consists_bows>,onDismiss: () -> Unit) {
+    Column(  modifier = Modifier
+        .fillMaxSize()
+
+        .background(
+            Brush.verticalGradient(
+                colors = listOf(
+                    Color(0xFFF4F4F4),
+                    Color(0xFFE7D2A9),
+                    Color(0xFFC1A88B),
+                    Color(0xFF6F4A48)
+                )
+            )
+        ),
+        horizontalAlignment = Alignment.CenterHorizontally,) {
+
+        Spacer(modifier = Modifier.height(50.dp))
+
+        LazyColumn (  modifier = Modifier.padding(16.dp)){
+            val cobow = conb.filter { it.id_bow == bow.id }
+            if (cobow != null) {
+                items(cobow) { conbo ->
+                    Box(
+                        modifier = Modifier
+                            .shadow(8.dp, RoundedCornerShape(30.dp))
+                    ) {
+                        Box(
+                            modifier = Modifier
+                                .background(
+
+                                    Color.White,
+
+                                    shape = RoundedCornerShape(30.dp)
+                                )
+                                .padding(8.dp)
+                                .wrapContentSize(Alignment.Center)
+
+                        ){
+                            Column(
+                            )
+                            {
+                                val thingid = conbo.id_components
+                                val thing = things.find { it.id == thingid }
+                                if (thing != null) {
+
+                                    if (thing.id == conbo.id_components) {
+                                        val imageState = rememberAsyncImagePainter(
+                                            model = ImageRequest.Builder(LocalContext.current)
+                                                .data(thing.img)
+                                                .size(Size.ORIGINAL).build()
+                                        ).state
+                                        if (imageState is AsyncImagePainter.State.Error) {
+                                            Box(
+                                                modifier = Modifier
+                                                    .fillMaxWidth()
+
+                                                    .height(250.dp),
+                                                contentAlignment = Alignment.Center
+                                            ) {
+                                                CircularProgressIndicator()
+                                            }
+                                        }
+
+                                        if (imageState is AsyncImagePainter.State.Success) {
+                                            Image(
+                                                modifier = Modifier
+                                                    .fillMaxWidth()
+                                                    .height(250.dp)
+//                                    .clip(RoundedCornerShape(8.dp))
+                                                ,
+                                                painter = imageState.painter,
+                                                contentDescription = "",
+                                                contentScale = ContentScale.Crop
+
+
+                                            )
+                                        }
+                                        Divider(
+                                            modifier = Modifier.padding(vertical = 8.dp),
+                                            color = Color.LightGray,
+                                            thickness = 1.dp
+                                        )
+                                        Spacer(modifier = Modifier.height(8.dp))
+                                        Text(
+                                            "Название: ${thing.title}",
+                                            fontSize = 18.sp,
+                                            modifier = Modifier.padding(start = 8.dp),
+                                            color = Color(0xFF92A2B0)
+                                        )
+                                    }
+                                }
+                            }
+
+
+
+
+                        }
+                    }
+                    Spacer(modifier = Modifier.height(16.dp))
+                }
+
+            }
+        }
+        Spacer(modifier = Modifier.height(16.dp))
+        Button(onClick = onDismiss) {
+            Text("Закрыть")
+        }
+    }
+}

+ 523 - 54
Project_exvesta/app/src/main/java/com/example/exvesta/Screans/Wardrob.kt

@@ -1,7 +1,10 @@
 package com.example.exvesta.Screans
 
 import android.content.Context
+import android.net.Uri
 import android.util.Log
+import androidx.activity.compose.rememberLauncherForActivityResult
+import androidx.activity.result.contract.ActivityResultContracts
 import androidx.compose.foundation.BorderStroke
 import androidx.compose.foundation.Image
 import androidx.compose.foundation.background
@@ -74,33 +77,53 @@ import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.launch
 import kotlinx.coroutines.withContext
 import androidx.appcompat.app.AlertDialog
+import androidx.compose.foundation.selection.selectable
+import androidx.compose.runtime.livedata.observeAsState
 import androidx.compose.ui.tooling.preview.Preview
+import androidx.core.content.ContextCompat
+import coil.compose.rememberImagePainter
+import android.Manifest
+import android.content.pm.PackageManager
 
+@OptIn(ExperimentalMaterialApi::class, ExperimentalLayoutApi::class)
 @Composable
 fun Wardrob(navHost: NavHostController) {
     var drawerState = rememberDrawerState(DrawerValue.Closed)
+    var isBottomSheetVisible by remember { mutableStateOf(false) }
     val scope = rememberCoroutineScope()
     var isFiltersVisible by remember { mutableStateOf(false) }
     var filteredPublicThings by remember { mutableStateOf<List<Consists_wardrob>>(listOf()) }
     var subdubtype by remember { mutableStateOf<List<Type_subtype>>(listOf()) }
     var types by remember { mutableStateOf<List<Type>>(listOf()) }
     var season by remember { mutableStateOf<List<Season>>(listOf()) }
-    var userthings by remember { mutableStateOf<List<Things_user>>(listOf()) }
+//    var userthings by remember { mutableStateOf<List<Things_user>>(listOf()) }
     var style by remember { mutableStateOf<List<Style>>(listOf()) }
     var filtersApplied by remember { mutableStateOf(false) }
-    var isFilterSheetVisible by remember { mutableStateOf(false) }
     var wardrobs by remember { mutableStateOf<List<Wardob>>(listOf()) }
     var cwardrobs by remember { mutableStateOf<List<Consists_wardrob>>(listOf()) }
     var users by remember { mutableStateOf<List<Users>>(listOf()) }
-    val context = LocalContext.current // Получение контекста
-    val coroutineScope = rememberCoroutineScope() // Создание корутинного скоупа
     var openDialog by remember { mutableStateOf(false) }
-    var itemToDelete by remember { mutableStateOf<Consists_wardrob?>(null) }
+    var itemToDelete by remember { mutableStateOf<Things_user?>(null) }
+    var newThingName by remember { mutableStateOf("") }
+    var selectSeason by remember { mutableStateOf<Season?>(null) }
+    var selectStyle by remember { mutableStateOf<Style?>(null) }
+    var selectSubtype by remember { mutableStateOf<Type_subtype?>(null) }
+    var imageUri by remember { mutableStateOf<Uri?>(null) }
+    var selectwardrob by remember { mutableStateOf<Wardob?>(null) }
+    val context = LocalContext.current
+    var click by remember { mutableStateOf(false) }
+    // Создаем экземпляр Auth ViewModel
+    val viewModel  = remember { Auth(context) }
+    val userthings by viewModel.userThingsState.collectAsState() // Подписываемся на состояние
+
+var rememberthings   by remember { mutableStateOf<List<Things_user>>(listOf()) }
+    var isFilterSheetVisible by remember { mutableStateOf(false) }
 
-    val viewModel = Auth()
     LaunchedEffect(Unit) {
         withContext(Dispatchers.IO) {
-            userthings  = Constants.supabase.from("Things_user")
+//            userthings  = Constants.supabase.from("Things_user")
+//                .select().decodeList<Things_user>()
+            rememberthings  = Constants.supabase.from("Things_user")
                 .select().decodeList<Things_user>()
             wardrobs  = Constants.supabase.from("Wardob")
                 .select().decodeList<Wardob>()
@@ -118,30 +141,58 @@ fun Wardrob(navHost: NavHostController) {
                 .select().decodeList<Users>()
 //            cwardrobs.forEach { it ->
 //                Log.d("ts", it.toString())
+
+            }
+          viewModel.refreshUserThings()
+
+
+    }
+
+    filteredPublicThings = cwardrobs
+    val imagePickerLauncher = rememberLauncherForActivityResult(
+        contract = ActivityResultContracts.GetContent(),
+        onResult = { uri: Uri? ->
+            imageUri = uri
+        }
+    )
+    val permissionLauncher = rememberLauncherForActivityResult(
+        contract = ActivityResultContracts.RequestPermission(),
+        onResult = { isGranted: Boolean ->
+            if (isGranted) {
+                // Если разрешение предоставлено, открываем галерею
+                imagePickerLauncher.launch("image/*")
+            } else {
+                // Обработка случая, когда разрешение не предоставлено
+                Log.e("Permission", "Разрешение на чтение хранилища не предоставлено")
             }
         }
-        filteredPublicThings = cwardrobs
-//    DeleteConfirmationDialog(
-//        openDialog = openDialog,
-//        userthing = itemToDelete!!, // Убедитесь, что itemToDelete не null
-//        onConfirm = { item ->
-//            item?.let {
-//                viewModel.deleteItem(it) // Вызов функции удаления из ViewModel
-//                openDialog = false // Закрыть диалог
-//                itemToDelete = null // Сбросить элемент после удаления
-//            }
-//        },
-//        onDismiss = {
-//            openDialog = false
-//            itemToDelete = null // Сбросить элемент после закрытия диалога
-//        }
-//            )
+    )
+
+
+
+
+    // Функция для проверки разрешений
+    @Composable
+    fun checkPermission() {
+        when {
+            ContextCompat.checkSelfPermission(LocalContext.current, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED -> {
+                // Если разрешение уже предоставлено, открываем галерею
+                imagePickerLauncher.launch("image/*")
+            }
+            else -> {
+                // Запрашиваем разрешение
+                permissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE)
+            }
+        }
+    }
+
     ModalDrawer(
         drawerState = drawerState,
         drawerContent = {
             DrawerContent(navHost)
         },
     ) {
+
         Column(
             modifier = Modifier
                 .fillMaxSize()
@@ -167,7 +218,7 @@ fun Wardrob(navHost: NavHostController) {
                     Button(
                         onClick = {
 
-                            scope.launch { drawerState.close() } // Закрываем drawer
+                            scope.launch {  isFilterSheetVisible = true } // Закрываем drawer
                         },
                         border = BorderStroke(1.dp, Color(0xFF92A2B0)),
                         modifier = Modifier
@@ -180,22 +231,26 @@ fun Wardrob(navHost: NavHostController) {
 
 
                     Button(
-                        onClick = { /*TODO*/ },
+                        onClick = { isBottomSheetVisible = true  },
                         border = BorderStroke(1.dp, Color(0xFF92A2B0)),
                         modifier = Modifier
                             .fillMaxWidth()
-                            .padding(vertical = 8.dp),
+                      ,
                         colors = ButtonDefaults.buttonColors(Color.White)
                     ) {
                         Text(text = "+ добавить вещь", color = Color(0xFF92A2B0))
                     }
 
                 }
+
             }
+
+
+
             if (filtersApplied) {
                 Button(
                     onClick = {
-                        filteredPublicThings = cwardrobs
+//                        userthings = rememberthings
                         filtersApplied = false
                     },
                     border = BorderStroke(1.dp, Color(0xFF92A2B0)),
@@ -207,23 +262,39 @@ fun Wardrob(navHost: NavHostController) {
                     Text(text = "сбросить фильтры", color = Color(0xFF92A2B0))
                 }
             }
+            Spacer(modifier = Modifier.height(10.dp))
+
+
+
+
+
 
 
 
 
 
 
-            Spacer(modifier = Modifier.height(10.dp))
             val userId = Constants.supabase.auth.currentUserOrNull()?.id
             val authorizedUser  = users.find { it.user == userId }
 
+
             if (authorizedUser  != null) {
+                val userWardrobes = wardrobs.filter { it.id_user == authorizedUser.id } // Предполагается, что у вас есть поле userId в Wardob
+
+                // Если у пользователя есть гардеробы, выбираем первый
+                if (userWardrobes.isNotEmpty()) {
+                    selectwardrob = userWardrobes.first() // Сохраняем первый гардероб в selectwardrob
+                } else {
+                    // Обработка случая, когда у пользователя нет гардеробов
+                    Log.d("Wardrob", "У пользователя нет гардеробов.")
+                }
                 // Group items by type
-                val itemsByType = filteredPublicThings.groupBy { userthing ->
+                 val itemsByType = filteredPublicThings.groupBy { userthing ->
                     val thing = userthings.find { it.id == userthing.id_thing }
                     thing?.subtype?.let { subtype ->
                         subdubtype.find { it.id == subtype }?.id_type
                     }
+
                 }
 
                 LazyColumn(modifier = Modifier.fillMaxSize().padding(10.dp)) {
@@ -316,7 +387,7 @@ fun Wardrob(navHost: NavHostController) {
 
                                                 Button(
                                                     onClick = {
-                                                        itemToDelete = userthing
+                                                        itemToDelete = thing
                                                         openDialog = true
                                                     },
                                                     modifier = Modifier
@@ -353,7 +424,9 @@ fun Wardrob(navHost: NavHostController) {
                         userthing = itemToDelete!!, // Уверены, что itemToDelete не null
                         onConfirm = { item ->
                             item?.let {
-                                viewModel.deleteItem(it) // Вызов функции удаления из ViewModel
+
+                                    viewModel.deleteItem(it) // Вызов функции удаления из ViewModel
+
                             }
                             openDialog = false // Закрыть диалог
                             itemToDelete = null // Сбросить элемент после удаления
@@ -361,43 +434,438 @@ fun Wardrob(navHost: NavHostController) {
                         onDismiss = {
                             openDialog = false // Закрыть диалог при отмене
                             itemToDelete = null // Сбросить элемент после закрытия диалога
-                        }
+                        },
+                        navHost
                     )
                 }
             }
 
         }
+        if (isBottomSheetVisible) {
+            ModalBottomSheetLayout(
+                sheetState = rememberModalBottomSheetState(ModalBottomSheetValue.Expanded),
+                sheetContent = {
+                    Column(   modifier = Modifier
+                        .fillMaxHeight()
+                        .fillMaxWidth()
+                        .background(
+                            Brush.verticalGradient(
+                                colors = listOf(
+                                    Color(0xFFF4F4F4),
+                                    Color(0xFFE7D2A9),
+                                    Color(0xFFC1A88B),
+                                    Color(0xFF6F4A48)
+                                )
+                            )
+                        )) {
+                        Box(
+                            modifier = Modifier
+                                .fillMaxWidth() // Бокс на всю ширину
+                                .padding(start = 16.dp, end = 16.dp)
+                                .background(
+                                    color = Color.White,
+                                    shape = RoundedCornerShape(16.dp) // Закругленные края
+                                )
+                                .padding(16.dp) // Отступы внутри бокса
+                        ) {
+
+                            // Отображение выбранного изображения
+
+
+                            LazyColumn(horizontalAlignment = Alignment.CenterHorizontally) {
+                                item {
+                                    Text("Добавить новую вещь", fontWeight = FontWeight.Bold)
+
+                                                                // Поле для ввода названия вещи
+                                                                TextField(
+                                                                    value = newThingName,
+                                                                    onValueChange = { newThingName = it },
+                                                                    label = { Text("Название вещи") },
+                                                                    modifier = Modifier.fillMaxWidth()
+                                                                )
+
+                                                                // Выбор изображения
+                                                                Button(onClick = {
+                                                                    imagePickerLauncher.launch("image/*")
+                                                              }) {
+                                                                    Text("Выбрать изображение")
+                                                                }
+                                                                imageUri?.let {
+                                                                    Image(
+                                                                        painter = rememberImagePainter(it),
+                                                                        contentDescription = "Выбранное изображение",
+                                                                        modifier = Modifier
+                                                                            .fillMaxWidth()
+                                                                            .height(200.dp)
+                                                                            .clip(RoundedCornerShape(8.dp))
+                                                                            .padding(vertical = 8.dp)
+                                                                    )
+                                                                }
+                                    Spacer(modifier = Modifier.height(10.dp))
+                                    Text(
+                                        text = "Фильтры",
+                                        fontSize = 16.sp,
+                                        fontWeight = FontWeight.Medium,
+                                        color = Color(0xFF92A2B0)
+                                    )
+                                    androidx.compose.material3.Divider(
+                                        modifier = Modifier.padding(vertical = 8.dp),
+                                        color = Color.LightGray,
+                                        thickness = 1.dp
+                                    )
+
+
+                                    Spacer(modifier = Modifier.height(10.dp)) // Отступ между текстом и кнопкой
+
+                                    // Текст "Сезон"
+                                    Box(
+
+                                        modifier = Modifier
+//                                .align(Alignment.Start)
+                                            .fillMaxWidth()
+                                    ) {
+                                        Text("Сезон")
+
+
+                                        FlowRow(
+                                            modifier = Modifier
+                                                .fillMaxWidth()
+                                                .padding(10.dp)
+                                        ) {
+                                            season.forEach { seasondub ->
+                                                Row(
+                                                    verticalAlignment = Alignment.CenterVertically,
+                                                    modifier = Modifier
+                                                        .padding(4.dp) // Отступы между элементами
+                                                        .selectable(
+                                                            selected = (seasondub == selectSeason),
+                                                            onClick = { selectSeason = seasondub }
+                                                        )
+                                                ) {
+                                                    androidx.compose.material3.RadioButton(
+                                                        selected = (seasondub == selectSeason),
+                                                        onClick = { selectSeason = seasondub }
+                                                    )
+                                                    Text(
+                                                        text = seasondub.title_season,
+                                                        fontSize = 16.sp,
+                                                        modifier = Modifier.padding(start = 8.dp),
+                                                        color = Color(0xFF92A2B0)
+                                                    )
+                                                }
+                                            }
+                                        }
+                                    }
+                                    Spacer(modifier = Modifier.height(10.dp))
+                                    Box(
+
+                                        modifier = Modifier
+//                                .align(Alignment.Start)
+                                            .fillMaxWidth()
+
+                                    ) {
+                                        Text("Стиль")
+                                    }
+                                    Box(
+
+                                        modifier = Modifier
+//                                .align(Alignment.Start)
+                                            .fillMaxWidth()
+                                            .padding(10.dp)
+                                    ) {
+                                        FlowRow(
+                                            modifier = Modifier
+                                                .fillMaxWidth()
+                                                .padding(10.dp)
+                                        ) {
+                                            style.forEach { styledub ->
+                                                Box(
+                                                    modifier = Modifier
+                                                        .padding(4.dp) // Отступы между элементами
+                                                        .background(
+                                                            Color(0xFFF1F1F3),
+                                                            shape = RoundedCornerShape(20.dp)
+                                                        )
+                                                        .width(145.dp)// Задаем одинаковую ширину для всех элементов
+                                                        .height(38.dp) // Устанавливаем фиксированную высоту для всех элементов
+                                                ) {
+                                                    Row(
+                                                        verticalAlignment = Alignment.CenterVertically,
+                                                        modifier = Modifier
+
+                                                            .selectable(
+                                                                selected = (styledub == selectStyle),
+                                                                onClick = { selectStyle = styledub }
+                                                            )
+                                                    ) {
+                                                        androidx.compose.material3.RadioButton(
+                                                            selected = (styledub == selectStyle),
+                                                            onClick = { selectStyle = styledub }
+                                                        )
+                                                        Text(
+                                                            text = styledub.title_style,
+                                                            fontSize = 16.sp,
+                                                            modifier = Modifier.padding(start = 0.dp), // Отступ слева от радиокнопки
+                                                            color = Color(0xFF92A2B0)
+                                                        )
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }
+                                    Box(
+
+                                        modifier = Modifier
+//                                .align(Alignment.Start)
+                                            .fillMaxWidth()
+
+                                    ) {
+                                        Text("Типы")
+                                    }
+
+                                    FlowRow(
+                                        modifier = Modifier
+                                            .fillMaxWidth()
+                                            .padding(10.dp)
+                                    )
+                                    {
+                                        types.forEach { typedub ->
+
+                                            Box(
+                                                modifier = Modifier
+                                                    .padding(4.dp) // Отступы между элементами
+                                                    .background(
+                                                        Color(0xFFF1F1F3),
+                                                        shape = RoundedCornerShape(20.dp)
+                                                    )
+                                                    .width(145.dp)// Задаем одинаковую ширину для всех элементов
+                                                    .height(245.dp) // Устанавливаем фиксированную высоту для всех элементов
+                                            ) {
+
+                                                Text(text = typedub.title_type)
+
+
+
+                                                LazyColumn {
+                                                    items(
+                                                        subdubtype,
+                                                        key = { subdubtype -> subdubtype.id },
+                                                    ) { subtypedub ->
+                                                        if (subtypedub.id_type == typedub.id) {
+                                                            Row(
+                                                                verticalAlignment = Alignment.CenterVertically,
+                                                                modifier = Modifier
+
+                                                                    .selectable(
+                                                                        selected = (subtypedub ==  selectSubtype),
+                                                                        onClick = { selectSubtype = subtypedub }
+                                                                    )
+                                                                    .padding(top = 14.dp)
+
+
+
+                                                            ) {
+                                                                androidx.compose.material3.RadioButton(
+                                                                    selected = (subtypedub == selectSubtype),
+                                                                    onClick = {
+                                                                        selectSubtype = subtypedub
+                                                                    }
+                                                                )
+                                                                Text(
+                                                                    text = subtypedub.sub_type,
+                                                                    fontSize = 16.sp,
+                                                                    modifier = Modifier.padding(start = 0.dp), // Отступ слева от радиокнопки
+                                                                    color = Color(0xFF92A2B0)
+
+                                                                )
+                                                            }
+                                                        }
+
+                                                    }
+
+                                                }
+
+
+                                            }
+
+                                        }
+
+
+
+                                    }
+                                    Column(
+                                        modifier = Modifier
+                                            .fillMaxWidth()
+                                            .padding(bottom = 50.dp), // Отступ внизу для всего столбца
+                                        verticalArrangement = Arrangement.Bottom // Располагаем кнопки внизу
+                                    ) {
+                                        Button(
+                                            onClick = {
+                                                viewModel.insertItem(
+                                                    season = selectSeason?.id ?: 0,
+                                                    styles = selectStyle?.id ?: 0,
+                                                    title = newThingName,
+                                                    subtype = selectSubtype?.id ?: 0,
+                                                    imgUri = imageUri
+                                                )
+                                                // Закрываем панель
+
+                                            },
+                                            modifier = Modifier
+                                                .fillMaxWidth()
+                                                .height(50.dp)
+                                                .padding(horizontal = 20.dp)
+                                                .background(
+                                                    brush = Brush.horizontalGradient(
+                                                        colors = listOf(
+                                                            Color(0xFF6F4A48),
+                                                            Color(0xFFE7D2A9),
+                                                        )
+                                                    ),
+                                                    shape = ButtonDefaults.shape
+                                                ),
+                                            colors = ButtonDefaults.buttonColors(containerColor = Color.Transparent),
+                                        ) {
+                                            Text("Добавить")
+                                        }
+
+                                        Spacer(modifier = Modifier.height(10.dp)) // Отступ между кнопками
+
+                                        Button(
+                                            onClick = {
+                                                val filteredSortedThings = userthings
+
+                                                // Обрабатываем результат
+                                                Log.d("SortedThings", filteredSortedThings.toString())
+                                                val lastId: Int? = filteredSortedThings.lastOrNull()?.id
+
+                                                if (lastId == null) {
+                                                    Log.e("lastId", "lastId is null, filteredSortedThings is empty or does not have a valid id")
+                                                } else {
+                                                    Log.d("lastId", lastId.toString())
+                                                    viewModel.addc(
+                                                        idWardrob = selectwardrob?.id ?: 0,
+                                                        firstId = lastId
+                                                    )
+                                                }
+
+                                                isBottomSheetVisible = false
+                                                navHost.navigate("Wardrob")
+
+                                            },
+                                            modifier = Modifier
+                                                .fillMaxWidth()
+                                                .height(50.dp)
+                                                .padding(horizontal = 20.dp)
+                                                .background(
+                                                    brush = Brush.horizontalGradient(
+                                                        colors = listOf(
+                                                            Color(0xFF6F4A48),
+                                                            Color(0xFFE7D2A9),
+                                                        )
+                                                    ),
+                                                    shape = ButtonDefaults.shape
+                                                ),
+                                            colors = ButtonDefaults.buttonColors(containerColor = Color.Transparent),
+                                        ) {
+                                            Text("Добавить")
+                                        }
+                                    }
+                                }
+
+                            }
+
+
+
+
+
+
+
+
+                        }
+                    }
+                },
+                content = {
+
+                },
+
+                )
+
+        }
+    }
+    if (isFilterSheetVisible) {
+        Column {
+            FiltersUser(
+                onApplyFilter = { selectedSubtype, selectedSeason, selectedStyle ->
+                    // Получаем текущего авторизованного пользователя
+                    val userId = Constants.supabase.auth.currentUserOrNull()?.id
+                    val authorizedUser  = users.find { it.user == userId }
+
+                    if (authorizedUser  != null) {
+
+                         userthings.filter { userthing ->
+                            (selectedSubtype == null || userthing.subtype == selectedSubtype.id) &&
+                                    (selectedSeason == null || userthing.id_season == selectedSeason.id) &&
+                                    (selectedStyle == null || userthing.style == selectedStyle.id)
+                        }
+
+
+                    }
 
+                    isFilterSheetVisible = false // Закрываем окно фильтров
+                    filtersApplied = true
+                },
+                onDismiss = { isFilterSheetVisible = false }
+            )
+        }
     }
-//    if (isFilterSheetVisible) {
-//        Column {
-//            Filters(
-//                onApplyFilters = { selectedSubtype, selectedSeason, selectedStyle ->
-//                    // Применяем фильтры и обновляем отображение
-//                    filteredPublicThings = userthings.filter { userthing ->
-//                        (selectedSubtype == null || userthing.subtype == selectedSubtype.id) &&
-//                                (selectedSeason == null || userthing.id_season == selectedSeason.id)&&
-//                                (selectedStyle == null || userthing.style == selectedStyle.id)
-//                    }
-//
-//                    isFilterSheetVisible = false // Закрываем окно фильтров
-//                    filtersApplied = true;
-//                },
-//                onDismiss = { isFilterSheetVisible = false })
-//
-//        }
-//    }
 
 
 
 }
-
+@Composable
+fun FilterAndSortThings(
+    userthings: List<Things_user>,
+    newThingName: String,
+    selectSeason: Season?,
+    selectStyle: Style?,
+    selectSubtype: Type_subtype?,
+    onResult: (List<Things_user>) -> Unit
+) {
+    val filteredSortedThings = userthings
+        .filter { thing ->
+            // Фильтрация по имени
+            newThingName.isEmpty() || thing.title.contains(newThingName, ignoreCase = true)
+        }
+        .filter { thing ->
+            // Фильтрация по сезону
+            selectSeason == null || thing.id_season == selectSeason?.id
+        }
+        .filter { thing ->
+            // Фильтрация по стилю
+            selectStyle == null || thing.style == selectStyle?.id
+        }
+        .filter { thing ->
+            // Фильтрация по подтипу
+            selectSubtype == null || thing.subtype == selectSubtype?.id
+        }
+        .sortedWith(compareBy(
+            { it.title },         // Сортировка по названию
+            { it.id_season },    // Затем по сезону
+            { it.style },        // Затем по стилю
+            { it.subtype }       // И затем по подтипу
+        ))
+
+    // Возвращаем результат через callback
+    onResult(filteredSortedThings)
+}
 @Composable
 fun DeleteConfirmationDialog(
     openDialog: Boolean,
-    userthing: Consists_wardrob,
-    onConfirm: (Consists_wardrob) -> Unit,
-    onDismiss: () -> Unit
+    userthing: Things_user,
+    onConfirm: (Things_user) -> Unit,
+    onDismiss: () -> Unit,
+    navHost: NavHostController
 ) {
     if (openDialog) {
         AlertDialog(
@@ -412,6 +880,7 @@ fun DeleteConfirmationDialog(
                 Button(onClick = {
                     onConfirm(userthing) // Вызов функции для удаления элемента
                     onDismiss() // Закрыть диалог после подтверждения
+                    navHost.navigate("Wardrob")
                 }) {
                     Text("Да")
                 }

+ 674 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/Screans/addBow.kt

@@ -0,0 +1,674 @@
+package com.example.exvesta.Screans
+
+import android.content.Context
+import android.net.Uri
+import android.util.Log
+import androidx.activity.compose.rememberLauncherForActivityResult
+import androidx.activity.result.contract.ActivityResultContracts
+import androidx.compose.foundation.BorderStroke
+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.fillMaxHeight
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.offset
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonDefaults
+import androidx.compose.material.DrawerValue
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
+import androidx.compose.material3.rememberDrawerState
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.rememberCoroutineScope
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.draw.shadow
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.unit.dp
+import androidx.navigation.NavHostController
+
+//noinspection UsingMaterialAndMaterial3Libraries
+import androidx.compose.material.*
+import androidx.compose.runtime.*
+
+import androidx.compose.foundation.layout.*
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.LazyRow
+import androidx.compose.foundation.lazy.items
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Menu
+import androidx.compose.ui.graphics.Brush
+import androidx.compose.ui.layout.ContentScale
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.sp
+import coil.compose.AsyncImagePainter
+import coil.compose.rememberAsyncImagePainter
+import coil.request.ImageRequest
+import coil.size.Size
+import com.example.exvesta.domain.utils.Constants
+import com.example.exvesta.model.Consists_wardrob
+import com.example.exvesta.model.Publicthings
+import com.example.exvesta.model.Season
+import com.example.exvesta.model.Season_dublicate
+import com.example.exvesta.model.Style
+import com.example.exvesta.model.Style_dublicate
+import com.example.exvesta.model.Things_user
+import com.example.exvesta.model.Type
+import com.example.exvesta.model.Type_dublicate
+import com.example.exvesta.model.Type_subtype
+import com.example.exvesta.model.Type_subtype_dublicate
+import com.example.exvesta.model.Users
+import com.example.exvesta.model.Wardob
+import io.github.jan.supabase.gotrue.auth
+import io.github.jan.supabase.postgrest.from
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+import androidx.appcompat.app.AlertDialog
+import androidx.compose.foundation.selection.selectable
+import androidx.compose.runtime.livedata.observeAsState
+import androidx.compose.ui.tooling.preview.Preview
+import androidx.core.content.ContextCompat
+import coil.compose.rememberImagePainter
+import android.Manifest
+import android.content.pm.PackageManager
+
+@OptIn(ExperimentalMaterialApi::class, ExperimentalLayoutApi::class)
+@Composable
+fun addBow(navHost: NavHostController) {
+    var drawerState = rememberDrawerState(DrawerValue.Closed)
+    var isBottomSheetVisible by remember { mutableStateOf(true) }
+    val scope = rememberCoroutineScope()
+    var filteredPublicThings by remember { mutableStateOf<List<Consists_wardrob>>(listOf()) }
+    var subdubtype by remember { mutableStateOf<List<Type_subtype>>(listOf()) }
+    var types by remember { mutableStateOf<List<Type>>(listOf()) }
+    var season by remember { mutableStateOf<List<Season>>(listOf()) }
+    var style by remember { mutableStateOf<List<Style>>(listOf()) }
+    var filtersApplied by remember { mutableStateOf(false) }
+    var wardrobs by remember { mutableStateOf<List<Wardob>>(listOf()) }
+    var cwardrobs by remember { mutableStateOf<List<Consists_wardrob>>(listOf()) }
+    var users by remember { mutableStateOf<List<Users>>(listOf()) }
+    var openDialog by remember { mutableStateOf(false) }
+    var itemToDelete by remember { mutableStateOf<Things_user?>(null) }
+    var newThingName by remember { mutableStateOf("") }
+    var newThingName1 by remember { mutableStateOf("") }
+    var newThingName2 by remember { mutableStateOf("") }
+    var newThingName3 by remember { mutableStateOf("") }
+    var selectSeason by remember { mutableStateOf<Season?>(null) }
+    var selectStyle by remember { mutableStateOf<Style?>(null) }
+    var selectSubtype by remember { mutableStateOf<Type_subtype?>(null) }
+    var imageUri by remember { mutableStateOf<Uri?>(null) }
+    var selectwardrob by remember { mutableStateOf<Wardob?>(null) }
+    val context = LocalContext.current
+    var public by remember { mutableStateOf(false) }
+
+    val viewModel  = remember { Auth(context) }
+    val userthings by viewModel.userThingsState.collectAsState() // Подписываемся на состояние
+
+    var rememberthings   by remember { mutableStateOf<List<Things_user>>(listOf()) }
+    var isFilterSheetVisible by remember { mutableStateOf(false) }
+
+    LaunchedEffect(Unit) {
+        withContext(Dispatchers.IO) {
+//            userthings  = Constants.supabase.from("Things_user")
+//                .select().decodeList<Things_user>()
+            rememberthings  = Constants.supabase.from("Things_user")
+                .select().decodeList<Things_user>()
+            wardrobs  = Constants.supabase.from("Wardob")
+                .select().decodeList<Wardob>()
+            cwardrobs  = Constants.supabase.from("Consists_wardrob")
+                .select().decodeList<Consists_wardrob>()
+            subdubtype = Constants.supabase.from("Type_subtype")
+                .select().decodeList<Type_subtype>()
+            types = Constants.supabase.from("Type")
+                .select().decodeList<Type>()
+            season = Constants.supabase.from("Season")
+                .select().decodeList<Season>()
+            style = Constants.supabase.from("Style")
+                .select().decodeList<Style>()
+            users = Constants.supabase.from("Users")
+                .select().decodeList<Users>()
+//            cwardrobs.forEach { it ->
+//                Log.d("ts", it.toString())
+
+        }
+        viewModel.refreshUserThings()
+
+
+    }
+
+    filteredPublicThings = cwardrobs
+    val imagePickerLauncher = rememberLauncherForActivityResult(
+        contract = ActivityResultContracts.GetContent(),
+        onResult = { uri: Uri? ->
+            imageUri = uri
+        }
+    )
+    val permissionLauncher = rememberLauncherForActivityResult(
+        contract = ActivityResultContracts.RequestPermission(),
+        onResult = { isGranted: Boolean ->
+            if (isGranted) {
+                // Если разрешение предоставлено, открываем галерею
+                imagePickerLauncher.launch("image/*")
+            } else {
+                // Обработка случая, когда разрешение не предоставлено
+                Log.e("Permission", "Разрешение на чтение хранилища не предоставлено")
+            }
+        }
+    )
+
+
+
+
+    // Функция для проверки разрешений
+    @Composable
+    fun checkPermission() {
+        when {
+            ContextCompat.checkSelfPermission(LocalContext.current, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED -> {
+                // Если разрешение уже предоставлено, открываем галерею
+                imagePickerLauncher.launch("image/*")
+            }
+            else -> {
+                // Запрашиваем разрешение
+                permissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE)
+            }
+        }
+    }
+
+    ModalDrawer(
+        drawerState = drawerState,
+        drawerContent = {
+            DrawerContent(navHost)
+        },
+    ) {
+
+        Column(
+            modifier = Modifier
+                .fillMaxSize()
+                .background(Color.White)
+                .padding(16.dp),
+            horizontalAlignment = Alignment.CenterHorizontally
+        ) {
+            Row(
+                modifier = Modifier
+                    .fillMaxWidth()
+                    .padding(vertical = 16.dp),
+                verticalAlignment = Alignment.CenterVertically,
+                horizontalArrangement = Arrangement.Start
+            ) {
+                IconButton(onClick = {
+                    scope.launch { drawerState.open() }
+                }) {
+                    Icon(imageVector = Icons.Filled.Menu, contentDescription = "Menu")
+                }
+
+
+                Column(){
+                    Button(
+                        onClick = {
+
+                            scope.launch {  isFilterSheetVisible = true } // Закрываем drawer
+                        },
+                        border = BorderStroke(1.dp, Color(0xFF92A2B0)),
+                        modifier = Modifier
+                            .fillMaxWidth()
+                            .padding(vertical = 8.dp),
+                        colors = ButtonDefaults.buttonColors(Color.White)
+                    ) {
+                        Text(text = "+ добавить фильтр", color = Color(0xFF92A2B0))
+                    }
+
+
+
+                }
+
+            }
+
+
+
+            if (filtersApplied) {
+                Button(
+                    onClick = {
+//                        userthings = rememberthings
+                        filtersApplied = false
+                    },
+                    border = BorderStroke(1.dp, Color(0xFF92A2B0)),
+                    modifier = Modifier
+                        .fillMaxWidth()
+                        .padding(vertical = 8.dp),
+                    colors = ButtonDefaults.buttonColors(Color(0xFFF1F1F3))
+                ) {
+                    Text(text = "сбросить фильтры", color = Color(0xFF92A2B0))
+                }
+            }
+            Spacer(modifier = Modifier.height(10.dp))
+
+
+
+
+
+
+
+
+
+
+
+            val userId = Constants.supabase.auth.currentUserOrNull()?.id
+            val authorizedUser  = users.find { it.user == userId }
+
+
+            if (authorizedUser  != null) {
+                val userWardrobes = wardrobs.filter { it.id_user == authorizedUser.id } // Предполагается, что у вас есть поле userId в Wardob
+
+                // Если у пользователя есть гардеробы, выбираем первый
+                if (userWardrobes.isNotEmpty()) {
+                    selectwardrob = userWardrobes.first() // Сохраняем первый гардероб в selectwardrob
+                } else {
+                    // Обработка случая, когда у пользователя нет гардеробов
+                    Log.d("Wardrob", "У пользователя нет гардеробов.")
+                }
+                // Group items by type
+                val itemsByType = filteredPublicThings.groupBy { userthing ->
+                    val thing = userthings.find { it.id == userthing.id_thing }
+                    thing?.subtype?.let { subtype ->
+                        subdubtype.find { it.id == subtype }?.id_type
+                    }
+
+                }
+
+                LazyColumn(modifier = Modifier.fillMaxSize().padding(10.dp)) {
+                    items(types) { type ->
+                        val typeItems = itemsByType[type.id] ?: emptyList()
+
+                        if (typeItems.isNotEmpty()) {
+                            Text(
+                                text = type.title_type,
+
+                                modifier = Modifier.padding(8.dp)
+                            )
+
+                            LazyRow {
+                                items(typeItems) { userthing ->
+                                    val thing = userthings.find { it.id == userthing.id_thing }
+                                    if (thing != null) {
+                                        val imageState = rememberAsyncImagePainter(
+                                            model = ImageRequest.Builder(LocalContext.current)
+                                                .data(thing.img)
+                                                .size(Size.ORIGINAL).build()
+                                        ).state
+
+                                        Card(
+                                            modifier = Modifier
+                                                .padding(8.dp)
+                                                .width(330.dp)
+                                                .shadow(8.dp, RoundedCornerShape(30.dp)),
+                                            shape = RoundedCornerShape(30.dp),
+                                            backgroundColor = Color.White
+                                        ) {
+                                            Column {
+                                                if (imageState is AsyncImagePainter.State.Error) {
+                                                    Box(
+                                                        modifier = Modifier
+                                                            .fillMaxWidth()
+                                                            .height(250.dp),
+                                                        contentAlignment = Alignment.Center
+                                                    ) {
+                                                        CircularProgressIndicator()
+                                                    }
+                                                }
+
+                                                if (imageState is AsyncImagePainter.State.Success) {
+                                                    Image(
+                                                        modifier = Modifier
+                                                            .fillMaxWidth()
+                                                            .height(250.dp),
+                                                        painter = imageState.painter,
+                                                        contentDescription = "",
+                                                        contentScale = ContentScale.Crop
+                                                    )
+                                                }
+
+                                                Divider(
+                                                    modifier = Modifier.padding(vertical = 8.dp),
+                                                    color = Color.LightGray,
+                                                    thickness = 1.dp
+                                                )
+
+                                                Text(
+                                                    "Название: ${thing.title}",
+                                                    fontSize = 18.sp,
+                                                    modifier = Modifier.padding(start = 8.dp),
+                                                    color = Color(0xFF92A2B0)
+                                                )
+
+                                                // Display categories
+                                                val seasonid = thing.id_season
+                                                val seasonItem = season.find { it.id == seasonid }
+                                                val styleid = thing.style
+                                                val styleItem = style.find { it.id == styleid }
+                                                val subtypeid = thing.subtype
+                                                val subtypeItem =
+                                                    subdubtype.find { it.id == subtypeid }
+
+                                                if (subtypeItem != null) {
+                                                    val typeid = subtypeItem.id_type
+                                                    val typeItem = types.find { it.id == typeid }
+                                                    if (seasonItem != null && styleItem != null && typeItem != null) {
+                                                        Text(
+                                                            "Категории: ${styleItem.title_style}, ${typeItem.title_type}, ${subtypeItem.sub_type}, ${seasonItem.title_season}",
+                                                            fontSize = 18.sp,
+                                                            modifier = Modifier.padding(start = 8.dp),
+                                                            color = Color(0xFF92A2B0)
+                                                        )
+                                                    }
+                                                }
+
+
+                                                Button(
+                                                    onClick = {
+                                                        itemToDelete = thing
+                                                        openDialog = true
+                                                    },
+                                                    modifier = Modifier
+                                                        .padding(8.dp)
+                                                        .align(Alignment.CenterHorizontally)
+                                                ) {
+
+
+                                                    Text("Удалить")
+                                                }
+
+
+
+
+
+
+                                            }
+                                        }
+
+                                    }
+
+                                }
+
+                            }
+
+
+                        }
+                    }
+
+                }
+                if (itemToDelete != null) {
+                    DeleteConfirmationDialog(
+                        openDialog = openDialog,
+                        userthing = itemToDelete!!, // Уверены, что itemToDelete не null
+                        onConfirm = { item ->
+                            item?.let {
+
+                                viewModel.deleteItem(it) // Вызов функции удаления из ViewModel
+
+                            }
+                            openDialog = false // Закрыть диалог
+                            itemToDelete = null // Сбросить элемент после удаления
+                        },
+                        onDismiss = {
+                            openDialog = false // Закрыть диалог при отмене
+                            itemToDelete = null // Сбросить элемент после закрытия диалога
+                        },
+                        navHost
+                    )
+                }
+            }
+
+        }
+        if (isBottomSheetVisible) {
+            ModalBottomSheetLayout(
+                sheetState = rememberModalBottomSheetState(ModalBottomSheetValue.Expanded),
+                sheetContent = {
+                    Column(   modifier = Modifier
+                        .fillMaxHeight()
+                        .fillMaxWidth()
+                        .background(
+                            Brush.verticalGradient(
+                                colors = listOf(
+                                    Color(0xFFF4F4F4),
+                                    Color(0xFFE7D2A9),
+                                    Color(0xFFC1A88B),
+                                    Color(0xFF6F4A48)
+                                )
+                            )
+                        )) {
+                        Box(
+                            modifier = Modifier
+                                .fillMaxWidth() // Бокс на всю ширину
+                                .padding(start = 16.dp, end = 16.dp)
+                                .background(
+                                    color = Color.White,
+                                    shape = RoundedCornerShape(16.dp) // Закругленные края
+                                )
+                                .padding(16.dp) // Отступы внутри бокса
+                        ) {
+
+                            // Отображение выбранного изображения
+
+
+                            LazyColumn(horizontalAlignment = Alignment.CenterHorizontally) {
+                                item {
+                                    Text("Новый образ", fontWeight = FontWeight.Bold)
+
+                                    // Поле для ввода названия вещи
+                                    TextField(
+                                        value = newThingName,
+                                        onValueChange = { newThingName = it },
+                                        label = { Text("Название образа") },
+                                        modifier = Modifier.fillMaxWidth()
+                                    )
+
+                                    // Выбор изображения
+                                    Button(onClick = {
+                                        imagePickerLauncher.launch("image/*")
+                                    }) {
+                                        Text("Выбрать изображение")
+                                    }
+                                    imageUri?.let {
+                                        Image(
+                                            painter = rememberImagePainter(it),
+                                            contentDescription = "Выбранное изображение",
+                                            modifier = Modifier
+                                                .fillMaxWidth()
+                                                .height(200.dp)
+                                                .clip(RoundedCornerShape(8.dp))
+                                                .padding(vertical = 8.dp)
+                                        )
+                                    }
+                                    Spacer(modifier = Modifier.height(10.dp)) // Отступ между текстом и кнопкой
+                                    TextField(
+                                        value = newThingName1,
+                                        onValueChange = { newThingName1 = it },
+                                        label = { Text("Название  вещи 1") },
+                                        modifier = Modifier.fillMaxWidth()
+                                    )
+                                    Spacer(modifier = Modifier.height(10.dp)) // Отступ между текстом и кнопкой
+                                    TextField(
+                                        value = newThingName2,
+                                        onValueChange = { newThingName2 = it },
+                                        label = { Text("Название  вещи 2") },
+                                        modifier = Modifier.fillMaxWidth()
+                                    )
+                                    Spacer(modifier = Modifier.height(10.dp)) // Отступ между текстом и кнопкой
+                                    TextField(
+                                        value = newThingName3,
+                                        onValueChange = { newThingName3 = it },
+                                        label = { Text("Название  вещи 2") },
+                                        modifier = Modifier.fillMaxWidth()
+                                    )
+
+                                    Spacer(modifier = Modifier.height(10.dp)) // Отступ между текстом и кнопкой
+                                      Text("Публиковать?")
+                                    Row(
+                                        verticalAlignment = Alignment.CenterVertically,
+                                        modifier = Modifier
+
+                                            .selectable(
+                                                selected = (public),
+                                                onClick = { public = true}
+                                            )
+                                            .padding(top = 14.dp)
+
+
+
+                                    ) {
+                                        androidx.compose.material3.RadioButton(
+                                            selected = (public),
+                                            onClick = { public = true}
+                                        )
+                                        Text(
+                                            text = "Да",
+                                            fontSize = 16.sp,
+                                            modifier = Modifier.padding(start = 0.dp), // Отступ слева от радиокнопки
+                                            color = Color(0xFF92A2B0)
+
+                                        )
+                                    }
+
+                                    Column(
+                                        modifier = Modifier
+                                            .fillMaxWidth()
+                                            .padding(bottom = 50.dp), // Отступ внизу для всего столбца
+                                        verticalArrangement = Arrangement.Bottom // Располагаем кнопки внизу
+                                    ) {
+                                        Button(
+                                            onClick = {
+                                                viewModel.insertItem(
+                                                    season = selectSeason?.id ?: 0,
+                                                    styles = selectStyle?.id ?: 0,
+                                                    title = newThingName,
+                                                    subtype = selectSubtype?.id ?: 0,
+                                                    imgUri = imageUri
+                                                )
+                                                // Закрываем панель
+
+                                            },
+                                            modifier = Modifier
+                                                .fillMaxWidth()
+                                                .height(50.dp)
+                                                .padding(horizontal = 20.dp)
+                                                .background(
+                                                    brush = Brush.horizontalGradient(
+                                                        colors = listOf(
+                                                            Color(0xFF6F4A48),
+                                                            Color(0xFFE7D2A9),
+                                                        )
+                                                    ),
+                                                    shape = ButtonDefaults.shape
+                                                ),
+                                            colors = ButtonDefaults.buttonColors(containerColor = Color.Transparent),
+                                        ) {
+                                            Text("Добавить")
+                                        }
+
+                                        Spacer(modifier = Modifier.height(10.dp)) // Отступ между кнопками
+
+                                        Button(
+                                            onClick = {
+                                                val filteredSortedThings = userthings
+
+                                                // Обрабатываем результат
+                                                Log.d("SortedThings", filteredSortedThings.toString())
+                                                val lastId: Int? = filteredSortedThings.lastOrNull()?.id
+
+                                                if (lastId == null) {
+                                                    Log.e("lastId", "lastId is null, filteredSortedThings is empty or does not have a valid id")
+                                                } else {
+                                                    Log.d("lastId", lastId.toString())
+                                                    viewModel.addc(
+                                                        idWardrob = selectwardrob?.id ?: 0,
+                                                        firstId = lastId
+                                                    )
+                                                }
+
+                                                isBottomSheetVisible = false
+                                                navHost.navigate("Wardrob")
+
+                                            },
+                                            modifier = Modifier
+                                                .fillMaxWidth()
+                                                .height(50.dp)
+                                                .padding(horizontal = 20.dp)
+                                                .background(
+                                                    brush = Brush.horizontalGradient(
+                                                        colors = listOf(
+                                                            Color(0xFF6F4A48),
+                                                            Color(0xFFE7D2A9),
+                                                        )
+                                                    ),
+                                                    shape = ButtonDefaults.shape
+                                                ),
+                                            colors = ButtonDefaults.buttonColors(containerColor = Color.Transparent),
+                                        ) {
+                                            Text("Добавить")
+                                        }
+                                    }
+                                }
+
+                            }
+
+
+
+
+
+
+
+
+                        }
+                    }
+                },
+                content = {
+
+                },
+
+                )
+
+        }
+    }
+    if (isFilterSheetVisible) {
+        Column {
+            FiltersUser(
+                onApplyFilter = { selectedSubtype, selectedSeason, selectedStyle ->
+                    // Получаем текущего авторизованного пользователя
+                    val userId = Constants.supabase.auth.currentUserOrNull()?.id
+                    val authorizedUser  = users.find { it.user == userId }
+
+                    if (authorizedUser  != null) {
+
+                        userthings.filter { userthing ->
+                            (selectedSubtype == null || userthing.subtype == selectedSubtype.id) &&
+                                    (selectedSeason == null || userthing.id_season == selectedSeason.id) &&
+                                    (selectedStyle == null || userthing.style == selectedStyle.id)
+                        }
+
+
+                    }
+
+                    isFilterSheetVisible = false // Закрываем окно фильтров
+                    filtersApplied = true
+                },
+                onDismiss = { isFilterSheetVisible = false }
+            )
+        }
+    }
+
+
+
+}

+ 2 - 1
Project_exvesta/app/src/main/java/com/example/exvesta/model/Bows.kt

@@ -5,6 +5,7 @@ public data class Bows (
     val id: Int,
     val title_bow: String,
     val id_user: Int,
-    val status: Boolean
+    val status: Boolean,
+    val img: String?,
 
 )

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

@@ -2,7 +2,7 @@ package com.example.exvesta.model
 import kotlinx.serialization.Serializable
 @Serializable
 public data class Consists_wardrob (
-    val id: Int,
+    val id: Int?= null,
     val id_wardrob: Int,
     val id_thing: Int
     )

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

@@ -2,7 +2,7 @@ package com.example.exvesta.model
 import kotlinx.serialization.Serializable
 @Serializable
 public data class Things_user (
-    val id: Int,
+    val id: Int? = null,
     val style: Int,
     val title: String,
     val subtype: Int,
@@ -10,4 +10,4 @@ public data class Things_user (
     val id_season: Int,
     val no: Boolean?,
     val public_status: Boolean?,
-)
+)

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

@@ -2,6 +2,6 @@ package com.example.exvesta.model
 import kotlinx.serialization.Serializable
 @Serializable
 public data class Wardob(
-    val id: Int,
+    val id: Int?= null,
     val id_user: Int
 )

+ 12 - 0
Project_exvesta/app/src/main/java/com/example/exvesta/navigation/Navigation.kt

@@ -5,12 +5,15 @@ import androidx.compose.ui.input.key.Key.Companion.Home
 import androidx.navigation.compose.NavHost
 import androidx.navigation.compose.composable
 import androidx.navigation.compose.rememberNavController
+import com.example.exvesta.Screans.Bows
 import com.example.exvesta.Screans.Home
 import com.example.exvesta.Screans.Login
+import com.example.exvesta.Screans.MyBows
 import com.example.exvesta.Screans.Preloading
 import com.example.exvesta.Screans.RegAuth
 import com.example.exvesta.Screans.Registration
 import com.example.exvesta.Screans.Wardrob
+import com.example.exvesta.Screans.addBow
 
 @Composable
 fun Navigation(){
@@ -36,5 +39,14 @@ fun Navigation(){
         composable("Wardrob"){
             Wardrob(navController)
         }
+        composable("Bows"){
+            Bows(navController)
+        }
+        composable("MyBows"){
+            MyBows(navController)
+        }
+        composable("addBow"){
+            addBow(navController)
+        }
     }
 }

+ 4 - 0
Project_exvesta/app/src/main/res/xml/file_paths.xml

@@ -0,0 +1,4 @@
+<?xml version ="1.0" encoding ="utf-8"?><!--  Learn More about how to use App Actions: https://developer.android.com/guide/actions/index.html -->
+<paths>
+    <external-path name="external_files" path="." />
+</paths>

+ 2 - 0
Project_exvesta/gradle/libs.versions.toml

@@ -25,6 +25,7 @@ material = "1.7.5"
 coilCompose = "2.4.0"
 toolsCore = "1.0.0-alpha10"
 appcompat = "1.7.0"
+runtimeLivedata = "1.7.5"
 [libraries]
 androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
 bom = { module = "io.github.jan-tennert.supabase:bom", version.ref = "bom" }
@@ -71,6 +72,7 @@ androidx-ui-android = { group = "androidx.compose.ui", name = "ui-android", vers
 volley = { group = "com.android.volley", name = "volley", version.ref = "volley" }
 androidx-tools-core = { group = "androidx.privacysandbox.tools", name = "tools-core", version.ref = "toolsCore" }
 androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
+androidx-runtime-livedata = { group = "androidx.compose.runtime", name = "runtime-livedata", version.ref = "runtimeLivedata" }
 
 [plugins]
 android-application = { id = "com.android.application", version.ref = "agp" }