Skip to content

Commit

Permalink
Refactor toast messages and add rerouting info (#622)
Browse files Browse the repository at this point in the history
* WIP

* WIP

* WIP

* WIP

* use normal tickerproviderstatemixin

* Fix animation interrupted by navigator pop

* Add podfile lock

---------

Co-authored-by: PaulPickhardt <s2137275@msx.tu-dresden.de>
  • Loading branch information
PhilippMatthes and PaulPickhardt authored Jun 26, 2024
1 parent bb42a72 commit f4fe14d
Show file tree
Hide file tree
Showing 20 changed files with 217 additions and 66 deletions.
10 changes: 0 additions & 10 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ PODS:
- Flutter
- flutter_tts (0.0.1):
- Flutter
- fluttertoast (0.0.2):
- Flutter
- Toast
- geolocator_apple (1.2.0):
- Flutter
- GoogleDataTransport (9.4.1):
Expand Down Expand Up @@ -118,7 +115,6 @@ PODS:
- FlutterMacOS
- system_info_plus (0.0.1):
- Flutter
- Toast (4.1.1)
- Turf (2.8.0)
- url_launcher_ios (0.0.1):
- Flutter
Expand All @@ -137,7 +133,6 @@ DEPENDENCIES:
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- flutter_tts (from `.symlinks/plugins/flutter_tts/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- geolocator_apple (from `.symlinks/plugins/geolocator_apple/ios`)
- in_app_review (from `.symlinks/plugins/in_app_review/ios`)
- mapbox_maps_flutter (from `.symlinks/plugins/mapbox_maps_flutter/ios`)
Expand Down Expand Up @@ -165,7 +160,6 @@ SPEC REPOS:
- MTBBarcodeScanner
- nanopb
- PromisesObjC
- Toast
- Turf

EXTERNAL SOURCES:
Expand All @@ -191,8 +185,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_native_splash/ios"
flutter_tts:
:path: ".symlinks/plugins/flutter_tts/ios"
fluttertoast:
:path: ".symlinks/plugins/fluttertoast/ios"
geolocator_apple:
:path: ".symlinks/plugins/geolocator_apple/ios"
in_app_review:
Expand Down Expand Up @@ -233,7 +225,6 @@ SPEC CHECKSUMS:
flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086
flutter_native_splash: edf599c81f74d093a4daf8e17bd7a018854bc778
flutter_tts: 0f492aab6accf87059b72354fcb4ba934304771d
fluttertoast: e9a18c7be5413da53898f660530c56f35edfba9c
geolocator_apple: 6cbaf322953988e009e5ecb481f07efece75c450
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
Expand All @@ -251,7 +242,6 @@ SPEC CHECKSUMS:
share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
system_info_plus: 5393c8da281d899950d751713575fbf91c7709aa
Toast: 1f5ea13423a1e6674c4abdac5be53587ae481c4e
Turf: aa2ede4298009639d10db36aba1a7ebaad072a5e
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
wakelock_plus: 78ec7c5b202cab7761af8e2b2b3d0671be6c4ae1
Expand Down
10 changes: 5 additions & 5 deletions lib/common/layout/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ void showSaveShortcutSheet(context) {
onPressed: () async {
final name = nameController.text;
if (name.trim().isEmpty) {
ToastMessage.showError("Name darf nicht leer sein.");
getIt<Toast>().showError("Name darf nicht leer sein.");
return;
}
await getIt<Shortcuts>().saveNewShortcutRoute(name);
ToastMessage.showSuccess("Route gespeichert!");
getIt<Toast>().showSuccess("Route gespeichert!");

if (!context.mounted) return;
Navigator.pop(context);
Expand Down Expand Up @@ -174,12 +174,12 @@ void showSaveShortcutLocationSheet(context, Waypoint waypoint) {
onPressed: () async {
final name = nameController.text;
if (name.trim().isEmpty) {
ToastMessage.showError("Name darf nicht leer sein.");
getIt<Toast>().showError("Name darf nicht leer sein.");
return;
}
await getIt<Shortcuts>().saveNewShortcutLocation(name, waypoint);
await getIt<Geosearch>().addToSearchHistory(waypoint);
ToastMessage.showSuccess("Ort gespeichert!");
getIt<Toast>().showSuccess("Ort gespeichert!");
Navigator.pop(context);
},
boxConstraints: BoxConstraints(minWidth: MediaQuery.of(context).size.width, minHeight: 36),
Expand Down Expand Up @@ -246,7 +246,7 @@ void showSaveShortcutFromShortcutSheet(context, {required Shortcut shortcut}) {
onPressed: () async {
final name = nameController.text;
if (name.trim().isEmpty) {
ToastMessage.showError("Name darf nicht leer sein.");
getIt<Toast>().showError("Name darf nicht leer sein.");
return;
}
final shortcuts = getIt<Shortcuts>();
Expand Down
2 changes: 1 addition & 1 deletion lib/common/map/image_cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class MapboxTileImageCache {
if (!await imagesDir.exists()) return;
await imagesDir.delete(recursive: true);
log.i("Deleted all images from $dirPath");
if (showToast) ToastMessage.showSuccess("Alle Hintergrundbilder gelöscht");
if (showToast) getIt<Toast>().showSuccess("Alle Hintergrundbilder gelöscht");
}

/// Prunes all images that were not used within 7 days since last fetch of background image.
Expand Down
2 changes: 1 addition & 1 deletion lib/feedback/views/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class FeedbackViewState extends State<FeedbackView> {
await feedback.reset();

if (didSendSomething) {
ToastMessage.showSuccess("Danke für's Testen!");
getIt<Toast>().showSuccess("Danke für's Testen!");
}

if (mounted) {
Expand Down
2 changes: 1 addition & 1 deletion lib/home/services/load.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class LoadStatus with ChangeNotifier {
// Don't switch the backend if the internal version is used. We want to keep the possibility
// to manually set the backend.
if (useFallback) {
ToastMessage.showError(
getIt<Toast>().showError(
"Fallback müsste benutzt werden. Aufgrund der internen Version wird das Fallback jedoch nicht benutzt.");
}
useFallback = false;
Expand Down
4 changes: 2 additions & 2 deletions lib/home/services/shortcuts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ class Shortcuts with ChangeNotifier {
getIt<Tutorial>().complete("priobike.tutorial.select-shortcut");

if (shortcut.runtimeType == ShortcutRoute) {
ToastMessage.showSuccess("Route gespeichert!");
getIt<Toast>().showSuccess("Route gespeichert!");
} else if (shortcut.runtimeType == ShortcutLocation) {
ToastMessage.showSuccess("Ort gespeichert!");
getIt<Toast>().showSuccess("Ort gespeichert!");
} else {
final hint = "Error unknown type ${shortcut.runtimeType} in saveNewShortcutObject.";
log.e(hint);
Expand Down
2 changes: 1 addition & 1 deletion lib/home/views/restart_route_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void showRestartRouteDialog(context, int lastRouteID, List<Waypoint> lastRoute)
// In case there is any error fetching the route.
if (routing.hadErrorDuringFetch) {
// Display error toast message.
ToastMessage.showError("Route konnte nicht geladen werden.");
getIt<Toast>().showError("Route konnte nicht geladen werden.");
// Pop the dialog.
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/home/views/shortcuts/edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ void showEditShortcutSheet(context, int idx) {
onPressed: () async {
final name = nameController.text;
if (name.trim().isEmpty) {
ToastMessage.showError("Name darf nicht leer sein.");
getIt<Toast>().showError("Name darf nicht leer sein.");
return;
}
await getIt<Shortcuts>().updateShortcutName(name, idx);
ToastMessage.showSuccess("Name gespeichert!");
getIt<Toast>().showSuccess("Name gespeichert!");
Navigator.pop(context);
},
boxConstraints: BoxConstraints(minWidth: MediaQuery.of(context).size.width, minHeight: 36),
Expand Down
4 changes: 2 additions & 2 deletions lib/home/views/shortcuts/import.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ImportShortcutDialogState<E> extends State<ImportShortcutDialog<E>> {
Trkseg seg = trk.trksegs[0];
points = seg.trkpts;
if (points.isEmpty) {
ToastMessage.showError('Die GPX Datei konnte nicht geladen werden.');
getIt<Toast>().showError('Die GPX Datei konnte nicht geladen werden.');
return [];
}
// check if all waypoints are within Hamburg
Expand All @@ -50,7 +50,7 @@ class ImportShortcutDialogState<E> extends State<ImportShortcutDialog<E>> {
initWaypoints.add(Waypoint(points[i].lat!, points[i].lon!));
}
if (!routing.inCityBoundary(initWaypoints)) {
ToastMessage.showError('Ein oder mehrere Punkte der GPX Datei liegen nicht in Hamburg.');
getIt<Toast>().showError('Ein oder mehrere Punkte der GPX Datei liegen nicht in Hamburg.');
return [];
}
return points;
Expand Down
2 changes: 1 addition & 1 deletion lib/home/views/shortcuts/import_gpx.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ImportGpxViewState extends State<ImportGpxView> {
Future<void> convertGpxToWaypoints(List<Wpt> points) async {
if (points.isEmpty) return;
List<Waypoint> waypoints = await gpxConversionNotifier.reduceWpts(points, routing);
ToastMessage.showSuccess("Die GPX Strecke wurde erfolgreich konvertiert.");
getIt<Toast>().showSuccess("Die GPX Strecke wurde erfolgreich konvertiert.");
if (mounted) {
showSaveShortcutFromShortcutSheet(
context,
Expand Down
3 changes: 2 additions & 1 deletion lib/home/views/shortcuts/qr_code_show.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:priobike/home/models/shortcut_location.dart';
import 'package:priobike/home/models/shortcut_route.dart';
import 'package:priobike/home/services/link_shortener.dart';
import 'package:priobike/logging/toast.dart';
import 'package:priobike/main.dart';
import 'package:qr_flutter/qr_flutter.dart';

class ShowQRCodeView extends StatefulWidget {
Expand Down Expand Up @@ -59,7 +60,7 @@ class ShowQRCodeViewState extends State<ShowQRCodeView> {
final longLink = shortcutWithoutName.getLongLink();
final newShortLink = await LinkShortener.createShortLink(longLink);
if (newShortLink == null) {
ToastMessage.showError("Fehler beim Erstellen des QR Codes");
getIt<Toast>().showError("Fehler beim Erstellen des QR Codes");
if (mounted) Navigator.pop(context);
return;
}
Expand Down
Loading

0 comments on commit f4fe14d

Please sign in to comment.