diff --git a/integration_test/job_test.dart b/integration_test/job_test.dart index 80e3e81..a9c92c0 100644 --- a/integration_test/job_test.dart +++ b/integration_test/job_test.dart @@ -5,7 +5,7 @@ void main() { testWidgets('tap on the floating action button, verify counter', (tester) async { // Load app widget. - await tester.pumpWidget(MyApp()); + await tester.pumpWidget(const MyApp()); // Verify the counter starts at 0. expect(find.text('HH1091'), findsOneWidget); diff --git a/lib/content_views/main_page.dart b/lib/content_views/main_page.dart index 158cd0a..b2fdc0a 100644 --- a/lib/content_views/main_page.dart +++ b/lib/content_views/main_page.dart @@ -77,7 +77,7 @@ class MainPage extends ContentViewWidget { rightButtonVisible: true, rightButtonImage: Util.fetchFutureIcon(const Icon(Icons.info_outline, size: 20.0, color: Colors.white)), rightButtonOnPressed: () async { - showInfosPopup(context, await MyApp.isarInstance.sessionStatus.where().findFirst()); + showInfosPopup(await MyApp.isarInstance.sessionStatus.where().findFirst()); }); } } diff --git a/lib/content_views/messages_page.dart b/lib/content_views/messages_page.dart index d427518..6ae0a12 100644 --- a/lib/content_views/messages_page.dart +++ b/lib/content_views/messages_page.dart @@ -183,7 +183,7 @@ class _MessagesPageState extends State { setState(() {}), - Navigator.of(context).pop() + Navigator.of(MyApp.appNavigatorKey.currentContext!).pop() }), ) ]) diff --git a/lib/content_views/tour_details_page.dart b/lib/content_views/tour_details_page.dart index 6625300..d5f7f97 100644 --- a/lib/content_views/tour_details_page.dart +++ b/lib/content_views/tour_details_page.dart @@ -117,7 +117,7 @@ class _TourDetailsPageState extends State { if (widget.tour.pos != null) { showMapPopup(context, widget.tour, widget.job.tours) } else { - showAlertDialog(context, 'Information', 'Es liegt keine Position für diese Station vor') + showAlertDialog('Information', 'Es liegt keine Position für diese Station vor') } }), ], diff --git a/lib/main.dart b/lib/main.dart index 01e5142..4551238 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -20,7 +20,6 @@ import 'package:stadtbote/tools/connection_status.dart'; import 'package:stadtbote/tools/message_service.dart'; import 'package:stadtbote/tools/messages/job_deleted_message.dart'; import 'package:stadtbote/tools/messages/job_received_message.dart'; -import 'package:stadtbote/tools/messages/refresh_badges_message.dart'; import 'package:stadtbote/tools/mqtt_core.dart'; import 'content_views/main_page.dart'; @@ -49,7 +48,7 @@ Future main() async { await _clearLog(); - runApp(MyApp()); + runApp(const MyApp()); }, (error, stackTrace) { _traceUncaughtExceptions(error, stackTrace); }); @@ -69,7 +68,7 @@ void _traceUncaughtExceptions(Object error, StackTrace stackTrace) { } class MyApp extends StatefulWidget { - MyApp({super.key}); + const MyApp({super.key}); static final appNavigatorKey = GlobalKey(); @@ -206,7 +205,7 @@ class _MainState extends State
with SingleTickerProviderStateMixin { _currentContent = MainPage(); - var headerInfo = await _currentContent.getHeaderInfo(context); + var headerInfo = await _currentContent.getHeaderInfo(MyApp.appNavigatorKey.currentContext!); _currentTitleWidget = headerInfo.titleWidget; _leftButtonVisible = false; @@ -482,7 +481,7 @@ class _MainState extends State
with SingleTickerProviderStateMixin { _checkForNewState0JobsJobsTimer ??= Timer.periodic(const Duration(seconds: 5), (Timer t) async { if (await _jobMap!.length() > 0 && !_dialogOpened) { _dialogOpened = true; - await showAcceptJobsPopup(context, _jobMap!.sharedReference(), () async { + await showAcceptJobsPopup(_jobMap!.sharedReference(), () async { _dialogOpened = false; }); } diff --git a/lib/popups/accept_jobs_popup.dart b/lib/popups/accept_jobs_popup.dart index fc54e84..d9fc841 100644 --- a/lib/popups/accept_jobs_popup.dart +++ b/lib/popups/accept_jobs_popup.dart @@ -23,13 +23,13 @@ late Timer _checkForNewJobsTimer; late Map _firstDelayTimeMap; late Map _infoExpandedMap; -Future showAcceptJobsPopup(BuildContext context, SharedMapReference mapReference, Function() onFinished) async { +Future showAcceptJobsPopup(SharedMapReference mapReference, Function() onFinished) async { _initTimer = true; _firstDelayTimeMap = {}; _infoExpandedMap = {}; await showDialog( - context: context, + context: MyApp.appNavigatorKey.currentContext!, builder: (BuildContext context) { return WillPopScope( onWillPop: () async { @@ -85,7 +85,7 @@ void _startTimer(BuildContext context, SharedMapReference mapReference, StateSet } else { _stopTimer(); - Navigator.of(context).pop(); + Navigator.of(MyApp.appNavigatorKey.currentContext!).pop(); onFinished(); } diff --git a/lib/popups/infos_popup.dart b/lib/popups/infos_popup.dart index 8b2ea77..9485ecb 100644 --- a/lib/popups/infos_popup.dart +++ b/lib/popups/infos_popup.dart @@ -8,7 +8,7 @@ import 'package:stadtbote/tools/messages/current_connection_status_message.dart' import 'package:stadtbote/tools/messages/request_connection_status_message.dart'; import 'package:stadtbote/tools/util.dart'; -void showInfosPopup(BuildContext context, SessionStatus? status) async { +void showInfosPopup(SessionStatus? status) async { final int version = await Util.getAppVersion(); late String connectedString = "Bitte warten..."; @@ -24,7 +24,7 @@ void showInfosPopup(BuildContext context, SessionStatus? status) async { await showDialog( // ignore: use_build_context_synchronously - context: context, + context: MyApp.appNavigatorKey.currentContext!, builder: (BuildContext context) { // ignore: deprecated_member_use return WillPopScope( diff --git a/lib/popups/map_popup.dart b/lib/popups/map_popup.dart index b93bfae..d10c737 100644 --- a/lib/popups/map_popup.dart +++ b/lib/popups/map_popup.dart @@ -36,7 +36,7 @@ showMapPopup(BuildContext context, JobTour currentTour, List tourList) currentTour = tour; streamController[tour.sort]!.sink.add(true); } else { - showAlertDialog(context, 'Information', 'Es liegt keine Position für diese Station vor'); + showAlertDialog('Information', 'Es liegt keine Position für diese Station vor'); } }, child: SizedBox( diff --git a/lib/popups/tasks_popups/pickup_delivery_status_popup.dart b/lib/popups/tasks_popups/pickup_delivery_status_popup.dart index 9f5d80b..a164930 100644 --- a/lib/popups/tasks_popups/pickup_delivery_status_popup.dart +++ b/lib/popups/tasks_popups/pickup_delivery_status_popup.dart @@ -69,7 +69,7 @@ showPickupDeliveryStatusPopup(BuildContext context, TaskInfo taskInfo, Function( onFinished(selectedTourEntry, remController.text) } else { - showAlertDialog(context, "Fehler", "Bitte geben Sie eine Bemerkung ein") + showAlertDialog("Fehler", "Bitte geben Sie eine Bemerkung ein") } } else { Navigator.of(context).pop(), diff --git a/lib/popups/tasks_popups/receipt_giver_popup.dart b/lib/popups/tasks_popups/receipt_giver_popup.dart index e4bcc00..10b347c 100644 --- a/lib/popups/tasks_popups/receipt_giver_popup.dart +++ b/lib/popups/tasks_popups/receipt_giver_popup.dart @@ -51,7 +51,7 @@ showReceiptGiverPopup(BuildContext context, TaskInfo taskInfo, Function(String) onFinished(textEditingController.text); } else { - showAlertDialog(context, "Fehler", "Sie müssen einen Text eingeben"); + showAlertDialog("Fehler", "Sie müssen einen Text eingeben"); } }) ], diff --git a/lib/popups/tasks_popups/signature_popup.dart b/lib/popups/tasks_popups/signature_popup.dart index 973e8bd..be1237b 100644 --- a/lib/popups/tasks_popups/signature_popup.dart +++ b/lib/popups/tasks_popups/signature_popup.dart @@ -81,7 +81,7 @@ showSignaturePopup(BuildContext context, TaskInfo taskInfo, Function(String?) on if (controller.points.length > 50) {Navigator.of(context).pop(), onFinished(convertPoints(controller.points))} else - {showAlertDialog(context, "Fehler", "Die Unterschrift ist zu kurz.")} + {showAlertDialog("Fehler", "Die Unterschrift ist zu kurz.")} }) ], ), diff --git a/lib/popups/tasks_popups/take_photos_popup.dart b/lib/popups/tasks_popups/take_photos_popup.dart index 0ae63ee..edc7a5e 100644 --- a/lib/popups/tasks_popups/take_photos_popup.dart +++ b/lib/popups/tasks_popups/take_photos_popup.dart @@ -132,7 +132,7 @@ Future showTakePhotosPopup(BuildContext context, TaskInfo taskInfo, Functi if (imageDataList.length >= taskInfo.task.min! && imageDataList.length <= taskInfo.task.max!) {Navigator.of(context).pop(), onFinished(imageDataList)} else - {showAlertDialog(context, 'Fehler', 'Es müssen mindestens ${taskInfo.task.min} Foto(s) aufgenommen werden')} + {showAlertDialog('Fehler', 'Es müssen mindestens ${taskInfo.task.min} Foto(s) aufgenommen werden')} }) ], ), diff --git a/lib/popups/tasks_popups/zip_popup.dart b/lib/popups/tasks_popups/zip_popup.dart index 8f57439..0d30164 100644 --- a/lib/popups/tasks_popups/zip_popup.dart +++ b/lib/popups/tasks_popups/zip_popup.dart @@ -64,7 +64,7 @@ bool _checkInput(BuildContext context, String input) { } if (message.isNotEmpty) { - showAlertDialog(context, 'Fehler', message); + showAlertDialog('Fehler', message); } return message.isEmpty; diff --git a/lib/tools/mqtt_core.dart b/lib/tools/mqtt_core.dart index 276c335..74f2ae2 100644 --- a/lib/tools/mqtt_core.dart +++ b/lib/tools/mqtt_core.dart @@ -450,7 +450,7 @@ class MqttCore { var message = bootstrapResponsePayload.message; if (status > 0) { - showAlertDialog(MyApp.appNavigatorKey.currentContext!, status == 1 ? "Information" : "Fehler", message); + showAlertDialog(status == 1 ? "Information" : "Fehler", message); } if (status < 2) { diff --git a/lib/tools/util.dart b/lib/tools/util.dart index 640eee7..10f300d 100644 --- a/lib/tools/util.dart +++ b/lib/tools/util.dart @@ -395,9 +395,9 @@ Future showQuestionDialog(BuildContext context, String title, String messa ); } -Future showAlertDialog(BuildContext context, String title, String message) async { +Future showAlertDialog(String title, String message) async { await showDialog( - context: context, + context: MyApp.appNavigatorKey.currentContext!, builder: (context) { return AlertDialog( title: Text(title), @@ -441,7 +441,7 @@ class DecimalTextInputFormatter extends TextInputFormatter { if (text != "") { RegExp regExp; if (decimalPlaces > 0) { - regExp = RegExp(r'[0-9]+[,]{0,1}[0-9]{0,' + decimalPlaces.toString() + '}'); + regExp = RegExp(r'[0-9]+[,]{0,1}[0-9]{0,${' + decimalPlaces.toString() + '}'); } else { regExp = RegExp(r'[0-9]{0,' + maxLength.toString() +'}'); } @@ -460,12 +460,12 @@ Future taskDialogSecurityException(BuildContext context) async { bool close = false; await showQuestionDialog(context, "Achtung", "Wenn Sie den Dialog jetzt schließen gehen erfasste Daten verloren und die Aufgabe oder Station bleibt unerledigt.", [ - TextButton(onPressed: () => {Navigator.of(context).pop(), close = true}, child: const Text('Schließen')), - TextButton(onPressed: () => {Navigator.of(context).pop(), close = false}, child: const Text('Zurück')), + TextButton(onPressed: () => {Navigator.of(MyApp.appNavigatorKey.currentContext!).pop(), close = true}, child: const Text('Schließen')), + TextButton(onPressed: () => {Navigator.of(MyApp.appNavigatorKey.currentContext!).pop(), close = false}, child: const Text('Zurück')), ]); if (close) { - Navigator.of(context).pop(); + Navigator.of(MyApp.appNavigatorKey.currentContext!).pop(); } return close; diff --git a/pubspec.lock b/pubspec.lock index 040a39b..93d7bbf 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -34,13 +34,13 @@ packages: source: hosted version: "1.2.2" archive: - dependency: transitive + dependency: "direct main" description: name: archive - sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d" + sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d url: "https://pub.dev" source: hosted - version: "3.4.10" + version: "3.6.1" args: dependency: transitive description: @@ -721,13 +721,13 @@ packages: source: hosted version: "4.0.2" image: - dependency: transitive + dependency: "direct main" description: name: image - sha256: "4c68bfd5ae83e700b5204c1e74451e7bf3cf750e6843c6e158289cf56bda018e" + sha256: "2237616a36c0d69aef7549ab439b833fb7f9fb9fc861af2cc9ac3eedddd69ca8" url: "https://pub.dev" source: hosted - version: "4.1.7" + version: "4.2.0" image_picker: dependency: "direct main" description: @@ -1152,14 +1152,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" - pointycastle: - dependency: transitive - description: - name: pointycastle - sha256: "70fe966348fe08c34bf929582f1d8247d9d9408130723206472b4687227e4333" - url: "https://pub.dev" - source: hosted - version: "3.8.0" polylabel: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 1dddd14..443eb68 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -73,6 +73,8 @@ dependencies: is_lock_screen: ^2.0.0 flutter_local_notifications: ^17.1.2 shared_map: ^1.1.9 + image: ^4.2.0 + archive: ^3.6.1 dev_dependencies: flutter_test: