Fix status text contrast on green rows

Green status rows used white text, which was difficult to read against the green background. This change selects a contrasting text color based on the status color so green rows use black text and other statuses keep white text for better legibility in the status table.
This commit is contained in:
Tony Bark 2026-08-23 21:46:15 -04:00
parent 915d0ec2dc
commit c74e6166bf

View file

@ -60,7 +60,9 @@ struct ContentView: View {
RoundedRectangle(cornerRadius: 0) RoundedRectangle(cornerRadius: 0)
.fill(row.status.color) .fill(row.status.color)
Text(row.status.descrption) Text(row.status.descrption)
.foregroundColor(Color.white) .foregroundColor(
statusColour(row.status.color)
)
} }
} }
TableColumn("Track", value: \TrainStatusRow.platform) TableColumn("Track", value: \TrainStatusRow.platform)
@ -92,6 +94,15 @@ struct ContentView: View {
var normalizedStationCode: String { var normalizedStationCode: String {
stationCode.trimmingCharacters(in: .whitespacesAndNewlines).uppercased() stationCode.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()
} }
func statusColour(_ color: Color) -> Color {
switch color {
case .green:
return .black
default:
return .white
}
}
func loadTrainStatus(forStationCode code: String) async { func loadTrainStatus(forStationCode code: String) async {
guard !code.isEmpty else { guard !code.isEmpty else {