Explorar o código

all bases verstka

костюниноа hai 6 días
pai
achega
0d80541992

+ 2 - 2
.idea/deploymentTargetSelector.xml

@@ -4,10 +4,10 @@
     <selectionStates>
       <SelectionState runConfigName="app">
         <option name="selectionMode" value="DROPDOWN" />
-        <DropdownSelection timestamp="2024-11-19T09:56:03.583239500Z">
+        <DropdownSelection timestamp="2024-11-19T12:22:40.863364100Z">
           <Target type="DEFAULT_BOOT">
             <handle>
-              <DeviceId pluginId="LocalEmulator" identifier="path=C:\AndroidSettings\.android\avd\Pixel_8_Pro_API_34.avd" />
+              <DeviceId pluginId="LocalEmulator" identifier="path=C:\AndroidSettings\.android\avd\Pixel_7a_API_34.avd" />
             </handle>
           </Target>
         </DropdownSelection>

+ 15 - 0
app/src/main/java/com/example/lectionsupabase/model/Benchs.kt

@@ -0,0 +1,15 @@
+package com.example.lectionsupabase.model
+
+import kotlinx.serialization.Serializable
+
+
+@Serializable
+data class Benchs(
+    val id: Int,
+    val district: String,
+    val coordinates: String,
+    val state: String,
+    val picture: String?
+
+
+)

+ 6 - 1
app/src/main/java/com/example/lectionsupabase/navigation/Navigation.kt

@@ -6,6 +6,7 @@ import androidx.navigation.compose.composable
 import androidx.navigation.compose.rememberNavController
 import auth
 import com.example.lectionsupabase.view.mainActivity.MainViewModel
+import com.example.lectionsupabase.view.mainActivity.components.Benchs
 import com.example.lectionsupabase.view.mainActivity.components.Cinema
 import com.example.lectionsupabase.view.mainActivity.components.Concerts
 import com.example.lectionsupabase.view.mainActivity.components.DealersList
