Erweiterungen
This commit is contained in:
1 parent
70fb6dd5ef
commit
70a8c04516
3 files changed
+40
-11
No files matched your search
+22
-8
@@ -122,7 +122,7 @@ class Main extends StatefulWidget {
|
|||||||
State<Main> createState() => _MainState();
|
State<Main> createState() => _MainState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MainState extends State<Main> {
|
class _MainState extends State<Main> with SingleTickerProviderStateMixin {
|
||||||
late ContentViewWidget _currentContent;
|
late ContentViewWidget _currentContent;
|
||||||
late WidgetStack<ContentViewWidget> contentStack = WidgetStack();
|
late WidgetStack<ContentViewWidget> contentStack = WidgetStack();
|
||||||
|
|
||||||
@@ -141,10 +141,17 @@ class _MainState extends State<Main> {
|
|||||||
|
|
||||||
final ValueNotifier<bool> _connectionLostValueNotifier = ValueNotifier<bool>(true);
|
final ValueNotifier<bool> _connectionLostValueNotifier = ValueNotifier<bool>(true);
|
||||||
|
|
||||||
|
late AnimationController _animationController;
|
||||||
|
late Animation<double> _animation;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
|
_animationController = AnimationController(vsync: this, duration: const Duration(milliseconds: 1000));
|
||||||
|
_animationController.repeat(reverse: true);
|
||||||
|
_animation = Tween<double>(begin: 0.5, end: 1.0).animate(_animationController);
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
_initMessages();
|
_initMessages();
|
||||||
|
|
||||||
@@ -269,26 +276,33 @@ class _MainState extends State<Main> {
|
|||||||
builder: (context, value, child) {
|
builder: (context, value, child) {
|
||||||
return Visibility(
|
return Visibility(
|
||||||
visible: value,
|
visible: value,
|
||||||
child: Container(
|
child: Column(
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 1),
|
||||||
|
Container(
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
height: 30,
|
height: 40,
|
||||||
color: Colors.red,
|
color: Constants.colorPrimary,
|
||||||
child: const Center(
|
child: Center(
|
||||||
child: Text(
|
child: FadeTransition(
|
||||||
|
opacity: _animation,
|
||||||
|
child: const Text(
|
||||||
"*** OFFLINE ***",
|
"*** OFFLINE ***",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 15.0,
|
fontSize: 25.0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
)),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Expanded(child: _currentContent),
|
Expanded(child: _currentContent),
|
||||||
],
|
],
|
||||||
), // This trailing comma makes auto-formatting nicer for build methods.
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:kumi_popup_window/kumi_popup_window.dart';
|
import 'package:kumi_popup_window/kumi_popup_window.dart';
|
||||||
|
import 'package:stadtbote/main.dart';
|
||||||
import 'package:stadtbote/model/status.dart';
|
import 'package:stadtbote/model/status.dart';
|
||||||
|
import 'package:stadtbote/tools/mqtt_core.dart';
|
||||||
import 'package:stadtbote/tools/util.dart';
|
import 'package:stadtbote/tools/util.dart';
|
||||||
|
|
||||||
void showInfosPopup(BuildContext context, Status? status) {
|
void showInfosPopup(BuildContext context, Status? status) {
|
||||||
var text = "Versionsnummer: a203\n";
|
var text = "Versionsnummer: a203\n";
|
||||||
text += "Verbindungsstatus: Unbekannt\n";
|
text += "Verbindungsstatus: ${MqttCore.instance.connectionState == ConnectionStateEnum.connected ? "Verbunden" : "NICHT verbunden"}\n";
|
||||||
text += "GPS-Status: Unbekannt\n";
|
text += "GPS-Status: ${MyApp.currentPosition != null ? "Position gefunden" : "Position NICHT gefunden"}\n";
|
||||||
|
text += "Version GPS: ${MyApp.currentPosition != null ? MyApp.currentPosition!.timestamp.toString() : "Unbekannt"}\n";
|
||||||
text += "\n";
|
text += "\n";
|
||||||
text += "User Status:\n";
|
text += "User Status:\n";
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
@@ -16,7 +19,6 @@ void showInfosPopup(BuildContext context, Status? status) {
|
|||||||
text += "vht_id: ${status.vhtId}\n";
|
text += "vht_id: ${status.vhtId}\n";
|
||||||
text += "server_version: ${status.serverVersion}\n";
|
text += "server_version: ${status.serverVersion}\n";
|
||||||
text += "server_instance: ${status.serverInstance}\n";
|
text += "server_instance: ${status.serverInstance}\n";
|
||||||
text += "Version GPS: Unbekannt";
|
|
||||||
} else {
|
} else {
|
||||||
text += "Keine Informationen gefunden";
|
text += "Keine Informationen gefunden";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,9 +30,16 @@ import '../model/status.dart';
|
|||||||
import 'constants.dart';
|
import 'constants.dart';
|
||||||
import 'util.dart';
|
import 'util.dart';
|
||||||
|
|
||||||
|
enum ConnectionStateEnum {
|
||||||
|
not_connected,
|
||||||
|
connected
|
||||||
|
}
|
||||||
|
|
||||||
class MqttCore {
|
class MqttCore {
|
||||||
static late MqttCore instance;
|
static late MqttCore instance;
|
||||||
|
|
||||||
|
late ConnectionStateEnum connectionState = ConnectionStateEnum.not_connected;
|
||||||
|
|
||||||
late String _brokerUri;
|
late String _brokerUri;
|
||||||
late int _brokerPort;
|
late int _brokerPort;
|
||||||
late String _fromServerTopic;
|
late String _fromServerTopic;
|
||||||
@@ -191,6 +198,8 @@ class MqttCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _sessionMessageReceived(payloadData) async {
|
void _sessionMessageReceived(payloadData) async {
|
||||||
|
connectionState = ConnectionStateEnum.connected;
|
||||||
|
|
||||||
await _sendSyncMessage();
|
await _sendSyncMessage();
|
||||||
|
|
||||||
var statusMessage = Status.fromJson(payloadData['status']);
|
var statusMessage = Status.fromJson(payloadData['status']);
|
||||||
@@ -265,6 +274,8 @@ class MqttCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _startReconnectTimer() {
|
void _startReconnectTimer() {
|
||||||
|
connectionState = ConnectionStateEnum.not_connected;
|
||||||
|
|
||||||
Util.logInfo("_startReconnectTimer called");
|
Util.logInfo("_startReconnectTimer called");
|
||||||
|
|
||||||
_reconnectDelay = min(_reconnectDelay + 1, 30);
|
_reconnectDelay = min(_reconnectDelay + 1, 30);
|
||||||
@@ -275,6 +286,8 @@ class MqttCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _clientDisconnected() {
|
void _clientDisconnected() {
|
||||||
|
connectionState = ConnectionStateEnum.not_connected;
|
||||||
|
|
||||||
Util.logInfo("_clientDisconnected called");
|
Util.logInfo("_clientDisconnected called");
|
||||||
|
|
||||||
BroadcastReceiver().publish<ConnectionStatus>(Constants.messageTopicConnectionStatusChanged, arguments: ConnectionStatus(status: ConnectionStatusEnum.notConnected));
|
BroadcastReceiver().publish<ConnectionStatus>(Constants.messageTopicConnectionStatusChanged, arguments: ConnectionStatus(status: ConnectionStatusEnum.notConnected));
|
||||||
|
|||||||
Reference in new issue
Block a user