Browse Source

update: package AdviceScreen, screen done full

Maksutka 5 ngày trước cách đây
mục cha
commit
cc304fa4f6

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

@@ -37,10 +37,12 @@ import androidx.navigation.NavController
 import com.example.testirovanye_supabase.R
 import com.example.testirovanye_supabase.R
 import com.example.triphelper.view.style.AttractionsLazy
 import com.example.triphelper.view.style.AttractionsLazy
 import com.example.triphelper.view.style.FoodAdviceLazy
 import com.example.triphelper.view.style.FoodAdviceLazy
+import com.example.triphelper.view.style.HealthAdviceLazy
 import com.example.triphelper.view.style.HotelsLazy
 import com.example.triphelper.view.style.HotelsLazy
 import com.example.triphelper.view.style.MetroLazy
 import com.example.triphelper.view.style.MetroLazy
 import com.example.triphelper.view.style.RestaurantsLazy
 import com.example.triphelper.view.style.RestaurantsLazy
 import com.example.triphelper.view.style.StyleMainFone
 import com.example.triphelper.view.style.StyleMainFone
+import com.example.triphelper.view.style.TripAdviceLazy
 import com.example.triphelper.view.theme.RobotoB
 import com.example.triphelper.view.theme.RobotoB
 import com.example.triphelper.view.theme.SeoulBold
 import com.example.triphelper.view.theme.SeoulBold
 
 
@@ -148,13 +150,13 @@ fun AdviceScreen(navController: NavController, iconsAdviceIsActivity: MutableSta
             }
             }
         }
         }
         if (foodColumn) {
         if (foodColumn) {
-            FoodAdviceLazy(navController,advice)
+            FoodAdviceLazy(advice)
         }
         }
         if (tripColumn) {
         if (tripColumn) {
-            FoodAdviceLazy(navController,advice)
+            TripAdviceLazy(advice)
         }
         }
         if(helthColumn){
         if(helthColumn){
-            FoodAdviceLazy(navController,advice)
+            HealthAdviceLazy(advice)
         }
         }
     }
     }
 }
 }

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

