Shifting back the line

This commit is contained in:
2023-12-30 23:08:51 +02:00
parent 7a0bd79e37
commit 49508758b5

View File

@@ -108,6 +108,33 @@ class _FetchAPIState extends State<FetchAPI> {
} }
} }
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) { String weekNumToString(int weekday) {
switch (weekday) { switch (weekday) {
case 1: case 1:
@@ -129,33 +156,6 @@ String weekNumToString(int weekday) {
throw "Week Day Parse Error"; 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) { String directionParse(bool direction) {
switch (direction) { switch (direction) {
case true: case true:
@@ -164,3 +164,14 @@ String directionParse(bool direction) {
return "Victoria"; return "Victoria";
} }
} }
int lineShift(int line) {
switch (line) {
case 3:
return 1;
case 4:
return 2;
default:
return line;
}
}