@@ -22,7 +23,7 @@ import slide3
 fun Navigation() {
     val navController = rememberNavController()
     NavHost(navController = navController,
-        startDestination = "auth")
+        startDestination = "Restaurants")
     {
         composable("auth") {
             auth(navController, MainViewModel())
@@ -53,6 +54,9 @@ fun Navigation() {
         composable("Exhibition") {
             Exhibition(navController)
         }
+        composable("Benchs"){
+            Benchs(navController)
+        }
         composable("DealersList"){
             DealersList(navController)
         }
@@ -64,3 +68,4 @@ fun Navigation() {
 }
 
 
+

+ 226 - 0
app/src/main/java/com/example/lectionsupabase/view/mainActivity/components/Benchs.kt

@@ -0,0 +1,226 @@
+package com.example.lectionsupabase.view.mainActivity.components
+
+import androidx.compose.foundation.BorderStroke
+import androidx.compose.foundation.Image
+import androidx.compose.foundation.clickable
+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.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.items
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.ArrowBack
+import androidx.compose.material.icons.filled.ArrowForward
+import androidx.compose.material3.Card
+import androidx.compose.material3.CardDefaults
+import androidx.compose.material3.CircularProgressIndicator
+import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
+import androidx.compose.material3.MaterialTheme
+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.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.layout.ContentScale
+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.unit.dp
+import androidx.compose.ui.unit.sp
+import androidx.navigation.NavHostController
+import coil.compose.rememberImagePainter
+import com.example.lectionsupabase.R
+import com.example.lectionsupabase.domain.utils.Constants
+import com.example.lectionsupabase.model.Admin
+import com.example.lectionsupabase.model.Benchs
+import com.example.lectionsupabase.model.Movie
+import io.github.jan.supabase.postgrest.from
+
+@Composable
+fun Benchs(navHost: NavHostController) {
+    var benchs by remember { mutableStateOf<List<Benchs>>(listOf()) }
+    var loadingBench by remember { mutableStateOf(true) }
+    var loadingUsers by remember { mutableStateOf(true) }
+    var users by remember { mutableStateOf<List<Admin>>(listOf()) }
+    val montserratSemiBold = FontFamily(Font(R.font.mon_semibold))
+    val montserratRegular = FontFamily(Font(R.font.mon_regular))
+    val montserratMedium = FontFamily(Font(R.font.mon_medium))
+
+    LaunchedEffect(Unit) {
+        try {
+            benchs = Constants.supabase.from("Benchs")
+                .select()
+                .decodeList<Benchs>()
+            loadingBench = false
+        } catch (e: Exception) {
+            println("Error loading benches: ${e.message}")
+            loadingBench = false
+        }
+    }
+
+    LaunchedEffect(Unit) {
+        try {
+            users = Constants.supabase.from("Admin")
+                .select()
+                .decodeList<Admin>()
+            loadingUsers = false
+        } catch (e: Exception) {
+            println("Error loading users: ${e.message}")
+            loadingUsers = false
+        }
+    }
+
+    Column(
+        modifier = Modifier
+            .fillMaxSize()
+            .padding(16.dp)
+            .padding(top = 20.dp),
+    ) {
+        Row(
+            modifier = Modifier
+                .fillMaxWidth()
+                .padding(vertical = 6.dp),
+            verticalAlignment = Alignment.CenterVertically
+        ) {
+            // Стрелка влево
+            IconButton(
+                onClick = { navHost.navigate("Exhibition")},
+                modifier = Modifier.padding(end = 8.dp)
+            ) {
+                Icon(
+                    imageVector = Icons.Default.ArrowBack,
+                    contentDescription = "Назад",
+                    tint = Color.Black
+                )
+            }
+
+            // Текст "Скамейки" по центру
+            Text(
+                text = "Скамейки",
+                style = MaterialTheme.typography.headlineMedium,
+                fontWeight = FontWeight.Bold,
+                color = MaterialTheme.colorScheme.onBackground,
+                textAlign = TextAlign.Center,
+                fontSize = 20.sp,
+                fontFamily = montserratSemiBold,
+                modifier = Modifier.weight(1f)
+            // Занимаем оставшееся пространство
+            )
+
+            // Стрелка вправо
+            IconButton(
+                onClick = { navHost.navigate("Concerts") },
+
+            ) {
+                Icon(
+                    imageVector = Icons.Default.ArrowForward,
+                    contentDescription = "Перейти к киноафише",
+                    tint = Color.Black
+                )
+            }
+        }
+
+        if (loadingBench) {
+            Box(
+                modifier = Modifier.fillMaxSize(),
+                contentAlignment = Alignment.Center
+            ) {
+                CircularProgressIndicator(modifier = Modifier.size(72.dp))
+            }
+        } else {
+            LazyColumn(
+                modifier = Modifier
+                    .fillMaxHeight()
+                    .padding(bottom = 10.dp),
+                verticalArrangement = Arrangement.spacedBy(10.dp)
+            ) {
+                items(benchs, key = { bench -> bench.id }) { bench ->
+                    Card(
+                        modifier = Modifier
+                            .width(430.dp)
+                            .padding(8.dp), // Отступы для карточки
+                        elevation = CardDefaults.cardElevation(0.dp),
+                        shape = RoundedCornerShape(55.dp),
+                        colors = CardDefaults.cardColors(containerColor = Color.White),
+                        border = BorderStroke(0.5.dp, Color.LightGray)
+                    ) {
+                        Row(
+                            modifier = Modifier
+                                .fillMaxWidth()
+                                .padding(10.dp), // Отступы внутри карточки
+                            verticalAlignment = Alignment.CenterVertically
+                        ) {
+                            val painter = rememberImagePainter(
+                                data = bench.picture,
+                                builder = {
+                                    crossfade(true)
+                                }
+                            )
+
+                            Image(
+                                painter = painter,
+                                contentDescription = "Фото скамейки",
+                                modifier = Modifier
+                                    .size(88.dp) // Устанавливаем размер фотографии
+                                    .clip(CircleShape), // Делаем фото круглым
+                                contentScale = ContentScale.Crop
+                            )
+
+                            Spacer(modifier = Modifier.width(8.dp)) // Отступ между фото и текстом
+
+                            Column(
+                                modifier = Modifier.weight(1f) // Занимаем оставшееся пространство
+                            ) {
+                                Text(
+                                    text = "Район: ${bench.district}",
+                                    style = MaterialTheme.typography.titleMedium,
+                                    fontSize = 14.sp,
+                                    fontFamily = montserratRegular
+                                )
+                                Text(
+                                    text = "Координаты: ${bench.coordinates}",
+                                    style = MaterialTheme.typography.titleMedium,
+                                    fontSize = 14.sp,
+                                    fontFamily = montserratRegular
+                                )
+                                Text(
+                                    text = "Состояние: ${bench.state}",
+                                    style = MaterialTheme.typography.titleMedium,
+                                    fontSize = 14.sp,
+                                    fontFamily = montserratRegular
+                                )
+                                Text(
+                                    text = "Посмотреть на карте",
+                                    style = MaterialTheme.typography.titleMedium,
+                                    fontWeight = FontWeight.SemiBold,
+                                    fontSize = 14.sp,
+                                    color = Color(0xFF72C3F1),
+                                    modifier = Modifier.clickable { /* Действие при нажатии */ }
+                                )
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}

+ 15 - 5
app/src/main/java/com/example/lectionsupabase/view/mainActivity/components/Cinema.kt

@@ -17,6 +17,7 @@ import androidx.compose.foundation.lazy.LazyColumn
 import androidx.compose.foundation.lazy.items
 import androidx.compose.foundation.shape.RoundedCornerShape
 import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.ArrowBack
 import androidx.compose.material.icons.filled.ArrowForward
 import androidx.compose.material3.Card
 import androidx.compose.material3.CardDefaults
@@ -89,16 +90,24 @@ fun Cinema(navHost: NavHostController) {
         modifier = Modifier
             .fillMaxSize()
             .padding(16.dp)
+            .padding(top = 20.dp),
     ) {
-
         Row(
             modifier = Modifier
                 .fillMaxWidth()
-                .padding(vertical = 16.dp),
+                .padding(vertical = 6.dp),
             verticalAlignment = Alignment.CenterVertically
         ) {
-            // Spacer для создания пространства между текстом и иконкой
-            Spacer(modifier = Modifier.weight(1f))
+            // Стрелка влево
+            IconButton(
+                onClick = { navHost.navigate("Restaurants")},
+            ) {
+                Icon(
+                    imageVector = Icons.Default.ArrowBack,
+                    contentDescription = "Назад",
+                    tint = Color.Black
+                )
+            }
 
             Text(
                 text = "Киноафиша",
@@ -107,7 +116,8 @@ fun Cinema(navHost: NavHostController) {
                 color = MaterialTheme.colorScheme.onBackground,
                 textAlign = TextAlign.Center,
                 fontSize = 20.sp,
-                fontFamily = montserratSemiBold
+                fontFamily = montserratSemiBold,
+                modifier = Modifier.weight(1f)
             )
 
             // Стрелка с отступом

+ 15 - 5
app/src/main/java/com/example/lectionsupabase/view/mainActivity/components/Concerts.kt

@@ -17,6 +17,7 @@ import androidx.compose.foundation.lazy.LazyColumn
 import androidx.compose.foundation.lazy.items
 import androidx.compose.foundation.shape.RoundedCornerShape
 import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.ArrowBack
 import androidx.compose.material.icons.filled.ArrowForward
 import androidx.compose.material3.Card
 import androidx.compose.material3.CardDefaults
@@ -90,16 +91,24 @@ fun Concerts(navHost: NavHostController) {
         modifier = Modifier
             .fillMaxSize()
             .padding(16.dp)
+            .padding(top = 20.dp),
     ) {
-
         Row(
             modifier = Modifier
                 .fillMaxWidth()
-                .padding(vertical = 16.dp),
+                .padding(vertical = 6.dp),
             verticalAlignment = Alignment.CenterVertically
         ) {
-            // Spacer для создания пространства между текстом и иконкой
-            Spacer(modifier = Modifier.weight(1f))
+            // Стрелка влево
+            IconButton(
+                onClick = { navHost.navigate("Cinema")},
+            ) {
+                Icon(
+                    imageVector = Icons.Default.ArrowBack,
+                    contentDescription = "Назад",
+                    tint = Color.Black
+                )
+            }
 
             Text(
                 text = "Концерты",
@@ -108,7 +117,8 @@ fun Concerts(navHost: NavHostController) {
                 color = MaterialTheme.colorScheme.onBackground,
                 textAlign = TextAlign.Center,
                 fontSize = 20.sp,
-                fontFamily = montserratSemiBold
+                fontFamily = montserratSemiBold,
+                modifier = Modifier.weight(1f)
             )
 
             // Стрелка с отступом

+ 19 - 9
app/src/main/java/com/example/lectionsupabase/view/mainActivity/components/Exhibition.kt

@@ -17,6 +17,7 @@ import androidx.compose.foundation.lazy.LazyColumn
 import androidx.compose.foundation.lazy.items
 import androidx.compose.foundation.shape.RoundedCornerShape
 import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.ArrowBack
 import androidx.compose.material.icons.filled.ArrowForward
 import androidx.compose.material3.Card
 import androidx.compose.material3.CardDefaults
@@ -90,17 +91,25 @@ fun Exhibition(navHost: NavHostController) {
         modifier = Modifier
             .fillMaxSize()
             .padding(16.dp)
+            .padding(top = 20.dp),
     ) {
-
         Row(
             modifier = Modifier
                 .fillMaxWidth()
-                .padding(vertical = 16.dp),
+                .padding(vertical = 6.dp),
             verticalAlignment = Alignment.CenterVertically
         ) {
-            // Spacer для создания пространства между текстом и иконкой
-            Spacer(modifier = Modifier.weight(1f))
-
+            // Стрелка влево
+            IconButton(
+                onClick = { navHost.navigate("Concerts")},
+                modifier = Modifier.padding(end = 8.dp)
+            ) {
+                Icon(
+                    imageVector = Icons.Default.ArrowBack,
+                    contentDescription = "Назад",
+                    tint = Color.Black
+                )
+            }
             Text(
                 text = "Выставки",
                 style = MaterialTheme.typography.headlineMedium,
@@ -108,13 +117,14 @@ fun Exhibition(navHost: NavHostController) {
                 color = MaterialTheme.colorScheme.onBackground,
                 textAlign = TextAlign.Center,
                 fontSize = 20.sp,
-                fontFamily = montserratSemiBold
+                fontFamily = montserratSemiBold,
+                modifier = Modifier.weight(1f)
             )
 
             // Стрелка с отступом
             IconButton(
-                onClick = { navHost.navigate("Concerts") },
-                modifier = Modifier.padding(start = 8.dp) // Отступ слева для стрелки
+                onClick = { navHost.navigate("Benchs") },
+                // Отступ слева для стрелки
             ) {
                 Icon(
                     imageVector = Icons.Default.ArrowForward,
@@ -125,7 +135,7 @@ fun Exhibition(navHost: NavHostController) {
         }
 
 
-        // Загрузка ресторанов
+
         if (loadingEx) {
             Box(
                 modifier = Modifier.fillMaxSize(),

+ 13 - 5
app/src/main/java/com/example/lectionsupabase/view/mainActivity/components/Restaurants.kt

@@ -16,6 +16,7 @@ import androidx.compose.foundation.lazy.LazyColumn
 import androidx.compose.foundation.lazy.items
 import androidx.compose.foundation.shape.RoundedCornerShape
 import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.ArrowBack
 import androidx.compose.material.icons.filled.ArrowForward
 import androidx.compose.material3.Button
 import androidx.compose.material3.ButtonDefaults
@@ -90,21 +91,28 @@ fun Restaurants(navHost: NavHostController) {
         }
     }
 
-    // Основное содержимое экрана
     Column(
         modifier = Modifier
             .fillMaxSize()
             .padding(16.dp)
+            .padding(top = 20.dp),
     ) {
-        // Верхняя панель с заголовком и кнопкой перехода
         Row(
             modifier = Modifier
                 .fillMaxWidth()
-                .padding(vertical = 16.dp),
+                .padding(vertical = 6.dp),
             verticalAlignment = Alignment.CenterVertically
         ) {
-            // Spacer для создания пространства между текстом и иконкой
-            Spacer(modifier = Modifier.weight(1f))
+            // Стрелка влево
+            IconButton(
+                onClick = { navHost.navigate("Restaurants")},
+            ) {
+                Icon(
+                    imageVector = Icons.Default.ArrowBack,
+                    contentDescription = "Назад",
+                    tint = Color.Black
+                )
+            }
 
             Text(
                 text = "Рестораны",