From aed407e2d0a963f46e961bb4c46cfd436ec464a4 Mon Sep 17 00:00:00 2001 From: Remy Moll Date: Fri, 14 Feb 2025 12:14:45 +0100 Subject: [PATCH 1/7] logger and launch cleanup --- .vscode/launch.json | 5 ++++- frontend/android/settings.gradle | 2 +- frontend/lib/modules/new_trip_map.dart | 1 - 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 6f1ce86..fa7d5d9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -36,7 +36,10 @@ "type": "dart", "request": "launch", "program": "lib/main.dart", - "cwd": "${workspaceFolder}/frontend" + "cwd": "${workspaceFolder}/frontend", + "env": { + "GOOGLE_MAPS_API_KEY": "testing" + } }, { "name": "Frontend - profile", diff --git a/frontend/android/settings.gradle b/frontend/android/settings.gradle index c9fb5ba..8db313d 100644 --- a/frontend/android/settings.gradle +++ b/frontend/android/settings.gradle @@ -19,7 +19,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version "7.3.0" apply false + id "com.android.application" version "8.1.0" apply false id "org.jetbrains.kotlin.android" version "2.0.20" apply false } diff --git a/frontend/lib/modules/new_trip_map.dart b/frontend/lib/modules/new_trip_map.dart index deb7078..02d4174 100644 --- a/frontend/lib/modules/new_trip_map.dart +++ b/frontend/lib/modules/new_trip_map.dart @@ -30,7 +30,6 @@ class _NewTripMapState extends State { final Set _markers = {}; _onLongPress(LatLng location) { - log('Long press: $location'); widget.trip.landmarks.clear(); widget.trip.addLandmark( Landmark( From 8f6dfd404d6acc6e5bb854f9337c0b5494e906b8 Mon Sep 17 00:00:00 2001 From: Remy Moll Date: Fri, 14 Feb 2025 12:23:41 +0100 Subject: [PATCH 2/7] more pleasant progress handling, although somewhat flawed --- .../modules/current_trip_landmarks_list.dart | 21 +- frontend/lib/modules/current_trip_map.dart | 69 ++++- frontend/lib/modules/current_trip_panel.dart | 38 ++- .../lib/modules/current_trip_summary.dart | 34 ++- frontend/lib/modules/landmark_card.dart | 281 ++++++++++-------- frontend/lib/modules/landmark_map_marker.dart | 2 +- frontend/lib/structs/landmark.dart | 6 +- frontend/lib/structs/trip.dart | 8 +- 8 files changed, 287 insertions(+), 172 deletions(-) diff --git a/frontend/lib/modules/current_trip_landmarks_list.dart b/frontend/lib/modules/current_trip_landmarks_list.dart index 39333f6..c92e920 100644 --- a/frontend/lib/modules/current_trip_landmarks_list.dart +++ b/frontend/lib/modules/current_trip_landmarks_list.dart @@ -7,14 +7,11 @@ import 'package:anyway/structs/landmark.dart'; import 'package:anyway/structs/trip.dart'; - -List landmarksList(Trip trip) { - log("Trip ${trip.uuid} ${trip.landmarks.length} landmarks"); +// Returns a list of widgets that represent the landmarks matching the given selector +List landmarksList(Trip trip, {required bool Function(Landmark) selector}) { List children = []; - log("Trip ${trip.uuid} ${trip.landmarks.length} landmarks"); - if (trip.landmarks.isEmpty || trip.landmarks.length <= 1 && trip.landmarks.first.type == typeStart ) { children.add( const Text("No landmarks in this trip"), @@ -23,14 +20,16 @@ List landmarksList(Trip trip) { } for (Landmark landmark in trip.landmarks) { - children.add( - LandmarkCard(landmark, trip), - ); - - if (landmark.next != null) { + if (selector(landmark)) { children.add( - StepBetweenLandmarks(current: landmark, next: landmark.next!) + LandmarkCard(landmark, trip), ); + + if (!landmark.visited && landmark.next != null) { + children.add( + StepBetweenLandmarks(current: landmark, next: landmark.next!) + ); + } } } diff --git a/frontend/lib/modules/current_trip_map.dart b/frontend/lib/modules/current_trip_map.dart index 9efdc4c..1802404 100644 --- a/frontend/lib/modules/current_trip_map.dart +++ b/frontend/lib/modules/current_trip_map.dart @@ -9,14 +9,10 @@ import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:widget_to_marker/widget_to_marker.dart'; - class CurrentTripMap extends StatefulWidget { - final Trip? trip; - CurrentTripMap({ - this.trip - }); + CurrentTripMap({this.trip}); @override State createState() => _CurrentTripMapState(); @@ -30,7 +26,23 @@ class _CurrentTripMapState extends State { zoom: 11.0, ); Set mapMarkers = {}; - + Set mapPolylines = {}; + + @override + void initState() { + super.initState(); + widget.trip?.addListener(setMapMarkers); + widget.trip?.addListener(setMapRoute); + + } + + @override + void dispose() { + widget.trip?.removeListener(setMapMarkers); + widget.trip?.removeListener(setMapRoute); + + super.dispose(); + } void _onMapCreated(GoogleMapController controller) async { mapController = controller; @@ -40,16 +52,17 @@ class _CurrentTripMapState extends State { controller.moveCamera(update); } setMapMarkers(); + setMapRoute(); } void _onCameraIdle() { // print(mapController.getLatLng(ScreenCoordinate(x: 0, y: 0))); } - void setMapMarkers() async { List landmarks = widget.trip?.landmarks.toList() ?? []; - Set newMarkers = {}; + Set markers = {}; + for (int i = 0; i < landmarks.length; i++) { Landmark landmark = landmarks[i]; List location = landmark.location; @@ -58,20 +71,47 @@ class _CurrentTripMapState extends State { position: LatLng(location[0], location[1]), icon: await ThemedMarker(landmark: landmark, position: i).toBitmapDescriptor( logicalSize: const Size(150, 150), - imageSize: const Size(150, 150) + imageSize: const Size(150, 150), ), ); - newMarkers.add(marker); + markers.add(marker); } setState(() { - mapMarkers = newMarkers; + mapMarkers = markers; }); } + void setMapRoute() async { + List landmarks = widget.trip?.landmarks.toList() ?? []; + Set polyLines = {}; + + if (landmarks.length < 2) { + return; + } + + for (Landmark landmark in landmarks) { + if (landmark.next != null) { + List step = [ + LatLng(landmark.location[0], landmark.location[1]), + LatLng(landmark.next!.location[0], landmark.next!.location[1]) + ]; + Polyline stepLine = Polyline( + polylineId: PolylineId('step-${landmark.uuid}'), + points: step, + color: landmark.visited ? Colors.grey : PRIMARY_COLOR, + width: 5, + ); + polyLines.add(stepLine); + } + } + + setState(() { + mapPolylines = polyLines; + }); + } @override Widget build(BuildContext context) { - widget.trip?.addListener(setMapMarkers); Future preferences = SharedPreferences.getInstance(); return FutureBuilder( @@ -84,7 +124,7 @@ class _CurrentTripMapState extends State { } else { return const CircularProgressIndicator(); } - } + }, ); } @@ -93,8 +133,8 @@ class _CurrentTripMapState extends State { onMapCreated: _onMapCreated, initialCameraPosition: _cameraPosition, onCameraIdle: _onCameraIdle, - // onLongPress: , markers: mapMarkers, + polylines: mapPolylines, cloudMapId: MAP_ID, mapToolbarEnabled: false, zoomControlsEnabled: false, @@ -102,5 +142,4 @@ class _CurrentTripMapState extends State { myLocationButtonEnabled: false, ); } - } diff --git a/frontend/lib/modules/current_trip_panel.dart b/frontend/lib/modules/current_trip_panel.dart index 0cf111b..230c4c3 100644 --- a/frontend/lib/modules/current_trip_panel.dart +++ b/frontend/lib/modules/current_trip_panel.dart @@ -1,6 +1,7 @@ import 'package:anyway/constants.dart'; import 'package:anyway/modules/current_trip_error_message.dart'; import 'package:anyway/modules/current_trip_loading_indicator.dart'; +import 'package:anyway/structs/landmark.dart'; import 'package:flutter/material.dart'; import 'package:anyway/structs/trip.dart'; @@ -63,13 +64,40 @@ class _CurrentTripPanelState extends State { child: CurrentTripGreeter(trip: widget.trip), ), + Padding( + padding: EdgeInsets.all(10), + child: Container( + decoration: BoxDecoration( + color: Colors.grey[100], + borderRadius: BorderRadius.circular(10), + ), + child: Column( + children: [ + CurrentTripSummary(trip: widget.trip), + ExpansionTile( + leading: Icon(Icons.location_on), + title: Text('Visited Landmarks (tap to expand)'), + children: [ + ...landmarksList(widget.trip, selector: (Landmark landmark) => landmark.visited), + ], + visualDensity: VisualDensity.compact, + collapsedShape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), + ], + ), + ), + ), + + const Padding(padding: EdgeInsets.only(top: 10)), - // CurrentTripSummary(trip: widget.trip), - - // const Divider(), - - ...landmarksList(widget.trip), + // upcoming landmarks + ...landmarksList(widget.trip, selector: (Landmark landmark) => landmark.visited == false), const Padding(padding: EdgeInsets.only(top: 10)), diff --git a/frontend/lib/modules/current_trip_summary.dart b/frontend/lib/modules/current_trip_summary.dart index 77c9461..bc46092 100644 --- a/frontend/lib/modules/current_trip_summary.dart +++ b/frontend/lib/modules/current_trip_summary.dart @@ -15,17 +15,27 @@ class CurrentTripSummary extends StatefulWidget { class _CurrentTripSummaryState extends State { @override Widget build(BuildContext context) { - return Column( - children: [ - Text('Summary'), - // Text('Start: ${widget.trip.start}'), - // Text('End: ${widget.trip.end}'), - Text('Total duration: ${widget.trip.totalTime}'), - Text('Total distance: ${widget.trip.totalTime}'), - // Text('Fuel: ${widget.trip.fuel}'), - // Text('Cost: ${widget.trip.cost}'), - ], + return Padding( + padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Icon(Icons.flag, size: 20), + Padding(padding: EdgeInsets.only(right: 10)), + Text('Stops: ${widget.trip.landmarks.length}', style: Theme.of(context).textTheme.bodyLarge,), + ] + ), + Row( + children: [ + Icon(Icons.hourglass_bottom_rounded, size: 20), + Padding(padding: EdgeInsets.only(right: 10)), + Text('Duration: ${widget.trip.totalTime} minutes', style: Theme.of(context).textTheme.bodyLarge,), + ] + ), + ], + ) ); - } -} \ No newline at end of file +} diff --git a/frontend/lib/modules/landmark_card.dart b/frontend/lib/modules/landmark_card.dart index e920e79..e3e8a75 100644 --- a/frontend/lib/modules/landmark_card.dart +++ b/frontend/lib/modules/landmark_card.dart @@ -1,3 +1,4 @@ +import 'package:anyway/constants.dart'; import 'package:anyway/main.dart'; import 'package:anyway/structs/trip.dart'; import 'package:flutter/material.dart'; @@ -13,7 +14,7 @@ class LandmarkCard extends StatefulWidget { LandmarkCard( this.landmark, this.parentTrip, - ); + ); @override _LandmarkCardState createState() => _LandmarkCardState(); @@ -31,142 +32,176 @@ class _LandmarkCardState extends State { ); } - // else: + return Container( + constraints: BoxConstraints( + minHeight: 50, + maxHeight: 200, + ), child: Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15.0), ), elevation: 5, clipBehavior: Clip.antiAliasWithSaveLayer, + // if the image is available, display it on the left side of the card, otherwise only display the text - child: widget.landmark.imageURL != null ? splitLayout() : textLayout(), - ), - ); - } - - Widget splitLayout() { - // If an image is available, display it on the left side of the card - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - // the image on the left - width: 160, - height: 160, - - child: CachedNetworkImage( - imageUrl: widget.landmark.imageURL ?? '', - placeholder: (context, url) => Center(child: CircularProgressIndicator()), - errorWidget: (context, error, stackTrace) => Icon(Icons.question_mark_outlined), - fit: BoxFit.cover, - ), - ), - Flexible( - child: textLayout(), - ), - ], - ); - } - - Widget textLayout() { - return Padding( - padding: EdgeInsets.all(10), - child: Column( - children: [ - Row( - children: [ - Flexible( - child: Text( - widget.landmark.name, - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - ), - maxLines: 2, - ), - ) - ], - ), - if (widget.landmark.nameEN != null) - Row( - children: [ - Flexible( - child: Text( - widget.landmark.nameEN!, - style: const TextStyle( - fontSize: 16, - ), - maxLines: 1, - ), - ) - ], - ), - Padding(padding: EdgeInsets.only(top: 10)), - Align( - alignment: Alignment.centerLeft, - child: SingleChildScrollView( - // allows the buttons to be scrolled - scrollDirection: Axis.horizontal, - child: Wrap( - spacing: 10, - // show the type, the website, and the wikipedia link as buttons/labels in a row + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Image and landmark "type" on the left + AspectRatio( + aspectRatio: 3 / 4, + child: Column( children: [ - TextButton.icon( - onPressed: () {}, - icon: widget.landmark.type.icon, - label: Text(widget.landmark.type.name), - ), - if (widget.landmark.duration != null && widget.landmark.duration!.inMinutes > 0) - TextButton.icon( - onPressed: () {}, - icon: Icon(Icons.hourglass_bottom), - label: Text('${widget.landmark.duration!.inMinutes} minutes'), - ), - if (widget.landmark.websiteURL != null) - TextButton.icon( - onPressed: () async { - // open a browser with the website link - await launchUrl(Uri.parse(widget.landmark.websiteURL!)); - }, - icon: Icon(Icons.link), - label: Text('Website'), - ), - PopupMenuButton( - icon: Icon(Icons.settings), - style: TextButtonTheme.of(context).style, - itemBuilder: (context) => [ - PopupMenuItem( - child: ListTile( - leading: Icon(Icons.delete), - title: Text('Delete'), - onTap: () async { - widget.parentTrip.removeLandmark(widget.landmark); - rootScaffoldMessengerKey.currentState!.showSnackBar( - SnackBar(content: Text("We won't show ${widget.landmark.name} again")) - ); - }, + if (widget.landmark.imageURL != null && widget.landmark.imageURL!.isNotEmpty) + Expanded( + child: CachedNetworkImage( + imageUrl: widget.landmark.imageURL!, + placeholder: (context, url) => Center(child: CircularProgressIndicator()), + errorWidget: (context, error, stackTrace) => Icon(Icons.question_mark_outlined), + fit: BoxFit.cover, + ) + ) + else + Expanded( + child: + Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [GRADIENT_START, GRADIENT_END], + ), + ), + child: Center( + child: Icon(widget.landmark.type.icon.icon, size: 50), ), ), - PopupMenuItem( - child: ListTile( - leading: Icon(Icons.star), - title: Text('Favorite'), - onTap: () async { - // delete the landmark - // await deleteLandmark(widget.landmark); - }, - ), - ), - ], + ), + + Container( + color: PRIMARY_COLOR, + child: Center( + child: Padding( + padding: EdgeInsets.all(5), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + spacing: 5, + children: [ + Icon(widget.landmark.type.icon.icon, size: 16), + Text(widget.landmark.type.name, style: TextStyle(fontWeight: FontWeight.bold)), + ], + ) + ) + ), ) - ], - ), + ) ), - ), - ], - ), + + // Main information, useful buttons on the right + Expanded( + child: Padding( + padding: const EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.landmark.name, + style: Theme.of(context).textTheme.titleMedium, + overflow: TextOverflow.ellipsis, + maxLines: 2, + ), + + if (widget.landmark.nameEN != null) + Text( + widget.landmark.nameEN!, + style: Theme.of(context).textTheme.bodyMedium, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + + // fill the vspace + const Spacer(), + + SingleChildScrollView( + // allows the buttons to be scrolled + scrollDirection: Axis.horizontal, + child: Wrap( + spacing: 10, + // show the type, the website, and the wikipedia link as buttons/labels in a row + children: [ + doneToggleButton(), + // if (widget.landmark.duration != null && widget.landmark.duration!.inMinutes > 0) + // TextButton.icon( + // onPressed: () {}, + // icon: Icon(Icons.hourglass_bottom), + // label: Text('${widget.landmark.duration!.inMinutes} minutes'), + // ), + if (widget.landmark.websiteURL != null) + websiteButton(), + + optionsButton() + ], + ), + ), + ], + ), + ), + ) + ], + ) + ) ); } + + Widget doneToggleButton() { + return TextButton.icon( + onPressed: () async { + widget.landmark.visited = !widget.landmark.visited; + widget.parentTrip.notifyUpdate(); + }, + icon: Icon(widget.landmark.visited ? Icons.undo_sharp : Icons.check), + label: Text(widget.landmark.visited ? "Add to overview" : "Done!"), + ); + } + + Widget websiteButton () => TextButton.icon( + onPressed: () async { + // open a browser with the website link + await launchUrl(Uri.parse(widget.landmark.websiteURL!)); + }, + icon: Icon(Icons.link), + label: Text('Website'), + ); + + Widget optionsButton () => PopupMenuButton( + icon: Icon(Icons.settings), + style: TextButtonTheme.of(context).style, + itemBuilder: (context) => [ + PopupMenuItem( + child: ListTile( + leading: Icon(Icons.delete), + title: Text('Delete'), + onTap: () async { + widget.parentTrip.removeLandmark(widget.landmark); + rootScaffoldMessengerKey.currentState!.showSnackBar( + SnackBar(content: Text("We won't show ${widget.landmark.name} again")) + ); + }, + ), + ), + PopupMenuItem( + child: ListTile( + leading: Icon(Icons.star), + title: Text('Favorite'), + onTap: () async { + // delete the landmark + // await deleteLandmark(widget.landmark); + }, + ), + ), + ], + ); } diff --git a/frontend/lib/modules/landmark_map_marker.dart b/frontend/lib/modules/landmark_map_marker.dart index 2e8f5d7..fccf50a 100644 --- a/frontend/lib/modules/landmark_map_marker.dart +++ b/frontend/lib/modules/landmark_map_marker.dart @@ -40,7 +40,7 @@ class ThemedMarker extends StatelessWidget { children: [ Container( decoration: BoxDecoration( - gradient: APP_GRADIENT, + gradient: landmark.visited ? LinearGradient(colors: [Colors.grey, Colors.white]) : APP_GRADIENT, shape: BoxShape.circle, border: Border.all(color: Colors.black, width: 5), ), diff --git a/frontend/lib/structs/landmark.dart b/frontend/lib/structs/landmark.dart index 50a71c5..a0e5905 100644 --- a/frontend/lib/structs/landmark.dart +++ b/frontend/lib/structs/landmark.dart @@ -27,7 +27,7 @@ final class Landmark extends LinkedListEntry{ String? imageURL; // not final because it can be patched final String? description; final Duration? duration; - final bool? visited; + bool visited; // Next node // final Landmark? next; @@ -46,7 +46,7 @@ final class Landmark extends LinkedListEntry{ this.imageURL, this.description, this.duration, - this.visited, + this.visited = false, // this.next, this.tripTime, @@ -71,7 +71,7 @@ final class Landmark extends LinkedListEntry{ final imageURL = json['image_url'] as String?; final description = json['description'] as String?; var duration = Duration(minutes: json['duration'] ?? 0) as Duration?; - final visited = json['visited'] as bool?; + final visited = json['visited'] ?? false as bool; var tripTime = Duration(minutes: json['time_to_reach_next'] ?? 0) as Duration?; return Landmark( diff --git a/frontend/lib/structs/trip.dart b/frontend/lib/structs/trip.dart index 44e12c3..8d816ca 100644 --- a/frontend/lib/structs/trip.dart +++ b/frontend/lib/structs/trip.dart @@ -52,6 +52,7 @@ class Trip with ChangeNotifier { totalTime = json['total_time']; notifyListeners(); } + void addLandmark(Landmark landmark) { landmarks.add(landmark); notifyListeners(); @@ -66,12 +67,16 @@ class Trip with ChangeNotifier { landmarks.remove(landmark); notifyListeners(); } - + void updateError(String error) { errorDescription = error; notifyListeners(); } + void notifyUpdate(){ + notifyListeners(); + } + factory Trip.fromPrefs(SharedPreferences prefs, String uuid) { String? content = prefs.getString('trip_$uuid'); Map json = jsonDecode(content!); @@ -80,7 +85,6 @@ class Trip with ChangeNotifier { log('Loading trip $uuid with first landmark $firstUUID'); LinkedList landmarks = readLandmarks(prefs, firstUUID); trip.landmarks = landmarks; - // notifyListeners(); return trip; } From 56c55883ea778a26da253595458cddffb1b3fe9a Mon Sep 17 00:00:00 2001 From: Remy Moll Date: Sat, 15 Feb 2025 19:36:41 +0100 Subject: [PATCH 3/7] reworked page layout inheritence --- .../base_page.dart => layouts/scaffold.dart} | 74 ++++++---------- frontend/lib/main.dart | 23 ++--- .../modules/current_trip_landmarks_list.dart | 6 +- .../current_trip_loading_indicator.dart | 15 ++-- frontend/lib/modules/current_trip_map.dart | 51 ++++++----- frontend/lib/modules/current_trip_panel.dart | 39 +++++---- .../lib/modules/current_trip_save_button.dart | 5 +- .../lib/modules/current_trip_summary.dart | 15 ++-- frontend/lib/modules/help_dialog.dart | 2 +- frontend/lib/modules/landmark_card.dart | 86 ++++++++----------- frontend/lib/modules/new_trip_button.dart | 5 +- frontend/lib/modules/new_trip_map.dart | 14 +-- .../lib/modules/step_between_landmarks.dart | 37 ++++---- frontend/lib/pages/current_trip.dart | 15 ++-- frontend/lib/pages/new_trip_location.dart | 9 +- frontend/lib/pages/new_trip_preferences.dart | 32 +++---- frontend/lib/pages/settings.dart | 63 +++++++------- frontend/lib/structs/landmark.dart | 6 +- frontend/lib/structs/trip.dart | 12 +++ frontend/lib/utils/fetch_trip.dart | 32 +++---- frontend/lib/utils/get_first_page.dart | 15 ++-- 21 files changed, 278 insertions(+), 278 deletions(-) rename frontend/lib/{pages/base_page.dart => layouts/scaffold.dart} (67%) diff --git a/frontend/lib/pages/base_page.dart b/frontend/lib/layouts/scaffold.dart similarity index 67% rename from frontend/lib/pages/base_page.dart rename to frontend/lib/layouts/scaffold.dart index ce36f1f..e927e5f 100644 --- a/frontend/lib/pages/base_page.dart +++ b/frontend/lib/layouts/scaffold.dart @@ -1,72 +1,51 @@ -import 'package:anyway/main.dart'; -import 'package:anyway/modules/help_dialog.dart'; -import 'package:anyway/pages/current_trip.dart'; -import 'package:anyway/pages/settings.dart'; import 'package:flutter/material.dart'; import 'package:anyway/constants.dart'; -import 'package:anyway/structs/trip.dart'; +import 'package:anyway/main.dart'; +import 'package:anyway/modules/help_dialog.dart'; import 'package:anyway/modules/trips_saved_list.dart'; -import 'package:anyway/utils/load_trips.dart'; -import 'package:anyway/pages/new_trip_location.dart'; import 'package:anyway/pages/onboarding.dart'; +import 'package:anyway/pages/current_trip.dart'; +import 'package:anyway/pages/settings.dart'; +import 'package:anyway/pages/new_trip_location.dart'; - - -// BasePage is the scaffold that holds a child page and a side drawer -// The side drawer is the main way to switch between pages - -class BasePage extends StatefulWidget { - final Widget mainScreen; - final Widget title; - final List helpTexts; - - const BasePage({ - super.key, - required this.mainScreen, - this.title = const Text(APP_NAME), - this.helpTexts = const [], - }); - - @override - State createState() => _BasePageState(); -} - -class _BasePageState extends State { - - @override - Widget build(BuildContext context) { - savedTrips.loadTrips(); - - +mixin ScaffoldLayout on State { + Widget mainScaffold( + BuildContext context, + { + Widget child = const Text("emptiness"), + Widget title = const Text(APP_NAME), + List helpTexts = const [] + } + ) { return Scaffold( appBar: AppBar( - title: widget.title, + title: title, actions: [ IconButton( icon: const Icon(Icons.help), tooltip: 'Help', onPressed: () { - if (widget.helpTexts.isNotEmpty) { - helpDialog(context, widget.helpTexts[0], widget.helpTexts[1]); + if (helpTexts.isNotEmpty) { + helpDialog(context, helpTexts[0], helpTexts[1]); } } ), ], ), - body: Center(child: widget.mainScreen), + body: Center(child: child), drawer: Drawer( child: Column( children: [ Container( - decoration: BoxDecoration( + decoration: const BoxDecoration( gradient: APP_GRADIENT, ), height: 150, - child: Center( + child: const Center( child: Text( APP_NAME, style: TextStyle( @@ -81,8 +60,7 @@ class _BasePageState extends State { ListTile( title: const Text('Your Trips'), leading: const Icon(Icons.map), - // TODO: this is not working! - selected: widget.mainScreen is TripPage, + selected: widget is TripPage, onTap: () {}, trailing: ElevatedButton( onPressed: () { @@ -111,13 +89,12 @@ class _BasePageState extends State { const Divider(indent: 10, endIndent: 10), ListTile( title: const Text('How to use'), - leading: Icon(Icons.help), - // TODO: this is not working! - selected: widget.mainScreen is OnboardingPage, + leading: const Icon(Icons.help), + selected: widget is OnboardingPage, onTap: () { Navigator.of(context).push( MaterialPageRoute( - builder: (context) => OnboardingPage() + builder: (context) => const OnboardingPage() ) ); }, @@ -127,8 +104,7 @@ class _BasePageState extends State { ListTile( title: const Text('Settings'), leading: const Icon(Icons.settings), - // TODO: this is not working! - selected: widget.mainScreen is SettingsPage, + selected: widget is SettingsPage, onTap: () { Navigator.of(context).push( MaterialPageRoute( diff --git a/frontend/lib/main.dart b/frontend/lib/main.dart index 5f3dc49..ed4121f 100644 --- a/frontend/lib/main.dart +++ b/frontend/lib/main.dart @@ -1,24 +1,27 @@ +import 'package:flutter/material.dart'; + +import 'package:anyway/constants.dart'; import 'package:anyway/utils/get_first_page.dart'; import 'package:anyway/utils/load_trips.dart'; -import 'package:flutter/material.dart'; -import 'package:anyway/constants.dart'; + void main() => runApp(const App()); +// Some global variables final GlobalKey rootScaffoldMessengerKey = GlobalKey(); final SavedTrips savedTrips = SavedTrips(); +// the list of saved trips is then populated implicitly by getFirstPage() + class App extends StatelessWidget { const App({super.key}); @override - Widget build(BuildContext context) { - return MaterialApp( - title: APP_NAME, - home: getFirstPage(), - theme: APP_THEME, - scaffoldMessengerKey: rootScaffoldMessengerKey - ); - } + Widget build(BuildContext context) => MaterialApp( + title: APP_NAME, + home: getFirstPage(), + theme: APP_THEME, + scaffoldMessengerKey: rootScaffoldMessengerKey + ); } diff --git a/frontend/lib/modules/current_trip_landmarks_list.dart b/frontend/lib/modules/current_trip_landmarks_list.dart index c92e920..9ab4fbc 100644 --- a/frontend/lib/modules/current_trip_landmarks_list.dart +++ b/frontend/lib/modules/current_trip_landmarks_list.dart @@ -1,10 +1,9 @@ -import 'dart:developer'; -import 'package:anyway/modules/step_between_landmarks.dart'; import 'package:flutter/material.dart'; -import 'package:anyway/modules/landmark_card.dart'; import 'package:anyway/structs/landmark.dart'; import 'package:anyway/structs/trip.dart'; +import 'package:anyway/modules/step_between_landmarks.dart'; +import 'package:anyway/modules/landmark_card.dart'; // Returns a list of widgets that represent the landmarks matching the given selector @@ -35,4 +34,3 @@ List landmarksList(Trip trip, {required bool Function(Landmark) selector return children; } - diff --git a/frontend/lib/modules/current_trip_loading_indicator.dart b/frontend/lib/modules/current_trip_loading_indicator.dart index 96648a3..5eaf037 100644 --- a/frontend/lib/modules/current_trip_loading_indicator.dart +++ b/frontend/lib/modules/current_trip_loading_indicator.dart @@ -35,29 +35,29 @@ class _CurrentTripLoadingIndicatorState extends State _statusTextState(); + _StatusTextState createState() => _StatusTextState(); } -class _statusTextState extends State { +class _StatusTextState extends State { int statusIndex = 0; @override void initState() { super.initState(); - Future.delayed(Duration(seconds: 5), () { + Future.delayed(const Duration(seconds: 5), () { setState(() { statusIndex = (statusIndex + 1) % statusTexts.length; }); @@ -159,4 +159,3 @@ class _AnimatedGradientTextState extends State with Single ); } } - diff --git a/frontend/lib/modules/current_trip_map.dart b/frontend/lib/modules/current_trip_map.dart index 1802404..d1c6407 100644 --- a/frontend/lib/modules/current_trip_map.dart +++ b/frontend/lib/modules/current_trip_map.dart @@ -1,13 +1,14 @@ import 'dart:collection'; +import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:widget_to_marker/widget_to_marker.dart'; import 'package:anyway/constants.dart'; -import 'package:anyway/modules/landmark_map_marker.dart'; -import 'package:flutter/material.dart'; import 'package:anyway/structs/landmark.dart'; import 'package:anyway/structs/trip.dart'; -import 'package:google_maps_flutter/google_maps_flutter.dart'; -import 'package:shared_preferences/shared_preferences.dart'; -import 'package:widget_to_marker/widget_to_marker.dart'; +import 'package:anyway/modules/landmark_map_marker.dart'; + class CurrentTripMap extends StatefulWidget { final Trip? trip; @@ -60,25 +61,29 @@ class _CurrentTripMapState extends State { } void setMapMarkers() async { - List landmarks = widget.trip?.landmarks.toList() ?? []; - Set markers = {}; + Iterator<(int, Landmark)> it = (widget.trip?.landmarks.toList() ?? []).indexed.iterator; - for (int i = 0; i < landmarks.length; i++) { - Landmark landmark = landmarks[i]; + while (it.moveNext()) { + int i = it.current.$1; + Landmark landmark = it.current.$2; + + MarkerId markerId = MarkerId("${landmark.uuid} - ${landmark.visited}"); List location = landmark.location; - Marker marker = Marker( - markerId: MarkerId(landmark.uuid), - position: LatLng(location[0], location[1]), - icon: await ThemedMarker(landmark: landmark, position: i).toBitmapDescriptor( - logicalSize: const Size(150, 150), - imageSize: const Size(150, 150), - ), - ); - markers.add(marker); + // only create a new marker, if there is no marker for this landmark + if (!mapMarkers.any((Marker marker) => marker.markerId == markerId)) { + Marker marker = Marker( + markerId: markerId, + position: LatLng(location[0], location[1]), + icon: await ThemedMarker(landmark: landmark, position: i).toBitmapDescriptor( + logicalSize: const Size(150, 150), + imageSize: const Size(150, 150), + ) + ); + setState(() { + mapMarkers.add(marker); + }); + } } - setState(() { - mapMarkers = markers; - }); } void setMapRoute() async { @@ -98,8 +103,8 @@ class _CurrentTripMapState extends State { Polyline stepLine = Polyline( polylineId: PolylineId('step-${landmark.uuid}'), points: step, - color: landmark.visited ? Colors.grey : PRIMARY_COLOR, - width: 5, + color: landmark.visited || (landmark.next?.visited ?? false) ? Colors.grey : PRIMARY_COLOR, + width: 5 ); polyLines.add(stepLine); } diff --git a/frontend/lib/modules/current_trip_panel.dart b/frontend/lib/modules/current_trip_panel.dart index 230c4c3..8e55b83 100644 --- a/frontend/lib/modules/current_trip_panel.dart +++ b/frontend/lib/modules/current_trip_panel.dart @@ -1,10 +1,12 @@ -import 'package:anyway/constants.dart'; -import 'package:anyway/modules/current_trip_error_message.dart'; -import 'package:anyway/modules/current_trip_loading_indicator.dart'; -import 'package:anyway/structs/landmark.dart'; import 'package:flutter/material.dart'; +import 'package:anyway/constants.dart'; + +import 'package:anyway/structs/landmark.dart'; import 'package:anyway/structs/trip.dart'; + +import 'package:anyway/modules/current_trip_error_message.dart'; +import 'package:anyway/modules/current_trip_loading_indicator.dart'; import 'package:anyway/modules/current_trip_summary.dart'; import 'package:anyway/modules/current_trip_save_button.dart'; import 'package:anyway/modules/current_trip_landmarks_list.dart'; @@ -74,20 +76,21 @@ class _CurrentTripPanelState extends State { child: Column( children: [ CurrentTripSummary(trip: widget.trip), - ExpansionTile( - leading: Icon(Icons.location_on), - title: Text('Visited Landmarks (tap to expand)'), - children: [ - ...landmarksList(widget.trip, selector: (Landmark landmark) => landmark.visited), - ], - visualDensity: VisualDensity.compact, - collapsedShape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), + if (widget.trip.landmarks.where((Landmark landmark) => landmark.visited).isNotEmpty) + ExpansionTile( + leading: const Icon(Icons.location_on), + title: const Text('Visited Landmarks (tap to expand)'), + children: [ + ...landmarksList(widget.trip, selector: (Landmark landmark) => landmark.visited), + ], + visualDensity: VisualDensity.compact, + collapsedShape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), ), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - ), - ), ], ), ), @@ -108,4 +111,4 @@ class _CurrentTripPanelState extends State { } ); } -} +} diff --git a/frontend/lib/modules/current_trip_save_button.dart b/frontend/lib/modules/current_trip_save_button.dart index 0b8e773..64028e7 100644 --- a/frontend/lib/modules/current_trip_save_button.dart +++ b/frontend/lib/modules/current_trip_save_button.dart @@ -1,8 +1,8 @@ +import 'package:flutter/material.dart'; +import 'package:auto_size_text/auto_size_text.dart'; import 'package:anyway/main.dart'; import 'package:anyway/structs/trip.dart'; -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:flutter/material.dart'; class saveButton extends StatefulWidget { @@ -52,4 +52,3 @@ class _saveButtonState extends State { ); } } - diff --git a/frontend/lib/modules/current_trip_summary.dart b/frontend/lib/modules/current_trip_summary.dart index bc46092..e7aa4a5 100644 --- a/frontend/lib/modules/current_trip_summary.dart +++ b/frontend/lib/modules/current_trip_summary.dart @@ -1,6 +1,7 @@ import 'package:anyway/structs/trip.dart'; import 'package:flutter/material.dart'; + class CurrentTripSummary extends StatefulWidget { final Trip trip; const CurrentTripSummary({ @@ -16,22 +17,22 @@ class _CurrentTripSummaryState extends State { @override Widget build(BuildContext context) { return Padding( - padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20), + padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 20), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ - Icon(Icons.flag, size: 20), - Padding(padding: EdgeInsets.only(right: 10)), - Text('Stops: ${widget.trip.landmarks.length}', style: Theme.of(context).textTheme.bodyLarge,), + const Icon(Icons.flag, size: 20), + const Padding(padding: EdgeInsets.only(right: 10)), + Text('Stops: ${widget.trip.landmarks.length}', style: Theme.of(context).textTheme.bodyLarge), ] ), Row( children: [ - Icon(Icons.hourglass_bottom_rounded, size: 20), - Padding(padding: EdgeInsets.only(right: 10)), - Text('Duration: ${widget.trip.totalTime} minutes', style: Theme.of(context).textTheme.bodyLarge,), + const Icon(Icons.hourglass_bottom_rounded, size: 20), + const Padding(padding: EdgeInsets.only(right: 10)), + Text('Duration: ${widget.trip.totalTime} minutes', style: Theme.of(context).textTheme.bodyLarge), ] ), ], diff --git a/frontend/lib/modules/help_dialog.dart b/frontend/lib/modules/help_dialog.dart index 75db7b0..caf94aa 100644 --- a/frontend/lib/modules/help_dialog.dart +++ b/frontend/lib/modules/help_dialog.dart @@ -1,6 +1,6 @@ - import 'package:flutter/material.dart'; + Future helpDialog(BuildContext context, String title, String content) { return showDialog( context: context, diff --git a/frontend/lib/modules/landmark_card.dart b/frontend/lib/modules/landmark_card.dart index e3e8a75..9ef4875 100644 --- a/frontend/lib/modules/landmark_card.dart +++ b/frontend/lib/modules/landmark_card.dart @@ -1,12 +1,15 @@ -import 'package:anyway/constants.dart'; -import 'package:anyway/main.dart'; -import 'package:anyway/structs/trip.dart'; import 'package:flutter/material.dart'; import 'package:cached_network_image/cached_network_image.dart'; -import 'package:url_launcher/url_launcher.dart'; +import 'package:anyway/constants.dart'; + +import 'package:anyway/main.dart'; +import 'package:anyway/structs/trip.dart'; +import 'package:url_launcher/url_launcher.dart'; import 'package:anyway/structs/landmark.dart'; + + class LandmarkCard extends StatefulWidget { final Landmark landmark; final Trip parentTrip; @@ -23,20 +26,11 @@ class LandmarkCard extends StatefulWidget { class _LandmarkCardState extends State { @override - Widget build(BuildContext context) { - if (widget.landmark.type == typeStart || widget.landmark.type == typeFinish) { - return TextButton.icon( - onPressed: () {}, - icon: widget.landmark.type.icon, - label: Text(widget.landmark.name), - ); - - } - + Widget build(BuildContext context) { return Container( constraints: BoxConstraints( - minHeight: 50, - maxHeight: 200, + // express the max height in terms text lines + maxHeight: 7 * (Theme.of(context).textTheme.titleMedium!.fontSize! + 10), ), child: Card( shape: RoundedRectangleBorder( @@ -79,23 +73,23 @@ class _LandmarkCardState extends State { ), ), ), - - Container( - color: PRIMARY_COLOR, - child: Center( - child: Padding( - padding: EdgeInsets.all(5), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - spacing: 5, - children: [ - Icon(widget.landmark.type.icon.icon, size: 16), - Text(widget.landmark.type.name, style: TextStyle(fontWeight: FontWeight.bold)), - ], + if (widget.landmark.type != typeStart && widget.landmark.type != typeFinish) + Container( + color: PRIMARY_COLOR, + child: Center( + child: Padding( + padding: EdgeInsets.all(5), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + spacing: 5, + children: [ + Icon(Icons.timer_outlined, size: 16), + Text("${widget.landmark.duration?.inMinutes} minutes"), + ], + ) ) - ) - ), - ) + ), + ) ], ) ), @@ -133,12 +127,6 @@ class _LandmarkCardState extends State { // show the type, the website, and the wikipedia link as buttons/labels in a row children: [ doneToggleButton(), - // if (widget.landmark.duration != null && widget.landmark.duration!.inMinutes > 0) - // TextButton.icon( - // onPressed: () {}, - // icon: Icon(Icons.hourglass_bottom), - // label: Text('${widget.landmark.duration!.inMinutes} minutes'), - // ), if (widget.landmark.websiteURL != null) websiteButton(), @@ -172,33 +160,35 @@ class _LandmarkCardState extends State { // open a browser with the website link await launchUrl(Uri.parse(widget.landmark.websiteURL!)); }, - icon: Icon(Icons.link), - label: Text('Website'), + icon: const Icon(Icons.link), + label: const Text('Website'), ); + Widget optionsButton () => PopupMenuButton( - icon: Icon(Icons.settings), + icon: const Icon(Icons.settings), style: TextButtonTheme.of(context).style, itemBuilder: (context) => [ PopupMenuItem( child: ListTile( - leading: Icon(Icons.delete), - title: Text('Delete'), + leading: const Icon(Icons.delete), + title: const Text('Delete'), onTap: () async { widget.parentTrip.removeLandmark(widget.landmark); rootScaffoldMessengerKey.currentState!.showSnackBar( - SnackBar(content: Text("We won't show ${widget.landmark.name} again")) + SnackBar(content: Text("${widget.landmark.name} won't be shown again")) ); }, ), ), PopupMenuItem( child: ListTile( - leading: Icon(Icons.star), - title: Text('Favorite'), + leading: const Icon(Icons.star), + title: const Text('Favorite'), onTap: () async { - // delete the landmark - // await deleteLandmark(widget.landmark); + rootScaffoldMessengerKey.currentState!.showSnackBar( + SnackBar(content: Text("Not implemented yet")) + ); }, ), ), diff --git a/frontend/lib/modules/new_trip_button.dart b/frontend/lib/modules/new_trip_button.dart index 9dca910..3eb5d3b 100644 --- a/frontend/lib/modules/new_trip_button.dart +++ b/frontend/lib/modules/new_trip_button.dart @@ -46,11 +46,11 @@ class _NewTripButtonState extends State { UserPreferences preferences = widget.preferences; if (preferences.nature.value == 0 && preferences.shopping.value == 0 && preferences.sightseeing.value == 0){ rootScaffoldMessengerKey.currentState!.showSnackBar( - SnackBar(content: Text("Please specify at least one preference")) + const SnackBar(content: Text("Please specify at least one preference")) ); } else if (preferences.maxTime.value == 0){ rootScaffoldMessengerKey.currentState!.showSnackBar( - SnackBar(content: Text("Please choose a longer duration")) + const SnackBar(content: Text("Please choose a longer duration")) ); } else { Trip trip = widget.trip; @@ -63,4 +63,3 @@ class _NewTripButtonState extends State { } } } - diff --git a/frontend/lib/modules/new_trip_map.dart b/frontend/lib/modules/new_trip_map.dart index 02d4174..e4e5400 100644 --- a/frontend/lib/modules/new_trip_map.dart +++ b/frontend/lib/modules/new_trip_map.dart @@ -1,14 +1,14 @@ // A map that allows the user to select a location for a new trip. -import 'dart:developer'; +import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:widget_to_marker/widget_to_marker.dart'; import 'package:anyway/constants.dart'; -import 'package:anyway/modules/landmark_map_marker.dart'; -import 'package:anyway/structs/landmark.dart'; + import 'package:anyway/structs/trip.dart'; -import 'package:flutter/material.dart'; -import 'package:google_maps_flutter/google_maps_flutter.dart'; -import 'package:shared_preferences/shared_preferences.dart'; -import 'package:widget_to_marker/widget_to_marker.dart'; +import 'package:anyway/structs/landmark.dart'; +import 'package:anyway/modules/landmark_map_marker.dart'; class NewTripMap extends StatefulWidget { diff --git a/frontend/lib/modules/step_between_landmarks.dart b/frontend/lib/modules/step_between_landmarks.dart index b238cc1..739f1b6 100644 --- a/frontend/lib/modules/step_between_landmarks.dart +++ b/frontend/lib/modules/step_between_landmarks.dart @@ -1,7 +1,9 @@ -import 'package:anyway/structs/landmark.dart'; import 'package:flutter/material.dart'; + +import 'package:anyway/structs/landmark.dart'; import 'package:anyway/modules/map_chooser.dart'; + class StepBetweenLandmarks extends StatefulWidget { final Landmark current; final Landmark next; @@ -19,11 +21,15 @@ class StepBetweenLandmarks extends StatefulWidget { class _StepBetweenLandmarksState extends State { @override Widget build(BuildContext context) { - int time = widget.current.tripTime?.inMinutes ?? 0; + int? time = widget.current.tripTime?.inMinutes; + if (time != null && time < 1) { + time = 1; + } + return Container( - margin: EdgeInsets.all(10), - padding: EdgeInsets.all(10), - decoration: BoxDecoration( + margin: const EdgeInsets.all(10), + padding: const EdgeInsets.all(10), + decoration: const BoxDecoration( border: Border( left: BorderSide(width: 3.0, color: Colors.black), ), @@ -32,21 +38,22 @@ class _StepBetweenLandmarksState extends State { children: [ Column( children: [ - Icon(Icons.directions_walk), - Text("$time min", style: TextStyle(fontSize: 10)), + const Icon(Icons.directions_walk), + Text( + time == null ? "" : "About $time min", + style: const TextStyle(fontSize: 10) + ), ], ), - Spacer(), - ElevatedButton( + + const Spacer(), + + ElevatedButton.icon( onPressed: () async { showMapChooser(context, widget.current, widget.next); }, - child: Row( - children: [ - Icon(Icons.directions), - Text("Directions"), - ], - ), + icon: const Icon(Icons.directions), + label: const Text("Directions"), ) ], ), diff --git a/frontend/lib/pages/current_trip.dart b/frontend/lib/pages/current_trip.dart index 6f45e7f..8f70652 100644 --- a/frontend/lib/pages/current_trip.dart +++ b/frontend/lib/pages/current_trip.dart @@ -1,5 +1,5 @@ import 'package:anyway/constants.dart'; -import 'package:anyway/pages/base_page.dart'; +import 'package:anyway/layouts/scaffold.dart'; import 'package:flutter/material.dart'; import 'package:sliding_up_panel/sliding_up_panel.dart'; @@ -28,12 +28,13 @@ class TripPage extends StatefulWidget { -class _TripPageState extends State { +class _TripPageState extends State with ScaffoldLayout{ @override Widget build(BuildContext context) { - return BasePage( - mainScreen: SlidingUpPanel( + return mainScaffold( + context, + child: SlidingUpPanel( // use panelBuilder instead of panel so that we can reuse the scrollcontroller for the listview panelBuilder: (scrollcontroller) => CurrentTripPanel(controller: scrollcontroller, trip: widget.trip), // using collapsed and panelBuilder seems to show both at the same time, so we include the greeter in the panelBuilder @@ -58,9 +59,13 @@ class _TripPageState extends State { title: FutureBuilder( future: widget.trip.cityName, builder: (context, snapshot) => Text( - 'Your trip to ${snapshot.hasData ? snapshot.data! : "..."}', + 'Trip to ${snapshot.hasData ? snapshot.data! : "..."}', ) ), + helpTexts: [ + 'Current trip', + 'You can see and edit your current trip here. Swipe up from the bottom to see a detailed view of the recommendations.' + ], ); } } diff --git a/frontend/lib/pages/new_trip_location.dart b/frontend/lib/pages/new_trip_location.dart index 2fba16f..cca895d 100644 --- a/frontend/lib/pages/new_trip_location.dart +++ b/frontend/lib/pages/new_trip_location.dart @@ -1,5 +1,5 @@ +import 'package:anyway/layouts/scaffold.dart'; import 'package:anyway/modules/new_trip_options_button.dart'; -import 'package:anyway/pages/base_page.dart'; import 'package:flutter/material.dart'; import "package:anyway/structs/trip.dart"; @@ -14,7 +14,7 @@ class NewTripPage extends StatefulWidget { _NewTripPageState createState() => _NewTripPageState(); } -class _NewTripPageState extends State { +class _NewTripPageState extends State with ScaffoldLayout { final TextEditingController latController = TextEditingController(); final TextEditingController lonController = TextEditingController(); Trip trip = Trip(); @@ -23,8 +23,9 @@ class _NewTripPageState extends State { @override Widget build(BuildContext context) { // floating search bar and map as a background - return BasePage( - mainScreen: Scaffold( + return mainScaffold( + context, + child: Scaffold( body: Stack( children: [ NewTripMap(trip), diff --git a/frontend/lib/pages/new_trip_preferences.dart b/frontend/lib/pages/new_trip_preferences.dart index 15b7066..76aaf10 100644 --- a/frontend/lib/pages/new_trip_preferences.dart +++ b/frontend/lib/pages/new_trip_preferences.dart @@ -1,5 +1,5 @@ +import 'package:anyway/layouts/scaffold.dart'; import 'package:anyway/modules/new_trip_button.dart'; -import 'package:anyway/pages/base_page.dart'; import 'package:anyway/structs/preferences.dart'; import 'package:anyway/structs/trip.dart'; import 'package:flutter/cupertino.dart'; @@ -15,13 +15,14 @@ class NewTripPreferencesPage extends StatefulWidget { _NewTripPreferencesPageState createState() => _NewTripPreferencesPageState(); } -class _NewTripPreferencesPageState extends State { +class _NewTripPreferencesPageState extends State with ScaffoldLayout { UserPreferences preferences = UserPreferences(); @override Widget build(BuildContext context) { - return BasePage( - mainScreen: Scaffold( + return mainScaffold( + context, + child: Scaffold( body: ListView( children: [ // Center( @@ -41,23 +42,22 @@ class _NewTripPreferencesPageState extends State { // ) // ), - Center( - child: Padding( - padding: EdgeInsets.only(left: 10, right: 10, top: 20, bottom: 0), - child: Text('Tell us about your ideal trip.', style: TextStyle(fontSize: 18)) - ), + Center( + child: Padding( + padding: EdgeInsets.only(left: 10, right: 10, top: 20, bottom: 0), + child: Text('Tell us about your ideal trip.', style: TextStyle(fontSize: 18)) ), + ), - Divider(indent: 25, endIndent: 25, height: 50), + Divider(indent: 25, endIndent: 25, height: 50), - durationPicker(preferences.maxTime), + durationPicker(preferences.maxTime), - preferenceSliders([preferences.sightseeing, preferences.shopping, preferences.nature]), - ] - ), - floatingActionButton: NewTripButton(trip: widget.trip, preferences: preferences), + preferenceSliders([preferences.sightseeing, preferences.shopping, preferences.nature]), + ] + ), + floatingActionButton: NewTripButton(trip: widget.trip, preferences: preferences), ), - title: FutureBuilder( future: widget.trip.cityName, builder: (context, snapshot) => Text( diff --git a/frontend/lib/pages/settings.dart b/frontend/lib/pages/settings.dart index 3d5aff6..b5d3240 100644 --- a/frontend/lib/pages/settings.dart +++ b/frontend/lib/pages/settings.dart @@ -1,6 +1,6 @@ import 'package:anyway/constants.dart'; +import 'package:anyway/layouts/scaffold.dart'; import 'package:anyway/main.dart'; -import 'package:anyway/pages/base_page.dart'; import 'package:flutter/material.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -14,42 +14,41 @@ class SettingsPage extends StatefulWidget { _SettingsPageState createState() => _SettingsPageState(); } -class _SettingsPageState extends State { +class _SettingsPageState extends State with ScaffoldLayout { @override - Widget build(BuildContext context) { - return BasePage( - mainScreen: ListView( - padding: EdgeInsets.all(15), - children: [ - // First a round, centered image - Center( - child: CircleAvatar( - radius: 75, - child: Icon(Icons.settings, size: 100), - ) - ), - Center( - child: Text('Global settings', style: TextStyle(fontSize: 24)) - ), + Widget build (BuildContext context) => mainScaffold( + context, + child: ListView( + padding: EdgeInsets.all(15), + children: [ + // First a round, centered image + Center( + child: CircleAvatar( + radius: 75, + child: Icon(Icons.settings, size: 100), + ) + ), + Center( + child: Text('Global settings', style: TextStyle(fontSize: 24)) + ), - Divider(indent: 25, endIndent: 25, height: 50), + Divider(indent: 25, endIndent: 25, height: 50), - darkMode(), - setLocationUsage(), - setDebugMode(), + darkMode(), + setLocationUsage(), + setDebugMode(), - Divider(indent: 25, endIndent: 25, height: 50), + Divider(indent: 25, endIndent: 25, height: 50), - privacyInfo(), - ] - ), - title: Text('Settings'), - helpTexts: [ - 'Settings', - 'Preferences set in this page are global and will affect the entire application.' - ], - ); - } + privacyInfo(), + ] + ), + title: Text('Settings'), + helpTexts: [ + 'Settings', + 'Preferences set in this page are global and will affect the entire application.' + ], + ); Widget setDebugMode() { return Row( diff --git a/frontend/lib/structs/landmark.dart b/frontend/lib/structs/landmark.dart index a0e5905..8856047 100644 --- a/frontend/lib/structs/landmark.dart +++ b/frontend/lib/structs/landmark.dart @@ -70,10 +70,10 @@ final class Landmark extends LinkedListEntry{ final websiteURL = json['website_url'] as String?; final imageURL = json['image_url'] as String?; final description = json['description'] as String?; - var duration = Duration(minutes: json['duration'] ?? 0) as Duration?; - final visited = json['visited'] ?? false as bool; + var duration = Duration(minutes: json['duration']); + final visited = json['visited'] ?? false; var tripTime = Duration(minutes: json['time_to_reach_next'] ?? 0) as Duration?; - + return Landmark( uuid: uuid, name: name, diff --git a/frontend/lib/structs/trip.dart b/frontend/lib/structs/trip.dart index 8d816ca..e550540 100644 --- a/frontend/lib/structs/trip.dart +++ b/frontend/lib/structs/trip.dart @@ -29,6 +29,18 @@ class Trip with ChangeNotifier { } } + Future landmarkPosition (Landmark landmark) async { + int i = 0; + for (Landmark l in landmarks) { + if (l.uuid == landmark.uuid) { + return i; + } else if (l.type != typeStart && l.type != typeFinish) { + i++; + } + } + return -1; + } + Trip({ this.uuid = 'pending', diff --git a/frontend/lib/utils/fetch_trip.dart b/frontend/lib/utils/fetch_trip.dart index 4fc35e2..b243f0d 100644 --- a/frontend/lib/utils/fetch_trip.dart +++ b/frontend/lib/utils/fetch_trip.dart @@ -1,33 +1,33 @@ import "dart:convert"; import "dart:developer"; -import "package:anyway/utils/load_landmark_image.dart"; import 'package:dio/dio.dart'; import 'package:anyway/constants.dart'; +import "package:anyway/utils/load_landmark_image.dart"; import "package:anyway/structs/landmark.dart"; import "package:anyway/structs/trip.dart"; import "package:anyway/structs/preferences.dart"; Dio dio = Dio( - BaseOptions( - baseUrl: API_URL_BASE, - connectTimeout: const Duration(seconds: 5), - receiveTimeout: const Duration(seconds: 120), - // also accept 500 errors, since we cannot rule out that the server is at fault. We still want to gracefully handle these errors - validateStatus: (status) => status! <= 500, - receiveDataWhenStatusError: true, - // api is notoriously slow - // headers: { - // HttpHeaders.userAgentHeader: 'dio', - // 'api': '1.0.0', - // }, - contentType: Headers.jsonContentType, - responseType: ResponseType.json, - + BaseOptions( + baseUrl: API_URL_BASE, + connectTimeout: const Duration(seconds: 5), + receiveTimeout: const Duration(seconds: 120), + // also accept 500 errors, since we cannot rule out that the server is at fault. We still want to gracefully handle these errors + validateStatus: (status) => status! <= 500, + receiveDataWhenStatusError: true, + // api is notoriously slow + // headers: { + // HttpHeaders.userAgentHeader: 'dio', + // 'api': '1.0.0', + // }, + contentType: Headers.jsonContentType, + responseType: ResponseType.json, ), ); + fetchTrip( Trip trip, UserPreferences preferences, diff --git a/frontend/lib/utils/get_first_page.dart b/frontend/lib/utils/get_first_page.dart index e2dffd2..26f2787 100644 --- a/frontend/lib/utils/get_first_page.dart +++ b/frontend/lib/utils/get_first_page.dart @@ -1,11 +1,14 @@ -import 'package:anyway/pages/current_trip.dart'; -import 'package:anyway/pages/onboarding.dart'; -import 'package:anyway/structs/trip.dart'; -import 'package:anyway/utils/load_trips.dart'; +import 'package:anyway/main.dart'; import 'package:flutter/material.dart'; +import 'package:anyway/structs/trip.dart'; +import 'package:anyway/utils/load_trips.dart'; +import 'package:anyway/pages/current_trip.dart'; +import 'package:anyway/pages/onboarding.dart'; + + Widget getFirstPage() { - SavedTrips trips = SavedTrips(); + SavedTrips trips = savedTrips; trips.loadTrips(); return ListenableBuilder( @@ -15,7 +18,7 @@ Widget getFirstPage() { if (items.isNotEmpty) { return TripPage(trip: items[0]); } else { - return OnboardingPage(); + return const OnboardingPage(); } } ); From 6f2f86f936a90d23ff66c3cd623bb56debd024f1 Mon Sep 17 00:00:00 2001 From: Remy Moll Date: Sun, 16 Feb 2025 12:41:06 +0100 Subject: [PATCH 4/7] account for changed itineraries once landmarks are marked as done or deleted --- .../modules/current_trip_landmarks_list.dart | 16 ++- .../current_trip_loading_indicator.dart | 79 +++++------ frontend/lib/modules/landmark_card.dart | 127 ++++++++++-------- .../lib/modules/step_between_landmarks.dart | 8 ++ frontend/lib/structs/landmark.dart | 5 +- frontend/lib/structs/trip.dart | 10 +- 6 files changed, 135 insertions(+), 110 deletions(-) diff --git a/frontend/lib/modules/current_trip_landmarks_list.dart b/frontend/lib/modules/current_trip_landmarks_list.dart index 9ab4fbc..8a9f417 100644 --- a/frontend/lib/modules/current_trip_landmarks_list.dart +++ b/frontend/lib/modules/current_trip_landmarks_list.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:anyway/structs/landmark.dart'; @@ -24,10 +26,16 @@ List landmarksList(Trip trip, {required bool Function(Landmark) selector LandmarkCard(landmark, trip), ); - if (!landmark.visited && landmark.next != null) { - children.add( - StepBetweenLandmarks(current: landmark, next: landmark.next!) - ); + if (!landmark.visited) { + Landmark? nextLandmark = landmark.next; + while (nextLandmark != null && nextLandmark.visited) { + nextLandmark = nextLandmark.next; + } + if (nextLandmark != null) { + children.add( + StepBetweenLandmarks(current: landmark, next: nextLandmark!) + ); + } } } } diff --git a/frontend/lib/modules/current_trip_loading_indicator.dart b/frontend/lib/modules/current_trip_loading_indicator.dart index 5eaf037..83a216a 100644 --- a/frontend/lib/modules/current_trip_loading_indicator.dart +++ b/frontend/lib/modules/current_trip_loading_indicator.dart @@ -1,4 +1,5 @@ -import 'package:anyway/constants.dart'; +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:auto_size_text/auto_size_text.dart'; @@ -37,7 +38,10 @@ class _CurrentTripLoadingIndicatorState extends State FutureBuilder( Widget greeter; if (snapshot.hasData) { - greeter = AnimatedGradientText( - text: 'Creating your trip to ${snapshot.data}...', + greeter = AnimatedDotsText( + baseText: 'Creating your trip to ${snapshot.data}', style: greeterStyle, ); } else if (snapshot.hasError) { // the exact error is shown in the central part of the trip overview. No need to show it here - greeter = AnimatedGradientText( - text: 'Error while loading trip.', + greeter = Text( + 'Error while loading trip.', style: greeterStyle, ); } else { - greeter = AnimatedGradientText( - text: 'Creating your trip...', + greeter = AnimatedDotsText( + baseText: 'Creating your trip', style: greeterStyle, ); } @@ -101,61 +105,44 @@ Widget loadingText(Trip trip) => FutureBuilder( } ); -class AnimatedGradientText extends StatefulWidget { - final String text; +class AnimatedDotsText extends StatefulWidget { + final String baseText; final TextStyle style; - const AnimatedGradientText({ + const AnimatedDotsText({ Key? key, - required this.text, + required this.baseText, required this.style, }) : super(key: key); @override - _AnimatedGradientTextState createState() => _AnimatedGradientTextState(); + _AnimatedDotsTextState createState() => _AnimatedDotsTextState(); } -class _AnimatedGradientTextState extends State with SingleTickerProviderStateMixin { - late AnimationController _controller; +class _AnimatedDotsTextState extends State { + int dotCount = 0; @override void initState() { super.initState(); - _controller = AnimationController( - duration: const Duration(seconds: 1), - vsync: this, - )..repeat(); - } - - @override - void dispose() { - _controller.dispose(); - super.dispose(); + Timer.periodic(const Duration(seconds: 1), (timer) { + if (mounted) { + setState(() { + dotCount = (dotCount + 1) % 4; + // show up to 3 dots + }); + } else { + timer.cancel(); + } + }); } @override Widget build(BuildContext context) { - return AnimatedBuilder( - animation: _controller, - builder: (context, child) { - return ShaderMask( - shaderCallback: (bounds) { - return LinearGradient( - colors: [GRADIENT_START, GRADIENT_END, GRADIENT_START], - stops: [ - _controller.value - 1.0, - _controller.value, - _controller.value + 1.0, - ], - tileMode: TileMode.mirror, - ).createShader(bounds); - }, - child: Text( - widget.text, - style: widget.style, - ), - ); - }, + String dots = '.' * dotCount; + return Text( + '${widget.baseText}$dots', + style: widget.style, ); } } diff --git a/frontend/lib/modules/landmark_card.dart b/frontend/lib/modules/landmark_card.dart index 9ef4875..8579219 100644 --- a/frontend/lib/modules/landmark_card.dart +++ b/frontend/lib/modules/landmark_card.dart @@ -47,32 +47,20 @@ class _LandmarkCardState extends State { AspectRatio( aspectRatio: 3 / 4, child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ if (widget.landmark.imageURL != null && widget.landmark.imageURL!.isNotEmpty) Expanded( child: CachedNetworkImage( imageUrl: widget.landmark.imageURL!, - placeholder: (context, url) => Center(child: CircularProgressIndicator()), - errorWidget: (context, error, stackTrace) => Icon(Icons.question_mark_outlined), - fit: BoxFit.cover, + placeholder: (context, url) => const Center(child: CircularProgressIndicator()), + errorWidget: (context, url, error) => imagePlaceholder(widget.landmark), + fit: BoxFit.cover ) ) else - Expanded( - child: - Container( - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [GRADIENT_START, GRADIENT_END], - ), - ), - child: Center( - child: Icon(widget.landmark.type.icon.icon, size: 50), - ), - ), - ), + imagePlaceholder(widget.landmark), + if (widget.landmark.type != typeStart && widget.landmark.type != typeFinish) Container( color: PRIMARY_COLOR, @@ -96,47 +84,54 @@ class _LandmarkCardState extends State { // Main information, useful buttons on the right Expanded( - child: Padding( - padding: const EdgeInsets.all(10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - widget.landmark.name, - style: Theme.of(context).textTheme.titleMedium, - overflow: TextOverflow.ellipsis, - maxLines: 2, - ), - - if (widget.landmark.nameEN != null) - Text( - widget.landmark.nameEN!, - style: Theme.of(context).textTheme.bodyMedium, - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - - // fill the vspace - const Spacer(), - - SingleChildScrollView( - // allows the buttons to be scrolled - scrollDirection: Axis.horizontal, - child: Wrap( - spacing: 10, - // show the type, the website, and the wikipedia link as buttons/labels in a row - children: [ - doneToggleButton(), - if (widget.landmark.websiteURL != null) - websiteButton(), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.landmark.name, + style: Theme.of(context).textTheme.titleMedium, + overflow: TextOverflow.ellipsis, + maxLines: 2, + ), - optionsButton() - ], - ), + if (widget.landmark.nameEN != null) + Text( + widget.landmark.nameEN!, + style: Theme.of(context).textTheme.bodyMedium, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ] ), - ], - ), - ), + ), + + // fill the vspace + const Spacer(), + + SingleChildScrollView( + scrollDirection: Axis.horizontal, + padding: EdgeInsets.only(left: 5, right: 5, bottom: 10), + // the scroll view should be flush once the buttons are scrolled to the left + // but initially there should be some padding + child: Wrap( + spacing: 10, + // show the type, the website, and the wikipedia link as buttons/labels in a row + children: [ + doneToggleButton(), + if (widget.landmark.websiteURL != null) + websiteButton(), + + optionsButton() + ], + ), + ), + ], + ) ) ], ) @@ -195,3 +190,21 @@ class _LandmarkCardState extends State { ], ); } + + + +Widget imagePlaceholder (Landmark landmark) => Expanded( + child: + Container( + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [GRADIENT_START, GRADIENT_END], + ), + ), + child: Center( + child: Icon(landmark.type.icon.icon, size: 50), + ), + ), +); diff --git a/frontend/lib/modules/step_between_landmarks.dart b/frontend/lib/modules/step_between_landmarks.dart index 739f1b6..129763f 100644 --- a/frontend/lib/modules/step_between_landmarks.dart +++ b/frontend/lib/modules/step_between_landmarks.dart @@ -22,6 +22,14 @@ class _StepBetweenLandmarksState extends State { @override Widget build(BuildContext context) { int? time = widget.current.tripTime?.inMinutes; + + // since landmarks might have been marked as visited, the next landmark might not be the immediate next in the list + // => the precomputed trip time is not valid anymore + if (widget.current.next != widget.next) { + time = null; + } + + // round 0 travel time to 1 minute if (time != null && time < 1) { time = 1; } diff --git a/frontend/lib/structs/landmark.dart b/frontend/lib/structs/landmark.dart index 8856047..5ef2cfd 100644 --- a/frontend/lib/structs/landmark.dart +++ b/frontend/lib/structs/landmark.dart @@ -29,9 +29,10 @@ final class Landmark extends LinkedListEntry{ final Duration? duration; bool visited; - // Next node + // Next node is implicitly available through the LinkedListEntry mixin // final Landmark? next; - final Duration? tripTime; + Duration? tripTime; + // the trip time depends on the next landmark, so it is not final Landmark({ diff --git a/frontend/lib/structs/trip.dart b/frontend/lib/structs/trip.dart index e550540..820749e 100644 --- a/frontend/lib/structs/trip.dart +++ b/frontend/lib/structs/trip.dart @@ -75,8 +75,16 @@ class Trip with ChangeNotifier { notifyListeners(); } - void removeLandmark(Landmark landmark) { + void removeLandmark (Landmark landmark) async { + Landmark? previous = landmark.previous; + Landmark? next = landmark.next; landmarks.remove(landmark); + // removing the landmark means we need to recompute the time between the two adjoined landmarks + if (previous != null && next != null) { + // previous.next = next happens automatically since we are using a LinkedList + previous.tripTime = null; + // TODO + } notifyListeners(); } From 4ad867e609652f115cb2536c7d852b0cd1659a18 Mon Sep 17 00:00:00 2001 From: Remy Moll Date: Tue, 25 Feb 2025 19:18:44 +0100 Subject: [PATCH 5/7] revamped onboarding --- .vscode/launch.json | 2 +- frontend/assets/README.md | 2 + frontend/assets/cat.svg | 107 ----- frontend/assets/cel-snow-globe.svg | 79 ++++ frontend/assets/city.svg | 273 ----------- frontend/assets/cld-server.svg | 64 +++ frontend/assets/con-drill.svg | 64 +++ frontend/assets/con-warning.svg | 37 ++ frontend/assets/confused.svg | 427 ------------------ frontend/assets/gen-lifebelt.svg | 76 ++++ frontend/assets/plan.svg | 161 ------- frontend/assets/terms_and_conditions.md | 126 ++++++ frontend/ios/fastlane/Fastfile | 3 +- frontend/lib/main.dart | 1 - frontend/lib/modules/landmark_card.dart | 1 - .../lib/modules/onbarding_agreement_card.dart | 97 ++++ frontend/lib/modules/onboarding_card.dart | 11 +- frontend/lib/pages/onboarding.dart | 136 ++++-- frontend/lib/pages/settings.dart | 7 +- frontend/pubspec.lock | 90 ++-- frontend/pubspec.yaml | 1 + 21 files changed, 700 insertions(+), 1065 deletions(-) create mode 100644 frontend/assets/README.md delete mode 100644 frontend/assets/cat.svg create mode 100644 frontend/assets/cel-snow-globe.svg delete mode 100644 frontend/assets/city.svg create mode 100644 frontend/assets/cld-server.svg create mode 100644 frontend/assets/con-drill.svg create mode 100644 frontend/assets/con-warning.svg delete mode 100644 frontend/assets/confused.svg create mode 100644 frontend/assets/gen-lifebelt.svg delete mode 100644 frontend/assets/plan.svg create mode 100644 frontend/assets/terms_and_conditions.md create mode 100644 frontend/lib/modules/onbarding_agreement_card.dart diff --git a/.vscode/launch.json b/.vscode/launch.json index fa7d5d9..4454643 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -50,4 +50,4 @@ "cwd": "${workspaceFolder}/frontend" } ] -} \ No newline at end of file +} diff --git a/frontend/assets/README.md b/frontend/assets/README.md new file mode 100644 index 0000000..68dd298 --- /dev/null +++ b/frontend/assets/README.md @@ -0,0 +1,2 @@ +## Vector assets +As per https://www.svgrepo.com/collection/pixellove-bordered-vectors/ these icons are licensed under CC0. diff --git a/frontend/assets/cat.svg b/frontend/assets/cat.svg deleted file mode 100644 index f89158c..0000000 --- a/frontend/assets/cat.svg +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/frontend/assets/cel-snow-globe.svg b/frontend/assets/cel-snow-globe.svg new file mode 100644 index 0000000..bf299ba --- /dev/null +++ b/frontend/assets/cel-snow-globe.svg @@ -0,0 +1,79 @@ + + + + + cel-snow-globe + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/assets/city.svg b/frontend/assets/city.svg deleted file mode 100644 index 8f4bf7a..0000000 --- a/frontend/assets/city.svg +++ /dev/null @@ -1,273 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/frontend/assets/cld-server.svg b/frontend/assets/cld-server.svg new file mode 100644 index 0000000..b484198 --- /dev/null +++ b/frontend/assets/cld-server.svg @@ -0,0 +1,64 @@ + + + + + cld-server + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/assets/con-drill.svg b/frontend/assets/con-drill.svg new file mode 100644 index 0000000..b095d26 --- /dev/null +++ b/frontend/assets/con-drill.svg @@ -0,0 +1,64 @@ + + + + + con-drill + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/assets/con-warning.svg b/frontend/assets/con-warning.svg new file mode 100644 index 0000000..1e085b4 --- /dev/null +++ b/frontend/assets/con-warning.svg @@ -0,0 +1,37 @@ + + + + + con-warning + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/assets/confused.svg b/frontend/assets/confused.svg deleted file mode 100644 index e5182a2..0000000 --- a/frontend/assets/confused.svg +++ /dev/null @@ -1,427 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/frontend/assets/gen-lifebelt.svg b/frontend/assets/gen-lifebelt.svg new file mode 100644 index 0000000..c32fcef --- /dev/null +++ b/frontend/assets/gen-lifebelt.svg @@ -0,0 +1,76 @@ + + + + + gen-lifebelt + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/assets/plan.svg b/frontend/assets/plan.svg deleted file mode 100644 index 62705c9..0000000 --- a/frontend/assets/plan.svg +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - - - - - - - diff --git a/frontend/assets/terms_and_conditions.md b/frontend/assets/terms_and_conditions.md new file mode 100644 index 0000000..924a4ed --- /dev/null +++ b/frontend/assets/terms_and_conditions.md @@ -0,0 +1,126 @@ +# Terms and Conditions + +> Last updated: January 09, 2025 +> +> Also see: https://anydev.info/terms-and-conditions/ + +Please read these terms and conditions carefully before using our Service. + +## Interpretation and Definitions +### Interpretation + +The words of which the initial letter is capitalized have meanings defined under the following conditions. The following definitions shall have the same meaning regardless of whether they appear in singular or in plural. + +### Definitions + +For the purposes of these Terms and Conditions: + - **Application** means the software program provided by the Company downloaded by You on any electronic device, named AnyWay + - **Application Store** means the digital distribution service operated and developed by Apple Inc. (Apple App Store) or Google Inc. (Google Play Store) in which the Application has been downloaded. + - **Affiliate** means an entity that controls, is controlled by or is under common control with a party, where "control" means ownership of 50% or more of the shares, equity interest or other securities entitled to vote for election of directors or other managing authority. + - **Country** refers to: Switzerland + - **Company** (referred to as either "the Company", "We", "Us" or "Our" in this Agreement) refers to AnyDev. + - **Device** means any device that can access the Service such as a computer, a cellphone or a digital tablet. + - **Service** refers to the Application. + - **Terms and Conditions** (also referred as "Terms") mean these Terms and Conditions that form the entire agreement between You and the Company regarding the use of the Service. This Terms and Conditions agreement has been created with the help of the Terms and Conditions Generator. + - **Third-party Social Media Service** means any services or content (including data, information, products or services) provided by a third-party that may be displayed, included or made available by the Service. + - **You** means the individual accessing or using the Service, or the company, or other legal entity on behalf of which such individual is accessing or using the Service, as applicable. + +## Acknowledgment + +These are the Terms and Conditions governing the use of this Service and the agreement that operates between You and the Company. These Terms and Conditions set out the rights and obligations of all users regarding the use of the Service. + +Your access to and use of the Service is conditioned on Your acceptance of and compliance with these Terms and Conditions. These Terms and Conditions apply to all visitors, users and others who access or use the Service. + +By accessing or using the Service You agree to be bound by these Terms and Conditions. If You disagree with any part of these Terms and Conditions then You may not access the Service. + +You represent that you are over the age of 18. The Company does not permit those under 18 to use the Service. + +Your access to and use of the Service is also conditioned on Your acceptance of and compliance with the Privacy Policy of the Company. Our Privacy Policy describes Our policies and procedures on the collection, use and disclosure of Your personal information when You use the Application or the Website and tells You about Your privacy rights and how the law protects You. Please read Our Privacy Policy carefully before using Our Service. + + +## Links to Other Websites + +Our Service may contain links to third-party web sites or services that are not owned or controlled by the Company. + +The Company has no control over, and assumes no responsibility for, the content, privacy policies, or practices of any third party web sites or services. You further acknowledge and agree that the Company shall not be responsible or liable, directly or indirectly, for any damage or loss caused or alleged to be caused by or in connection with the use of or reliance on any such content, goods or services available on or through any such web sites or services. + +We strongly advise You to read the terms and conditions and privacy policies of any third-party web sites or services that You visit. + + +## Termination + +We may terminate or suspend Your access immediately, without prior notice or liability, for any reason whatsoever, including without limitation if You breach these Terms and Conditions. + +Upon termination, Your right to use the Service will cease immediately. + + +## Limitation of Liability + +Notwithstanding any damages that You might incur, the entire liability of the Company and any of its suppliers under any provision of this Terms and Your exclusive remedy for all of the foregoing shall be limited to the amount actually paid by You through the Service or 100 USD if You haven't purchased anything through the Service. + +To the maximum extent permitted by applicable law, in no event shall the Company or its suppliers be liable for any special, incidental, indirect, punitive, or consequential damages whatsoever (including, but not limited to, damages for loss of profits, loss of data, loss of use, loss of goodwill, business interruption, personal injury, loss of privacy, or any other pecuniary or non-pecuniary loss or damage) arising out of or in any way related to the use of or inability to use the Service, third-party software and/or third-party hardware used with the Service, or otherwise in connection with any provision of this Terms, even if the Company or any supplier has been advised of the possibility of such damages and even if the remedy fails of its essential purpose. + +In particular, the Company and its suppliers are not liable for any damages or losses that may arise from: + - Your reliance on any content provided through the Service; + - Errors, mistakes, or inaccuracies of content; + - Any unauthorized access to or use of our servers and/or any personal information stored therein; + - Any interruption or cessation of transmission to or from the Service; + - Any bugs, viruses, trojan horses, or the like which may be transmitted to or through the Service by any third party; + - Any errors or omissions in any content or for any loss or damage of any kind incurred as a result of Your use of any content posted, emailed, transmitted, or otherwise made available via the Service. + +The Company shall not be liable for any loss or damage resulting from failure to meet any of Your expectations related to the use or performance of the Service, including but not limited to inaccuracies in GPS location services, suggested itineraries, or other location-based services. + +Some jurisdictions do not allow the exclusion or limitation of certain types of liability, such as incidental or consequential damages or implied warranties. Therefore, the above limitations or exclusions may not apply to You. In such jurisdictions, each party's liability will be limited to the greatest extent permitted by law. + +To the extent permitted by applicable law, the Company and its suppliers’ aggregate liability to You for any claims arising from or related to the use of the Service shall in no event exceed the greater of (a) the amount You paid, if any, for accessing the Service during the twelve (12) month period preceding the claim or (b) one hundred (100) USD. + +You agree that the limitations of liability set forth in this section will survive any termination or expiration of these Terms and apply even if any limited remedy specified in these Terms is found to have failed its essential purpose. +"AS IS" and "AS AVAILABLE" Disclaimer + +The Service is provided to You "AS IS" and "AS AVAILABLE" and with all faults and defects without warranty of any kind. To the maximum extent permitted under applicable law, the Company, on its own behalf and on behalf of its Affiliates and its and their respective licensors and service providers, expressly disclaims all warranties, whether express, implied, statutory or otherwise, with respect to the Service, including all implied warranties of merchantability, fitness for a particular purpose, title and non-infringement, and warranties that may arise out of course of dealing, course of performance, usage or trade practice. Without limitation to the foregoing, the Company provides no warranty or undertaking, and makes no representation of any kind that the Service will meet Your requirements, achieve any intended results, be compatible or work with any other software, applications, systems or services, operate without interruption, meet any performance or reliability standards or be error free or that any errors or defects can or will be corrected. + +Without limiting the foregoing, neither the Company nor any of the company's provider makes any representation or warranty of any kind, express or implied: (i) as to the operation or availability of the Service, or the information, content, and materials or products included thereon; (ii) that the Service will be uninterrupted or error-free; (iii) as to the accuracy, reliability, or currency of any information or content provided through the Service; or (iv) that the Service, its servers, the content, or e-mails sent from or on behalf of the Company are free of viruses, scripts, trojan horses, worms, malware, timebombs or other harmful components. + +Some jurisdictions do not allow the exclusion of certain types of warranties or limitations on applicable statutory rights of a consumer, so some or all of the above exclusions and limitations may not apply to You. But in such a case the exclusions and limitations set forth in this section shall be applied to the greatest extent enforceable under applicable law. + + +## Governing Law + +The laws of the Country, excluding its conflicts of law rules, shall govern this Terms and Your use of the Service. Your use of the Application may also be subject to other local, state, national, or international laws. + + +## Disputes Resolution + +If You have any concern or dispute about the Service, You agree to first try to resolve the dispute informally by contacting the Company. +For European Union (EU) Users + +If You are a European Union consumer, you will benefit from any mandatory provisions of the law of the country in which You are resident. + + +## United States Legal Compliance + +You represent and warrant that (i) You are not located in a country that is subject to the United States government embargo, or that has been designated by the United States government as a "terrorist supporting" country, and (ii) You are not listed on any United States government list of prohibited or restricted parties. + + +## Severability and Waiver +### Severability + +If any provision of these Terms is held to be unenforceable or invalid, such provision will be changed and interpreted to accomplish the objectives of such provision to the greatest extent possible under applicable law and the remaining provisions will continue in full force and effect. + +### Waiver + +Except as provided herein, the failure to exercise a right or to require performance of an obligation under these Terms shall not affect a party's ability to exercise such right or require such performance at any time thereafter nor shall the waiver of a breach constitute a waiver of any subsequent breach. +Translation Interpretation + +These Terms and Conditions may have been translated if We have made them available to You on our Service. You agree that the original English text shall prevail in the case of a dispute. +Changes to These Terms and Conditions + +We reserve the right, at Our sole discretion, to modify or replace these Terms at any time. If a revision is material We will make reasonable efforts to provide at least 30 days' notice prior to any new terms taking effect. What constitutes a material change will be determined at Our sole discretion. + +By continuing to access or use Our Service after those revisions become effective, You agree to be bound by the revised terms. If You do not agree to the new terms, in whole or in part, please stop using the website and the Service. + + +## Contact Us + +If you have any questions about these Terms and Conditions, You can contact us: + - By visiting this page on our website: https://anydev.info diff --git a/frontend/ios/fastlane/Fastfile b/frontend/ios/fastlane/Fastfile index f3e23f4..b5e15f1 100644 --- a/frontend/ios/fastlane/Fastfile +++ b/frontend/ios/fastlane/Fastfile @@ -71,7 +71,6 @@ platform :ios do "", "s/IOS_GOOGLE_MAPS_API_KEY/#{ENV["IOS_GOOGLE_MAPS_API_KEY"]}/g", "../Runner/AppDelegate.swift" - ) sh( @@ -93,7 +92,7 @@ platform :ios do skip_screenshots: true, skip_metadata: true, precheck_include_in_app_purchases: false, - + submit_for_review: true, automatic_release: true, # automatically release the app after review diff --git a/frontend/lib/main.dart b/frontend/lib/main.dart index ed4121f..2fe5991 100644 --- a/frontend/lib/main.dart +++ b/frontend/lib/main.dart @@ -16,7 +16,6 @@ final SavedTrips savedTrips = SavedTrips(); class App extends StatelessWidget { const App({super.key}); - @override Widget build(BuildContext context) => MaterialApp( title: APP_NAME, diff --git a/frontend/lib/modules/landmark_card.dart b/frontend/lib/modules/landmark_card.dart index 8579219..491b6da 100644 --- a/frontend/lib/modules/landmark_card.dart +++ b/frontend/lib/modules/landmark_card.dart @@ -69,7 +69,6 @@ class _LandmarkCardState extends State { padding: EdgeInsets.all(5), child: Row( mainAxisAlignment: MainAxisAlignment.center, - spacing: 5, children: [ Icon(Icons.timer_outlined, size: 16), Text("${widget.landmark.duration?.inMinutes} minutes"), diff --git a/frontend/lib/modules/onbarding_agreement_card.dart b/frontend/lib/modules/onbarding_agreement_card.dart new file mode 100644 index 0000000..8f3d540 --- /dev/null +++ b/frontend/lib/modules/onbarding_agreement_card.dart @@ -0,0 +1,97 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_markdown/flutter_markdown.dart'; + +import 'package:anyway/modules/onboarding_card.dart'; + + +class OnboardingAgreementCard extends StatefulWidget { + final String title; + final String description; + final String imagePath; + final String agreementTextPath; + final ValueChanged onAgreementChanged; + + + OnboardingAgreementCard({ + super.key, + required this.title, + required this.description, + required this.imagePath, + required this.agreementTextPath, + required this.onAgreementChanged + }); + + @override + State createState() => _OnboardingAgreementCardState(); +} + +class _OnboardingAgreementCardState extends State { + bool agreed = false; + @override + Widget build(BuildContext context) { + return Padding( + padding: EdgeInsets.all(20), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + OnboardingCard(title: widget.title, description: widget.description, imagePath: widget.imagePath), + Padding(padding: EdgeInsets.only(top: 20)), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Checkbox( + value: agreed, + onChanged: (value) { + setState(() { + agreed = value!; + widget.onAgreementChanged(value); + }); + }, + ), + Text( + "I agree to the ", + style: Theme.of(context).textTheme.bodyMedium!.copyWith( + color: Colors.white, + ), + ), + GestureDetector( + onTap: () { + // show a dialog with the agreement text + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + scrollable: true, + content: FutureBuilder( + future: DefaultAssetBundle.of(context).loadString(widget.agreementTextPath), + builder: (context, snapshot) { + if (snapshot.hasData) { + return MarkdownBody( + data: snapshot.data.toString(), + ); + } else { + return CircularProgressIndicator(); + } + + }, + ) + ); + } + ); + + }, + child: Text( + "Terms of Service (click to view)", + style: Theme.of(context).textTheme.bodyMedium!.copyWith( + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ], + ), + ); + } +} diff --git a/frontend/lib/modules/onboarding_card.dart b/frontend/lib/modules/onboarding_card.dart index 05fc340..094d641 100644 --- a/frontend/lib/modules/onboarding_card.dart +++ b/frontend/lib/modules/onboarding_card.dart @@ -22,9 +22,7 @@ class OnboardingCard extends StatelessWidget { children: [ Text( title, - style: TextStyle( - fontSize: 24, - fontWeight: FontWeight.bold, + style: Theme.of(context).textTheme.headlineLarge!.copyWith( color: Colors.white, ), ), @@ -36,13 +34,12 @@ class OnboardingCard extends StatelessWidget { Padding(padding: EdgeInsets.only(top: 20)), Text( description, - style: TextStyle( - fontSize: 16, + style: Theme.of(context).textTheme.bodyMedium!.copyWith( + color: Colors.white, ), ), - ] ), ); } -} \ No newline at end of file +} diff --git a/frontend/lib/pages/onboarding.dart b/frontend/lib/pages/onboarding.dart index 3692cb8..2de42b6 100644 --- a/frontend/lib/pages/onboarding.dart +++ b/frontend/lib/pages/onboarding.dart @@ -1,33 +1,37 @@ import 'dart:ui'; import 'package:anyway/constants.dart'; +import 'package:anyway/modules/onbarding_agreement_card.dart'; import 'package:anyway/modules/onboarding_card.dart'; import 'package:anyway/pages/new_trip_location.dart'; import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; -const List onboardingCards = [ - OnboardingCard( + +List onboardingCards = [ + const OnboardingCard( title: "Welcome to anyway!", description: "Anyway helps you plan a city trip that suits your wishes.", - imagePath: "assets/city.svg" + imagePath: "assets/cld-server.svg" ), - OnboardingCard( - title: "Find your way", + const OnboardingCard( + title: "Do your thing", description: "Bored by churches? No problem! Hate shopping? No worries! Instead of suggesting the generic trips that bore you, anyway will try to give you recommendations that really suit you.", - imagePath: "assets/plan.svg" + imagePath: "assets/con-drill.svg" ), - OnboardingCard( + const OnboardingCard( title: "Change your mind", description: "Feet get sore, the weather changes. Anyway understands that! Move or remove destinations, visit hidden gems along your journey, do your own thing. Anyway adapts to your spontaneous decisions.", - imagePath: "assets/cat.svg" + imagePath: "assets/cel-snow-globe.svg" ), - OnboardingCard( + const OnboardingCard( title: "Feeling lost?", description: "Whenever you are confused or need help with the app, look out for the question mark in the top right corner. Help is just a tap away!", - imagePath: "assets/confused.svg" + imagePath: "assets/gen-lifebelt.svg" ), ]; + class OnboardingPage extends StatefulWidget { const OnboardingPage({super.key}); @@ -37,9 +41,24 @@ class OnboardingPage extends StatefulWidget { class _OnboardingPageState extends State { final PageController _controller = PageController(); + late List fullCards; + + @override Widget build(BuildContext context) { + + Widget agreementCard = OnboardingAgreementCard( + title: "The annoying stuff", + description: "By using anyway, you agree to our terms and conditions and privacy policy. We don't use cookies or tracking, we don't store the data you submit. We are not responsible for any damage or loss caused by using anyway.", + imagePath: "assets/con-warning.svg", + agreementTextPath: "assets/terms_and_conditions.md", + onAgreementChanged: onAgreementChanged, + ); + // need to add the agreement from within the function because it needs to be able to call setState + fullCards = onboardingCards + [agreementCard]; + + return Scaffold( body: Stack( children: [ @@ -55,8 +74,8 @@ class _OnboardingPageState extends State { end: Alignment.bottomRight, colors: APP_GRADIENT.colors, stops: [ - (_controller.hasClients ? _controller.page ?? _controller.initialPage : _controller.initialPage) / onboardingCards.length, - (_controller.hasClients ? _controller.page ?? _controller.initialPage + 1 : _controller.initialPage + 1) / onboardingCards.length, + (_controller.hasClients ? (_controller.page ?? _controller.initialPage) : _controller.initialPage) / onboardingCards.length, + (_controller.hasClients ? (_controller.page ?? _controller.initialPage) + 1 : _controller.initialPage + 1) / onboardingCards.length, ], ), ), @@ -64,7 +83,7 @@ class _OnboardingPageState extends State { BackdropFilter( filter: ImageFilter.blur(sigmaX: 100, sigmaY: 100), child: Container( - color: Colors.black.withOpacity(0), + color: Colors.black.withValues(alpha: 0.2) ), ), ], @@ -74,46 +93,73 @@ class _OnboardingPageState extends State { PageView( controller: _controller, children: List.generate( - onboardingCards.length, + fullCards.length, (index) { return Container( alignment: Alignment.center, - child: onboardingCards[index], + child: fullCards[index], ); } ), ), ], ), - floatingActionButton: FloatingActionButton.extended( - onPressed: () { - if (_controller.page == onboardingCards.length - 1) { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const NewTripPage() - ) - ); - } else { - _controller.nextPage(duration: Duration(milliseconds: 500), curve: Curves.ease); - } - }, - label: AnimatedBuilder( - animation: _controller, - builder: (context, child) { - if ((_controller.page ?? _controller.initialPage) == onboardingCards.length - 1) { - return Row( - children: [ - const Text("Start planning!"), - Padding(padding: const EdgeInsets.only(right: 8.0)), - const Icon(Icons.map_outlined) - ], - ); - } else { - return const Icon(Icons.arrow_forward); - } - } - ) - ), + + floatingActionButton: nextButton(_controller) ); } -} \ No newline at end of file + + Widget nextButton(PageController controller) => AnimatedBuilder( + animation: _controller, + builder: (context, child) { + if ((_controller.hasClients ? (_controller.page ?? _controller.initialPage) : 0) != fullCards.length - 1) { + return FloatingActionButton.extended( + onPressed: () { + controller.nextPage(duration: Duration(milliseconds: 500), curve: Curves.ease); + }, + label: Icon(Icons.arrow_forward) + ); + } else { + // only allow the user to proceed if they have agreed to the terms and conditions + Future hasAgreed = SharedPreferences.getInstance().then( + (SharedPreferences prefs) { + return prefs.getBool('TC_agree') ?? false; + } + ); + + return FutureBuilder( + future: hasAgreed, + builder: (context, snapshot){ + if (snapshot.hasData && snapshot.data!) { + return FloatingActionButton.extended( + onPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => const NewTripPage() + ) + ); + }, + label: const Row( + children: [ + Text("Start planning!"), + Padding(padding: EdgeInsets.only(right: 8.0)), + Icon(Icons.map_outlined) + ], + ) + ); + } else { + return Container(); + } + } + ); + } + } + ); + + void onAgreementChanged(bool value) async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.setBool('TC_agree', value); + // Update the state of the OnboardingPage + setState(() {}); + } +} diff --git a/frontend/lib/pages/settings.dart b/frontend/lib/pages/settings.dart index b5d3240..c2e71d2 100644 --- a/frontend/lib/pages/settings.dart +++ b/frontend/lib/pages/settings.dart @@ -1,11 +1,12 @@ -import 'package:anyway/constants.dart'; -import 'package:anyway/layouts/scaffold.dart'; -import 'package:anyway/main.dart'; import 'package:flutter/material.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:url_launcher/url_launcher.dart'; +import 'package:anyway/main.dart'; +import 'package:anyway/constants.dart'; +import 'package:anyway/layouts/scaffold.dart'; + bool debugMode = false; diff --git a/frontend/pubspec.lock b/frontend/pubspec.lock index bb2aad4..a79e921 100644 --- a/frontend/pubspec.lock +++ b/frontend/pubspec.lock @@ -21,10 +21,10 @@ packages: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 url: "https://pub.dev" source: hosted - version: "2.11.0" + version: "2.12.0" auto_size_text: dependency: "direct main" description: @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" cached_network_image: dependency: "direct main" description: @@ -69,10 +69,10 @@ packages: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.0" checked_yaml: dependency: transitive description: @@ -93,18 +93,18 @@ packages: dependency: transitive description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" collection: dependency: transitive description: name: collection - sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" url: "https://pub.dev" source: hosted - version: "1.19.0" + version: "1.19.1" crypto: dependency: transitive description: @@ -149,10 +149,10 @@ packages: dependency: transitive description: name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.2" ffi: dependency: transitive description: @@ -206,6 +206,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.0" + flutter_markdown: + dependency: "direct main" + description: + name: flutter_markdown + sha256: e7bbc718adc9476aa14cfddc1ef048d2e21e4e8f18311aaac723266db9f9e7b5 + url: "https://pub.dev" + source: hosted + version: "0.7.6+2" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -412,18 +420,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06" + sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec url: "https://pub.dev" source: hosted - version: "10.0.7" + version: "10.0.8" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379" + sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 url: "https://pub.dev" source: hosted - version: "3.0.8" + version: "3.0.9" leak_tracker_testing: dependency: transitive description: @@ -448,14 +456,22 @@ packages: url: "https://pub.dev" source: hosted version: "3.5.0" + markdown: + dependency: transitive + description: + name: markdown + sha256: "935e23e1ff3bc02d390bad4d4be001208ee92cc217cb5b5a6c19bc14aaa318c1" + url: "https://pub.dev" + source: hosted + version: "7.3.0" matcher: dependency: transitive description: name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 url: "https://pub.dev" source: hosted - version: "0.12.16+1" + version: "0.12.17" material_color_utilities: dependency: transitive description: @@ -468,10 +484,10 @@ packages: dependency: transitive description: name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.16.0" nested: dependency: transitive description: @@ -492,10 +508,10 @@ packages: dependency: transitive description: name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" path_parsing: dependency: transitive description: @@ -721,10 +737,10 @@ packages: dependency: transitive description: name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.10.1" sprintf: dependency: transitive description: @@ -753,18 +769,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" url: "https://pub.dev" source: hosted - version: "1.12.0" + version: "1.12.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" stream_transform: dependency: transitive description: @@ -777,10 +793,10 @@ packages: dependency: transitive description: name: string_scanner - sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.1" synchronized: dependency: transitive description: @@ -793,18 +809,18 @@ packages: dependency: transitive description: name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.2.2" test_api: dependency: transitive description: name: test_api - sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd url: "https://pub.dev" source: hosted - version: "0.7.3" + version: "0.7.4" typed_data: dependency: transitive description: @@ -921,10 +937,10 @@ packages: dependency: transitive description: name: vm_service - sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b + sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" url: "https://pub.dev" source: hosted - version: "14.3.0" + version: "14.3.1" web: dependency: transitive description: @@ -966,5 +982,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.5.0 <4.0.0" + dart: ">=3.7.0-0 <4.0.0" flutter: ">=3.24.0" diff --git a/frontend/pubspec.yaml b/frontend/pubspec.yaml index 458a132..ea783ef 100644 --- a/frontend/pubspec.yaml +++ b/frontend/pubspec.yaml @@ -52,6 +52,7 @@ dependencies: permission_handler: ^11.3.1 geolocator: ^13.0.1 fuzzywuzzy: ^1.2.0 + flutter_markdown: ^0.7.6+2 dev_dependencies: flutter_test: From e148c851e11e07c78f71e4bf13319d48fc466813 Mon Sep 17 00:00:00 2001 From: Remy Moll Date: Sun, 23 Mar 2025 20:00:24 +0100 Subject: [PATCH 6/7] quite a few UX improvements --- .../current_trip_loading_indicator.dart | 3 +- .../lib/modules/current_trip_summary.dart | 13 ++-- frontend/lib/modules/new_trip_map.dart | 1 + .../lib/modules/onbarding_agreement_card.dart | 37 +++++++--- .../lib/modules/step_between_landmarks.dart | 2 +- frontend/lib/pages/new_trip_preferences.dart | 9 +++ frontend/lib/pages/no_trips_page.dart | 50 ++++++++++++++ frontend/lib/pages/onboarding.dart | 10 +-- frontend/lib/structs/agreement.dart | 17 +++++ frontend/lib/structs/trip.dart | 13 ++-- frontend/lib/utils/get_first_page.dart | 68 ++++++++++--------- frontend/lib/utils/load_trips.dart | 3 +- 12 files changed, 166 insertions(+), 60 deletions(-) create mode 100644 frontend/lib/pages/no_trips_page.dart create mode 100644 frontend/lib/structs/agreement.dart diff --git a/frontend/lib/modules/current_trip_loading_indicator.dart b/frontend/lib/modules/current_trip_loading_indicator.dart index 83a216a..60cc98c 100644 --- a/frontend/lib/modules/current_trip_loading_indicator.dart +++ b/frontend/lib/modules/current_trip_loading_indicator.dart @@ -140,9 +140,10 @@ class _AnimatedDotsTextState extends State { @override Widget build(BuildContext context) { String dots = '.' * dotCount; - return Text( + return AutoSizeText( '${widget.baseText}$dots', style: widget.style, + maxLines: 2, ); } } diff --git a/frontend/lib/modules/current_trip_summary.dart b/frontend/lib/modules/current_trip_summary.dart index e7aa4a5..b7c5654 100644 --- a/frontend/lib/modules/current_trip_summary.dart +++ b/frontend/lib/modules/current_trip_summary.dart @@ -15,8 +15,9 @@ class CurrentTripSummary extends StatefulWidget { class _CurrentTripSummaryState extends State { @override - Widget build(BuildContext context) { - return Padding( + Widget build(BuildContext context) => ListenableBuilder( + listenable: widget.trip, + builder: (context, child) => Padding( padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 20), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -25,18 +26,18 @@ class _CurrentTripSummaryState extends State { children: [ const Icon(Icons.flag, size: 20), const Padding(padding: EdgeInsets.only(right: 10)), - Text('Stops: ${widget.trip.landmarks.length}', style: Theme.of(context).textTheme.bodyLarge), + Text('${widget.trip.landmarks.length} stops', style: Theme.of(context).textTheme.bodyLarge), ] ), Row( children: [ const Icon(Icons.hourglass_bottom_rounded, size: 20), const Padding(padding: EdgeInsets.only(right: 10)), - Text('Duration: ${widget.trip.totalTime} minutes', style: Theme.of(context).textTheme.bodyLarge), + Text('${widget.trip.totalTime.inHours}h ${widget.trip.totalTime.inMinutes.remainder(60)}min', style: Theme.of(context).textTheme.bodyLarge), ] ), ], ) - ); - } + ) + ); } diff --git a/frontend/lib/modules/new_trip_map.dart b/frontend/lib/modules/new_trip_map.dart index e4e5400..b033b16 100644 --- a/frontend/lib/modules/new_trip_map.dart +++ b/frontend/lib/modules/new_trip_map.dart @@ -78,6 +78,7 @@ class _NewTripMapState extends State { widget.trip.addListener(updateTripDetails); Future preferences = SharedPreferences.getInstance(); + return FutureBuilder( future: preferences, builder: (context, snapshot) { diff --git a/frontend/lib/modules/onbarding_agreement_card.dart b/frontend/lib/modules/onbarding_agreement_card.dart index 8f3d540..bc7a293 100644 --- a/frontend/lib/modules/onbarding_agreement_card.dart +++ b/frontend/lib/modules/onbarding_agreement_card.dart @@ -1,3 +1,4 @@ +import 'package:anyway/structs/agreement.dart'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -26,7 +27,6 @@ class OnboardingAgreementCard extends StatefulWidget { } class _OnboardingAgreementCardState extends State { - bool agreed = false; @override Widget build(BuildContext context) { return Padding( @@ -39,21 +39,42 @@ class _OnboardingAgreementCardState extends State { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Checkbox( - value: agreed, - onChanged: (value) { - setState(() { - agreed = value!; - widget.onAgreementChanged(value); - }); + // The checkbox of the agreement + FutureBuilder( + future: getAgreement(), + builder: (context, snapshot) { + bool agreed = false; + if (snapshot.connectionState == ConnectionState.done) { + if (snapshot.hasData) { + Agreement agreement = snapshot.data!; + agreed = agreement.agreed; + } else { + agreed = false; + } + } else { + agreed = false; + } + return Checkbox( + value: agreed, + onChanged: (value) { + setState(() { + widget.onAgreementChanged(value!); + }); + saveAgreement(value!); + }, + ); }, ), + + // The text of the agreement Text( "I agree to the ", style: Theme.of(context).textTheme.bodyMedium!.copyWith( color: Colors.white, ), ), + + // The clickable text of the agreement that shows the agreement text GestureDetector( onTap: () { // show a dialog with the agreement text diff --git a/frontend/lib/modules/step_between_landmarks.dart b/frontend/lib/modules/step_between_landmarks.dart index 129763f..6dbcf4b 100644 --- a/frontend/lib/modules/step_between_landmarks.dart +++ b/frontend/lib/modules/step_between_landmarks.dart @@ -48,7 +48,7 @@ class _StepBetweenLandmarksState extends State { children: [ const Icon(Icons.directions_walk), Text( - time == null ? "" : "About $time min", + time == null ? "" : "$time min", style: const TextStyle(fontSize: 10) ), ], diff --git a/frontend/lib/pages/new_trip_preferences.dart b/frontend/lib/pages/new_trip_preferences.dart index 76aaf10..ab6146a 100644 --- a/frontend/lib/pages/new_trip_preferences.dart +++ b/frontend/lib/pages/new_trip_preferences.dart @@ -1,5 +1,6 @@ import 'package:anyway/layouts/scaffold.dart'; import 'package:anyway/modules/new_trip_button.dart'; +import 'package:anyway/structs/landmark.dart'; import 'package:anyway/structs/preferences.dart'; import 'package:anyway/structs/trip.dart'; import 'package:flutter/cupertino.dart'; @@ -20,6 +21,14 @@ class _NewTripPreferencesPageState extends State with Sc @override Widget build(BuildContext context) { + // Ensure that the trip is "empty" save for the start landmark + // This is necessary because users can swipe back to this page even after the trip has been created + if (widget.trip.landmarks.length > 1) { + Landmark start = widget.trip.landmarks.first; + widget.trip.landmarks.clear(); + widget.trip.addLandmark(start); + } + return mainScaffold( context, child: Scaffold( diff --git a/frontend/lib/pages/no_trips_page.dart b/frontend/lib/pages/no_trips_page.dart new file mode 100644 index 0000000..9c46525 --- /dev/null +++ b/frontend/lib/pages/no_trips_page.dart @@ -0,0 +1,50 @@ +import 'package:anyway/pages/new_trip_location.dart'; +import 'package:flutter/material.dart'; + +import 'package:anyway/layouts/scaffold.dart'; +class NoTripsPage extends StatefulWidget { + const NoTripsPage({super.key}); + + @override + State createState() => _NoTripsPageState(); +} + +class _NoTripsPageState extends State with ScaffoldLayout { + @override + Widget build(BuildContext context) => mainScaffold( + context, + child: Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "No trips yet", + style: Theme.of(context).textTheme.headlineMedium, + ), + Text( + "You can start a new trip by clicking the button below", + style: Theme.of(context).textTheme.bodyMedium, + ), + ], + ), + ), + floatingActionButton: FloatingActionButton.extended( + onPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => const NewTripPage() + ) + ); + }, + label: const Row( + children: [ + Text("Start planning!"), + Padding(padding: EdgeInsets.only(right: 8.0)), + Icon(Icons.map_outlined) + ], + ) + ) + ) + ); +} \ No newline at end of file diff --git a/frontend/lib/pages/onboarding.dart b/frontend/lib/pages/onboarding.dart index 2de42b6..847ee3a 100644 --- a/frontend/lib/pages/onboarding.dart +++ b/frontend/lib/pages/onboarding.dart @@ -4,6 +4,7 @@ import 'package:anyway/constants.dart'; import 'package:anyway/modules/onbarding_agreement_card.dart'; import 'package:anyway/modules/onboarding_card.dart'; import 'package:anyway/pages/new_trip_location.dart'; +import 'package:anyway/structs/agreement.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -121,11 +122,7 @@ class _OnboardingPageState extends State { ); } else { // only allow the user to proceed if they have agreed to the terms and conditions - Future hasAgreed = SharedPreferences.getInstance().then( - (SharedPreferences prefs) { - return prefs.getBool('TC_agree') ?? false; - } - ); + Future hasAgreed = getAgreement().then((agreement) => agreement.agreed); return FutureBuilder( future: hasAgreed, @@ -157,8 +154,7 @@ class _OnboardingPageState extends State { ); void onAgreementChanged(bool value) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - await prefs.setBool('TC_agree', value); + saveAgreement(value); // Update the state of the OnboardingPage setState(() {}); } diff --git a/frontend/lib/structs/agreement.dart b/frontend/lib/structs/agreement.dart new file mode 100644 index 0000000..321ca74 --- /dev/null +++ b/frontend/lib/structs/agreement.dart @@ -0,0 +1,17 @@ +import 'package:shared_preferences/shared_preferences.dart'; + +final class Agreement{ + bool agreed; + + Agreement({required this.agreed}); +} + +void saveAgreement(bool agreed) async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.setBool('agreed_to_terms_and_conditions', agreed); +} + +Future getAgreement() async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + return Agreement(agreed: prefs.getBool('agreed_to_terms_and_conditions') ?? false); +} diff --git a/frontend/lib/structs/trip.dart b/frontend/lib/structs/trip.dart index 820749e..ef09e4e 100644 --- a/frontend/lib/structs/trip.dart +++ b/frontend/lib/structs/trip.dart @@ -12,7 +12,7 @@ import 'package:shared_preferences/shared_preferences.dart'; class Trip with ChangeNotifier { String uuid; - int totalTime; + Duration totalTime; LinkedList landmarks; // could be empty as well String? errorDescription; @@ -44,7 +44,7 @@ class Trip with ChangeNotifier { Trip({ this.uuid = 'pending', - this.totalTime = 0, + this.totalTime = Duration.zero, LinkedList? landmarks // a trip can be created with no landmarks, but the list should be initialized anyway }) : landmarks = landmarks ?? LinkedList(); @@ -53,7 +53,7 @@ class Trip with ChangeNotifier { factory Trip.fromJson(Map json) { Trip trip = Trip( uuid: json['uuid'], - totalTime: json['total_time'], + totalTime: Duration(minutes: json['total_time']), ); return trip; @@ -61,7 +61,7 @@ class Trip with ChangeNotifier { void loadFromJson(Map json) { uuid = json['uuid']; - totalTime = json['total_time']; + totalTime = Duration(minutes: json['total_time']); notifyListeners(); } @@ -82,9 +82,12 @@ class Trip with ChangeNotifier { // removing the landmark means we need to recompute the time between the two adjoined landmarks if (previous != null && next != null) { // previous.next = next happens automatically since we are using a LinkedList + this.totalTime -= previous.tripTime ?? Duration.zero; previous.tripTime = null; // TODO } + this.totalTime -= landmark.tripTime ?? Duration.zero; + notifyListeners(); } @@ -111,7 +114,7 @@ class Trip with ChangeNotifier { Map toJson() => { 'uuid': uuid, - 'total_time': totalTime, + 'total_time': totalTime.inMinutes, 'first_landmark_uuid': landmarks.first.uuid }; diff --git a/frontend/lib/utils/get_first_page.dart b/frontend/lib/utils/get_first_page.dart index 26f2787..bc54b79 100644 --- a/frontend/lib/utils/get_first_page.dart +++ b/frontend/lib/utils/get_first_page.dart @@ -1,44 +1,50 @@ import 'package:anyway/main.dart'; +import 'package:anyway/pages/no_trips_page.dart'; +import 'package:anyway/structs/agreement.dart'; import 'package:flutter/material.dart'; import 'package:anyway/structs/trip.dart'; -import 'package:anyway/utils/load_trips.dart'; import 'package:anyway/pages/current_trip.dart'; import 'package:anyway/pages/onboarding.dart'; Widget getFirstPage() { - SavedTrips trips = savedTrips; - trips.loadTrips(); - - return ListenableBuilder( - listenable: trips, - builder: (BuildContext context, Widget? child) { - List items = trips.trips; - if (items.isNotEmpty) { - return TripPage(trip: items[0]); + // check if the user has already seen the onboarding and agreed to the terms of service + return FutureBuilder( + future: getAgreement(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + if (snapshot.hasData) { + Agreement agrement = snapshot.data!; + if (agrement.agreed) { + return FutureBuilder( + future: savedTrips.loadTrips(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + if (snapshot.hasData) { + List trips = snapshot.data!; + if (trips.length > 0) { + return TripPage(trip: trips[0]); + } else { + return NoTripsPage(); + } + } else { + return Center(child: CircularProgressIndicator()); + } + } else { + return Center(child: CircularProgressIndicator()); + } + }, + ); + } else { + return OnboardingPage(); + } + } else { + return OnboardingPage(); + } } else { - return const OnboardingPage(); + return OnboardingPage(); } - } + }, ); - // Future> trips = loadTrips(); - // // test if there are any active trips - // // if there are, return the trip list - // // if there are not, return the onboarding page - // return FutureBuilder( - // future: trips, - // builder: (context, snapshot) { - // if (snapshot.hasData) { - // List availableTrips = snapshot.data!; - // if (availableTrips.isNotEmpty) { - // return TripPage(trip: availableTrips[0]); - // } else { - // return OnboardingPage(); - // } - // } else { - // return CircularProgressIndicator(); - // } - // } - // ); } \ No newline at end of file diff --git a/frontend/lib/utils/load_trips.dart b/frontend/lib/utils/load_trips.dart index dbf7aa7..6506e77 100644 --- a/frontend/lib/utils/load_trips.dart +++ b/frontend/lib/utils/load_trips.dart @@ -8,7 +8,7 @@ class SavedTrips extends ChangeNotifier { List get trips => _trips; - void loadTrips() async { + Future> loadTrips() async { SharedPreferences prefs = await SharedPreferences.getInstance(); List trips = []; @@ -21,6 +21,7 @@ class SavedTrips extends ChangeNotifier { } _trips = trips; notifyListeners(); + return trips; } void addTrip(Trip trip) async { From a676af3a67dcc91989bebc4d3e71349ebbc7130f Mon Sep 17 00:00:00 2001 From: Remy Moll Date: Sun, 23 Mar 2025 20:05:18 +0100 Subject: [PATCH 7/7] automatically save a trip when it is first created --- frontend/lib/modules/current_trip_save_button.dart | 2 -- frontend/lib/utils/fetch_trip.dart | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/lib/modules/current_trip_save_button.dart b/frontend/lib/modules/current_trip_save_button.dart index 64028e7..32d7ba6 100644 --- a/frontend/lib/modules/current_trip_save_button.dart +++ b/frontend/lib/modules/current_trip_save_button.dart @@ -19,8 +19,6 @@ class _saveButtonState extends State { return ElevatedButton( onPressed: () async { savedTrips.addTrip(widget.trip); - // SharedPreferences prefs = await SharedPreferences.getInstance(); - // setState(() => widget.trip.toPrefs(prefs)); rootScaffoldMessengerKey.currentState!.showSnackBar( SnackBar( content: Text('Trip saved'), diff --git a/frontend/lib/utils/fetch_trip.dart b/frontend/lib/utils/fetch_trip.dart index b243f0d..a1beb12 100644 --- a/frontend/lib/utils/fetch_trip.dart +++ b/frontend/lib/utils/fetch_trip.dart @@ -1,5 +1,6 @@ import "dart:convert"; import "dart:developer"; +import "package:anyway/main.dart"; import 'package:dio/dio.dart'; import 'package:anyway/constants.dart'; @@ -82,6 +83,8 @@ fetchTrip( } log(response.data.toString()); + // Also save the trip for the user's convenience + savedTrips.addTrip(trip); } } @@ -113,7 +116,7 @@ Future<(Landmark, String?)> fetchLandmark(String uuid) async { if (response.data["detail"] != null) { throw Exception(response.data["detail"]); } - log(response.data.toString()); + // log(response.data.toString()); Map json = response.data; String? nextUUID = json["next_uuid"]; Landmark landmark = Landmark.fromJson(json);