Навел марафету перед четвертой лабой

This commit is contained in:
Данила Мочалов 2023-11-18 20:32:54 +04:00
parent 7872460be3
commit e839f69d19
4 changed files with 276 additions and 229 deletions

View File

@ -73,13 +73,29 @@ abstract class AppDatabase : RoomDatabase() {
// OrderProducts
val orderProductDao = database.orderProductDao()
val op1 = OrderProductModel(1, 1, 2, 200)
val op2 = OrderProductModel(2, 4, 3, 150)
val op3 = OrderProductModel(3, 3, 1, 80)
val op4 = OrderProductModel(4, 2, 1, 120)
val op2 = OrderProductModel(1, 4, 3, 150)
val op3 = OrderProductModel(1, 3, 1, 80)
val op4 = OrderProductModel(2, 1, 2, 200)
val op5 = OrderProductModel(2, 4, 3, 150)
val op6 = OrderProductModel(2, 3, 1, 80)
val op7 = OrderProductModel(3, 1, 2, 200)
val op8 = OrderProductModel(3, 4, 3, 150)
val op9 = OrderProductModel(3, 3, 1, 80)
val op10 = OrderProductModel(4, 1, 2, 200)
val op11 = OrderProductModel(4, 4, 3, 150)
val op12 = OrderProductModel(4, 3, 1, 80)
orderProductDao.insert(op1)
orderProductDao.insert(op2)
orderProductDao.insert(op3)
orderProductDao.insert(op4)
orderProductDao.insert(op5)
orderProductDao.insert(op6)
orderProductDao.insert(op7)
orderProductDao.insert(op8)
orderProductDao.insert(op9)
orderProductDao.insert(op10)
orderProductDao.insert(op11)
orderProductDao.insert(op12)
}
}

View File

@ -7,5 +7,5 @@ data class OrderProductModelWithProduct(
@Embedded
val orderProductModel: OrderProductModel,
@Relation(entity = ProductModel::class, parentColumn = "product_id", entityColumn = "id")
val productList: List<ProductModel>
val product: ProductModel
)

View File

