Erweiterungen
This commit is contained in:
1 parent
550c11cb58
commit
fcda77177a
9 files changed
+1275
-13
No files matched your search
@@ -8,6 +8,7 @@ class Constants {
|
||||
static const String messageTopicSessionInfoUpdate = "status_info_updated";
|
||||
static const String messageTopicStatusInfoUpdate = "session_info_updated";
|
||||
static const String messageTopicJobReceived = "job_received";
|
||||
static const String messageTopicMessageReceived = "message_received";
|
||||
static const String messageTopicPushContentView = "push_content_view";
|
||||
static const String messageTopicPopContentView = "pop_content_view";
|
||||
static const String messageTopicReplaceContentView = "replace_content_view";
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:stadtbote/model/job.dart';
|
||||
import 'package:stadtbote/model/message.dart';
|
||||
|
||||
class MessageReceivedMessage {
|
||||
final Message message;
|
||||
|
||||
MessageReceivedMessage({required this.message});
|
||||
}
|
||||
@@ -9,9 +9,11 @@ import 'package:stadtbote/model/bootstrap_request.dart';
|
||||
import 'package:stadtbote/model/bootstrap_response_payload.dart';
|
||||
import 'package:stadtbote/model/device_object.dart';
|
||||
import 'package:stadtbote/model/job.dart';
|
||||
import 'package:stadtbote/model/message.dart';
|
||||
import 'package:stadtbote/model/start_session_message.dart';
|
||||
import 'package:stadtbote/tools/connection_status.dart';
|
||||
import 'package:stadtbote/tools/messages/job_received_message.dart';
|
||||
import 'package:stadtbote/tools/messages/message_message.dart';
|
||||
import 'package:stadtbote/tools/messages/session_info_update.dart';
|
||||
import 'package:typed_data/typed_buffers.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
@@ -131,6 +133,10 @@ class MqttCore {
|
||||
_jobMessageReceived(payloadData);
|
||||
break;
|
||||
|
||||
case "mssg":
|
||||
_messageMessageReceived(payloadData);
|
||||
break;
|
||||
|
||||
default:
|
||||
Util.logInfo('Unknown topic: $payloadEntry');
|
||||
break;
|
||||
@@ -171,6 +177,16 @@ class MqttCore {
|
||||
}
|
||||
}
|
||||
|
||||
void _messageMessageReceived(Map<String, dynamic> payloadData) async {
|
||||
var newMessage = Message.fromJson(payloadData);
|
||||
|
||||
await MyApp.isarInstance.writeTxn(() async {
|
||||
await MyApp.isarInstance.messages.put(newMessage);
|
||||
});
|
||||
|
||||
BroadcastReceiver().publish<MessageReceivedMessage>(Constants.messageTopicJobReceived, arguments: MessageReceivedMessage(message: newMessage));
|
||||
}
|
||||
|
||||
void _startReconnectTimer() {
|
||||
Util.logInfo("_startReconnectTimer called");
|
||||
|
||||
|
||||
+37
-4
@@ -177,15 +177,16 @@ class Util {
|
||||
}
|
||||
|
||||
Widget getDefaultButton(String text, Function() onPressed, {Image? image, double? buttonHeight}) {
|
||||
return SizedBox(
|
||||
/*return SizedBox(
|
||||
height: buttonHeight ?? 60,
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: Expanded(
|
||||
child: SizedBox(
|
||||
height: 60,
|
||||
child: ElevatedButton(
|
||||
@@ -211,6 +212,38 @@ Widget getDefaultButton(String text, Function() onPressed, {Image? image, double
|
||||
Positioned(left: 20, top: 15, child: Center(child: image))
|
||||
],
|
||||
),
|
||||
);*/
|
||||
return SizedBox(
|
||||
height: buttonHeight ?? 50,
|
||||
child: MaterialButton(
|
||||
color: const Color.fromARGB(255, 220, 220, 220),
|
||||
disabledColor: Colors.indigo[400],
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(15),
|
||||
),
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Visibility(
|
||||
visible: image != null,
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.transparent,
|
||||
child: image,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
text,
|
||||
style: const TextStyle(color: Colors.black, fontSize: 18.0),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user