feat: format group names
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2026 Gleb Zaharov. License: GPLv3 (see LICENSE).
|
||||
|
||||
package ru.sweetbread.unn.ui.composes
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.Shape
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun GroupsNameText(
|
||||
text: String,
|
||||
modifier: Modifier = Modifier,
|
||||
highlightColor: Color = MaterialTheme.colorScheme.secondaryContainer,
|
||||
highlightPadding: PaddingValues = PaddingValues(horizontal = 6.dp, vertical = 2.dp),
|
||||
highlightShape: Shape = MaterialTheme.shapes.small,
|
||||
horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
|
||||
) {
|
||||
val suffix = if (text.endsWith("-В-OUP")) "-В-OUP" else null
|
||||
val mainPart = if (suffix != null) text.dropLast(6) else text
|
||||
val blocks = mainPart.split('|')
|
||||
|
||||
FlowRow(
|
||||
modifier = modifier,
|
||||
horizontalArrangement = horizontalArrangement,
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
blocks.forEach { block ->
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(end = 2.dp)
|
||||
.background(highlightColor, highlightShape)
|
||||
.padding(highlightPadding)
|
||||
) {
|
||||
Text(text = block)
|
||||
}
|
||||
}
|
||||
|
||||
suffix?.let { Text(text = it) }
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,10 @@ fun ScheduleItem(modifier: Modifier = Modifier, unit: ScheduleUnit, expanded: Bo
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
AnimatedVisibility (expanded) {
|
||||
Text(text = unit.stream)
|
||||
GroupsNameText(
|
||||
unit.stream,
|
||||
highlightColor = MaterialTheme.colorScheme.inversePrimary
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user