@ -24,7 +24,9 @@ import androidx.compose.material.Icon
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -73,12 +75,12 @@ fun CartWidget(){
}
}
val unpaidOrders = mutableListOf<OrderWithProducts>()
var unpaidOrder: OrderWithProducts? = null
val preparingOrders = mutableListOf<OrderWithProducts>()
for(order in orders) {
if (order.order.status == OrderStatus.Неоплачено.toString()) {
unpaidOrders.add(order)
unpaidOrder = order
}
if (order.order.status == OrderStatus.Готовится.toString() || order.order.status == OrderStatus.Готово.toString()) {
preparingOrders.add(order)
@ -105,7 +107,7 @@ fun CartWidget(){
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxWidth()
.padding(top=55.dp)
.padding(top = 55.dp)
.verticalScroll(rememberScrollState())
) {
@ -132,14 +134,8 @@ fun CartWidget(){
modifier = Modifier.padding(top = 15.dp),
fontWeight = FontWeight.Bold
)
LazyColumn(
modifier = Modifier
.width(340.dp)
.height(200.dp)
) {
items(unpaidOrders.size) {index ->
CartItem(unpaidOrders[index])
}
if (unpaidOrder != null) {
CartItem(order = unpaidOrder)
}
Spacer(modifier = Modifier.height(20.dp))
@ -175,59 +171,62 @@ fun PaidItem(order : OrderWithProducts) {
shape = RoundedCornerShape(size = 20.dp),
backgroundColor = Color.White,
modifier = Modifier.size(340.dp, 100.dp)
) {
Column {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp)
){
Text(
text = order.orderWithProducts[0].productList[0].title,
fontFamily = NunitoFamily,
fontSize = 20.sp,
modifier = Modifier.padding(top = 15.dp),
fontWeight = FontWeight.Bold
)
Text(
text = "x" + order.orderWithProducts[0].orderProductModel.quantity,
fontFamily = NunitoFamily,
fontSize = 20.sp,
modifier = Modifier.padding(top = 15.dp),
fontWeight = FontWeight.Bold
)
Text(
text = order.orderWithProducts[0].orderProductModel.totalPrice.toString() + " руб.",
fontFamily = NunitoFamily,
fontSize = 20.sp,
modifier = Modifier.padding(top = 15.dp),
fontWeight = FontWeight.Bold
)
}
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp)
){
Text(
text = "Статус: ",
fontFamily = NunitoFamily,
fontSize = 20.sp,
modifier = Modifier.padding(top = 15.dp),
fontWeight = FontWeight.Bold,
color = Color.Gray
)
Text(
text = order.order.status,
fontFamily = NunitoFamily,
fontSize = 20.sp,
modifier = Modifier.padding(top = 15.dp),
fontWeight = FontWeight.Bold,
color = Color.Gray
)
) {
LazyColumn {
items(order.orderWithProducts.size) { index ->
if (index == 0) {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.fillMaxWidth()
.padding(start = 20.dp, end = 20.dp)
){
Text(
text = "Статус: ",
fontFamily = NunitoFamily,
fontSize = 20.sp,
modifier = Modifier.padding(top = 15.dp),
fontWeight = FontWeight.Bold,
color = Color.Gray
)
Text(
text = order.order.status,
fontFamily = NunitoFamily,
fontSize = 20.sp,
modifier = Modifier.padding(top = 15.dp),
fontWeight = FontWeight.Bold,
color = Color.Gray
)
}
}
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp)
) {
Text(
text = order.orderWithProducts[index].product.title,
fontFamily = NunitoFamily,
fontSize = 20.sp,
modifier = Modifier.padding(top = 15.dp),
fontWeight = FontWeight.Bold
)
Text(
text = "x" + order.orderWithProducts[index].orderProductModel.quantity,
fontFamily = NunitoFamily,
fontSize = 20.sp,
modifier = Modifier.padding(top = 15.dp),
fontWeight = FontWeight.Bold
)
Text(
text = order.orderWithProducts[index].orderProductModel.totalPrice.toString() + " руб.",
fontFamily = NunitoFamily,
fontSize = 20.sp,
modifier = Modifier.padding(top = 15.dp),
fontWeight = FontWeight.Bold
)
}
}
}
}
@ -240,60 +239,64 @@ fun CartItem(order : OrderWithProducts) {
border = BorderStroke(width = 2.dp, color = MyOrange),
shape = RoundedCornerShape(size = 20.dp),
backgroundColor = Color.White,
modifier = Modifier.size(340.dp, 100.dp)
modifier = Modifier.size(340.dp, 180.dp)
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.padding(20.dp)
LazyColumn (
horizontalAlignment = Alignment.CenterHorizontally
) {
Column(
modifier = Modifier.fillMaxWidth(0.5f)
) {
items(order.orderWithProducts.size) {index ->
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.fillMaxWidth()
){
Text(
text = order.orderWithProducts[0].productList[0].title,
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
Text(
text = "x" + order.orderWithProducts[0].orderProductModel.quantity,
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
}
Text(
text = order.orderWithProducts[0].orderProductModel.totalPrice.toString() + " руб.",
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
}
modifier = Modifier.padding(20.dp).size(340.dp, 60.dp)
) {
Column(
modifier = Modifier.fillMaxWidth(0.5f)
) {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.fillMaxWidth()
) {
Text(
text = order.orderWithProducts[index].product.title,
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
Text(
text = "x" + order.orderWithProducts[index].orderProductModel.quantity,
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
}
Text(
text = order.orderWithProducts[index].orderProductModel.totalPrice.toString() + " руб.",
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
}
Button(
colors = ButtonDefaults.buttonColors(
backgroundColor = MyLightRed
),
shape = RoundedCornerShape(size = 10.dp),
modifier = Modifier
.size(100.dp, 60.dp)
.fillMaxSize(0.5f),
onClick = { /*TODO*/ }
) {
Icon(
painter = painterResource(id = R.drawable.trash),
contentDescription = "Delete",
modifier = Modifier.size(42.dp)
)
}
Button(
colors = ButtonDefaults.buttonColors(
backgroundColor = MyLightRed
),
shape = RoundedCornerShape(size = 10.dp),
modifier = Modifier
.size(100.dp, 60.dp)
.fillMaxSize(0.5f),
onClick = { /*TODO*/ }
) {
Icon(
painter = painterResource(id = R.drawable.trash),
contentDescription = "Delete",
modifier = Modifier.size(42.dp)
)
}
}
}
}
Spacer(modifier = Modifier.height(20.dp))
}

View File

@ -5,6 +5,8 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
@ -180,61 +182,72 @@ fun PreparingItem(order : OrderWithProducts){
border = BorderStroke(width = 2.dp, color = MyOrange),
shape = RoundedCornerShape(size = 20.dp),
backgroundColor = Color.White,
modifier = Modifier.size(340.dp, 100.dp)
modifier = Modifier.size(340.dp, 200.dp)
){
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.padding(20.dp)
){
Column(
Column(
modifier = Modifier.fillMaxWidth(0.5f)
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.padding(20.dp).size(340.dp,60.dp)
){
val localDateFormat = SimpleDateFormat("HH:mm")
val time = localDateFormat.format(order.order.date)
Text(
text = time,
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.fillMaxWidth()
Column(
modifier = Modifier.fillMaxWidth(0.5f)
){
val localDateFormat = SimpleDateFormat("HH:mm")
val time = localDateFormat.format(order.order.date)
Text(
text = order.orderWithProducts[0].productList[0].title,
text = time,
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
}
Button(
colors = ButtonDefaults.buttonColors(
backgroundColor = MyLightYellow
),
shape = RoundedCornerShape(size = 10.dp),
modifier = Modifier
.size(170.dp, 80.dp)
.fillMaxSize(),
onClick = { /*TODO*/ }
) {
Text(
text = "x" + order.orderWithProducts[0].orderProductModel.quantity,
text = "Готово!",
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontSize = 14.sp,
fontWeight = FontWeight.Bold
)
}
}
LazyColumn(
modifier = Modifier.fillMaxWidth().padding(horizontal = 20.dp)
){
items(order.orderWithProducts.size) {index ->
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
Button(
colors = ButtonDefaults.buttonColors(
backgroundColor = MyLightYellow
),
shape = RoundedCornerShape(size = 10.dp),
modifier = Modifier
.size(100.dp, 60.dp)
.fillMaxSize(0.5f),
onClick = { /*TODO*/ }
) {
Text(
text = "Готово!",
fontFamily = NunitoFamily,
fontSize = 14.sp,
fontWeight = FontWeight.Bold
)
) {
Text(
text = order.orderWithProducts[index].product.title,
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
Text(
text = "x" + order.orderWithProducts[index].orderProductModel.quantity,
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
}
}
}
}
}
@ -248,61 +261,72 @@ fun PreparedItem(order : OrderWithProducts){
border = BorderStroke(width = 2.dp, color = MyOrange),
shape = RoundedCornerShape(size = 20.dp),
backgroundColor = Color.White,
modifier = Modifier.size(340.dp, 100.dp)
modifier = Modifier.size(340.dp, 200.dp)
){
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.padding(20.dp)
){
Column(
Column(
modifier = Modifier.fillMaxWidth(0.5f)
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.padding(20.dp).size(340.dp,60.dp)
){
val localDateFormat = SimpleDateFormat("HH:mm")
val time = localDateFormat.format(order.order.date)
Text(
text = time,
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.fillMaxWidth()
Column(
modifier = Modifier.fillMaxWidth(0.5f)
){
val localDateFormat = SimpleDateFormat("HH:mm")
val time = localDateFormat.format(order.order.date)
Text(
text = order.orderWithProducts[0].productList[0].title,
text = time,
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
}
Button(
colors = ButtonDefaults.buttonColors(
backgroundColor = MyLightYellow
),
shape = RoundedCornerShape(size = 10.dp),
modifier = Modifier
.size(170.dp, 80.dp)
.fillMaxSize(),
onClick = { /*TODO*/ }
) {
Text(
text = "x" + order.orderWithProducts[0].orderProductModel.quantity,
text = "Выдано!",
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontSize = 14.sp,
fontWeight = FontWeight.Bold
)
}
}
LazyColumn(
modifier = Modifier.fillMaxWidth().padding(horizontal = 20.dp)
){
items(order.orderWithProducts.size) {index ->
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
Button(
colors = ButtonDefaults.buttonColors(
backgroundColor = MyLightYellow
),
shape = RoundedCornerShape(size = 10.dp),
modifier = Modifier
.size(100.dp, 60.dp)
.fillMaxSize(0.5f),
onClick = { /*TODO*/ }
) {
Text(
text = "Выдано!",
fontFamily = NunitoFamily,
fontSize = 14.sp,
fontWeight = FontWeight.Bold
)
) {
Text(
text = order.orderWithProducts[index].product.title,
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
Text(
text = "x" + order.orderWithProducts[index].orderProductModel.quantity,
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
}
}
}
}
}
@ -316,61 +340,65 @@ fun ProcessedItem(order : OrderWithProducts){
border = BorderStroke(width = 2.dp, color = MyOrange),
shape = RoundedCornerShape(size = 20.dp),
backgroundColor = Color.White,
modifier = Modifier.size(340.dp, 100.dp)
modifier = Modifier.size(340.dp, 200.dp)
){
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.padding(20.dp)
){
Column(
Column(
modifier = Modifier.fillMaxWidth(0.5f)
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.padding(20.dp).size(340.dp,60.dp)
){
val localDateFormat = SimpleDateFormat("HH:mm")
val time = localDateFormat.format(order.order.date)
Text(
text = time,
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.fillMaxWidth()
Column(
modifier = Modifier.fillMaxWidth(0.5f)
){
val localDateFormat = SimpleDateFormat("HH:mm")
val time = localDateFormat.format(order.order.date)
Text(
text = order.orderWithProducts[0].productList[0].title,
text = time,
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
}
Column(
modifier = Modifier.fillMaxWidth(0.5f)
){
Text(
text = "x" + order.orderWithProducts[0].orderProductModel.quantity,
text = order.order.date.toString(),
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontSize = 16.sp,
fontWeight = FontWeight.Bold
)
}
}
Column(
modifier = Modifier.fillMaxWidth(0.5f)
LazyColumn(
modifier = Modifier.fillMaxWidth().padding(horizontal = 20.dp)
){
Text(
text = order.orderWithProducts[0].orderProductModel.totalPrice.toString(),
fontFamily = NunitoFamily,
fontSize = 14.sp,
fontWeight = FontWeight.Bold
)
Text(
text = order.order.date.toString(),
fontFamily = NunitoFamily,
fontSize = 14.sp,
fontWeight = FontWeight.Bold
)
items(order.orderWithProducts.size) {index ->
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
) {
Text(
text = order.orderWithProducts[index].product.title,
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
Text(
text = "x" + order.orderWithProducts[index].orderProductModel.quantity,
fontFamily = NunitoFamily,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
}
}
}
}
}