|
@@ -14,18 +14,12 @@ 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.shape.CircleShape
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
-import androidx.compose.material.icons.filled.ArrowBack
|
|
|
-import androidx.compose.material.icons.filled.Settings
|
|
|
import androidx.compose.material3.Button
|
|
|
import androidx.compose.material3.ButtonDefaults
|
|
|
-import androidx.compose.material3.Card
|
|
|
import androidx.compose.material3.Icon
|
|
|
import androidx.compose.material3.IconButton
|
|
|
-import androidx.compose.material3.MaterialTheme
|
|
|
import androidx.compose.material3.OutlinedTextField
|
|
|
import androidx.compose.material3.Text
|
|
|
import androidx.compose.runtime.Composable
|
|
@@ -34,22 +28,17 @@ 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.tooling.preview.Preview
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
-import coil.compose.rememberImagePainter
|
|
|
import com.example.iplace.R
|
|
|
import com.example.iplace.main.viewModel.MainViewModel
|
|
|
-import com.example.iplace.ui.theme.beige_white
|
|
|
import com.example.iplace.ui.theme.brown_contrast
|
|
|
|
|
|
-import androidx.compose.foundation.background
|
|
|
import androidx.compose.foundation.clickable
|
|
|
import androidx.compose.foundation.layout.*
|
|
|
import androidx.compose.foundation.lazy.LazyColumn
|
|
|
import androidx.compose.foundation.lazy.items
|
|
|
//noinspection UsingMaterialAndMaterial3Libraries
|
|
|
-import androidx.compose.material.*
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
import androidx.compose.material.icons.filled.Menu
|
|
|
import androidx.compose.material.icons.filled.Person
|
|
@@ -62,8 +51,9 @@ import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
import androidx.compose.ui.layout.ContentScale
|
|
|
import androidx.compose.ui.res.painterResource
|
|
|
-import androidx.compose.ui.unit.dp
|
|
|
import androidx.navigation.NavHostController
|
|
|
+import coil.compose.AsyncImage
|
|
|
+import com.example.iplace.model.Place
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
@@ -71,6 +61,16 @@ import androidx.navigation.NavHostController
|
|
|
fun MenuV(navController: NavHostController) {
|
|
|
val viewModel = MainViewModel()
|
|
|
var showDrawer by remember { mutableStateOf(false) }
|
|
|
+
|
|
|
+ var placeList by remember { mutableStateOf<List<Place>>(emptyList()) }
|
|
|
+// LaunchedEffect(key1 = true) {
|
|
|
+// viewModel.getPlaceListRealTime()
|
|
|
+// .collect {list -> placeList = list}
|
|
|
+// }
|
|
|
+ LaunchedEffect(key1 = true) {
|
|
|
+ placeList = viewModel.getPlaceList()
|
|
|
+ }
|
|
|
+
|
|
|
val headlinesOswald = FontFamily( //выбор шрифта
|
|
|
Font(resId = R.font.headlines_oswald)
|
|
|
)
|
|
@@ -240,43 +240,85 @@ fun MenuV(navController: NavHostController) {
|
|
|
.fillMaxWidth(),
|
|
|
textAlign = TextAlign.Center
|
|
|
)
|
|
|
+ LazyColumn(
|
|
|
+ contentPadding = PaddingValues(
|
|
|
+ horizontal = 16.dp,
|
|
|
+ vertical = 10.dp),
|
|
|
+ verticalArrangement = Arrangement.spacedBy(10.dp)
|
|
|
+ ){
|
|
|
+ items(placeList) {
|
|
|
+ place ->
|
|
|
+ PlaceCard(place = place, navController
|
|
|
|
|
|
- // 4 блока данных
|
|
|
- LazyColumn {
|
|
|
- items(listOf(1, 2, 3, 4)) { item ->
|
|
|
- Box(
|
|
|
- modifier = Modifier
|
|
|
- .fillMaxWidth()
|
|
|
- .height(230.dp)
|
|
|
- .padding(16.dp)
|
|
|
- .background(Color.LightGray)
|
|
|
- .clickable{navController.navigate("placeV")}
|
|
|
- ) {
|
|
|
- Column(
|
|
|
- modifier = Modifier
|
|
|
- .align(Alignment.BottomStart) // Выравниваем Column по левому нижнему углу
|
|
|
- ) {
|
|
|
- Text(text = "Название $item", modifier = Modifier)
|
|
|
- Text(text = "Категория $item", modifier = Modifier)
|
|
|
- }
|
|
|
-
|
|
|
- Button(
|
|
|
- onClick = { /* Обработка нажатия на фильтр */ },
|
|
|
- modifier = Modifier
|
|
|
- .align(Alignment.TopEnd) // Выравниваем Button по правому верхнему углу
|
|
|
- .width(40.dp)
|
|
|
- .height(40.dp),
|
|
|
- colors = ButtonDefaults.buttonColors(brown_contrast)
|
|
|
- ) {
|
|
|
- Text(text = "☆")
|
|
|
- }
|
|
|
- }
|
|
|
+ )
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+@Composable
|
|
|
+fun PlaceCard(place: Place, navController: NavHostController){
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .height(300.dp)
|
|
|
+ .clip(RoundedCornerShape(20.dp))
|
|
|
+ .clickable(onClick = { navController.navigate("placeV") })
|
|
|
+ ,
|
|
|
+ contentAlignment = Alignment.Center
|
|
|
+ ){
|
|
|
+
|
|
|
+ AsyncImage(
|
|
|
+ model = place.img_place,
|
|
|
+ contentDescription = null,
|
|
|
+ modifier = Modifier.fillMaxSize(),
|
|
|
+ contentScale = ContentScale.Crop
|
|
|
+ )
|
|
|
+ Box(
|
|
|
+
|
|
|
+ modifier = Modifier
|
|
|
+ .matchParentSize()
|
|
|
+ .background(color = Color.LightGray.copy(alpha = 0.6f))
|
|
|
+ ){
|
|
|
+ Column(
|
|
|
+ modifier = Modifier
|
|
|
+ .align(Alignment.BottomStart) // Выравниваем Column по левому нижнему углу
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ text = place.title,
|
|
|
+ fontSize = 18.sp,
|
|
|
+ color = Color.Black,
|
|
|
+
|
|
|
+ )
|
|
|
+ Text(
|
|
|
+ text = place.id_categoryFK.toString(),
|
|
|
+ fontSize = 18.sp,
|
|
|
+ color = Color.Black,
|
|
|
+
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ Button(
|
|
|
+ onClick = { /* Обработка нажатия на фильтр */ },
|
|
|
+ modifier = Modifier
|
|
|
+ .align(Alignment.TopEnd) // Выравниваем Button по правому верхнему углу
|
|
|
+ .width(40.dp)
|
|
|
+ .height(40.dp),
|
|
|
+ colors = ButtonDefaults.buttonColors(brown_contrast)
|
|
|
+ ) {
|
|
|
+ Text(text = "☆")
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Composable
|
|
|
fun DrawerContent(showDrawer: Boolean, navController: NavHostController) {
|
|
|
val headlinesOswald = FontFamily( //выбор шрифта
|