Bladeren bron

add: AdviceScreens - Advice and AdviceViewModel (Done: 90%); update: navigation, tource; fix: fix bags in LawScreen

Maksutka 2 dagen geleden
bovenliggende
commit
9a8b16f3fc
18 gewijzigde bestanden met toevoegingen van 446 en 77 verwijderingen
  1. 2 2
      TripHelper/.idea/deploymentTargetSelector.xml
  2. 1 1
      TripHelper/app/src/main/java/com/example/triphelper/model/Advice.kt
  3. 160 0
      TripHelper/app/src/main/java/com/example/triphelper/view/AdviceScreens/Advice.kt
  4. 71 0
      TripHelper/app/src/main/java/com/example/triphelper/view/AdviceScreens/AdviceViewModel.kt
  5. 44 10
      TripHelper/app/src/main/java/com/example/triphelper/view/LawScreen/LawScreen.kt
  6. 0 4
      TripHelper/app/src/main/java/com/example/triphelper/view/LawScreen/LawScreenViewModel.kt
  7. 15 3
      TripHelper/app/src/main/java/com/example/triphelper/view/MainScreen/MainScreen.kt
  8. 0 10
      TripHelper/app/src/main/java/com/example/triphelper/view/RouteScreens/AttractionsDesc.kt
  9. 0 3
      TripHelper/app/src/main/java/com/example/triphelper/view/RouteScreens/ChoiceTour.kt
  10. 0 10
      TripHelper/app/src/main/java/com/example/triphelper/view/RouteScreens/HotelsDesc.kt
  11. 0 11
      TripHelper/app/src/main/java/com/example/triphelper/view/RouteScreens/RestaurantsDesc.kt
  12. 0 16
      TripHelper/app/src/main/java/com/example/triphelper/view/RouteScreens/Tours.kt
  13. 12 1
      TripHelper/app/src/main/java/com/example/triphelper/view/navigation/Navigation.kt
  14. 1 0
      TripHelper/app/src/main/java/com/example/triphelper/view/navigation/NavigationRoutes.kt
  15. 78 6
      TripHelper/app/src/main/java/com/example/triphelper/view/style/LazyColumnStyle.kt
  16. 17 0
      TripHelper/app/src/main/res/drawable/food_advice.xml
  17. 12 0
      TripHelper/app/src/main/res/drawable/helth_advice.xml
  18. 33 0
      TripHelper/app/src/main/res/drawable/trip_advice.xml

+ 2 - 2
TripHelper/.idea/deploymentTargetSelector.xml

@@ -4,10 +4,10 @@
     <selectionStates>
       <SelectionState runConfigName="app">
         <option name="selectionMode" value="DROPDOWN" />
-        <DropdownSelection timestamp="2024-11-20T10:30:23.949012400Z">
+        <DropdownSelection timestamp="2024-11-22T20:33:49.947129Z">
           <Target type="DEFAULT_BOOT">
             <handle>
-              <DeviceId pluginId="LocalEmulator" identifier="path=C:\AndroidSettings\.android\avd\Pixel_8_API_34.avd" />
+              <DeviceId pluginId="LocalEmulator" identifier="path=C:\Users\mikam\.android\avd\Pixel_8_Pro_API_UpsideDownCakePrivacySandbox.avd" />
             </handle>
           </Target>
         </DropdownSelection>

+ 1 - 1
TripHelper/app/src/main/java/com/example/triphelper/model/Advice.kt

@@ -7,7 +7,7 @@ import kotlinx.serialization.Serializer
 @Serializable
 data class Advice(
     val id: Int,
-    val categoryAdvice: Int,
+    val category_advice: Category_advice,
     val title: String,
     val description: String
 )

+ 160 - 0
TripHelper/app/src/main/java/com/example/triphelper/view/AdviceScreens/Advice.kt

