|
@@ -47,117 +47,136 @@ fun CookingAdmin(viewModel: MainActivityViewModel, navController: NavController)
|
|
|
viewModel.allDishes()
|
|
|
flag.value = false
|
|
|
}
|
|
|
- if (cookings.isNotEmpty()) {
|
|
|
- LazyColumn {
|
|
|
- items(cookings) { cooking ->
|
|
|
- val image = rememberAsyncImagePainter(
|
|
|
- model = ImageRequest.Builder(LocalContext.current).data(cooking.Image)
|
|
|
- .size(200, 200).build()
|
|
|
- ).state
|
|
|
- Card(
|
|
|
- modifier = Modifier
|
|
|
- .fillMaxWidth()
|
|
|
- .padding(20.dp)
|
|
|
+
|
|
|
+ Column(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxSize()
|
|
|
+ .background(background)
|
|
|
+ .padding(top = 50.dp),
|
|
|
+ horizontalAlignment = Alignment.CenterHorizontally
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ text = "ПРОФИЛЬ",
|
|
|
+ fontWeight = FontWeight.Light,
|
|
|
+ fontSize = 24.sp,
|
|
|
+ color = Color(0xFFFFFFFF),
|
|
|
+ letterSpacing = 10.sp
|
|
|
+ )
|
|
|
+
|
|
|
+ if (cookings.isNotEmpty()) {
|
|
|
+ LazyColumn {
|
|
|
+ items(cookings) { cooking ->
|
|
|
+ val image = rememberAsyncImagePainter(
|
|
|
+ model = ImageRequest.Builder(LocalContext.current).data(cooking.Image)
|
|
|
+ .size(200, 200).build()
|
|
|
+ ).state
|
|
|
+ Card(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .padding(20.dp)
|
|
|
|
|
|
|
|
|
- ) {
|
|
|
- Column(
|
|
|
- Modifier.fillMaxSize(),
|
|
|
- verticalArrangement = Arrangement.Center,
|
|
|
- horizontalAlignment = Alignment.CenterHorizontally
|
|
|
) {
|
|
|
- if (image is AsyncImagePainter.State.Success) {
|
|
|
- Box(
|
|
|
- modifier = Modifier
|
|
|
- .height(200.dp)
|
|
|
- .padding(10.dp),
|
|
|
- contentAlignment = Alignment.Center
|
|
|
- ) {
|
|
|
- Image(
|
|
|
+ Column(
|
|
|
+ Modifier.fillMaxSize(),
|
|
|
+ verticalArrangement = Arrangement.Center,
|
|
|
+ horizontalAlignment = Alignment.CenterHorizontally
|
|
|
+ ) {
|
|
|
+ if (image is AsyncImagePainter.State.Success) {
|
|
|
+ Box(
|
|
|
modifier = Modifier
|
|
|
- .fillMaxWidth()
|
|
|
- .height(200.dp),
|
|
|
- painter = image.painter,
|
|
|
- contentDescription = "",
|
|
|
- contentScale = ContentScale.Crop,
|
|
|
- alignment = Alignment.Center
|
|
|
- )
|
|
|
+ .height(200.dp)
|
|
|
+ .padding(10.dp),
|
|
|
+ contentAlignment = Alignment.Center
|
|
|
+ ) {
|
|
|
+ Image(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .height(200.dp),
|
|
|
+ painter = image.painter,
|
|
|
+ contentDescription = "",
|
|
|
+ contentScale = ContentScale.Crop,
|
|
|
+ alignment = Alignment.Center
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if (image is AsyncImagePainter.State.Loading) {
|
|
|
- Box(
|
|
|
- modifier = Modifier
|
|
|
- .fillMaxWidth()
|
|
|
- .height(250.dp),
|
|
|
- contentAlignment = Alignment.Center
|
|
|
- ) {
|
|
|
- CircularProgressIndicator()
|
|
|
+ if (image is AsyncImagePainter.State.Loading) {
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .height(250.dp),
|
|
|
+ contentAlignment = Alignment.Center
|
|
|
+ ) {
|
|
|
+ CircularProgressIndicator()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- Column(
|
|
|
- Modifier.fillMaxSize().padding(12.dp),
|
|
|
- horizontalAlignment = Alignment.Start
|
|
|
- ) {
|
|
|
+ Column(
|
|
|
+ Modifier.fillMaxSize().padding(12.dp),
|
|
|
+ horizontalAlignment = Alignment.Start
|
|
|
+ ) {
|
|
|
|
|
|
- Text(
|
|
|
- text = cooking.Name,
|
|
|
- fontWeight = FontWeight.Medium,
|
|
|
- fontSize = 20.sp,
|
|
|
- color = Color.Black,
|
|
|
- modifier = Modifier.padding(5.dp)
|
|
|
- )
|
|
|
- Text(
|
|
|
- text = cooking.Descriptions,
|
|
|
- fontWeight = FontWeight.Light,
|
|
|
- fontSize = 14.sp,
|
|
|
- color = Color.Black,
|
|
|
- modifier = Modifier.padding(5.dp)
|
|
|
- )
|
|
|
+ Text(
|
|
|
+ text = cooking.Name,
|
|
|
+ fontWeight = FontWeight.Medium,
|
|
|
+ fontSize = 20.sp,
|
|
|
+ color = Color.Black,
|
|
|
+ modifier = Modifier.padding(5.dp)
|
|
|
+ )
|
|
|
+ Text(
|
|
|
+ text = cooking.Descriptions,
|
|
|
+ fontWeight = FontWeight.Light,
|
|
|
+ fontSize = 14.sp,
|
|
|
+ color = Color.Black,
|
|
|
+ modifier = Modifier.padding(5.dp)
|
|
|
+ )
|
|
|
|
|
|
- Column(Modifier, horizontalAlignment = Alignment.CenterHorizontally) {
|
|
|
- Button(
|
|
|
- onClick = { viewModel.deleteCooking(cooking.id!!) },
|
|
|
- modifier = Modifier
|
|
|
- .fillMaxWidth(0.5f)
|
|
|
- .padding(5.dp),
|
|
|
- shape = RoundedCornerShape(20),
|
|
|
- colors = ButtonColors(
|
|
|
- contentColor = Color.White,
|
|
|
- containerColor = Color(0xFF7DAD01),
|
|
|
- disabledContentColor = Color.White,
|
|
|
- disabledContainerColor = Color(0xFF7DAD01)
|
|
|
- )
|
|
|
+ Column(
|
|
|
+ Modifier,
|
|
|
+ horizontalAlignment = Alignment.CenterHorizontally
|
|
|
) {
|
|
|
- Text("Удалить")
|
|
|
- }
|
|
|
- Button(
|
|
|
- onClick = {
|
|
|
- viewModel.giveCooking(cooking)
|
|
|
- navController.navigate(Screen.CookingUpdate.route)
|
|
|
- }, modifier = Modifier
|
|
|
- .fillMaxWidth(0.5f)
|
|
|
- .padding(5.dp),
|
|
|
- shape = RoundedCornerShape(20),
|
|
|
- colors = ButtonColors(
|
|
|
- contentColor = Color.White,
|
|
|
- containerColor = Color(0xFF7DAD01),
|
|
|
- disabledContentColor = Color.White,
|
|
|
- disabledContainerColor = Color(0xFF7DAD01)
|
|
|
- )
|
|
|
- ) {
|
|
|
- Text("Изменить")
|
|
|
+ Button(
|
|
|
+ onClick = { viewModel.deleteCooking(cooking.id!!) },
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth(0.5f)
|
|
|
+ .padding(5.dp),
|
|
|
+ shape = RoundedCornerShape(20),
|
|
|
+ colors = ButtonColors(
|
|
|
+ contentColor = Color.White,
|
|
|
+ containerColor = Color(0xFF7DAD01),
|
|
|
+ disabledContentColor = Color.White,
|
|
|
+ disabledContainerColor = Color(0xFF7DAD01)
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ Text("Удалить")
|
|
|
+ }
|
|
|
+ Button(
|
|
|
+ onClick = {
|
|
|
+ viewModel.giveCooking(cooking)
|
|
|
+ navController.navigate(Screen.CookingUpdate.route)
|
|
|
+ }, modifier = Modifier
|
|
|
+ .fillMaxWidth(0.5f)
|
|
|
+ .padding(5.dp),
|
|
|
+ shape = RoundedCornerShape(20),
|
|
|
+ colors = ButtonColors(
|
|
|
+ contentColor = Color.White,
|
|
|
+ containerColor = Color(0xFF7DAD01),
|
|
|
+ disabledContentColor = Color.White,
|
|
|
+ disabledContainerColor = Color(0xFF7DAD01)
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ Text("Изменить")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
|
|
+ CircularProgressIndicator()
|
|
|
}
|
|
|
- else {
|
|
|
- Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
|
|
- CircularProgressIndicator()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+}
|