unknown 1 week ago
parent
commit
211b3c7d85

+ 123 - 0
.idea/codeStyles/Project.xml

@@ -0,0 +1,123 @@
+<component name="ProjectCodeStyleConfiguration">
+  <code_scheme name="Project" version="173">
+    <JetCodeStyleSettings>
+      <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
+    </JetCodeStyleSettings>
+    <codeStyleSettings language="XML">
+      <option name="FORCE_REARRANGE_MODE" value="1" />
+      <indentOptions>
+        <option name="CONTINUATION_INDENT_SIZE" value="4" />
+      </indentOptions>
+      <arrangement>
+        <rules>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>xmlns:android</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>^$</XML_NAMESPACE>
+                </AND>
+              </match>
+            </rule>
+          </section>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>xmlns:.*</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>^$</XML_NAMESPACE>
+                </AND>
+              </match>
+              <order>BY_NAME</order>
+            </rule>
+          </section>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>.*:id</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+                </AND>
+              </match>
+            </rule>
+          </section>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>.*:name</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+                </AND>
+              </match>
+            </rule>
+          </section>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>name</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>^$</XML_NAMESPACE>
+                </AND>
+              </match>
+            </rule>
+          </section>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>style</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>^$</XML_NAMESPACE>
+                </AND>
+              </match>
+            </rule>
+          </section>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>.*</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>^$</XML_NAMESPACE>
+                </AND>
+              </match>
+              <order>BY_NAME</order>
+            </rule>
+          </section>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>.*</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+                </AND>
+              </match>
+              <order>ANDROID_ATTRIBUTE_ORDER</order>
+            </rule>
+          </section>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>.*</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>.*</XML_NAMESPACE>
+                </AND>
+              </match>
+              <order>BY_NAME</order>
+            </rule>
+          </section>
+        </rules>
+      </arrangement>
+    </codeStyleSettings>
+    <codeStyleSettings language="kotlin">
+      <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
+    </codeStyleSettings>
+  </code_scheme>
+</component>

+ 5 - 0
.idea/codeStyles/codeStyleConfig.xml

@@ -0,0 +1,5 @@
+<component name="ProjectCodeStyleConfiguration">
+  <state>
+    <option name="USE_PER_PROJECT_SETTINGS" value="true" />
+  </state>
+</component>

+ 1 - 0
.idea/misc.xml

@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ExternalStorageConfigurationManager" enabled="true" />
   <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">

+ 1 - 1
app/build.gradle.kts

@@ -81,6 +81,6 @@ dependencies {
     implementation(libs.storage.kt)
 
     implementation(libs.coil.compose)
-    implementation("io.github.jan-tennert.supabase:storage-kt:2.6.1")
+    implementation(libs.storage.kt.v261)
 
 }

+ 1 - 1
app/src/main/AndroidManifest.xml

@@ -2,7 +2,7 @@
 <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.INTERNET"/>
 
 
     <application

+ 12 - 0
app/src/main/java/com/example/lectionsupabase/model/Restaurants.kt

@@ -0,0 +1,12 @@
+package com.example.lectionsupabase.model
+
+import kotlinx.serialization.Serializable
+
+@Serializable
+data class Restaurants(
+    val id: Int,
+    val name: String,
+    val location: String,
+    val cuisin: String,
+    val picture: String?
+)

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

@@ -6,9 +6,9 @@ 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.CarsList
 import com.example.lectionsupabase.view.mainActivity.components.DealersList
 import com.example.lectionsupabase.view.mainActivity.components.InsertCar
+import com.example.lectionsupabase.view.mainActivity.components.Restaurants
 import com.example.lectionsupabase.view.mainActivity.components.reg
 import com.example.lectionsupabase.view.mainActivity.components.slide1
 import slide2