@@ -0,0 +1,160 @@
+package com.example.triphelper.view.RouteScreens
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.border
+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.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.shape.RoundedCornerShape
+import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.MutableState
+import androidx.compose.runtime.collectAsState
+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.graphics.Color
+import androidx.compose.ui.res.painterResource
+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.hilt.navigation.compose.hiltViewModel
+import androidx.navigation.NavController
+import com.example.testirovanye_supabase.R
+import com.example.triphelper.view.style.AttractionsLazy
+import com.example.triphelper.view.style.FoodAdviceLazy
+import com.example.triphelper.view.style.HotelsLazy
+import com.example.triphelper.view.style.MetroLazy
+import com.example.triphelper.view.style.RestaurantsLazy
+import com.example.triphelper.view.style.StyleMainFone
+import com.example.triphelper.view.theme.RobotoB
+import com.example.triphelper.view.theme.SeoulBold
+
+@Composable
+fun AdviceScreen(navController: NavController, iconsAdviceIsActivity: MutableState<Boolean>,  viewModel: AdviceViewModel = hiltViewModel()) {
+    iconsAdviceIsActivity.value = true
+    var foodColumn by remember { mutableStateOf(true) }
+    var tripColumn by remember { mutableStateOf(false) }
+    var helthColumn by remember { mutableStateOf(false) }
+    val advice by viewModel.advice.collectAsState(initial = emptyList())
+
+
+    LaunchedEffect(key1 = viewModel.navigationTo) {
+        viewModel.navigationTo.collect { destination ->
+            destination?.let {
+                navController.navigate(destination)
+            }
+        }
+    }
+    StyleMainFone()
+    Column(
+        modifier = Modifier
+            .fillMaxSize()
+            .padding(top = 65.dp),
+        horizontalAlignment = Alignment.CenterHorizontally
+    ) {
+        Row(
+            modifier = Modifier
+                .fillMaxWidth()
+                .padding(top = 10.dp)
+                .fillMaxHeight(0.08f)
+                .background(Color.White)
+                .border(
+                    width = 5.dp,
+                    color = Color(0xFF510B3C)
+                ),
+            verticalAlignment = Alignment.CenterVertically,
+            horizontalArrangement = Arrangement.SpaceEvenly
+        ) {
+            Box(
+                modifier = Modifier
+                    .fillMaxHeight(0.9f)
+                    .background(if (foodColumn) Color(0xFFDC5B6E).copy(alpha = 0.4f) else Color.Transparent)
+            ) {
+                IconButton(
+                    onClick = {
+                        foodColumn = true
+                        tripColumn = false
+                        helthColumn = false
+                    },
+                    modifier = Modifier
+                        .size(60.dp)
+                ) {
+                    Icon(
+                        painter = painterResource(id = R.drawable.food_advice),
+                        contentDescription = "Советы по еде",
+                        tint = Color.Unspecified,
+                        modifier = Modifier.size(50.dp)
+                    )
+                }
+            }
+            Box(
+                modifier = Modifier
+                    .fillMaxHeight(0.9f)
+                    .background(if (tripColumn) Color(0xFFDC5B6E).copy(alpha = 0.4f) else Color.Transparent)
+            ) {
+                IconButton(
+                    onClick = {
+                        foodColumn = false
+                        tripColumn = true
+                        helthColumn = false
+                    },
+                    modifier = Modifier
+                        .size(60.dp)
+                ) {
+                    Icon(
+                        painter = painterResource(id = R.drawable.trip_advice),
+                        contentDescription = "Советы по путешествию",
+                        tint = Color.Unspecified,
+                        modifier = Modifier.size(50.dp)
+                    )
+                }
+            }
+            Box(
+                modifier = Modifier
+                    .fillMaxHeight(0.9f)
+                    .background(if (helthColumn) Color(0xFFDC5B6E).copy(alpha = 0.4f) else Color.Transparent)
+            ) {
+                IconButton(
+                    onClick = {
+                        foodColumn = false
+                        tripColumn = false
+                        helthColumn = true
+                    },
+                    modifier = Modifier
+                        .size(60.dp)
+                ) {
+                    Icon(
+                        painter = painterResource(id = R.drawable.helth_advice),
+                        contentDescription = "Советы по здоровью",
+                        tint = Color.Unspecified,
+                        modifier = Modifier.size(45.dp)
+                    )
+                }
+            }
+        }
+        if (foodColumn) {
+            FoodAdviceLazy(navController,advice)
+        }
+        if (tripColumn) {
+            FoodAdviceLazy(navController,advice)
+        }
+        if(helthColumn){
+            FoodAdviceLazy(navController,advice)
+        }
+    }
+}

+ 71 - 0
TripHelper/app/src/main/java/com/example/triphelper/view/AdviceScreens/AdviceViewModel.kt

@@ -0,0 +1,71 @@
+package com.example.triphelper.view.RouteScreens
+
+import android.util.Log
+import androidx.compose.runtime.mutableStateOf
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
+import com.example.triphelper.domain.Constants
+import com.example.triphelper.model.Advice
+import com.example.triphelper.model.Attractions
+import com.example.triphelper.model.City
+import com.example.triphelper.model.Country
+import com.example.triphelper.model.Hotels
+import com.example.triphelper.model.Metro
+import com.example.triphelper.model.Organization_of_tours
+import com.example.triphelper.model.Restaurants
+import com.example.triphelper.model.Rules
+import com.example.triphelper.model.Tours
+import dagger.hilt.android.lifecycle.HiltViewModel
+import io.github.jan.supabase.postgrest.from
+import io.github.jan.supabase.postgrest.query.Columns
+import io.github.jan.supabase.postgrest.query.Order
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asStateFlow
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+import javax.inject.Inject
+
+
+@HiltViewModel
+class AdviceViewModel @Inject constructor() : ViewModel() {
+    private var _navigationTo = MutableStateFlow<String?>(null)
+    val navigationTo = _navigationTo.asStateFlow()
+
+    private val _advice: MutableStateFlow<List<Advice>> = MutableStateFlow(listOf())
+    val advice: StateFlow<List<Advice>> = _advice.asStateFlow()
+
+//    private var _foodAdvice: MutableStateFlow<List<Ad>> = MutableStateFlow(listOf())
+//    val foodAdvice: StateFlow<List<Attractions>> = _foodAdvice.asStateFlow()
+//
+//    private var _hotels: MutableStateFlow<List<Hotels>> = MutableStateFlow(listOf())
+//    val hotels: StateFlow<List<Hotels>> = _hotels.asStateFlow()
+//
+//    private var _restaurants: MutableStateFlow<List<Restaurants>> = MutableStateFlow(listOf())
+//    val restaurants: StateFlow<List<Restaurants>> = _restaurants.asStateFlow()
+
+    fun GetAdvice(titleCatAdvice: String) {
+        viewModelScope.launch {
+            withContext(Dispatchers.IO) {
+                val columns = Columns.raw("""
+                    id,
+                    category_advice!inner(id,title),
+                    title,
+                    description
+                """.trimIndent()
+                )
+                val responce = Constants.supabase.from("advices").select(
+                    columns = columns
+                ) {
+                    filter {
+                        eq("category_advice.title", titleCatAdvice)
+                    }
+                }.decodeList<Advice>()
+                _advice.value = responce
+                Log.i("orgTour", "${_advice.value}")
+            }
+        }
+    }
+}

