Refactoring
This commit is contained in:
1 parent
91d50fe58c
commit
e0bd8792d1
2 files changed
+53
-37
No files matched your search
+50
-37
@@ -1,9 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stadtbote/main.dart';
|
||||
import 'package:stadtbote/model/session_status.dart';
|
||||
import 'package:stadtbote/tools/connection_status.dart';
|
||||
import 'package:stadtbote/tools/constants.dart';
|
||||
import 'package:stadtbote/tools/message_service.dart';
|
||||
import 'package:stadtbote/tools/mqtt_core.dart';
|
||||
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 {
|
||||
@@ -12,7 +14,8 @@ void showInfosPopup(BuildContext context, SessionStatus? status) async {
|
||||
late String connectedString = "Bitte warten...";
|
||||
|
||||
Future.delayed(const Duration(seconds: 2), () async {
|
||||
MessageService().publish<RequestConnectionStatusMessage>(Constants.messageTopicRequestConnectionStatus, arguments: RequestConnectionStatusMessage());
|
||||
MessageService()
|
||||
.publish<RequestConnectionStatusMessage>(Constants.messageTopicRequestConnectionStatus, arguments: RequestConnectionStatusMessage());
|
||||
});
|
||||
|
||||
void unsubscribeMessages() {
|
||||
@@ -52,41 +55,51 @@ void showInfosPopup(BuildContext context, SessionStatus? status) async {
|
||||
text += "Keine Informationen gefunden";
|
||||
}
|
||||
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
shadowColor: Colors.transparent,
|
||||
backgroundColor: Colors.white,
|
||||
content: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||
return SizedBox(
|
||||
key: GlobalKey(),
|
||||
height: 350,
|
||||
width: MediaQuery.of(context).size.width * 0.8,
|
||||
child: Container(
|
||||
height: 100,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Colors.white,
|
||||
border: Border.all(
|
||||
color: Colors.grey,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(child: Text(text, textAlign: TextAlign.left)),
|
||||
getDefaultButton(
|
||||
'OK',
|
||||
() => {Navigator.pop(context)},
|
||||
MessageService().subscribe<CurrentConnectionStatusMessage>(Constants.messageTopicCurrentConnectionStatus, version,
|
||||
(CurrentConnectionStatusMessage currentConnectionStatusMessage) async {
|
||||
connectedString = currentConnectionStatusMessage.state ? "Verbunden" : "NICHT verbunden";
|
||||
|
||||
if (context.mounted) setState(() {});
|
||||
});
|
||||
|
||||
MessageService().subscribe<ConnectionStatus>(Constants.messageTopicConnectionStatusChanged, version,
|
||||
(ConnectionStatus connectionStatus) async {
|
||||
connectedString = connectionStatus.status == ConnectionStatusEnum.connected ? "Verbunden" : "NICHT verbunden";
|
||||
|
||||
if (context.mounted) setState(() {});
|
||||
});
|
||||
|
||||
return SizedBox(
|
||||
key: GlobalKey(),
|
||||
height: 350,
|
||||
width: MediaQuery.of(context).size.width * 0.8,
|
||||
child: Container(
|
||||
height: 100,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Colors.white,
|
||||
border: Border.all(
|
||||
color: Colors.grey,
|
||||
width: 1,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
}));
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(child: Text(text, textAlign: TextAlign.left)),
|
||||
getDefaultButton(
|
||||
'OK',
|
||||
() {
|
||||
unsubscribeMessages();
|
||||
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
})));
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user