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