Jelajahi Sumber

restaurants

oleg 1 Minggu lalu
induk
melakukan
e64ce4473a

+ 0 - 1
.idea/misc.xml

@@ -1,4 +1,3 @@
-<?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 - 0
app/build.gradle.kts

@@ -64,6 +64,7 @@ dependencies {
     implementation(libs.androidx.espresso.core)
     implementation(libs.androidx.navigation.compose)
     implementation(libs.androidx.runtime.livedata)
+    implementation(libs.androidx.tools.core)
     testImplementation(libs.junit)
     androidTestImplementation(libs.androidx.junit)
     androidTestImplementation(libs.androidx.espresso.core)

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

@@ -19,7 +19,7 @@ import slide3
 fun Navigation() {
     val navController = rememberNavController()
     NavHost(navController = navController,
-        startDestination = "slide3")
+        startDestination = "auth")
     {
         composable("auth") {
             auth(navController, MainViewModel())

+ 9 - 5
app/src/main/java/com/example/lectionsupabase/view/mainActivity/MainViewModel.kt

@@ -4,7 +4,9 @@ import androidx.lifecycle.LiveData
 import androidx.lifecycle.MutableLiveData
 import androidx.lifecycle.ViewModel
 import androidx.lifecycle.viewModelScope
+import androidx.navigation.NavController
 import androidx.navigation.NavHostController
+import androidx.privacysandbox.tools.core.model.Constant
 import com.example.lectionsupabase.domain.utils.Constants
 import io.github.jan.supabase.gotrue.auth
 import io.github.jan.supabase.gotrue.providers.builtin.Email
@@ -15,18 +17,20 @@ class MainViewModel : ViewModel() {
     private val _loginResult = MutableLiveData<Boolean>()
     val loginResult: LiveData<Boolean> = _loginResult
 
-    fun onSignInEmailPassword(emailUser: String, passwordUser: String) {
+    fun onSignInEmailPassword(emailUser: String, passwordUser: String, navController: NavController) {
         viewModelScope.launch {
             try {
                 val user = Constants.supabase.auth.signInWith(Email) {
                     email = emailUser
                     password = passwordUser
                 }
-                println("Success: ${user.toString()}")
-                _loginResult.postValue(true) // Обновляем результат
+                println(user.toString())
+                println(Constants.supabase.auth.currentUserOrNull()!!.id)
+                println("Success")
+                navController.navigate("slide1")
             } catch (e: Exception) {
-                println("Error: ${e.message}")
-                _loginResult.postValue(false) // В случае ошибки
+                println("Error")
+                println(e.message.toString())
             }
         }
     }

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

@@ -1,4 +1,5 @@
 package com.example.lectionsupabase.view.mainActivity.components
+import androidx.compose.foundation.BorderStroke
 import androidx.compose.foundation.Image
 import androidx.compose.foundation.layout.Arrangement
 import androidx.compose.foundation.layout.Box
@@ -35,11 +36,15 @@ import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.layout.ContentScale
+import androidx.compose.ui.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.Cars
@@ -53,8 +58,13 @@ fun Restaurants(navHost: NavHostController) {
     var loadingRest 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 montserratExtraBold = FontFamily(Font(R.font.mon_extrabold))
+    val montserratRegular = FontFamily(Font(R.font.mon_regular))
+    val montserratMedium = FontFamily(Font(R.font.mon_medium))
+    val montserratLigth = FontFamily(Font(R.font.mon_light))
 
-    // Загружаем список автомобилей
+    // Загружаем список ресторанов
     LaunchedEffect(Unit) {
         try {
             restaurants = Constants.supabase.from("Restaurants")
@@ -62,7 +72,7 @@ fun Restaurants(navHost: NavHostController) {
                 .decodeList<Restaurants>()
             loadingRest = false
         } catch (e: Exception) {
-            println("Error loading cars: ${e.message}")
+            println("Error loading restaurants: ${e.message}")
             loadingRest = false
         }
     }
@@ -91,17 +101,24 @@ fun Restaurants(navHost: NavHostController) {
             modifier = Modifier
                 .fillMaxWidth()
                 .padding(vertical = 16.dp),
-            verticalAlignment = Alignment.CenterVertically,
-            horizontalArrangement = Arrangement.SpaceBetween
+            verticalAlignment = Alignment.CenterVertically
         ) {
+            // Spacer для создания пространства между текстом и иконкой
+            Spacer(modifier = Modifier.weight(1f))
+
             Text(
                 text = "Рестораны",
                 style = MaterialTheme.typography.headlineMedium,
                 fontWeight = FontWeight.Bold,
-                color = MaterialTheme.colorScheme.onBackground
+                color = MaterialTheme.colorScheme.onBackground,
+                textAlign = TextAlign.Center,
+                fontSize = 25.sp
             )
+
+            // Стрелка с отступом
             IconButton(
-                onClick = { navHost.navigate("Cinema") }
+                onClick = { navHost.navigate("Cinema") },
+                modifier = Modifier.padding(start = 8.dp) // Отступ слева для стрелки
             ) {
                 Icon(
                     imageVector = Icons.Default.ArrowForward,
@@ -111,7 +128,8 @@ fun Restaurants(navHost: NavHostController) {
             }
         }
 
-        // Загрузка автомобилей
+
+        // Загрузка ресторанов
         if (loadingRest) {
             Box(
                 modifier = Modifier.fillMaxSize(),
@@ -120,7 +138,7 @@ fun Restaurants(navHost: NavHostController) {
                 CircularProgressIndicator(modifier = Modifier.size(72.dp))
             }
         } else {
-            // Список автомобилей
+            // Список ресторанов
             LazyColumn(
                 modifier = Modifier
                     .fillMaxHeight(0.9f) // Оставляем немного места для кнопки
@@ -133,31 +151,11 @@ fun Restaurants(navHost: NavHostController) {
                             .fillMaxWidth()
                             .padding(8.dp),
                         elevation = CardDefaults.cardElevation(0.dp),
-                        shape = RoundedCornerShape(8.dp),
-                        colors = CardDefaults.cardColors(containerColor = Color(0XFFcce6ff))
+                        shape = RoundedCornerShape(20.dp),
+                        colors = CardDefaults.cardColors(containerColor = Color.White),
+                        border = BorderStroke(0.5.dp, Color.LightGray) // Светло-серая окантовка
                     ) {
                         Column(modifier = Modifier.fillMaxWidth()) {
-                            Text(
-                                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 = restaurant.picture,
                                 builder = {
@@ -170,14 +168,54 @@ fun Restaurants(navHost: NavHostController) {
                                 contentDescription = "Фото ресторана",
                                 modifier = Modifier
                                     .fillMaxWidth()
-                                    .height(200.dp),
+                                    .height(190.dp),
                                 contentScale = ContentScale.Crop
                             )
+                            Spacer(modifier = Modifier.height(10.dp))
+                            // Информация о ресторане
+                            Text(
+                                text = "Название: ${restaurant.name}",
+                                style = MaterialTheme.typography.titleMedium,
+                                fontSize = 14.sp,
+                                modifier = Modifier.padding(horizontal = 10.dp)
+                                .padding(start = 3.dp),
+                                fontFamily = montserratRegular
+                            )
+                            Text(
+                                text = "Адрес: ${restaurant.location}",
+                                style = MaterialTheme.typography.titleMedium,
+                                fontSize = 14.sp,
+                                modifier = Modifier.padding(horizontal = 10.dp)
+                                    .padding(start = 3.dp),
+                                fontFamily = montserratRegular
+                            )
+                            Text(
+                                text = "Кухня: ${restaurant.cuisin}",
+                                style = MaterialTheme.typography.titleMedium,
+                                fontSize = 14.sp,
+                                modifier = Modifier.padding(horizontal = 10.dp)
+                                    .padding(start = 3.dp),
+                                fontFamily = montserratRegular,
+
+                            )
+                            Text(
+                                text = "Посмотреть на карте",
+                                style = MaterialTheme.typography.titleMedium,
+                                fontWeight = FontWeight.SemiBold,
+                                fontSize = 14.sp,
+                                modifier = Modifier.padding(horizontal = 10.dp)
+                                    .padding(start = 3.dp),
+                                fontFamily = montserratMedium,
+                                color = Color(0xFF72C3F1)
+                            )
+                            Spacer(modifier = Modifier.height(10.dp))
                         }
                     }
                 }
             }
         }
+    }
+}
 
 
 //        val userId = Constants.supabase.auth.currentUserOrNull()?.id
@@ -203,8 +241,6 @@ fun Restaurants(navHost: NavHostController) {
 //                    Text("Добавить новый автомобиль", fontSize = 18.sp)
 //                }
 //            }
-        }
-    }
 
 
 

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

@@ -58,9 +58,9 @@ fun auth(navHostController: NavHostController, viewModel: MainViewModel) {
     val email = remember { mutableStateOf("") }
     val password = remember { mutableStateOf("") }
     var passwordVisibility by remember { mutableStateOf(false) }
-    val montserratSemiBold = FontFamily(Font(R.font.mon_semibold) )
-    val montserratRegular = FontFamily(Font(R.font.mon_regular) )
-    val montserratMedium = FontFamily(Font(R.font.mon_medium) )
+    val montserratSemiBold = FontFamily(Font(R.font.mon_semibold))
+    val montserratRegular = FontFamily(Font(R.font.mon_regular))
+    val montserratMedium = FontFamily(Font(R.font.mon_medium))
     val loginResult by viewModel.loginResult.observeAsState()
 
     Column(
@@ -74,14 +74,22 @@ fun auth(navHostController: NavHostController, viewModel: MainViewModel) {
         Spacer(modifier = Modifier.height(150.dp))
         Text(
             text = "BenchMap",
-            style = TextStyle(fontSize = 35.sp, fontWeight = FontWeight.SemiBold, fontFamily = montserratSemiBold),
+            style = TextStyle(
+                fontSize = 35.sp,
+                fontWeight = FontWeight.SemiBold,
+                fontFamily = montserratSemiBold
+            ),
             color = Color.White
         )
         Spacer(modifier = Modifier.height(16.dp))
 
         Text(
             text = "Найдите место куда сходить",
-            style = TextStyle(fontSize = 19.sp, fontWeight = FontWeight.Normal, fontFamily = montserratRegular),
+            style = TextStyle(
+                fontSize = 19.sp,
+                fontWeight = FontWeight.Normal,
+                fontFamily = montserratRegular
+            ),
             color = Color.White,
             modifier = Modifier.padding(bottom = 32.dp)
         )
@@ -137,7 +145,7 @@ fun auth(navHostController: NavHostController, viewModel: MainViewModel) {
                     },
                     textStyle = TextStyle(fontSize = 18.sp, color = Color.White),
                     colors = TextFieldDefaults.textFieldColors(
-                        focusedIndicatorColor = Color .Transparent,
+                        focusedIndicatorColor = Color.Transparent,
                         unfocusedIndicatorColor = Color.Transparent,
                         containerColor = Color(0xFF96C7E5)
                     )
@@ -146,7 +154,13 @@ fun auth(navHostController: NavHostController, viewModel: MainViewModel) {
 
                 // Кнопка
                 Button(
-                    onClick = { viewModel.onSignInEmailPassword(email.value, password.value) },
+                    onClick = {
+                        viewModel.onSignInEmailPassword(
+                            email.value,
+                            password.value,
+                            navHostController
+                        )
+                    },
                     modifier = Modifier
                         .fillMaxWidth()
                         .height(46.dp),
@@ -158,7 +172,11 @@ fun auth(navHostController: NavHostController, viewModel: MainViewModel) {
                 ) {
                     Text(
                         "Вход",
-                        style = TextStyle(fontSize = 18.sp, fontWeight = FontWeight.SemiBold, fontFamily = montserratSemiBold)
+                        style = TextStyle(
+                            fontSize = 18.sp,
+                            fontWeight = FontWeight.SemiBold,
+                            fontFamily = montserratSemiBold
+                        )
                     )
                 }
             }
@@ -167,27 +185,21 @@ fun auth(navHostController: NavHostController, viewModel: MainViewModel) {
         // Кнопка регистрации вынесена за пределы Box
         Spacer(modifier = Modifier.height(285.dp)) // Отступ перед кнопкой регистрации
         TextButton(
-            onClick = { navHostController.navigate("reg")
+            onClick = {
+                navHostController.navigate("reg")
             },
             modifier = Modifier.align(Alignment.CenterHorizontally)
         ) {
             Text(
                 text = "Еще нет аккаунта? Зарегистрируйтесь",
-                style = TextStyle(fontSize = 17.sp, color = Color.White, fontFamily = montserratMedium)
+                style = TextStyle(
+                    fontSize = 17.sp,
+                    color = Color.White,
+                    fontFamily = montserratMedium
+                )
             )
         }
     }
-
-    loginResult?.let {
-        if (it) {
-            navHostController.navigate("slide1") {
-                popUpTo(navHostController.graph.startDestinationId) {
-                    inclusive = true
-                }
-            }
-        } else {
-            Toast.makeText(LocalContext.current, "Ошибка авторизации", Toast.LENGTH_SHORT).show()
-        }
-    }
 }
 
+

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

@@ -82,7 +82,7 @@ fun slide1(navController: NavHostController) {
         Text(
             text = "Узнавайте о интересных местах \n в вашем городе",
             fontFamily = montserratRegular,
-            fontSize = 17.sp,
+            fontSize = 14.sp,
             color = Color(0xFFA2A2A2),
             modifier = Modifier.align(Alignment.CenterHorizontally)
                 .padding(vertical = 10.dp),
@@ -113,15 +113,15 @@ fun slide1(navController: NavHostController) {
         Button(
             onClick = { navController.navigate("slide2") },
             modifier = Modifier
-                .width(280.dp)
-                .height(39.dp),
+                .width(300.dp)
+                .height(44.dp),
             shape = RoundedCornerShape(5.dp),
             colors = ButtonDefaults.buttonColors(
                 containerColor = Color(0xFFA3D6F1),
                 contentColor = Color.White
             )
         ) {
-            Text("Далее", fontSize = 18.sp, fontFamily = montserratSemiBold)
+            Text("Далее", fontSize = 17.sp, fontFamily = montserratSemiBold)
         }
     }
 }

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

@@ -80,7 +80,7 @@ fun slide2(navController: NavHostController) {
         Text(
             text = "Проверяйте ленту и следите за \n обновлением подборки",
             fontFamily = montserratRegular,
-            fontSize = 17.sp,
+            fontSize = 14.sp,
             color = Color(0xFFA2A2A2),
             modifier = Modifier.align(Alignment.CenterHorizontally)
                 .padding(vertical = 10.dp),
@@ -111,15 +111,15 @@ fun slide2(navController: NavHostController) {
         Button(
             onClick = { navController.navigate("slide3") },
             modifier = Modifier
-                .width(280.dp)
-                .height(39.dp),
+                .width(300.dp)
+                .height(44.dp),
             shape = RoundedCornerShape(5.dp),
             colors = ButtonDefaults.buttonColors(
                 containerColor = Color(0xFFA3D6F1),
                 contentColor = Color.White
             )
         ) {
-            Text("Далее", fontSize = 18.sp, fontFamily = montserratSemiBold)
+            Text("Далее", fontSize = 17.sp, fontFamily = montserratSemiBold)
         }
     }
 }

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

@@ -80,7 +80,7 @@ fun slide3(navController: NavHostController) {
         Text(
             text = "Посещайте новые места в вашем городе \n первым и добавляйте свой отзыв",
             fontFamily = montserratRegular,
-            fontSize = 17.sp,
+            fontSize = 14.sp,
             color = Color(0xFFA2A2A2),
             modifier = Modifier.align(Alignment.CenterHorizontally)
                 .padding(vertical = 10.dp),
@@ -111,15 +111,15 @@ fun slide3(navController: NavHostController) {
         Button(
             onClick = { navController.navigate("Restaurants") },
             modifier = Modifier
-                .width(280.dp)
-                .height(39.dp),
+                .width(300.dp)
+                .height(44.dp),
             shape = RoundedCornerShape(5.dp),
             colors = ButtonDefaults.buttonColors(
                 containerColor = Color(0xFFA3D6F1),
                 contentColor = Color.White
             )
         ) {
-            Text("К интересным местам", fontSize = 18.sp, fontFamily = montserratSemiBold)
+            Text("К интересным местам", fontSize = 17.sp, fontFamily = montserratSemiBold)
         }
     }
 }

+ 2 - 0
gradle/libs.versions.toml

@@ -18,6 +18,7 @@ xmodule_z = "2.6.0"
 volley = "1.2.1"
 navigationCompose = "2.8.1"
 runtimeLivedata = "1.7.2"
+toolsCore = "1.0.0-alpha10"
 
 [libraries]
 androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -49,6 +50,7 @@ xmodule_z = { module = "io.github.jan-tennert.supabase:[module]", version.ref =
 volley = { group = "com.android.volley", name = "volley", version.ref = "volley" }
 androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigationCompose" }
 androidx-runtime-livedata = { group = "androidx.compose.runtime", name = "runtime-livedata", version.ref = "runtimeLivedata" }
+androidx-tools-core = { group = "androidx.privacysandbox.tools", name = "tools-core", version.ref = "toolsCore" }
 
 [plugins]
 android-application = { id = "com.android.application", version.ref = "agp" }