Cosmetics
This commit is contained in:
@@ -34,10 +34,13 @@ import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import compose.icons.TablerIcons
|
||||
import compose.icons.tablericons.Table
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import compose.icons.FontAwesomeIcons
|
||||
import compose.icons.fontawesomeicons.Solid
|
||||
import compose.icons.tablericons.ArrowBigRight
|
||||
import compose.icons.tablericons.FileText
|
||||
import compose.icons.fontawesomeicons.solid.PlayCircle
|
||||
import compose.icons.tablericons.ArrowBigLeft
|
||||
import models.Term
|
||||
import models.TermFull
|
||||
import kotlinx.coroutines.*
|
||||
@@ -45,12 +48,13 @@ import kotlinx.coroutines.*
|
||||
@Composable
|
||||
fun RowScope.TableCell(
|
||||
text: String,
|
||||
weight: Float
|
||||
weight: Float,
|
||||
color: Color = Color.Gray
|
||||
) {
|
||||
Text(
|
||||
text = text,
|
||||
Modifier
|
||||
.border(1.dp, Color.Black)
|
||||
.border(1.dp, Color.LightGray)
|
||||
.weight(weight)
|
||||
.padding(4.dp)
|
||||
)
|
||||
@@ -83,7 +87,8 @@ fun groupByString1(terms: List<TermFull>): MutableList<MutableList<TermFull>> {
|
||||
@Composable
|
||||
fun SearchBarTextField(viewModel: MainModelView) {
|
||||
val query = remember { mutableStateOf("") }
|
||||
val columnViewType = remember { mutableStateOf(false) }
|
||||
var columnViewType = remember { mutableStateOf(false) }
|
||||
var tDirection = remember { mutableStateOf(1) }
|
||||
Column {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
@@ -114,9 +119,23 @@ fun SearchBarTextField(viewModel: MainModelView) {
|
||||
)
|
||||
Row (Modifier.width(155.dp).border(width = 2.dp, Color.Black)) {
|
||||
Spacer(modifier = Modifier.padding(2.dp))
|
||||
Icon(TablerIcons.Table, contentDescription = "Table View", modifier = Modifier.size(width = 50.dp, height = 50.dp))
|
||||
IconButton(onClick = {
|
||||
columnViewType.value = !columnViewType.value
|
||||
}) {
|
||||
if (columnViewType.value)
|
||||
Icon(TablerIcons.Table, contentDescription = "Table View", modifier = Modifier.size(width = 50.dp, height = 50.dp))
|
||||
else
|
||||
Icon(TablerIcons.FileText, contentDescription = "Table View", modifier = Modifier.size(width = 50.dp, height = 50.dp))
|
||||
}
|
||||
Spacer(modifier = Modifier.padding(2.dp))
|
||||
Icon(TablerIcons.ArrowBigRight, contentDescription = "Table View", modifier = Modifier.size(width = 50.dp, height = 50.dp))
|
||||
IconButton(onClick = {
|
||||
tDirection.value = if (tDirection.value == 1) 2 else 1
|
||||
}) {
|
||||
if (tDirection.value == 1)
|
||||
Icon(TablerIcons.ArrowBigRight, contentDescription = "Table View", modifier = Modifier.size(width = 50.dp, height = 50.dp))
|
||||
else
|
||||
Icon(TablerIcons.ArrowBigLeft, contentDescription = "Table View", modifier = Modifier.size(width = 50.dp, height = 50.dp))
|
||||
}
|
||||
Spacer(modifier = Modifier.padding(2.dp))
|
||||
Icon(Icons.Filled.Settings, contentDescription = "Table View", modifier = Modifier.size(width = 50.dp, height = 50.dp))
|
||||
//Spacer(modifier = Modifier.fillMaxWidth())
|
||||
@@ -138,11 +157,10 @@ fun SearchBarTextField(viewModel: MainModelView) {
|
||||
val column2Weight = .5f // 50%
|
||||
// The LazyColumn will be our table. Notice the use of the weights below
|
||||
LazyColumn(Modifier.fillMaxSize().padding(0.dp)) {
|
||||
// Here is the header
|
||||
itemsIndexed(items = terms!!, itemContent = { i, t ->
|
||||
val color = if (i % 2 == 1) Color.hsl(hue = 168f, saturation = .77f, lightness = .68f, alpha = 1f) else Color.hsl(hue = 217f, saturation = .77f, lightness = .68f, alpha = 1f)
|
||||
|
||||
items(items = terms!!, itemContent = { t ->
|
||||
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
Row(Modifier.fillMaxWidth().background(color)) {
|
||||
TableCell(text = t.string1, weight = column1Weight)
|
||||
TableCell(text = t.string2, weight = column2Weight)
|
||||
}
|
||||
@@ -155,13 +173,12 @@ fun SearchBarTextField(viewModel: MainModelView) {
|
||||
val terms2: MutableList<MutableList<TermFull>> = groupByString1(terms!!)
|
||||
|
||||
LazyColumn(Modifier.fillMaxSize().padding(0.dp)) {
|
||||
var i=0
|
||||
var rowBackground = Color.LightGray
|
||||
items(items = terms2, itemContent = { t2 ->
|
||||
itemsIndexed(items = terms2, itemContent = { i, t2 ->
|
||||
var t : TermFull? = null
|
||||
if (t2.size > 0) t = t2[0]
|
||||
else return@items
|
||||
when ( i++ % 2 ) {
|
||||
else return@itemsIndexed
|
||||
when ( i % 2 ) {
|
||||
0 -> rowBackground = Color.LightGray
|
||||
1 -> rowBackground = Color.Gray
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user