Я бы не заснул, если бы не доделал дезигн, вот сейчас еще доделаю ошибочки а завтра на работу к 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.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
@ -213,7 +215,7 @@ fun ReportPage (navController: NavController?, viewModel: ReportViewModel = view
TableScreen(reportData = reportResultPageState.resReport)
Spacer(modifier = Modifier.height(16.dp))
Spacer(modifier = Modifier.height(4.dp))
if (viewModel.reportPageUiState.isEntryValid) {
Button(
@ -287,31 +289,43 @@ fun RowScope.TableCell(
@Composable
fun TableScreen(reportData: List<ReportRemote>) {
val column1Weight = .3f // 30%
val column2Weight = 1f // 30%
Column(
Modifier
.padding(16.dp)
.padding(8.dp)
) {
Row(Modifier.background(Color.White)) {
TableCell(text = "ID\n", weight = column1Weight)
TableCell(text = "Дата\n", weight = column1Weight)
TableCell(text = "Вес\n", weight = column1Weight)
TableCell(text = "Кол-во", weight = column1Weight)
TableCell(text = "ID вел.", weight = column1Weight)
Row(
modifier = Modifier
.background(MaterialTheme.colorScheme.onBackground)
.height(48.dp)
.padding(4.dp)
.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.
reportData.forEach {
val (id, dateTime, weight, maxCount, bikeId) = it
Row(Modifier.fillMaxWidth()) {
TableCell(text = id.toString(), weight = column1Weight)
TableCell(text = dateTime.toString(), weight = column1Weight)
TableCell(text = weight.toString(), weight = column1Weight)
TableCell(text = maxCount.toString(), weight = column1Weight)
TableCell(text = bikeId.toString(), weight = column1Weight)
Card(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 8.dp, horizontal = 4.dp),
) {
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))
}
}
}
}