Erweiterungen
This commit is contained in:
1 parent
6981cfbf8a
commit
7a681ddcc6
7 files changed
+45
-5
No files matched your search
@@ -329,7 +329,7 @@ class _MainPageState extends State<MainPage> {
|
|||||||
showLogoutAlertDialog(BuildContext context) async {
|
showLogoutAlertDialog(BuildContext context) async {
|
||||||
Widget yesButton = TextButton(
|
Widget yesButton = TextButton(
|
||||||
child: const Text("Ja"),
|
child: const Text("Ja"),
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
showMessageDialog(context, "Information", "Sie werden abgemeldet.\nBitte warten...");
|
showMessageDialog(context, "Information", "Sie werden abgemeldet.\nBitte warten...");
|
||||||
@@ -338,7 +338,10 @@ class _MainPageState extends State<MainPage> {
|
|||||||
|
|
||||||
_loggedOut = true;
|
_loggedOut = true;
|
||||||
|
|
||||||
|
await MessageService().publish<DisconnectClientMessage>(Constants.messageTopicDisconnectClient, arguments: DisconnectClientMessage());
|
||||||
|
|
||||||
Future.delayed(const Duration(seconds: 5), () async {
|
Future.delayed(const Duration(seconds: 5), () async {
|
||||||
|
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ void _traceUncaughtExceptions(Object error, StackTrace stackTrace) {
|
|||||||
class MyApp extends StatefulWidget {
|
class MyApp extends StatefulWidget {
|
||||||
MyApp({super.key});
|
MyApp({super.key});
|
||||||
|
|
||||||
|
static final appNavigatorKey = GlobalKey<NavigatorState>();
|
||||||
|
|
||||||
static late Isar isarInstance;
|
static late Isar isarInstance;
|
||||||
|
|
||||||
static Position? currentPosition;
|
static Position? currentPosition;
|
||||||
@@ -93,6 +95,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
|
navigatorKey: MyApp.appNavigatorKey,
|
||||||
title: 'Stadtbote',
|
title: 'Stadtbote',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
primarySwatch: Colors.blue,
|
primarySwatch: Colors.blue,
|
||||||
|
|||||||
@@ -21,10 +21,12 @@ import '../tools/messages/publish_payload_message.dart';
|
|||||||
late bool _initTimer;
|
late bool _initTimer;
|
||||||
late Timer _checkForNewJobsTimer;
|
late Timer _checkForNewJobsTimer;
|
||||||
late Map<int, DateTime> _firstDelayTimeMap;
|
late Map<int, DateTime> _firstDelayTimeMap;
|
||||||
|
late Map<int, bool> _infoExpandedMap;
|
||||||
|
|
||||||
Future<void> showAcceptJobsPopup(BuildContext context, SharedMapReference mapReference, Function() onFinished) async {
|
Future<void> showAcceptJobsPopup(BuildContext context, SharedMapReference mapReference, Function() onFinished) async {
|
||||||
_initTimer = true;
|
_initTimer = true;
|
||||||
_firstDelayTimeMap = {};
|
_firstDelayTimeMap = {};
|
||||||
|
_infoExpandedMap = {};
|
||||||
|
|
||||||
await showDialog<void>(
|
await showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -104,7 +106,7 @@ Future<List<Widget>> _fetchJobWidgets(StateSetter dialogState, Function() onFini
|
|||||||
for (var jobEntry in entries) {
|
for (var jobEntry in entries) {
|
||||||
var job = jobEntry.value;
|
var job = jobEntry.value;
|
||||||
|
|
||||||
int enableDelay = 3; //job.delayOrderTime;
|
int enableDelay = job.delayOrderTime;
|
||||||
if (!_firstDelayTimeMap.containsKey(job.id)) {
|
if (!_firstDelayTimeMap.containsKey(job.id)) {
|
||||||
_firstDelayTimeMap[job.id] = DateTime.now();
|
_firstDelayTimeMap[job.id] = DateTime.now();
|
||||||
} else {
|
} else {
|
||||||
@@ -113,6 +115,17 @@ Future<List<Widget>> _fetchJobWidgets(StateSetter dialogState, Function() onFini
|
|||||||
enableDelay = min(0, diffInSeconds);
|
enableDelay = min(0, diffInSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExpandableController controller = ExpandableController();
|
||||||
|
controller.expanded = _infoExpandedMap[job.id] != null ? _infoExpandedMap[job.id]! : false;
|
||||||
|
|
||||||
|
controller.addListener(() {
|
||||||
|
if (controller.expanded) {
|
||||||
|
_infoExpandedMap[job.id] = true;
|
||||||
|
} else {
|
||||||
|
_infoExpandedMap[job.id] = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
widgets.add(StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
widgets.add(StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||||
return ExpandableNotifier(
|
return ExpandableNotifier(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
@@ -170,6 +183,7 @@ Future<List<Widget>> _fetchJobWidgets(StateSetter dialogState, Function() onFini
|
|||||||
scrollOnExpand: true,
|
scrollOnExpand: true,
|
||||||
scrollOnCollapse: false,
|
scrollOnCollapse: false,
|
||||||
child: ExpandablePanel(
|
child: ExpandablePanel(
|
||||||
|
controller: controller,
|
||||||
theme: const ExpandableThemeData(
|
theme: const ExpandableThemeData(
|
||||||
headerAlignment: ExpandablePanelHeaderAlignment.center,
|
headerAlignment: ExpandablePanelHeaderAlignment.center,
|
||||||
tapBodyToCollapse: true,
|
tapBodyToCollapse: true,
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ class BootstrapResponse
|
|||||||
@JsonKey(name: "from_server")
|
@JsonKey(name: "from_server")
|
||||||
late String fromServer;
|
late String fromServer;
|
||||||
|
|
||||||
|
late int status;
|
||||||
|
|
||||||
|
late String message;
|
||||||
|
|
||||||
BootstrapResponse();
|
BootstrapResponse();
|
||||||
|
|
||||||
factory BootstrapResponse.fromJson(Map<String, dynamic> json) => _$BootstrapResponseFromJson(json);
|
factory BootstrapResponse.fromJson(Map<String, dynamic> json) => _$BootstrapResponseFromJson(json);
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ BootstrapResponse _$BootstrapResponseFromJson(Map<String, dynamic> json) =>
|
|||||||
..broker = json['broker'] as String
|
..broker = json['broker'] as String
|
||||||
..id = json['id'] as String
|
..id = json['id'] as String
|
||||||
..toServer = json['to_server'] as String
|
..toServer = json['to_server'] as String
|
||||||
..fromServer = json['from_server'] as String;
|
..fromServer = json['from_server'] as String
|
||||||
|
..status = json['status'] as int
|
||||||
|
..message = json['message'] as String;
|
||||||
|
|
||||||
Map<String, dynamic> _$BootstrapResponseToJson(BootstrapResponse instance) =>
|
Map<String, dynamic> _$BootstrapResponseToJson(BootstrapResponse instance) =>
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
@@ -19,4 +21,6 @@ Map<String, dynamic> _$BootstrapResponseToJson(BootstrapResponse instance) =>
|
|||||||
'id': instance.id,
|
'id': instance.id,
|
||||||
'to_server': instance.toServer,
|
'to_server': instance.toServer,
|
||||||
'from_server': instance.fromServer,
|
'from_server': instance.fromServer,
|
||||||
|
'status': instance.status,
|
||||||
|
'message': instance.message,
|
||||||
};
|
};
|
||||||
@@ -4,7 +4,6 @@ import 'dart:math';
|
|||||||
|
|
||||||
import 'package:archive/archive.dart';
|
import 'package:archive/archive.dart';
|
||||||
import 'package:device_info_plus/device_info_plus.dart';
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:isar/isar.dart';
|
import 'package:isar/isar.dart';
|
||||||
import 'package:mqtt_client/mqtt_client.dart';
|
import 'package:mqtt_client/mqtt_client.dart';
|
||||||
@@ -151,8 +150,12 @@ class MqttCore {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
Util.logInfo("send failed!");
|
||||||
|
|
||||||
if (enqueueOnError) {
|
if (enqueueOnError) {
|
||||||
_enqueueMessage(topic, text);
|
_enqueueMessage(topic, text);
|
||||||
|
|
||||||
|
Util.logInfo("message enqueued");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,6 +446,14 @@ class MqttCore {
|
|||||||
|
|
||||||
var bootstrapResponsePayload = BootstrapResponse.fromJson(jsonDecode(responseText));
|
var bootstrapResponsePayload = BootstrapResponse.fromJson(jsonDecode(responseText));
|
||||||
|
|
||||||
|
var status = bootstrapResponsePayload.status;
|
||||||
|
var message = bootstrapResponsePayload.message;
|
||||||
|
|
||||||
|
if (status > 0) {
|
||||||
|
showAlertDialog(MyApp.appNavigatorKey.currentContext!, status == 1 ? "Information" : "Fehler", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status < 2) {
|
||||||
var brokerUriAndPortArray = bootstrapResponsePayload.broker.replaceFirst("mqtt://", "").split(":");
|
var brokerUriAndPortArray = bootstrapResponsePayload.broker.replaceFirst("mqtt://", "").split(":");
|
||||||
_brokerUri = brokerUriAndPortArray[0];
|
_brokerUri = brokerUriAndPortArray[0];
|
||||||
_brokerPort = int.parse(brokerUriAndPortArray[1]);
|
_brokerPort = int.parse(brokerUriAndPortArray[1]);
|
||||||
@@ -451,6 +462,7 @@ class MqttCore {
|
|||||||
_toServerTopic = bootstrapResponsePayload.toServer;
|
_toServerTopic = bootstrapResponsePayload.toServer;
|
||||||
|
|
||||||
_connectToBroker();
|
_connectToBroker();
|
||||||
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
Util.logException("bootstrap failed: {$ex}");
|
Util.logException("bootstrap failed: {$ex}");
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 320.0.0+320
|
version: 321.0.0+321
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.19.6 <3.0.0'
|
sdk: '>=2.19.6 <3.0.0'
|
||||||
|
|||||||
Reference in new issue
Block a user