Public Access
feat(routes): add route page with functioning route
route is build from previously chosen segments
This commit is contained in:
+76
-16
@@ -233,12 +233,25 @@ class ChooseDeparturePage extends StatefulWidget {
|
||||
|
||||
class _ChooseDeparturePageState extends State<ChooseDeparturePage> {
|
||||
List<Departure> departureList = [];
|
||||
Journey? singleJourney;
|
||||
|
||||
void loadDepartures(Station startStation) async {
|
||||
departureList = await ApiHandler.departures(startStation.id);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void loadJourney(int journeyId) async {
|
||||
singleJourney = await Journey.dbGet(journeyId);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => JourneyDetailPage(
|
||||
singleJourney: singleJourney as Journey,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
initState() {
|
||||
super.initState();
|
||||
@@ -249,7 +262,9 @@ class _ChooseDeparturePageState extends State<ChooseDeparturePage> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('RoutePicker for ${widget.startStation.name}'),
|
||||
title: Text(
|
||||
'RoutePicker for ${widget.startStation.name} // ${widget.journeyId}',
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
@@ -265,12 +280,11 @@ class _ChooseDeparturePageState extends State<ChooseDeparturePage> {
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => ChooseStationPage()),
|
||||
);
|
||||
if (widget.journeyId != null) {
|
||||
loadJourney(widget.journeyId as int);
|
||||
}
|
||||
},
|
||||
child: const Text('Vehicle picked!'),
|
||||
child: const Text('Finish Route'),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -355,7 +369,9 @@ class _ChooseArrivalPageState extends State<ChooseArrivalPage> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Arrivals for ${widget.departure.vehicleName}'),
|
||||
title: Text(
|
||||
'Arrivals for ${widget.departure.vehicleName}// ${widget.journeyId}',
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
@@ -370,15 +386,6 @@ class _ChooseArrivalPageState extends State<ChooseArrivalPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => ChooseStationPage()),
|
||||
);
|
||||
},
|
||||
child: const Text('Vehicle picked!'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -443,3 +450,56 @@ class ArrivalList extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class JourneyDetailPage extends StatefulWidget {
|
||||
final Journey singleJourney;
|
||||
|
||||
const JourneyDetailPage({
|
||||
super.key,
|
||||
required this.singleJourney,
|
||||
});
|
||||
|
||||
@override
|
||||
State<JourneyDetailPage> createState() => _JourneyDetailPageState();
|
||||
}
|
||||
|
||||
class _JourneyDetailPageState extends State<JourneyDetailPage> {
|
||||
Duration duration = Duration(minutes: 0);
|
||||
|
||||
@override
|
||||
initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text('Connection Details \n$duration')),
|
||||
body: Center(
|
||||
child: SegmentList(journey: widget.singleJourney),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SegmentList extends StatelessWidget {
|
||||
final Journey journey;
|
||||
|
||||
const SegmentList({
|
||||
super.key,
|
||||
required this.journey,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView(
|
||||
children: [
|
||||
for (Segment seg in journey.segments)
|
||||
ListTile(
|
||||
title: Text(seg.start.direction),
|
||||
subtitle: Text(seg.start.departureTime.toString()),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user