Cleanup
This commit is contained in:
1 parent
7a681ddcc6
commit
0ac8ab8cf5
17 files changed
+34
-41
No files matched your search
@@ -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());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ class _MessagesPageState extends State<MessagesPage> {
|
||||
|
||||
setState(() {}),
|
||||
|
||||
Navigator.of(context).pop()
|
||||
Navigator.of(MyApp.appNavigatorKey.currentContext!).pop()
|
||||
}),
|
||||
)
|
||||
])
|
||||
|
||||
@@ -117,7 +117,7 @@ class _TourDetailsPageState extends State<TourDetailsPage> {
|
||||
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')
|
||||
}
|
||||
}),
|
||||
],
|
||||
|
||||
+4
-5
@@ -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<void> 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<NavigatorState>();
|
||||
|
||||
@@ -206,7 +205,7 @@ class _MainState extends State<Main> 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<Main> 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;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@ late Timer _checkForNewJobsTimer;
|
||||
late Map<int, DateTime> _firstDelayTimeMap;
|
||||
late Map<int, bool> _infoExpandedMap;
|
||||
|
||||
Future<void> showAcceptJobsPopup(BuildContext context, SharedMapReference mapReference, Function() onFinished) async {
|
||||
Future<void> showAcceptJobsPopup(SharedMapReference mapReference, Function() onFinished) async {
|
||||
_initTimer = true;
|
||||
_firstDelayTimeMap = {};
|
||||
_infoExpandedMap = {};
|
||||
|
||||
await showDialog<void>(
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -36,7 +36,7 @@ showMapPopup(BuildContext context, JobTour currentTour, List<JobTour> 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(
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
})
|
||||
],
|
||||
|
||||
@@ -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.")}
|
||||
})
|
||||
],
|
||||
),
|
||||
|
||||
@@ -132,7 +132,7 @@ Future<void> 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')}
|
||||
})
|
||||
],
|
||||
),
|
||||
|
||||
@@ -64,7 +64,7 @@ bool _checkInput(BuildContext context, String input) {
|
||||
}
|
||||
|
||||
if (message.isNotEmpty) {
|
||||
showAlertDialog(context, 'Fehler', message);
|
||||
showAlertDialog('Fehler', message);
|
||||
}
|
||||
|
||||
return message.isEmpty;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+6
-6
@@ -395,9 +395,9 @@ Future<void> showQuestionDialog(BuildContext context, String title, String messa
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> showAlertDialog(BuildContext context, String title, String message) async {
|
||||
Future<void> 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<bool> 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;
|
||||
|
||||
Reference in new issue
Block a user