+ 44 - 10
TripHelper/app/src/main/java/com/example/triphelper/view/LawScreen/LawScreen.kt

@@ -1,6 +1,8 @@
 package com.example.triphelper.view.MainScreen
 
 
+import android.util.Log
+import androidx.compose.foundation.background
 import androidx.compose.foundation.border
 import com.example.triphelper.view.style.ButtonStyleBackSquare
 import androidx.compose.foundation.layout.Arrangement
@@ -29,6 +31,7 @@ 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.res.painterResource
 import androidx.compose.ui.text.font.FontWeight
@@ -45,12 +48,17 @@ import com.example.triphelper.view.theme.RobotoB
 import com.example.triphelper.view.theme.SeoulBold
 
 @Composable
-fun LawScreen(navController: NavController, iconsLawIsActivity: MutableState<Boolean>,viewModel: LawScreenViewModel = hiltViewModel()) {
+fun LawScreen(
+    navController: NavController,
+    iconsLawIsActivity: MutableState<Boolean>,
+    viewModel: LawScreenViewModel = hiltViewModel()
+) {
     iconsLawIsActivity.value = true
     var selectedItem by remember { mutableStateOf("") } //Переменная для всплывающего списка
     val coutryTitle = remember { mutableStateOf("") } //Переменная для сохранения названия страны
     val country by viewModel.country.collectAsState(initial = emptyList())
     var expanded by remember { mutableStateOf(false) } //Переменная для всплывающего списка
+    var wrongEmpty by remember { mutableStateOf(false) }
 
     LaunchedEffect(key1 = viewModel.navigationTo) {
         viewModel.navigationTo.collect { destination ->
@@ -61,10 +69,12 @@ fun LawScreen(navController: NavController, iconsLawIsActivity: MutableState<Boo
     }
     StyleMainFone()
     Column(
-        modifier = Modifier.fillMaxWidth().fillMaxHeight(0.9f),
+        modifier = Modifier
+            .fillMaxWidth()
+            .fillMaxHeight(0.9f),
         verticalArrangement = Arrangement.Center,
         horizontalAlignment = Alignment.CenterHorizontally
-    ){
+    ) {
         Text(
             text = "Страна",
             fontFamily = SeoulBold,
@@ -116,12 +126,11 @@ fun LawScreen(navController: NavController, iconsLawIsActivity: MutableState<Boo
                                 painter = painterResource(id = R.drawable.galka_down),
                                 contentDescription = null,
                                 tint = Color(0xFFDC5B6E).copy(alpha = 0.7f),
-
-                                )
+                            )
                         }
                     } else {
                         Text(
-                            "$selectedItem",
+                            selectedItem,
                             fontFamily = RobotoB,
                             fontWeight = FontWeight.W600,
                             fontSize = 23.sp,
@@ -160,14 +169,39 @@ fun LawScreen(navController: NavController, iconsLawIsActivity: MutableState<Boo
                 }
             }
         }
-        Row(modifier = Modifier.fillMaxWidth(0.6f)) {
-            ButtonStyleBackSquare("Далее",33.sp) {
+        if (wrongEmpty) {
+            Box(
+                modifier = Modifier
+                    .fillMaxWidth(0.8f)
+                    .clip(RoundedCornerShape(10.dp))
+                    .background(color = Color.White)
+                    .border(
+                        width = 2.dp,
+                        color = Color.White,
+                        shape = RoundedCornerShape(10.dp)
+                    ),
+            ) {
+                Text(
+                    text = "Не выбрана страна",
+                    fontFamily = Roboto,
+                    fontWeight = FontWeight.W600,
+                    fontSize = 22.sp,
+                    color = Color.Red,
+                    modifier = Modifier.align(Alignment.Center)
+                )
+            }
+        }
+        Row(modifier = Modifier.fillMaxWidth(0.6f).padding(top = 10.dp)) {
+            ButtonStyleBackSquare("Далее", 33.sp) {
                 viewModel.GetRules(coutryTitle.value)
-                if(viewModel.wrong.value){
+                if (coutryTitle.value != "") {
+                    wrongEmpty = false
                     navController.navigate("${NavigationRoutes.DESCLAW}/${coutryTitle.value}")
                 }
+                else{
+                    wrongEmpty = true
+                }
             }
         }
     }
-
 }

+ 0 - 4
TripHelper/app/src/main/java/com/example/triphelper/view/LawScreen/LawScreenViewModel.kt

@@ -40,8 +40,6 @@ class LawScreenViewModel@Inject constructor(): ViewModel(){
     private val _idCountry = MutableStateFlow<Int?>(null)
     val idCountry: StateFlow<Int?> = _idCountry.asStateFlow()
 
-    var wrong = mutableStateOf(false)
-
     fun getCountry(){
         viewModelScope.launch {
             try {
@@ -94,12 +92,10 @@ class LawScreenViewModel@Inject constructor(): ViewModel(){
                     }
                 }.decodeList<Rules>()
                 _ruleses.value = responce
-               wrong.value = true
                Log.i("Rules","${_idCountry.value}")
             }
            catch (e: Exception){
                Log.e("Error","error")
-               wrong.value = false
            }
         }
     }

+ 15 - 3
TripHelper/app/src/main/java/com/example/triphelper/view/MainScreen/MainScreen.kt

@@ -25,6 +25,7 @@ import androidx.compose.runtime.LaunchedEffect
 import androidx.compose.runtime.MutableState
 import androidx.compose.runtime.collectAsState
 import androidx.compose.runtime.getValue
+import androidx.compose.runtime.remember
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.draw.clip
@@ -40,15 +41,20 @@ import androidx.navigation.NavController
 import coil.compose.AsyncImagePainter
 import coil.compose.rememberAsyncImagePainter
 import coil.request.ImageRequest
+import com.example.triphelper.view.navigation.NavigationRoutes
 import com.example.triphelper.view.style.StyleMainFone
 import com.example.triphelper.view.theme.RobotoB
 import com.example.triphelper.view.theme.SeoulBold
+import kotlin.random.Random
 
 @Composable
 fun MainScreen(
     navController: NavController, iconsMainIsActivity: MutableState<Boolean>, viewModel: MainScreenViewModel = hiltViewModel()) {
     iconsMainIsActivity.value = true
     val attractions by viewModel.attractions.collectAsState(initial = emptyList())
+    val shuffledAttractions = remember(attractions) { // Перемешивание ТОЛЬКО при изменении attractions
+        attractions.shuffled(Random(System.currentTimeMillis()))
+    }
     LaunchedEffect(key1 = viewModel.navigationTo) {
         viewModel.navigationTo.collect { destination ->
             destination?.let {
@@ -85,7 +91,7 @@ fun MainScreen(
         }
         LazyColumn {
             items(
-                attractions,
+                shuffledAttractions,
                 key = { attractions -> attractions.id },
             ) { attractions ->
                 val imageState = rememberAsyncImagePainter(
@@ -114,7 +120,11 @@ fun MainScreen(
                             .padding(bottom = 40.dp),
                     ) {
                         Box(
-                            Modifier.fillMaxSize()
+                            Modifier
+                                .fillMaxSize()
+                                .clickable {
+                                    navController.navigate("${NavigationRoutes.ATT_DESC}/${attractions.id}/${attractions.name}")
+                                }
                         ) {
 
                             Image(
@@ -127,7 +137,9 @@ fun MainScreen(
                                         width = 5.dp,
                                         shape = RoundedCornerShape(20.dp)
                                     )
-                                    .clickable {},
+                                    .clickable {
+                                        navController.navigate("${NavigationRoutes.ATT_DESC}/${attractions.id}/${attractions.name}")
+                                    },
                                 painter = imageState.painter,
                                 contentDescription = "",
                                 contentScale = ContentScale.Crop

+ 0 - 10
TripHelper/app/src/main/java/com/example/triphelper/view/RouteScreens/AttractionsDesc.kt

@@ -1,10 +1,7 @@
 package com.example.triphelper.view.RouteScreens
 
-import android.media.audiofx.AudioEffect.Descriptor
 import androidx.compose.foundation.Image
 import androidx.compose.foundation.background
-import androidx.compose.foundation.border
-import androidx.compose.foundation.clickable
 import androidx.compose.foundation.layout.Arrangement
 import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.Column
@@ -13,9 +10,6 @@ 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.layout.wrapContentSize
 import androidx.compose.foundation.lazy.LazyColumn
 import androidx.compose.foundation.lazy.items
 import androidx.compose.foundation.shape.RoundedCornerShape
@@ -41,10 +35,6 @@ import androidx.navigation.NavController
 import coil.compose.AsyncImagePainter
 import coil.compose.rememberAsyncImagePainter
 import coil.request.ImageRequest
-import com.example.triphelper.model.Attractions
-import com.example.triphelper.view.MainScreen.LawScreenViewModel
-import com.example.triphelper.view.style.StyleMainFone
-import com.example.triphelper.view.theme.Roboto
 import com.example.triphelper.view.theme.Roboto
 import com.example.triphelper.view.theme.SeoulBold
 

+ 0 - 3
TripHelper/app/src/main/java/com/example/triphelper/view/RouteScreens/ChoiceTour.kt

@@ -4,15 +4,12 @@ import androidx.compose.foundation.layout.Arrangement
 import androidx.compose.foundation.layout.Column
 import androidx.compose.foundation.layout.Row
 import androidx.compose.foundation.layout.fillMaxHeight
-import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.foundation.layout.fillMaxWidth
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.LaunchedEffect
 import androidx.compose.runtime.MutableState
-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.unit.dp

+ 0 - 10
TripHelper/app/src/main/java/com/example/triphelper/view/RouteScreens/HotelsDesc.kt

@@ -1,10 +1,7 @@
 package com.example.triphelper.view.RouteScreens
 
-import android.media.audiofx.AudioEffect.Descriptor
 import androidx.compose.foundation.Image
 import androidx.compose.foundation.background
-import androidx.compose.foundation.border
-import androidx.compose.foundation.clickable
 import androidx.compose.foundation.layout.Arrangement
 import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.Column
@@ -13,9 +10,6 @@ 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.layout.wrapContentSize
 import androidx.compose.foundation.lazy.LazyColumn
 import androidx.compose.foundation.lazy.items
 import androidx.compose.foundation.shape.RoundedCornerShape
@@ -41,11 +35,7 @@ import androidx.navigation.NavController
 import coil.compose.AsyncImagePainter
 import coil.compose.rememberAsyncImagePainter
 import coil.request.ImageRequest
-import com.example.triphelper.model.Attractions
-import com.example.triphelper.view.MainScreen.LawScreenViewModel
-import com.example.triphelper.view.style.StyleMainFone
 import com.example.triphelper.view.theme.Roboto
-import com.example.triphelper.view.theme.RobotoB
 import com.example.triphelper.view.theme.SeoulBold
 
 @Composable

+ 0 - 11
TripHelper/app/src/main/java/com/example/triphelper/view/RouteScreens/RestaurantsDesc.kt

@@ -1,10 +1,7 @@
 package com.example.triphelper.view.RouteScreens
 
-import android.media.audiofx.AudioEffect.Descriptor
 import androidx.compose.foundation.Image
 import androidx.compose.foundation.background
-import androidx.compose.foundation.border
-import androidx.compose.foundation.clickable
 import androidx.compose.foundation.layout.Arrangement
 import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.Column
@@ -13,9 +10,6 @@ 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.layout.wrapContentSize
 import androidx.compose.foundation.lazy.LazyColumn
 import androidx.compose.foundation.lazy.items
 import androidx.compose.foundation.shape.RoundedCornerShape
@@ -41,12 +35,7 @@ import androidx.navigation.NavController
 import coil.compose.AsyncImagePainter
 import coil.compose.rememberAsyncImagePainter
 import coil.request.ImageRequest
-import com.example.triphelper.model.Attractions
-import com.example.triphelper.model.Restaurants
-import com.example.triphelper.view.MainScreen.LawScreenViewModel
-import com.example.triphelper.view.style.StyleMainFone
 import com.example.triphelper.view.theme.Roboto
-import com.example.triphelper.view.theme.RobotoB
 import com.example.triphelper.view.theme.SeoulBold
 
 @Composable

+ 0 - 16
TripHelper/app/src/main/java/com/example/triphelper/view/RouteScreens/Tours.kt

@@ -1,10 +1,7 @@
 package com.example.triphelper.view.RouteScreens
 
-import androidx.compose.foundation.Image
 import androidx.compose.foundation.background
 import androidx.compose.foundation.border
-import androidx.compose.foundation.clickable
-import androidx.compose.foundation.content.MediaType.Companion.Text
 import androidx.compose.foundation.layout.Arrangement
 import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.Column
@@ -15,12 +12,7 @@ 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.layout.wrapContentSize
-import androidx.compose.foundation.lazy.LazyColumn
-import androidx.compose.foundation.lazy.items
 import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material3.CircularProgressIndicator
 import androidx.compose.material3.Icon
 import androidx.compose.material3.IconButton
 import androidx.compose.material3.Text
@@ -34,10 +26,7 @@ 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.platform.LocalContext
 import androidx.compose.ui.res.painterResource
 import androidx.compose.ui.text.font.FontWeight
 import androidx.compose.ui.text.style.TextAlign
@@ -45,19 +34,14 @@ import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
 import androidx.hilt.navigation.compose.hiltViewModel
 import androidx.navigation.NavController
-import coil.compose.AsyncImagePainter
-import coil.compose.rememberAsyncImagePainter
-import coil.request.ImageRequest
 import com.example.testirovanye_supabase.R
 import com.example.triphelper.view.style.AttractionsLazy
 import com.example.triphelper.view.style.HotelsLazy
 import com.example.triphelper.view.style.MetroLazy
 import com.example.triphelper.view.style.RestaurantsLazy
 import com.example.triphelper.view.style.StyleMainFone
-import com.example.triphelper.view.theme.Roboto
 import com.example.triphelper.view.theme.RobotoB
 import com.example.triphelper.view.theme.SeoulBold
-import io.github.jan.supabase.realtime.Column
 
 //
 @Composable

+ 12 - 1
TripHelper/app/src/main/java/com/example/triphelper/view/navigation/Navigation.kt

@@ -8,11 +8,13 @@ import androidx.navigation.NavHostController
 import androidx.navigation.compose.NavHost
 import androidx.navigation.compose.composable
 import androidx.navigation.compose.rememberNavController
+import com.example.triphelper.model.Advice
 import com.example.triphelper.view.Auth.Auth
 import com.example.triphelper.view.LawScreen.DescriptionLaws
 import com.example.triphelper.view.MainScreen.LawScreen
 import com.example.triphelper.view.MainScreen.MainScreen
 import com.example.triphelper.view.Registration.Registration
+import com.example.triphelper.view.RouteScreens.AdviceScreen
 import com.example.triphelper.view.RouteScreens.AttractionsDesc
 import com.example.triphelper.view.RouteScreens.ChoiceLocation
 import com.example.triphelper.view.RouteScreens.ChoiceTour
@@ -27,7 +29,7 @@ fun Navigation(controller: NavHostController, barsIsVisible: MutableState<Boolea
                iconsLawIsActivity: MutableState<Boolean>, iconsProfileIsActivity: MutableState<Boolean>,
                iconsAdviceIsActivity: MutableState<Boolean>,iconsMainIsActivity: MutableState<Boolean>, iconsRoutsIsActivity: MutableState<Boolean>) {
     NavHost(navController = controller,
-        startDestination = NavigationRoutes.MAIN)
+        startDestination = NavigationRoutes.ADVICE)
     {
         composable( NavigationRoutes.SPLASH){
             barsIsVisible.value = false
@@ -150,5 +152,14 @@ fun Navigation(controller: NavHostController, barsIsVisible: MutableState<Boolea
                 RestaurantsDesc(controller, iconsRoutsIsActivity, idRest.toInt(), titleRest)
             }
         }
+        composable(NavigationRoutes.ADVICE){
+            barsIsVisible.value = true
+            iconsLawIsActivity.value = false
+            iconsAdviceIsActivity.value = false
+            iconsProfileIsActivity.value = false
+            iconsMainIsActivity.value = false
+            iconsRoutsIsActivity.value = false
+            AdviceScreen(controller, iconsAdviceIsActivity)
+        }
     }
 }

+ 1 - 0
TripHelper/app/src/main/java/com/example/triphelper/view/navigation/NavigationRoutes.kt

@@ -13,4 +13,5 @@ object NavigationRoutes {
     const val ATT_DESC = "attractionsdesc"
     const val HOTEL_DESC = "hotelsdesc"
     const val REST_DESC = "restauransdesc"
+    const val  ADVICE = "advice"
 }

+ 78 - 6
TripHelper/app/src/main/java/com/example/triphelper/view/style/LazyColumnStyle.kt

@@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.Column
 import androidx.compose.foundation.layout.Row
 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
@@ -18,13 +17,10 @@ import androidx.compose.foundation.layout.width
 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.material3.CircularProgressIndicator
-import androidx.compose.material3.Icon
 import androidx.compose.material3.Text
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.LaunchedEffect
-import androidx.compose.runtime.MutableState
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.draw.clip
@@ -41,10 +37,10 @@ import coil.compose.AsyncImagePainter
 import coil.compose.rememberAsyncImagePainter
 import coil.request.ImageRequest
 import com.example.testirovanye_supabase.R
-import com.example.triphelper.model.Attractions
+import com.example.triphelper.model.Advice
 import com.example.triphelper.model.Metro
 import com.example.triphelper.model.Organization_of_tours
-import com.example.triphelper.model.Restaurants
+import com.example.triphelper.view.RouteScreens.AdviceViewModel
 import com.example.triphelper.view.RouteScreens.RouteViewModel
 import com.example.triphelper.view.navigation.NavigationRoutes
 import com.example.triphelper.view.theme.Roboto
@@ -551,4 +547,80 @@ fun MetroLazy(metro:List<Metro>, viewModel: RouteViewModel = hiltViewModel()){
             }
         }
     }
+}
+
+@Composable
+fun FoodAdviceLazy(navController: NavController, advice: List<Advice>, viewModel: AdviceViewModel = hiltViewModel()) {
+    LaunchedEffect(Unit) {
+        viewModel.GetAdvice("Питание")
+    }
+    LazyColumn(
+        modifier = Modifier.fillMaxHeight(0.84f)
+    ) {
+        items(
+            advice,
+            key = { advice -> advice.id },
+        ) { advice ->
+            Column(
+                modifier = Modifier
+                    .fillMaxWidth(0.8f)
+                    .padding(top = 10.dp)
+                    .height(175.dp)
+                    .padding(bottom = 10.dp)
+                    .border(
+                        width = 4.dp,
+                        color = Color(0xFF510B3C),
+                        shape = RoundedCornerShape(15.dp)
+                    ),
+            ) {
+                Box(
+                    Modifier
+                        .fillMaxWidth()
+                        .fillMaxHeight()
+                        .clip(RoundedCornerShape(15.dp))
+                        .background(Color.White)
+                ) {
+                    Row {
+                        Box(
+                            Modifier
+                                .fillMaxWidth()
+                                .fillMaxHeight()
+                                .size(210.dp)
+                                .padding(top = 10.dp),
+                            contentAlignment = Alignment.TopCenter
+                        ) {
+                            Text(
+                                text = advice.title,
+                                color = Color(0xFF510B3C),
+                                fontSize = 16.sp,
+                                fontFamily = RobotoB,
+                                textAlign = TextAlign.Center
+                            )
+                            Box(
+                                Modifier
+                                    .fillMaxWidth()
+                                    .fillMaxHeight()
+                                    .padding(top = 10.dp, bottom = 20.dp, start = 5.dp),
+                                contentAlignment = Alignment.BottomStart
+                            ) {
+                                Column(
+                                    verticalArrangement = Arrangement.spacedBy(10.dp)
+                                ) {
+                                    Text(
+                                        text = advice.description,
+                                        color = Color(0xFF510B3C),
+                                        fontSize = 14.sp,
+                                        fontFamily = Roboto,
+                                        textAlign = TextAlign.Center
+                                    )
+                                }
+                            }
+                        }
+                    }
+                }
+
+            }
+        }
+
+    }
 }

File diff suppressed because it is too large
+ 17 - 0
TripHelper/app/src/main/res/drawable/food_advice.xml


+ 12 - 0
TripHelper/app/src/main/res/drawable/helth_advice.xml

@@ -0,0 +1,12 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="34dp"
+    android:height="34dp"
+    android:viewportWidth="34"
+    android:viewportHeight="34">
+  <path
+      android:pathData="M33.566,9.583C33.146,8.583 32.449,7.736 31.569,7.136C30.69,6.537 29.622,6.186 28.484,6.186H23.821V4.92C23.821,4.244 23.684,3.594 23.437,3.004C23.065,2.12 22.449,1.371 21.67,0.841C20.893,0.311 19.947,-0.001 18.942,0H15.058C14.389,0 13.743,0.138 13.159,0.387C12.281,0.762 11.539,1.384 11.013,2.168C10.487,2.952 10.179,3.905 10.179,4.919V6.186H5.515C4.758,6.186 4.028,6.342 3.369,6.624C2.377,7.047 1.537,7.75 0.942,8.637C0.348,9.524 -0.001,10.6 0,11.747V28.439C0,29.204 0.154,29.938 0.434,30.604C0.853,31.603 1.551,32.45 2.431,33.049C3.31,33.649 4.378,34 5.515,34H28.485C29.242,34 29.971,33.845 30.632,33.562C31.623,33.14 32.463,32.436 33.057,31.549C33.652,30.663 34,29.586 34,28.439V11.747C34,10.983 33.846,10.248 33.566,9.583ZM12.665,4.92C12.665,4.583 12.732,4.268 12.853,3.98C13.034,3.549 13.339,3.178 13.721,2.918C14.105,2.658 14.559,2.507 15.058,2.507H18.942C19.275,2.507 19.587,2.574 19.872,2.696C20.301,2.878 20.668,3.186 20.927,3.571C21.185,3.958 21.334,4.415 21.334,4.92V6.186H12.665V4.92ZM31.514,28.439C31.514,28.864 31.429,29.263 31.276,29.627C31.047,30.174 30.661,30.643 30.177,30.972C29.692,31.302 29.116,31.493 28.484,31.493H5.515C5.094,31.493 4.699,31.408 4.337,31.253C3.795,31.023 3.33,30.634 3.003,30.145C2.676,29.657 2.487,29.076 2.486,28.439V15.704H31.514V28.439H31.514ZM31.514,13.667H2.486V11.747C2.487,11.322 2.571,10.924 2.724,10.559C2.952,10.012 3.339,9.544 3.823,9.214C4.307,8.885 4.884,8.693 5.515,8.693H28.485C28.906,8.693 29.301,8.778 29.663,8.933C30.205,9.163 30.67,9.553 30.997,10.04C31.324,10.529 31.513,11.111 31.514,11.747V13.667H31.514Z"
+      android:fillColor="#510B3C"/>
+  <path
+      android:pathData="M15.211,29.202H19.069V25.572H22.67V21.681H19.069V18.051H15.211V21.681H11.61V25.572H15.211V29.202Z"
+      android:fillColor="#510B3C"/>
+</vector>

+ 33 - 0
TripHelper/app/src/main/res/drawable/trip_advice.xml

@@ -0,0 +1,33 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="34dp"
+    android:height="34dp"
+    android:viewportWidth="34"
+    android:viewportHeight="34">
+  <path
+      android:pathData="M30.302,25.34H10.48C8.347,25.34 6.613,23.281 6.613,20.748V9.515C6.613,9.111 6.834,8.758 7.148,8.637C7.471,8.516 7.82,8.657 8.015,8.98L12.52,16.56H30.302C32.342,16.56 34,18.528 34,20.94C34,23.372 32.342,25.34 30.302,25.34ZM8.16,12.412V20.758C8.16,22.272 9.197,23.514 10.48,23.514H30.302C31.484,23.514 32.453,22.373 32.453,20.96C32.453,19.547 31.492,18.407 30.302,18.407H12.121C11.866,18.407 11.636,18.265 11.492,18.013L8.16,12.412Z"
+      android:fillColor="#510B3C"/>
+  <path
+      android:pathData="M19.992,34C19.916,34 19.831,33.99 19.754,33.96L17.68,33.152C17.391,33.041 17.179,32.738 17.153,32.375L16.473,24.523C16.431,24.018 16.737,23.564 17.162,23.514C17.578,23.443 17.969,23.826 18.012,24.331L18.641,31.588L19.542,31.941L22.083,24.089C22.236,23.615 22.687,23.382 23.078,23.564C23.477,23.746 23.673,24.281 23.52,24.755L20.715,33.415C20.596,33.778 20.307,34 19.992,34Z"
+      android:fillColor="#510B3C"/>
+  <path
+      android:pathData="M16.609,18.407C16.244,18.407 15.921,18.094 15.853,17.65L15.079,12.603C15.028,12.29 15.122,11.967 15.326,11.755L16.728,10.262C17.043,9.929 17.519,9.949 17.808,10.312L23.027,16.852C23.324,17.216 23.307,17.801 23.001,18.154C22.695,18.497 22.202,18.487 21.913,18.114L17.213,12.23L16.694,12.785L17.391,17.327C17.468,17.831 17.187,18.306 16.771,18.397C16.703,18.397 16.66,18.407 16.609,18.407Z"
+      android:fillColor="#510B3C"/>
+  <path
+      android:pathData="M17.459,31.083H14.102C12.929,31.083 11.977,29.953 11.977,28.56C11.977,27.167 12.929,26.037 14.102,26.037H17.459C17.884,26.037 18.233,26.451 18.233,26.955C18.233,27.46 17.884,27.874 17.459,27.874H14.102C13.779,27.874 13.524,28.187 13.524,28.56C13.524,28.944 13.787,29.246 14.102,29.246H17.459C17.884,29.246 18.233,29.66 18.233,30.165C18.233,30.669 17.884,31.083 17.459,31.083Z"
+      android:fillColor="#510B3C"/>
+  <path
+      android:pathData="M27.744,14.682C27.54,14.682 27.345,14.582 27.2,14.41L24.03,10.645C23.035,9.464 22.491,7.9 22.491,6.235C22.491,4.569 23.035,3.005 24.03,1.824C26.078,-0.608 29.41,-0.608 31.459,1.824C32.453,3.005 32.997,4.569 32.997,6.235C32.997,7.9 32.453,9.464 31.459,10.645L28.288,14.41C28.144,14.582 27.948,14.682 27.744,14.682ZM27.744,1.834C26.792,1.834 25.849,2.258 25.118,3.116C24.421,3.944 24.03,5.054 24.03,6.235C24.03,7.406 24.412,8.516 25.118,9.343L27.744,12.462L30.371,9.343C31.068,8.516 31.459,7.406 31.459,6.235C31.459,5.054 31.076,3.954 30.371,3.116C29.64,2.268 28.696,1.834 27.744,1.834Z"
+      android:fillColor="#510B3C"/>
+  <path
+      android:pathData="M27.744,8.253C26.579,8.253 25.627,7.123 25.627,5.74C25.627,4.358 26.579,3.227 27.744,3.227C28.908,3.227 29.86,4.358 29.86,5.74C29.86,7.133 28.908,8.253 27.744,8.253ZM27.744,5.064C27.429,5.064 27.174,5.367 27.174,5.74C27.174,6.114 27.429,6.416 27.744,6.416C28.058,6.416 28.313,6.114 28.313,5.74C28.313,5.367 28.058,5.064 27.744,5.064Z"
+      android:fillColor="#510B3C"/>
+  <path
+      android:pathData="M5.117,14.107H0.774C0.349,14.107 0,13.693 0,13.189C0,12.684 0.349,12.27 0.774,12.27H5.117C5.542,12.27 5.891,12.684 5.891,13.189C5.891,13.693 5.55,14.107 5.117,14.107Z"
+      android:fillColor="#510B3C"/>
+  <path
+      android:pathData="M5.117,17.892H0.774C0.349,17.892 0,17.478 0,16.973C0,16.469 0.349,16.055 0.774,16.055H5.117C5.542,16.055 5.891,16.469 5.891,16.973C5.891,17.478 5.55,17.892 5.117,17.892Z"
+      android:fillColor="#510B3C"/>
+  <path
+      android:pathData="M5.117,21.909H0.774C0.349,21.909 0,21.495 0,20.99C0,20.486 0.349,20.072 0.774,20.072H5.117C5.542,20.072 5.891,20.486 5.891,20.99C5.891,21.495 5.55,21.909 5.117,21.909Z"
+      android:fillColor="#510B3C"/>
+</vector>

Some files were not shown because too many files changed in this diff