mirror of
https://github.com/praktimarc/kst4contest.git
synced 2026-10-19 05:42:58 +02:00
Etappen 3 to 6a of the migration (129 commits). Every window the operator sees is Compose; the JavaFX ones still exist beside them so the two could be compared against a live session, which is the only way the differences came to light. The toolchain first, then the settings window with its eleven tabs and 72 real preferences; then the multi-column table as a component, and with it the rules it needs -- stable row identity, a selection that survives a refresh, column order the operator can drag, and a repaint when the rows change rather than when the list instance does. Then the update and monitor windows, and the main window: 22 station columns, the filter bar, the selected-station panel, the message tabs, the priority bar, the sked controls, the status indicators and the timeline, assembled behind a splitter because Compose has none. The map stops being a WebView. A Compose canvas projects WebMercator tiles itself, with the clustering in core and an asynchronous fetcher in place of the local tile proxy; derive() becomes a pure Kotlin reimplementation instead of a reflection call into com.sun.javafx. Most of the volume here is parity the operator would notice rather than new behaviour: desktop density instead of Material's phone minimums, colours taken from the JavaFX stylesheets instead of Material's palette, row dividers, band columns, grid-square labels and their colours, the home marker and antenna beam, pinch-to-zoom under Wayland, and layouts that survive a window narrower than the chart they stack. Two lessons are worth more than the diff. A control bound to a value Compose cannot observe writes through and never redraws -- that one shipped repeatedly with a green build, because no test drew anything. And a layout that clips instead of wrapping is worse than one that is merely too narrow: half a word is the worst available outcome.
183 lines
7.0 KiB
Python
183 lines
7.0 KiB
Python
import sys
|
|
|
|
content = """package kst4contest.view.compose
|
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
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.fillMaxWidth
|
|
import androidx.compose.foundation.layout.heightIn
|
|
import androidx.compose.foundation.layout.padding
|
|
import androidx.compose.foundation.layout.width
|
|
import androidx.compose.material3.MaterialTheme
|
|
import androidx.compose.material3.Text
|
|
import androidx.compose.material3.TextField
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.ui.Alignment
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
/**
|
|
* The filter bar above the station list.
|
|
*/
|
|
@OptIn(ExperimentalLayoutApi::class)
|
|
@Composable
|
|
fun StationFilterBar(
|
|
filters: StationFilterState,
|
|
onChanged: () -> Unit,
|
|
modifier: Modifier = Modifier,
|
|
) {
|
|
Column(
|
|
modifier = modifier.fillMaxWidth().padding(2.dp),
|
|
verticalArrangement = Arrangement.spacedBy(2.dp),
|
|
) {
|
|
Row(
|
|
modifier = Modifier.fillMaxWidth(),
|
|
horizontalArrangement = Arrangement.SpaceBetween,
|
|
verticalAlignment = Alignment.CenterVertically
|
|
) {
|
|
Row(horizontalArrangement = Arrangement.spacedBy(Density.BUTTON_GAP), verticalAlignment = Alignment.CenterVertically) {
|
|
androidx.compose.material3.OutlinedTextField(
|
|
value = filters.searchText,
|
|
onValueChange = {
|
|
filters.searchText = it
|
|
onChanged()
|
|
},
|
|
label = { Text("User filter", style = MaterialTheme.typography.bodySmall) },
|
|
modifier = Modifier.width(150.dp).heightIn(min = Density.BUTTON_MIN_HEIGHT),
|
|
singleLine = true,
|
|
textStyle = MaterialTheme.typography.bodySmall
|
|
)
|
|
androidx.compose.material3.Button(
|
|
onClick = {
|
|
filters.reset()
|
|
onChanged()
|
|
},
|
|
shape = Density.BUTTON_SHAPE,
|
|
contentPadding = Density.BUTTON_CONTENT_PADDING,
|
|
modifier = Modifier.heightIn(min = Density.BUTTON_MIN_HEIGHT)
|
|
) {
|
|
Text("Reset filters", style = MaterialTheme.typography.bodySmall)
|
|
}
|
|
}
|
|
}
|
|
|
|
FlowRow(horizontalArrangement = Arrangement.spacedBy(Density.BUTTON_GAP)) {
|
|
FilterToggle("Only new grids", filters.onlyNewGrids) {
|
|
filters.onlyNewGrids = it
|
|
onChanged()
|
|
}
|
|
FilterToggle("Tropo >=0dB", filters.tropoReachable) {
|
|
filters.tropoReachable = it
|
|
onChanged()
|
|
}
|
|
FilterToggle("New bands", filters.newBands) {
|
|
filters.newBands = it
|
|
onChanged()
|
|
}
|
|
FilterToggle("AS next 5m", filters.airScoutNext5Min) {
|
|
filters.airScoutNext5Min = it
|
|
onChanged()
|
|
}
|
|
FilterToggle("Inactive stations", filters.hideInactive) {
|
|
filters.hideInactive = it
|
|
onChanged()
|
|
}
|
|
/* Not a filter. It colours the locator cell and hides nothing. */
|
|
FilterToggle("Grid color", filters.gridColouring) { filters.gridColouring = it }
|
|
}
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
Text("Hide worked:", style = MaterialTheme.typography.bodySmall,
|
|
modifier = Modifier.width(90.dp))
|
|
|
|
FilterToggle("wkd", filters.hideWorkedAny) {
|
|
filters.hideWorkedAny = it
|
|
onChanged()
|
|
}
|
|
|
|
FlowRow(horizontalArrangement = Arrangement.spacedBy(Density.BUTTON_GAP)) {
|
|
WorkedBandFilter.entries.forEach { band ->
|
|
FilterToggle(band.label, filters.isHideWorkedOn(band)) {
|
|
filters.setHideWorkedOn(band, it)
|
|
onChanged()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
Text("Show only QTF:", style = MaterialTheme.typography.bodySmall,
|
|
modifier = Modifier.width(90.dp))
|
|
|
|
FilterToggle("on", filters.qtfEnabled) {
|
|
filters.qtfEnabled = it
|
|
onChanged()
|
|
}
|
|
|
|
androidx.compose.material3.OutlinedTextField(
|
|
value = if (filters.qtfDegrees.rem(1) == 0.0) filters.qtfDegrees.toInt().toString() else filters.qtfDegrees.toString(),
|
|
onValueChange = {
|
|
val parsed = it.toDoubleOrNull()
|
|
if (parsed != null) {
|
|
filters.qtfDegrees = parsed
|
|
filters.bearing = null
|
|
if (filters.qtfEnabled) {
|
|
onChanged()
|
|
}
|
|
} else if (it.isEmpty()) {
|
|
filters.qtfDegrees = 0.0
|
|
filters.bearing = null
|
|
if (filters.qtfEnabled) {
|
|
onChanged()
|
|
}
|
|
}
|
|
},
|
|
modifier = Modifier.width(60.dp).padding(start = 6.dp).heightIn(min = Density.BUTTON_MIN_HEIGHT),
|
|
singleLine = true,
|
|
textStyle = MaterialTheme.typography.bodySmall
|
|
)
|
|
|
|
FlowRow(
|
|
horizontalArrangement = Arrangement.spacedBy(Density.BUTTON_GAP),
|
|
modifier = Modifier.padding(start = 6.dp),
|
|
) {
|
|
Bearing.entries.forEach { bearing ->
|
|
FilterToggle(bearing.name, filters.bearing == bearing) {
|
|
filters.selectBearing(bearing)
|
|
if (filters.qtfEnabled) {
|
|
onChanged()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/** A toggle in the filter bar: pressed means on, and it says so by its colour. */
|
|
@Composable
|
|
private fun FilterToggle(label: String, on: Boolean, onChange: (Boolean) -> Unit) {
|
|
val colours = if (on) {
|
|
androidx.compose.material3.ButtonDefaults.buttonColors()
|
|
} else {
|
|
androidx.compose.material3.ButtonDefaults.outlinedButtonColors()
|
|
}
|
|
|
|
androidx.compose.material3.Button(
|
|
onClick = { onChange(!on) },
|
|
colors = colours,
|
|
shape = Density.BUTTON_SHAPE,
|
|
contentPadding = Density.BUTTON_CONTENT_PADDING,
|
|
border = if (on) null else androidx.compose.foundation.BorderStroke(
|
|
Density.HAIRLINE,
|
|
MaterialTheme.colorScheme.outline,
|
|
),
|
|
modifier = Modifier.heightIn(min = Density.BUTTON_MIN_HEIGHT),
|
|
) {
|
|
Text(label, style = MaterialTheme.typography.bodySmall, maxLines = 1)
|
|
}
|
|
}
|