Arrival data can be shown on click

This commit is contained in:
2023-12-30 22:53:30 +02:00
parent d39a000fb7
commit 23218c22d7
2 changed files with 41 additions and 2 deletions

View File

@@ -51,6 +51,9 @@ class _FetchAPIState extends State<FetchAPI> {
title: Text("Arrival Time: ${snapshot.data![index].timeOfDay}"), title: Text("Arrival Time: ${snapshot.data![index].timeOfDay}"),
titleAlignment: ListTileTitleAlignment.center, titleAlignment: ListTileTitleAlignment.center,
subtitle: Text("Week Day: ${weekNumToString(snapshot.data![index].weekDay)}"), subtitle: Text("Week Day: ${weekNumToString(snapshot.data![index].weekDay)}"),
onTap: () => {
showArrivalInfo(context, snapshot.data![index])
},
); );
}, },
); );
@@ -107,5 +110,41 @@ String weekNumToString(int weekday) {
return "Sunday"; return "Sunday";
} }
throw "AAAAAAAAA"; 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 dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}
String directionParse(bool direction) {
switch (direction) {
case true:
return "Raml";
case false:
return "Victoria";
}
} }

View File

@@ -205,7 +205,7 @@ class _InputDataState extends State<InputData> {
} }
} }
showAlertDialog(BuildContext context, int chosenLine, String chosenColour, String chosenDir, String submissionDate) { showSubmissionSuccess(BuildContext context, int chosenLine, String chosenColour, String chosenDir, String submissionDate) {
// Delay (I want the splash to show) // Delay (I want the splash to show)
//Future.delayed(const Duration(milliseconds: 200)); //Future.delayed(const Duration(milliseconds: 200));