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