From 49508758b58fb3b517e7bca049e20840b5f37a0f Mon Sep 17 00:00:00 2001 From: Supermjork Date: Sat, 30 Dec 2023 23:08:51 +0200 Subject: [PATCH] Shifting back the line --- lib/fetcher.dart | 65 ++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/lib/fetcher.dart b/lib/fetcher.dart index d89dc4f..44a24d9 100644 --- a/lib/fetcher.dart +++ b/lib/fetcher.dart @@ -108,6 +108,33 @@ class _FetchAPIState extends State { } } +showArrivalInfo(BuildContext context, Arrival data) { + // set up the button + Widget okButton = TextButton( + child: const Text("Back"), + onPressed: () { + Navigator.pop(context); + }, + ); + + // set up the AlertDialog + AlertDialog alert = AlertDialog( + title: const Text("Selected Arrival Info"), + content: Text("Tram Colour: JSON DOESN'T HAVE COLOUR\n\nChosen Line: ${lineShift(data.tramLine)}\n\nDirection: ${directionParse(data.direction)}\n\nSubmitted On: ${data.timeOfDay} (Needs to include date)"), + actions: [ + okButton, + ], + ); + + // show the dialogue + showDialog( + context: context, + builder: (BuildContext context) { + return alert; + }, + ); +} + String weekNumToString(int weekday) { switch (weekday) { case 1: @@ -129,33 +156,6 @@ String weekNumToString(int weekday) { throw "Week Day Parse Error"; } -showArrivalInfo(BuildContext context, Arrival data) { - // set up the button - Widget okButton = TextButton( - child: const Text("Back"), - onPressed: () { - Navigator.pop(context); - }, - ); - - // set up the AlertDialog - AlertDialog alert = AlertDialog( - title: const Text("Selected Arrival Info"), - content: Text("Tram Colour: JSON DOESN'T HAVE COLOUR\n\nChosen Line: ${data.tramLine}\n\nDirection: ${directionParse(data.direction)}\n\nSubmitted On: ${data.timeOfDay} (Needs to include date)"), - actions: [ - okButton, - ], - ); - - // show the dialogue - showDialog( - context: context, - builder: (BuildContext context) { - return alert; - }, - ); -} - String directionParse(bool direction) { switch (direction) { case true: @@ -164,3 +164,14 @@ String directionParse(bool direction) { return "Victoria"; } } + +int lineShift(int line) { + switch (line) { + case 3: + return 1; + case 4: + return 2; + default: + return line; + } +} \ No newline at end of file