mirror of
https://github.com/tonytins/amtkstat.git
synced 2026-10-24 05:32:54 -04:00
Added a few pre-selected stations
- Went with the popular Virtual Railfan ones first. - Moved the error message to its own dedicated space so it doesn't pop up out of nowhere - Fixed a few typos
This commit is contained in:
parent
b9349e2c24
commit
789e697828
2 changed files with 38 additions and 11 deletions
10
README.md
10
README.md
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
## 🖥️ Supported Platforms
|
## 🖥️ Supported Platforms
|
||||||
|
|
||||||
| Platform | Minimum Version |
|
| Platform | Minimum Version |
|
||||||
| --- | --- |
|
| ---------------------------- | --------------- |
|
||||||
| macOS | 13+ |
|
| macOS | 10.15+ |
|
||||||
| Windows | 10+ |
|
| Windows | 10+ |
|
||||||
| Linux | gtk 3+ |
|
| Linux | gtk 3+ |
|
||||||
|
|
||||||
## 🔨 Setup
|
## 🔨 Setup
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ struct ContentView: View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
// TODO: Add pre-selected options in the form of buttons like the original
|
|
||||||
HStack {
|
HStack {
|
||||||
Text("Station Code:")
|
Text("Station Code:")
|
||||||
TextField("e.g. ASD", text: $stationCode)
|
TextField("e.g. ASD", text: $stationCode)
|
||||||
|
|
@ -22,11 +21,32 @@ struct ContentView: View {
|
||||||
}
|
}
|
||||||
}.disabled(normalizedStationCode.isEmpty || isLoading)
|
}.disabled(normalizedStationCode.isEmpty || isLoading)
|
||||||
}.padding(10)
|
}.padding(10)
|
||||||
|
|
||||||
if let errorMessage {
|
// Most popular Virtual Railfan stations
|
||||||
Text(errorMessage).padding(10)
|
HStack {
|
||||||
|
Button("Ashland, VA")
|
||||||
|
{
|
||||||
|
Task {
|
||||||
|
await loadTrainStatus(forStationCode: "ASD")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button("San Juan Capistrano, CA")
|
||||||
|
{
|
||||||
|
Task {
|
||||||
|
await loadTrainStatus(forStationCode: "SNC")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button("La Plata, MO")
|
||||||
|
{
|
||||||
|
Task {
|
||||||
|
await loadTrainStatus(forStationCode: "LAP")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Table(rows) {
|
Table(rows) {
|
||||||
TableColumn("Number", value: \TrainStatusRow.trainNum)
|
TableColumn("Number", value: \TrainStatusRow.trainNum)
|
||||||
TableColumn("Route", value: \TrainStatusRow.routeName)
|
TableColumn("Route", value: \TrainStatusRow.routeName)
|
||||||
|
|
@ -39,6 +59,13 @@ struct ContentView: View {
|
||||||
.padding(10)
|
.padding(10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
if let errorMessage {
|
||||||
|
Text(errorMessage)
|
||||||
|
}
|
||||||
|
}.padding(10)
|
||||||
|
|
||||||
}.padding()
|
}.padding()
|
||||||
.onAppear {
|
.onAppear {
|
||||||
Task {
|
Task {
|
||||||
|
|
@ -67,7 +94,7 @@ struct ContentView: View {
|
||||||
)
|
)
|
||||||
|
|
||||||
guard !trainNumbers.isEmpty else {
|
guard !trainNumbers.isEmpty else {
|
||||||
errorMessage = "Station \(code) has no trains listed right now"
|
errorMessage = "\(code) has no trains listed right now"
|
||||||
rows = []
|
rows = []
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -93,7 +120,7 @@ struct ContentView: View {
|
||||||
}
|
}
|
||||||
rows = newRows
|
rows = newRows
|
||||||
} catch let AmtrakError.stationNotFound(code) {
|
} catch let AmtrakError.stationNotFound(code) {
|
||||||
errorMessage = "Station \(code) not foudn"
|
errorMessage = "Station \(code) not found"
|
||||||
rows = []
|
rows = []
|
||||||
} catch {
|
} catch {
|
||||||
errorMessage = "Couldn't load train status: \(error.localizedDescription)"
|
errorMessage = "Couldn't load train status: \(error.localizedDescription)"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue