Beginning to use different contexts
This commit is contained in:
@@ -19,8 +19,8 @@ Widget Greeter (ThemeData theme, {bool full = false}) {
|
||||
if (full) {
|
||||
bottomGreeter = Text(
|
||||
"Busy day ahead? Here is how to make the most of it!",
|
||||
style: TextStyle(color: Colors.black, fontSize: 18.0),
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: Colors.black, fontSize: 18),
|
||||
textAlign: TextAlign.center,
|
||||
);
|
||||
}
|
||||
Widget greeter = Center(
|
||||
|
@@ -40,7 +40,7 @@ class _loadLandmarksOverviewState extends State<loadLandmarksOverview> {
|
||||
),
|
||||
];
|
||||
} else {
|
||||
children = [LandmarkCard(Landmark(name: "loading", location: [0,0], type: LandmarkType(name: "loading")))];
|
||||
children = [Center(child: CircularProgressIndicator())];
|
||||
}
|
||||
return Center(
|
||||
child: Column(
|
||||
|
65
frontend/lib/modules/trips_overview.dart
Normal file
65
frontend/lib/modules/trips_overview.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fast_network_navigation/layout.dart';
|
||||
import 'package:fast_network_navigation/structs/trip.dart';
|
||||
import 'package:fast_network_navigation/utils/get_trips.dart';
|
||||
|
||||
|
||||
class TripsOverview extends StatefulWidget {
|
||||
|
||||
const TripsOverview({super.key});
|
||||
|
||||
@override
|
||||
State<TripsOverview> createState() => _TripsOverviewState();
|
||||
}
|
||||
|
||||
class _TripsOverviewState extends State<TripsOverview> {
|
||||
final Future<List<Trip>> _trips = loadTrips();
|
||||
|
||||
|
||||
Widget listBuild (BuildContext context, AsyncSnapshot<List<Trip>> snapshot) {
|
||||
List<Widget> children;
|
||||
if (snapshot.hasData) {
|
||||
children = List<Widget>.generate(snapshot.data!.length, (index) {
|
||||
Trip trip = snapshot.data![index];
|
||||
return ListTile(
|
||||
title: Text("Trip to ${trip.cityName} (${trip.landmarks.length} stops)"),
|
||||
leading: Icon(Icons.pin_drop),
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => BasePage(mainScreen: "map") //, trip: trip)
|
||||
)
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
} else if (snapshot.hasError) {
|
||||
children = [
|
||||
const Icon(
|
||||
Icons.error_outline,
|
||||
color: Colors.red,
|
||||
size: 60,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 16),
|
||||
child: Text('Error: ${snapshot.error}'),
|
||||
),
|
||||
];
|
||||
} else {
|
||||
children = [Center(child: CircularProgressIndicator())];
|
||||
}
|
||||
|
||||
return ListView(
|
||||
children: children,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: _trips,
|
||||
builder: listBuild,
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user