2 Commits 1296190060 ... 42dae9c604

Auteur SHA1 Message Date
  AlexMin 42dae9c604 сделал вывод всех мест в меню, и добавил логику перехода на нужную страницу с нужным местом при нажатии на место в меню il y a 3 jours
  AlexMin fff7272f20 полностью доделал создание пользователя il y a 3 jours

BIN
.gradle/8.7/executionHistory/executionHistory.bin


BIN
.gradle/8.7/executionHistory/executionHistory.lock


BIN
.gradle/8.7/fileHashes/fileHashes.bin


BIN
.gradle/8.7/fileHashes/fileHashes.lock


BIN
.gradle/8.7/fileHashes/resourceHashesCache.bin


BIN
.gradle/buildOutputCleanup/buildOutputCleanup.lock


BIN
.gradle/file-system.probe


+ 3 - 0
app/build.gradle.kts

@@ -56,6 +56,7 @@ android {
 }
 
 dependencies {
+
     implementation(libs.androidx.core.ktx)
     implementation(libs.androidx.lifecycle.runtime.ktx)
     implementation(libs.androidx.activity.compose)
@@ -97,4 +98,6 @@ dependencies {
     implementation(libs.coil.compose) // Или последняя версия
 
     implementation(libs.ui.tooling.preview)
+
+
 }

+ 7 - 0
app/src/main/java/com/example/iplace/domain/Constants.kt

@@ -1,10 +1,14 @@
+@file:OptIn(SupabaseInternal::class)
+
 package com.example.iplace.domain
 
 
+import io.github.jan.supabase.annotations.SupabaseInternal
 import io.github.jan.supabase.createSupabaseClient
 import io.github.jan.supabase.gotrue.Auth
 import io.github.jan.supabase.postgrest.Postgrest
 import io.github.jan.supabase.realtime.Realtime
+import io.ktor.client.plugins.websocket.WebSockets
 
 object Constants {
     val supabase = createSupabaseClient(
@@ -14,6 +18,9 @@ object Constants {
         install(Auth)
         install(Postgrest)
         install(Realtime)
+        httpConfig {
+            this.install(WebSockets)
+        }
     }
 }
 

+ 27 - 0
app/src/main/java/com/example/iplace/main/viewModel/MainViewModel.kt

@@ -1,3 +1,5 @@
+@file:OptIn(SupabaseExperimental::class)
+
 package com.example.iplace.main.viewModel
 
 import android.content.Context
@@ -21,14 +23,21 @@ import androidx.navigation.NavHostController
 import com.example.iplace.R
 import com.example.iplace.domain.Constants
 import com.example.iplace.model.Gender
+import com.example.iplace.model.Place
 import com.example.iplace.model.Users
+import io.github.jan.supabase.annotations.SupabaseExperimental
 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.postgrest.query.Columns
+import io.github.jan.supabase.realtime.selectAsFlow
+import io.github.jan.supabase.supabaseJson
+import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.flow.MutableStateFlow
 import kotlinx.coroutines.flow.StateFlow
 import kotlinx.coroutines.flow.asStateFlow
 import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
 
 class MainViewModel(): ViewModel() {
 
@@ -126,6 +135,24 @@ class MainViewModel(): ViewModel() {
         }
     }
 
+
+    suspend fun getPlaceList() = Constants.supabase.from("place")
+        .select()
+        .decodeList<Place>()
+    private val _place: MutableStateFlow<List<Place>> = MutableStateFlow(listOf())
+
+    fun getPlaceListRealTime() = Constants.supabase.from("Place")
+        .selectAsFlow(Place ::id_place)
+
+
+    suspend fun getPlaceById(id: Int) = Constants.supabase.from("place")
+        .select(columns = Columns.list("id_place","title","img_place","id_categoryFK","description","address","mapping","author")){
+            filter {
+                Place::id_place eq id
+            }
+        }.decodeSingle<Place>()
+
+
 }
 
 

+ 84 - 42
app/src/main/java/com/example/iplace/main/viewModel/dataView/MenuV.kt

@@ -14,18 +14,12 @@ import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.foundation.layout.fillMaxWidth
 import androidx.compose.foundation.layout.height
 import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.size
 import androidx.compose.foundation.layout.width
-import androidx.compose.foundation.shape.CircleShape
 import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material.icons.filled.ArrowBack
-import androidx.compose.material.icons.filled.Settings
 import androidx.compose.material3.Button
 import androidx.compose.material3.ButtonDefaults
-import androidx.compose.material3.Card
 import androidx.compose.material3.Icon
 import androidx.compose.material3.IconButton
-import androidx.compose.material3.MaterialTheme
 import androidx.compose.material3.OutlinedTextField
 import androidx.compose.material3.Text
 import androidx.compose.runtime.Composable
@@ -34,22 +28,17 @@ import androidx.compose.ui.text.font.Font
 import androidx.compose.ui.text.font.FontFamily
 import androidx.compose.ui.text.font.FontWeight
 import androidx.compose.ui.text.style.TextAlign
-import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
-import coil.compose.rememberImagePainter
 import com.example.iplace.R
 import com.example.iplace.main.viewModel.MainViewModel
-import com.example.iplace.ui.theme.beige_white
 import com.example.iplace.ui.theme.brown_contrast
 
-import androidx.compose.foundation.background
 import androidx.compose.foundation.clickable
 import androidx.compose.foundation.layout.*
 import androidx.compose.foundation.lazy.LazyColumn
 import androidx.compose.foundation.lazy.items
 //noinspection UsingMaterialAndMaterial3Libraries
-import androidx.compose.material.*
 import androidx.compose.material.icons.Icons
 import androidx.compose.material.icons.filled.Menu
 import androidx.compose.material.icons.filled.Person
@@ -62,8 +51,9 @@ import androidx.compose.ui.Modifier
 import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.layout.ContentScale
 import androidx.compose.ui.res.painterResource
-import androidx.compose.ui.unit.dp
 import androidx.navigation.NavHostController
+import coil.compose.AsyncImage
+import com.example.iplace.model.Place
 
 
 @OptIn(ExperimentalMaterial3Api::class)
@@ -71,6 +61,16 @@ import androidx.navigation.NavHostController
 fun MenuV(navController: NavHostController) {
     val viewModel = MainViewModel()
     var showDrawer by remember { mutableStateOf(false) }
+
+    var placeList by remember { mutableStateOf<List<Place>>(emptyList()) }
+//    LaunchedEffect(key1 = true) {
+//        viewModel.getPlaceListRealTime()
+//            .collect {list -> placeList = list}
+//    }
+    LaunchedEffect(key1 = true) {
+        placeList = viewModel.getPlaceList()
+    }
+
     val headlinesOswald = FontFamily( //выбор шрифта
         Font(resId = R.font.headlines_oswald)
     )
@@ -240,43 +240,85 @@ fun MenuV(navController: NavHostController) {
                     .fillMaxWidth(),
                 textAlign = TextAlign.Center
             )
+            LazyColumn(
+                contentPadding = PaddingValues(
+                    horizontal = 16.dp,
+                    vertical = 10.dp),
+                verticalArrangement = Arrangement.spacedBy(10.dp)
+            ){
+                items(placeList) {
+                    place ->
+                        PlaceCard(place = place, navController
 
-            // 4 блока данных
-            LazyColumn {
-                items(listOf(1, 2, 3, 4)) { item ->
-                    Box(
-                        modifier = Modifier
-                            .fillMaxWidth()
-                            .height(230.dp)
-                            .padding(16.dp)
-                            .background(Color.LightGray)
-                            .clickable{navController.navigate("placeV")}
-                    ) {
-                        Column(
-                            modifier = Modifier
-                                .align(Alignment.BottomStart) // Выравниваем Column по левому нижнему углу
-                        ) {
-                            Text(text = "Название $item", modifier = Modifier)
-                            Text(text = "Категория $item", modifier = Modifier)
-                        }
-
-                        Button(
-                            onClick = { /* Обработка нажатия на фильтр */ },
-                            modifier = Modifier
-                                .align(Alignment.TopEnd) // Выравниваем Button по правому верхнему углу
-                                .width(40.dp)
-                                .height(40.dp),
-                            colors = ButtonDefaults.buttonColors(brown_contrast)
-                        ) {
-                            Text(text = "☆")
-                        }
-                    }
+                        )
                 }
+
+            }
+        }
+    }
+}
+
+@Composable
+fun PlaceCard(place: Place, navController: NavHostController){
+    Box(
+        modifier = Modifier
+            .fillMaxWidth()
+            .height(300.dp)
+            .clip(RoundedCornerShape(20.dp))
+            .clickable(onClick = { navController.navigate("placeV") })
+        ,
+        contentAlignment = Alignment.Center
+    ){
+
+        AsyncImage(
+            model = place.img_place,
+            contentDescription = null,
+            modifier = Modifier.fillMaxSize(),
+            contentScale = ContentScale.Crop
+        )
+        Box(
+
+            modifier = Modifier
+                .matchParentSize()
+                .background(color = Color.LightGray.copy(alpha = 0.6f))
+        ){
+            Column(
+                modifier = Modifier
+                    .align(Alignment.BottomStart) // Выравниваем Column по левому нижнему углу
+            ) {
+                Text(
+                    text = place.title,
+                    fontSize = 18.sp,
+                    color = Color.Black,
+
+                    )
+                Text(
+                    text = place.id_categoryFK.toString(),
+                    fontSize = 18.sp,
+                    color = Color.Black,
+
+                    )
+            }
+
+            Button(
+                onClick = { /* Обработка нажатия на фильтр */ },
+                modifier = Modifier
+                    .align(Alignment.TopEnd) // Выравниваем Button по правому верхнему углу
+                    .width(40.dp)
+                    .height(40.dp),
+                colors = ButtonDefaults.buttonColors(brown_contrast)
+            ) {
+                Text(text = "☆")
             }
         }
+
+
+
     }
+
 }
 
+
 @Composable
 fun DrawerContent(showDrawer: Boolean, navController: NavHostController) {
     val headlinesOswald = FontFamily( //выбор шрифта

+ 31 - 2
app/src/main/java/com/example/iplace/main/viewModel/dataView/PlaceV.kt

@@ -25,6 +25,10 @@ import androidx.compose.material3.IconButton
 import androidx.compose.material3.OutlinedTextField
 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.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.draw.clip
@@ -36,15 +40,25 @@ import androidx.compose.ui.text.font.FontFamily
 import androidx.compose.ui.text.font.FontWeight
 import androidx.compose.ui.text.style.TextAlign
 import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
 import androidx.navigation.NavHostController
+import coil.compose.AsyncImage
 import com.example.iplace.R
 import com.example.iplace.main.viewModel.MainViewModel
+import com.example.iplace.model.Place
 import com.example.iplace.ui.theme.brown_contrast
 
 @Composable
-fun PlaceV(navController: NavHostController) {
+fun PlaceV(navController: NavHostController, PlaceId : Int) {
     val viewModel = MainViewModel()
 
+    val place by remember { mutableStateOf<Place?>(null) }
+
+    LaunchedEffect (key1 = true){
+        viewModel.getPlaceById(id = PlaceId)
+    }
+
+
     val headlinesOswald = FontFamily( //выбор шрифта
         Font(resId = R.font.headlines_oswald)
     )
@@ -69,6 +83,12 @@ fun PlaceV(navController: NavHostController) {
                 .background(Color.LightGray.copy(alpha = 0.6f))
                 .padding(16.dp)
         ) {
+            AsyncImage(
+                model = place?.img_place,
+                contentDescription = null,
+                modifier = Modifier.fillMaxSize(),
+                contentScale = ContentScale.Crop
+            )
             // Кнопки назад и автора
             Row(
                 modifier = Modifier
@@ -94,7 +114,16 @@ fun PlaceV(navController: NavHostController) {
                     .align(Alignment.BottomStart) // Выравнивание по левому нижнему углу
                     .padding(16.dp) // Отступ от краев
             ) {
-                Text(text = "Название")
+                Text(
+                    text = place?.title ?:"",
+                    fontWeight = FontWeight.Bold,
+                    fontSize = 32.sp
+                )
+                Text(
+                    text = place?.id_categoryFK.toString() ?:"",
+                    fontWeight = FontWeight.Bold,
+                    fontSize = 18.sp
+                )
                 Spacer(modifier = Modifier.height(8.dp)) // Отступ между текстами
                 Text(text = "Категория")
             }

+ 2 - 2
app/src/main/java/com/example/iplace/main/viewModel/dataView/PolicyConditionality.kt

@@ -112,7 +112,7 @@ fun PolicyConditionality(navController: NavHostController) {
                     verticalAlignment = Alignment.CenterVertically,
                     modifier = Modifier.fillMaxWidth()
                 ) {
-                    IconButton(onClick = { navController.navigate("selectEnter") }) {
+                    IconButton(onClick = { navController.navigate("creatingUser") }) {
                         Icon(
                             imageVector = Icons.Default.ArrowBack,
                             contentDescription = "Назад",
@@ -196,7 +196,7 @@ fun PolicyConditionality(navController: NavHostController) {
                             fontFamily = basicNunitosans
                         )
                     }
-                    Spacer(modifier = Modifier.height(16.dp))
+                    Spacer(modifier = Modifier.height(40.dp))
                 }
             }
         }

+ 56 - 80
app/src/main/java/com/example/iplace/main/viewModel/mainView/CreatingUser.kt

@@ -56,6 +56,13 @@ import com.example.iplace.main.viewModel.MainViewModel
 import com.example.iplace.ui.theme.beige_white
 import com.example.iplace.ui.theme.brown_contrast
 import java.io.IOException
+import androidx.compose.foundation.layout.*
+import androidx.compose.material.*
+import androidx.compose.material.icons.filled.ArrowDropDown
+import androidx.compose.runtime.*
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+
 
 @Composable
 fun CreatingUser(navController: NavHostController) {
@@ -67,8 +74,7 @@ fun CreatingUser(navController: NavHostController) {
         Font(resId = R.font.basic_nunitosans)
     )
 
-    var expanded by remember { mutableStateOf(false) }
-    var selectedItem by remember { mutableStateOf("") }
+
 
     var selectedImageUri by remember { mutableStateOf<Uri?>(null) }
     var imageBitmap by remember { mutableStateOf<androidx.compose.ui.graphics.ImageBitmap?>(null) }
@@ -88,13 +94,19 @@ fun CreatingUser(navController: NavHostController) {
         }
     }
 
-    val emailUser = remember { mutableStateOf("") }
-    val passwordUser = remember { mutableStateOf("") }
+
     val nameUser = remember { mutableStateOf("") }
     val address = remember { mutableStateOf("") }
     val about_me = remember { mutableStateOf("") }
+    var expanded by remember { mutableStateOf(false) }
+    var selectedItem by remember { mutableStateOf("") }
     val id_genderFK = remember { mutableStateOf("") }
-    val img_user = remember { mutableStateOf("") }
+
+    val genderOptions = listOf(
+        Pair("Мужчина", "1"),
+        Pair("Женщина", "2")
+    )
+
 
     Image(
         painter = painterResource(id = R.drawable.cu6),
@@ -136,7 +148,7 @@ fun CreatingUser(navController: NavHostController) {
                     verticalAlignment = Alignment.CenterVertically,
                     modifier = Modifier.fillMaxWidth()
                 ) {
-                    IconButton(onClick = { navController.navigate("selectEnter") }) {
+                    IconButton(onClick = { navController.navigate("registration") }) {
                         Icon(
                             imageVector = Icons.Default.ArrowBack, // Или другой иконки
                             contentDescription = "Назад",
@@ -165,51 +177,50 @@ fun CreatingUser(navController: NavHostController) {
                         .clip(RoundedCornerShape(20.dp))
                 )
                 Spacer(modifier = Modifier.height(10.dp))
-                Box(
+
+                Column(
                     modifier = Modifier
                         .fillMaxWidth()
-                        .padding(horizontal = 16.dp)
-                        .clip(RoundedCornerShape(20.dp))
-                        .background(Color.White) // Фон выпадающего списка
-                        .clickable { expanded = !expanded } // Клик для раскрытия/сворачивания
+                        .padding(16.dp),
+                    horizontalAlignment = Alignment.CenterHorizontally
                 ) {
-                    // Выбранный элемент
-                    Text(
-                        text = selectedItem,
-                        modifier = Modifier.padding(16.dp),
-                        color = Color.Gray // Цвет текста выбранного элемента
+                    OutlinedTextField(
+                        value = selectedItem,
+                        onValueChange = { selectedItem = it },
+                        readOnly = true,
+                        label = { Text("Пол") },
+                        trailingIcon = {
+                            IconButton(onClick = { expanded = !expanded }) {
+                                Icon(Icons.Filled.ArrowDropDown, contentDescription = null)
+                            }
+                        },
+                        modifier = Modifier.fillMaxWidth()
                     )
 
-                    // Иконка раскрытия/сворачивания
-                    Icon(
-                        imageVector = if (expanded) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown,
-                        contentDescription = null,
+                    DropdownMenu(
+                        expanded = expanded,
+                        onDismissRequest = { expanded = false },
                         modifier = Modifier
-                            .align(Alignment.BottomEnd)
-                            .padding(16.dp)
-                    )
-
-//                    DropdownMenu(
-//                        expanded = expanded,
-//                        onDismissRequest = { expanded = false },
-//                        modifier = Modifier
-//                            .fillMaxWidth()
-//                            .background(Color.White) // Фон выпадающего меню
-//                    ) {
-//                        // Элементы выпадающего списка
-//                        listOf("Мужской", "Женский").forEach { item ->
-//                            DropdownMenuItem(
-//                                onClick = {
-//                                    selectedItem = item
-//                                    expanded = false
-//                                }
-//                            ) {
-//                                Text(text = item)
-//                            }
-//                        }
-//                    }
+                            .fillMaxWidth()
+                            .width(200.dp)
+                    ) {
+                        genderOptions.forEach { (gender, id) ->
+                            DropdownMenuItem(
+                                onClick = {
+                                    selectedItem = gender
+                                    id_genderFK.value = id
+                                    expanded = false
+                                },
+                                text = {
+                                    Text(text = gender)
+                                }
+                            )
+                        }
+                    }
                 }
 
+
+
                 Spacer(modifier = Modifier.height(10.dp))
 
                 OutlinedTextField(
@@ -229,47 +240,12 @@ fun CreatingUser(navController: NavHostController) {
                     label = { Text("О себе") },
                     modifier = Modifier
                         .fillMaxWidth()
-                        .height(45.dp)
                         .padding(horizontal = 16.dp)
                         .clip(RoundedCornerShape(20.dp))
                 )
                 Spacer(modifier = Modifier.height(10.dp))
-                Column(
-//                    modifier = Modifier
-//                        .fillMaxSize()
-//                        .padding(16.dp),
-                    horizontalAlignment = Alignment.CenterHorizontally
-                ) {
-                    Button(onClick = { launcher.launch("image/*") }) {
-                        Text("Выбрать фото")
-                    }
-                    Spacer(modifier = Modifier.height(0.dp))
-                    if (imageBitmap != null) {
-                        Image(
-                            painter = rememberImagePainter(
-                                data = imageBitmap
-                            ),
-                            contentDescription = "Selected Image",
-                            modifier = Modifier
-                                .width(50.dp)
-                                .height(50.dp)
-                        )
-                    } else if (selectedImageUri != null) {
-//                        Image(
-//                            painter = rememberImagePainter(
-//                                request = ImageRequest.Builder(context)
-//                                    .data(selectedImageUri)
-//                                    .build()
-//                            ),
-//                            contentDescription = "Selected Image",
-//                            modifier = Modifier
-//                                .width(200.dp)
-//                                .height(200.dp)
-//                        )
-                    } else {
-                        Text("Выберите фото", fontSize = 18.sp)
-                    }
-                }
+
+
 
 
 

+ 7 - 1
app/src/main/java/com/example/iplace/main/viewModel/navigation.kt

@@ -3,9 +3,14 @@ package com.example.iplace.main.viewModel
 import android.os.Build
 import androidx.annotation.RequiresApi
 import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
 import androidx.navigation.NavHostController
 import androidx.navigation.compose.NavHost
 import androidx.navigation.compose.composable
+import androidx.navigation.compose.rememberNavController
 import com.example.iplace.main.viewModel.dataView.FavouritesV
 import com.example.iplace.main.viewModel.dataView.MenuV
 import com.example.iplace.main.viewModel.dataView.PlaceV
@@ -26,6 +31,7 @@ import com.example.iplace.main.viewModel.mainView.UserSettings
 @RequiresApi(Build.VERSION_CODES.O)
 @Composable
 fun Navigation(controller: NavHostController) {
+    var PlaceId by remember { mutableStateOf(0) }
     NavHost(
         navController = controller,
         startDestination = View.splashScreen.route
@@ -70,7 +76,7 @@ fun Navigation(controller: NavHostController) {
             FavouritesV(controller)
         }
         composable(View.placeV.route){
-            PlaceV(controller)
+            PlaceV(controller, PlaceId)
         }
         composable(View.addPlace.route){
             AddPlace(controller)

+ 0 - 1
app/src/main/java/com/example/iplace/model/Place.kt

@@ -11,7 +11,6 @@ data class Place (
     val id_categoryFK: Int,
     val description: String,
     val address: String,
-    val id_img_placeFK: Int,
     val mapping: String,
     val author: String,
 )