@@ -19,7 +19,7 @@ import slide3
 fun Navigation() {
     val navController = rememberNavController()
     NavHost(navController = navController,
-        startDestination = "auth")
+        startDestination = "slide3")
     {
         composable("auth") {
             auth(navController, MainViewModel())
@@ -37,8 +37,8 @@ fun Navigation() {
         composable("slide1"){
             slide1(navController)
         }
-        composable("CarsList"){
-            CarsList(navController)
+        composable("Restaurants"){
+            Restaurants(navController)
         }
         composable("DealersList"){
             DealersList(navController)

+ 0 - 1
app/src/main/java/com/example/lectionsupabase/view/mainActivity/MainActivity.kt

@@ -11,7 +11,6 @@ import androidx.compose.material3.Scaffold
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import com.example.lectionsupabase.ui.theme.LectionSupaBaseTheme
-import com.example.lectionsupabase.view.mainActivity.components.CarsList
 
 import com.example.test.navigation.Navigation
 

+ 54 - 40
app/src/main/java/com/example/lectionsupabase/view/mainActivity/components/CarsList.kt → app/src/main/java/com/example/lectionsupabase/view/mainActivity/components/Restaurants.kt

@@ -40,30 +40,30 @@ 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.Cars
+import com.example.lectionsupabase.model.Restaurants
 import io.github.jan.supabase.gotrue.auth
 import io.github.jan.supabase.postgrest.from
 
 @Composable
-fun CarsList(navHost: NavHostController) {
-    var cars by remember { mutableStateOf<List<Cars>>(listOf()) }
-    var loadingCars by remember { mutableStateOf(true) }
+fun Restaurants(navHost: NavHostController) {
+    var restaurants by remember { mutableStateOf<List<Restaurants>>(listOf()) }
+    var loadingRest by remember { mutableStateOf(true) }
     var loadingUsers by remember { mutableStateOf(true) }
     var users by remember { mutableStateOf<List<Admin>>(listOf()) }
 
     // Загружаем список автомобилей
     LaunchedEffect(Unit) {
         try {
-            cars = Constants.supabase.from("Cars")
+            restaurants = Constants.supabase.from("Restaurants")
                 .select()
-                .decodeList<Cars>()
-            loadingCars = false
+                .decodeList<Restaurants>()
+            loadingRest = false
         } catch (e: Exception) {
             println("Error loading cars: ${e.message}")
-            loadingCars = false
+            loadingRest = false
         }
     }
 
@@ -95,24 +95,24 @@ fun CarsList(navHost: NavHostController) {
             horizontalArrangement = Arrangement.SpaceBetween
         ) {
             Text(
-                text = "Модельный ряд Lexus",
+                text = "Рестораны",
                 style = MaterialTheme.typography.headlineMedium,
                 fontWeight = FontWeight.Bold,
                 color = MaterialTheme.colorScheme.onBackground
             )
             IconButton(
-                onClick = { navHost.navigate("DealersList") }
+                onClick = { navHost.navigate("Cinema") }
             ) {
                 Icon(
                     imageVector = Icons.Default.ArrowForward,
-                    contentDescription = "Перейти к дилерам",
+                    contentDescription = "Перейти к киноафише",
                     tint = MaterialTheme.colorScheme.primary
                 )
             }
         }
 
         // Загрузка автомобилей
-        if (loadingCars) {
+        if (loadingRest) {
             Box(
                 modifier = Modifier.fillMaxSize(),
                 contentAlignment = Alignment.Center
@@ -127,7 +127,7 @@ fun CarsList(navHost: NavHostController) {
                     .padding(bottom = 16.dp),
                 verticalArrangement = Arrangement.spacedBy(16.dp)
             ) {
-                items(cars, key = { car -> car.id }) { car ->
+                items(restaurants, key = { restaurant -> restaurant.id }) { restaurant ->
                     Card(
                         modifier = Modifier
                             .fillMaxWidth()
@@ -138,14 +138,28 @@ fun CarsList(navHost: NavHostController) {
                     ) {
                         Column(modifier = Modifier.fillMaxWidth()) {
                             Text(
-                                text = "${car.brand} ${car.model}",
+                                text = "${restaurant.name}",
+                                style = MaterialTheme.typography.titleMedium,
+                                fontWeight = FontWeight.SemiBold,
+                                fontSize = 18.sp,
+                                modifier = Modifier.padding(16.dp)
+                            )
+                            Text(
+                                text = "${restaurant.location}",
+                                style = MaterialTheme.typography.titleMedium,
+                                fontWeight = FontWeight.SemiBold,
+                                fontSize = 18.sp,
+                                modifier = Modifier.padding(16.dp)
+                            )
+                            Text(
+                                text = "${restaurant.cuisin}",
                                 style = MaterialTheme.typography.titleMedium,
                                 fontWeight = FontWeight.SemiBold,
                                 fontSize = 18.sp,
                                 modifier = Modifier.padding(16.dp)
                             )
                             val painter = rememberImagePainter(
-                                data = car.image,
+                                data = restaurant.picture,
                                 builder = {
                                     crossfade(true)
                                 }
@@ -153,7 +167,7 @@ fun CarsList(navHost: NavHostController) {
 
                             Image(
                                 painter = painter,
-                                contentDescription = "Фото автомобиля",
+                                contentDescription = "Фото ресторана",
                                 modifier = Modifier
                                     .fillMaxWidth()
                                     .height(200.dp),
@@ -165,33 +179,33 @@ fun CarsList(navHost: NavHostController) {
             }
         }
 
-        // Кнопка "Добавить новый автомобиль" только для администраторов
-        val userId = Constants.supabase.auth.currentUserOrNull()?.id
-        val userIdString = userId?.toString() ?: ""
 
-        if (!loadingUsers && userId != null) {
-            val user = users.find { it.id_user == userIdString }
-            if (user != null) {
-                Spacer(modifier = Modifier.weight(1f)) // Занимаем оставшееся пространство для размещения кнопки внизу
-                Button(
-                    onClick = { navHost.navigate("InsertCar") },
-                    modifier = Modifier
-                        .fillMaxWidth()
-                        .height(56.dp)
-                        .padding(8.dp)
-                        .padding(bottom = 24.dp),
-                shape = RoundedCornerShape(12.dp), // Кнопка с более квадратными углами
-                    colors = ButtonDefaults.buttonColors(
-                        containerColor = Color(0XFFcce6ff),
-                        contentColor = Color.White
-                    )
-                ) {
-                    Text("Добавить новый автомобиль", fontSize = 18.sp)
-                }
-            }
+//        val userId = Constants.supabase.auth.currentUserOrNull()?.id
+//        val userIdString = userId?.toString() ?: ""
+//
+//        if (!loadingUsers && userId != null) {
+//            val user = users.find { it.id_user == userIdString }
+//            if (user != null) {
+//                Spacer(modifier = Modifier.weight(1f)) // Занимаем оставшееся пространство для размещения кнопки внизу
+//                Button(
+//                    onClick = { navHost.navigate("InsertCar") },
+//                    modifier = Modifier
+//                        .fillMaxWidth()
+//                        .height(56.dp)
+//                        .padding(8.dp)
+//                        .padding(bottom = 24.dp),
+//                shape = RoundedCornerShape(12.dp), // Кнопка с более квадратными углами
+//                    colors = ButtonDefaults.buttonColors(
+//                        containerColor = Color(0XFFcce6ff),
+//                        contentColor = Color.White
+//                    )
+//                ) {
+//                    Text("Добавить новый автомобиль", fontSize = 18.sp)
+//                }
+//            }
         }
     }
-}
+
 
 
 

+ 4 - 3
app/src/main/java/com/example/lectionsupabase/view/mainActivity/components/auth.kt

@@ -71,7 +71,7 @@ fun auth(navHostController: NavHostController, viewModel: MainViewModel) {
         verticalArrangement = Arrangement.Center,
         horizontalAlignment = Alignment.CenterHorizontally
     ) {
-        Spacer(modifier = Modifier.height(80.dp))
+        Spacer(modifier = Modifier.height(150.dp))
         Text(
             text = "BenchMap",
             style = TextStyle(fontSize = 35.sp, fontWeight = FontWeight.SemiBold, fontFamily = montserratSemiBold),
@@ -85,7 +85,7 @@ fun auth(navHostController: NavHostController, viewModel: MainViewModel) {
             color = Color.White,
             modifier = Modifier.padding(bottom = 32.dp)
         )
-        Spacer(modifier = Modifier.height(40.dp))
+        Spacer(modifier = Modifier.height(20.dp))
         Box(
             modifier = Modifier
                 .size(370.dp, 260.dp) // Размеры формы
@@ -130,6 +130,7 @@ fun auth(navHostController: NavHostController, viewModel: MainViewModel) {
                                 imageVector = if (passwordVisibility) ImageVector.vectorResource(id = R.drawable.baseline_person_24) else ImageVector.vectorResource(
                                     id = R.drawable.baseline_person_off_24
                                 ),
+                                tint = Color.Black,
                                 contentDescription = if (passwordVisibility) "Скрыть пароль" else "Показать пароль"
                             )
                         }
@@ -164,7 +165,7 @@ fun auth(navHostController: NavHostController, viewModel: MainViewModel) {
         }
 
         // Кнопка регистрации вынесена за пределы Box
-        Spacer(modifier = Modifier.height(245.dp)) // Отступ перед кнопкой регистрации
+        Spacer(modifier = Modifier.height(285.dp)) // Отступ перед кнопкой регистрации
         TextButton(
             onClick = { navHostController.navigate("reg")
             },

+ 3 - 3
app/src/main/java/com/example/lectionsupabase/view/mainActivity/components/reg.kt

@@ -73,7 +73,7 @@ fun reg(navHostController: NavHostController, viewModel: MainViewModel) {
         verticalArrangement = Arrangement.Center,
         horizontalAlignment = Alignment.CenterHorizontally
     ) {
-        Spacer(modifier = Modifier.height(80.dp))
+        Spacer(modifier = Modifier.height(150.dp))
         Text(
             text = "BenchMap",
             style = TextStyle(fontSize = 35.sp, fontWeight = FontWeight.SemiBold, fontFamily = montserratSemiBold),
@@ -87,7 +87,7 @@ fun reg(navHostController: NavHostController, viewModel: MainViewModel) {
             color = Color.White,
             modifier = Modifier.padding(bottom = 32.dp)
         )
-        Spacer(modifier = Modifier.height(40.dp))
+        Spacer(modifier = Modifier.height(20.dp))
         Box(
             modifier = Modifier
                 .size(370.dp, 260.dp) // Размеры формы
@@ -166,7 +166,7 @@ fun reg(navHostController: NavHostController, viewModel: MainViewModel) {
         }
 
         // Кнопка регистрации вынесена за пределы Box
-        Spacer(modifier = Modifier.height(245.dp)) // Отступ перед кнопкой регистрации
+        Spacer(modifier = Modifier.height(285.dp)) // Отступ перед кнопкой регистрации
         TextButton(
             onClick = { navHostController.navigate("auth")
             },

+ 1 - 1
app/src/main/java/com/example/lectionsupabase/view/mainActivity/components/slide3.kt

@@ -109,7 +109,7 @@ fun slide3(navController: NavHostController) {
         Spacer(modifier = Modifier.height(30.dp))
         // Кнопка "Далее" внизу
         Button(
-            onClick = { navController.navigate("nextScreen") },
+            onClick = { navController.navigate("Restaurants") },
             modifier = Modifier
                 .width(280.dp)
                 .height(39.dp),

+ 2 - 0
gradle/libs.versions.toml

@@ -13,6 +13,7 @@ lifecycleRuntimeKtx = "2.6.1"
 activityCompose = "1.8.0"
 composeBom = "2024.04.01"
 storageKt = "2.0.4"
+storageKtVersion = "2.6.1"
 xmodule_z = "2.6.0"
 volley = "1.2.1"
 navigationCompose = "2.8.1"
@@ -41,6 +42,7 @@ ktor-client-engine_z = { module = "io.ktor:ktor-client-[engine]", version.ref =
 realtime-kt = { module = "io.github.jan-tennert.supabase:realtime-kt" }
 postgrest-kt = { module = "io.github.jan-tennert.supabase:postgrest-kt" }
 storage-kt = { module = "io.github.jan-tennert.supabase:storage-kt", version.ref = "storageKt" }
+storage-kt-v261 = { module = "io.github.jan-tennert.supabase:storage-kt", version.ref = "storageKtVersion" }
 supabase-realtime-kt = { module = "io.github.jan-tennert.supabase:realtime-kt" }
 supabase-postgrest-kt = { module = "io.github.jan-tennert.supabase:postgrest-kt" }
 xmodule_z = { module = "io.github.jan-tennert.supabase:[module]", version.ref = "xmodule_z" }