@@ -37,15 +37,6 @@ class AdviceViewModel @Inject constructor() : ViewModel() {
     private val _advice: MutableStateFlow<List<Advice>> = MutableStateFlow(listOf())
     private val _advice: MutableStateFlow<List<Advice>> = MutableStateFlow(listOf())
     val advice: StateFlow<List<Advice>> = _advice.asStateFlow()
     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) {
     fun GetAdvice(titleCatAdvice: String) {
         viewModelScope.launch {
         viewModelScope.launch {
             withContext(Dispatchers.IO) {
             withContext(Dispatchers.IO) {

+ 1 - 0
TripHelper/app/src/main/java/com/example/triphelper/view/AppBar/bottombar/BottomBar.kt

@@ -124,6 +124,7 @@ fun BottomBar(controller: NavController,
                     ) {
                     ) {
                         IconButton(
                         IconButton(
                             onClick = {
                             onClick = {
+                                controller.navigate(NavigationRoutes.ADVICE)
                             },
                             },
                             modifier = Modifier
                             modifier = Modifier
                                 .size(50.dp)
                                 .size(50.dp)

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

@@ -550,12 +550,12 @@ fun MetroLazy(metro:List<Metro>, viewModel: RouteViewModel = hiltViewModel()){
 }
 }
 
 
 @Composable
 @Composable
-fun FoodAdviceLazy(navController: NavController, advice: List<Advice>, viewModel: AdviceViewModel = hiltViewModel()) {
+fun FoodAdviceLazy(advice: List<Advice>, viewModel: AdviceViewModel = hiltViewModel()) {
     LaunchedEffect(Unit) {
     LaunchedEffect(Unit) {
         viewModel.GetAdvice("Питание")
         viewModel.GetAdvice("Питание")
     }
     }
     LazyColumn(
     LazyColumn(
-        modifier = Modifier.fillMaxHeight(0.84f)
+        modifier = Modifier.fillMaxHeight(0.86f)
     ) {
     ) {
         items(
         items(
             advice,
             advice,
@@ -563,9 +563,9 @@ fun FoodAdviceLazy(navController: NavController, advice: List<Advice>, viewModel
         ) { advice ->
         ) { advice ->
             Column(
             Column(
                 modifier = Modifier
                 modifier = Modifier
-                    .fillMaxWidth(0.8f)
+                    .fillMaxWidth(0.9f)
                     .padding(top = 10.dp)
                     .padding(top = 10.dp)
-                    .height(175.dp)
+                    .height(150.dp)
                     .padding(bottom = 10.dp)
                     .padding(bottom = 10.dp)
                     .border(
                     .border(
                         width = 4.dp,
                         width = 4.dp,
@@ -585,31 +585,30 @@ fun FoodAdviceLazy(navController: NavController, advice: List<Advice>, viewModel
                             Modifier
                             Modifier
                                 .fillMaxWidth()
                                 .fillMaxWidth()
                                 .fillMaxHeight()
                                 .fillMaxHeight()
-                                .size(210.dp)
-                                .padding(top = 10.dp),
+                                .padding(top = 10.dp, bottom = 0.dp),
                             contentAlignment = Alignment.TopCenter
                             contentAlignment = Alignment.TopCenter
                         ) {
                         ) {
                             Text(
                             Text(
                                 text = advice.title,
                                 text = advice.title,
                                 color = Color(0xFF510B3C),
                                 color = Color(0xFF510B3C),
-                                fontSize = 16.sp,
+                                fontSize = 19.sp,
                                 fontFamily = RobotoB,
                                 fontFamily = RobotoB,
                                 textAlign = TextAlign.Center
                                 textAlign = TextAlign.Center
                             )
                             )
                             Box(
                             Box(
                                 Modifier
                                 Modifier
-                                    .fillMaxWidth()
+                                    .fillMaxWidth(0.95f)
                                     .fillMaxHeight()
                                     .fillMaxHeight()
-                                    .padding(top = 10.dp, bottom = 20.dp, start = 5.dp),
-                                contentAlignment = Alignment.BottomStart
+                                    .padding(top = 20.dp,bottom = 10.dp),
+                                contentAlignment = Alignment.CenterStart
                             ) {
                             ) {
                                 Column(
                                 Column(
-                                    verticalArrangement = Arrangement.spacedBy(10.dp)
+                                    verticalArrangement = Arrangement.spacedBy(0.dp)
                                 ) {
                                 ) {
                                     Text(
                                     Text(
                                         text = advice.description,
                                         text = advice.description,
                                         color = Color(0xFF510B3C),
                                         color = Color(0xFF510B3C),
-                                        fontSize = 14.sp,
+                                        fontSize = 16.sp,
                                         fontFamily = Roboto,
                                         fontFamily = Roboto,
                                         textAlign = TextAlign.Center
                                         textAlign = TextAlign.Center
                                     )
                                     )
@@ -621,6 +620,153 @@ fun FoodAdviceLazy(navController: NavController, advice: List<Advice>, viewModel
 
 
             }
             }
         }
         }
+    }
+}
 
 
+@Composable
+fun TripAdviceLazy(advice: List<Advice>, viewModel: AdviceViewModel = hiltViewModel()) {
+    LaunchedEffect(Unit) {
+        viewModel.GetAdvice("Путешествие")
+    }
+    LazyColumn(
+        modifier = Modifier.fillMaxHeight(0.86f)
+    ) {
+        items(
+            advice,
+            key = { advice -> advice.id },
+        ) { advice ->
+            Column(
+                modifier = Modifier
+                    .fillMaxWidth(0.9f)
+                    .padding(top = 10.dp)
+                    .height(150.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()
+                                .padding(top = 10.dp, bottom = 0.dp),
+                            contentAlignment = Alignment.TopCenter
+                        ) {
+                            Text(
+                                text = advice.title,
+                                color = Color(0xFF510B3C),
+                                fontSize = 19.sp,
+                                fontFamily = RobotoB,
+                                textAlign = TextAlign.Center
+                            )
+                            Box(
+                                Modifier
+                                    .fillMaxWidth(0.95f)
+                                    .fillMaxHeight()
+                                    .padding(top = 20.dp,bottom = 10.dp),
+                                contentAlignment = Alignment.CenterStart
+                            ) {
+                                Column(
+                                    verticalArrangement = Arrangement.spacedBy(0.dp)
+                                ) {
+                                    Text(
+                                        text = advice.description,
+                                        color = Color(0xFF510B3C),
+                                        fontSize = 16.sp,
+                                        fontFamily = Roboto,
+                                        textAlign = TextAlign.Center
+                                    )
+                                }
+                            }
+                        }
+                    }
+                }
+
+            }
+        }
+    }
+}
+
+@Composable
+fun HealthAdviceLazy(advice: List<Advice>, viewModel: AdviceViewModel = hiltViewModel()) {
+    LaunchedEffect(Unit) {
+        viewModel.GetAdvice("Здоровье")
+    }
+    LazyColumn(
+        modifier = Modifier.fillMaxHeight(0.86f)
+    ) {
+        items(
+            advice,
+            key = { advice -> advice.id },
+        ) { advice ->
+            Column(
+                modifier = Modifier
+                    .fillMaxWidth(0.9f)
+                    .padding(top = 10.dp)
+                    .height(150.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()
+                                .padding(top = 10.dp, bottom = 0.dp),
+                            contentAlignment = Alignment.TopCenter
+                        ) {
+                            Text(
+                                text = advice.title,
+                                color = Color(0xFF510B3C),
+                                fontSize = 19.sp,
+                                fontFamily = RobotoB,
+                                textAlign = TextAlign.Center
+                            )
+                            Box(
+                                Modifier
+                                    .fillMaxWidth(0.95f)
+                                    .fillMaxHeight()
+                                    .padding(top = 20.dp,bottom = 10.dp),
+                                contentAlignment = Alignment.CenterStart
+                            ) {
+                                Column(
+                                    verticalArrangement = Arrangement.spacedBy(0.dp)
+                                ) {
+                                    Text(
+                                        text = advice.description,
+                                        color = Color(0xFF510B3C),
+                                        fontSize = 16.sp,
+                                        fontFamily = Roboto,
+                                        textAlign = TextAlign.Center
+                                    )
+                                }
+                            }
+                        }
+                    }
+                }
+
+            }
+        }
     }
     }
 }
 }