Я бы не заснул, если бы не доделал дезигн, вот сейчас еще доделаю ошибочки а завтра на работу к 9....

This commit is contained in:
Кашин Максим 2023-12-26 01:27:26 +04:00
parent 3b1dfec3bd
commit 34f56e6c89

View File

@ -50,7 +50,9 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.TextStyle
@ -213,7 +215,7 @@ fun ReportPage (navController: NavController?, viewModel: ReportViewModel = view
TableScreen(reportData = reportResultPageState.resReport) TableScreen(reportData = reportResultPageState.resReport)
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(4.dp))
if (viewModel.reportPageUiState.isEntryValid) { if (viewModel.reportPageUiState.isEntryValid) {
Button( Button(
@ -287,31 +289,43 @@ fun RowScope.TableCell(
@Composable @Composable
fun TableScreen(reportData: List<ReportRemote>) { fun TableScreen(reportData: List<ReportRemote>) {
val column1Weight = .3f // 30%
val column2Weight = 1f // 30%
Column( Column(
Modifier Modifier
.padding(16.dp) .padding(8.dp)
) { ) {
Row(Modifier.background(Color.White)) { Row(
TableCell(text = "ID\n", weight = column1Weight) modifier = Modifier
TableCell(text = "Дата\n", weight = column1Weight) .background(MaterialTheme.colorScheme.onBackground)
TableCell(text = "Вес\n", weight = column1Weight) .height(48.dp)
TableCell(text = "Кол-во", weight = column1Weight) .padding(4.dp)
TableCell(text = "ID вел.", weight = column1Weight) .fillMaxWidth(), // Занимаем максимальную ширину
verticalAlignment = Alignment.CenterVertically // Выравниваем по центру вертикали
) {
Text("ID", Modifier.weight(0.5f), color = MaterialTheme.colorScheme.background)
Text("Дата", Modifier.weight(1.0f), color = MaterialTheme.colorScheme.background)
Text("Вес", Modifier.weight(1.0f), color = MaterialTheme.colorScheme.background)
Text("Кол-во", Modifier.weight(1.0f), color = MaterialTheme.colorScheme.background)
Text("ID вел.", Modifier.weight(1.0f), color = MaterialTheme.colorScheme.background)
} }
// Here are all the lines of your table. // Here are all the lines of your table.
reportData.forEach { reportData.forEach {
val (id, dateTime, weight, maxCount, bikeId) = it val (id, dateTime, weight, maxCount, bikeId) = it
Row(Modifier.fillMaxWidth()) { Card(
TableCell(text = id.toString(), weight = column1Weight) modifier = Modifier
TableCell(text = dateTime.toString(), weight = column1Weight) .fillMaxWidth()
TableCell(text = weight.toString(), weight = column1Weight) .padding(vertical = 8.dp, horizontal = 4.dp),
TableCell(text = maxCount.toString(), weight = column1Weight) ) {
TableCell(text = bikeId.toString(), weight = column1Weight) Row(Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.background)) {
Text(id.toString(), Modifier.weight(0.5f))
Text(dateTime.toString(), Modifier.weight(1.0f))
Text(weight.toString(), Modifier.weight(1.0f))
Text(maxCount.toString(), Modifier.weight(1.0f))
Text(bikeId.toString(), Modifier.weight(1.0f))
}
} }
} }
} }