Erweiterungen
This commit is contained in:
1 parent
550c11cb58
commit
fcda77177a
9 files changed
+1275
-13
No files matched your search
@@ -3,6 +3,7 @@ import 'package:isar/isar.dart';
|
|||||||
import 'package:stadtbote/content_views/utils/content_view_widget.dart';
|
import 'package:stadtbote/content_views/utils/content_view_widget.dart';
|
||||||
import 'package:stadtbote/content_views/utils/header_info.dart';
|
import 'package:stadtbote/content_views/utils/header_info.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:stadtbote/popups/accept_job_popup.dart';
|
||||||
|
|
||||||
import '../main.dart';
|
import '../main.dart';
|
||||||
import '../model/job.dart';
|
import '../model/job.dart';
|
||||||
@@ -128,5 +129,6 @@ class _AssignedJobsPageState extends State<AssignedJobsPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _clicked(Job job) {
|
void _clicked(Job job) {
|
||||||
|
showAcceptJobPopup(context, job);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@ import 'package:stadtbote/content_views/utils/content_view_widget.dart';
|
|||||||
import 'package:stadtbote/content_views/utils/header_info.dart';
|
import 'package:stadtbote/content_views/utils/header_info.dart';
|
||||||
import 'package:stadtbote/model/job.dart';
|
import 'package:stadtbote/model/job.dart';
|
||||||
import 'package:stadtbote/model/status.dart';
|
import 'package:stadtbote/model/status.dart';
|
||||||
|
import 'package:stadtbote/popups/accept_job_popup.dart';
|
||||||
import 'package:stadtbote/popups/infos_popup.dart';
|
import 'package:stadtbote/popups/infos_popup.dart';
|
||||||
import 'package:stadtbote/tools/messages/job_received_message.dart';
|
import 'package:stadtbote/tools/messages/job_received_message.dart';
|
||||||
import 'package:stadtbote/tools/messages/session_info_update.dart';
|
import 'package:stadtbote/tools/messages/session_info_update.dart';
|
||||||
@@ -107,7 +108,7 @@ class _MainPageState extends State<MainPage> {
|
|||||||
builder: (context, value, child) {
|
builder: (context, value, child) {
|
||||||
return badges.Badge(
|
return badges.Badge(
|
||||||
showBadge: value > 0,
|
showBadge: value > 0,
|
||||||
position: badges.BadgePosition.topEnd(top: 0, end: -5),
|
position: badges.BadgePosition.topEnd(top: -12, end: -5),
|
||||||
badgeContent: Text(
|
badgeContent: Text(
|
||||||
value.toString(),
|
value.toString(),
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
@@ -129,13 +130,13 @@ class _MainPageState extends State<MainPage> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 20),
|
||||||
ValueListenableBuilder<int>(
|
ValueListenableBuilder<int>(
|
||||||
valueListenable: _acceptedJobsValueNotifier,
|
valueListenable: _acceptedJobsValueNotifier,
|
||||||
builder: (context, value, child) {
|
builder: (context, value, child) {
|
||||||
return badges.Badge(
|
return badges.Badge(
|
||||||
showBadge: value > 0,
|
showBadge: value > 0,
|
||||||
position: badges.BadgePosition.topEnd(top: 0, end: -5),
|
position: badges.BadgePosition.topEnd(top: -12, end: -5),
|
||||||
badgeContent: Text(
|
badgeContent: Text(
|
||||||
value.toString(),
|
value.toString(),
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
@@ -157,18 +158,18 @@ class _MainPageState extends State<MainPage> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 20),
|
||||||
getDefaultButton(
|
getDefaultButton(
|
||||||
'Erledigte Aufträge',
|
'Erledigte Aufträge',
|
||||||
image: Image.asset('assets/erledigte_auftraege.png', width: 30, height: 30),
|
image: Image.asset('assets/erledigte_auftraege.png', width: 30, height: 30),
|
||||||
() => {BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: const FinishedJobsPage())}),
|
() => {BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: const FinishedJobsPage())}),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 20),
|
||||||
ValueListenableBuilder<int>(
|
ValueListenableBuilder<int>(
|
||||||
valueListenable: _messagesValueNotifier,
|
valueListenable: _messagesValueNotifier,
|
||||||
builder: (context, value, child) {
|
builder: (context, value, child) {
|
||||||
return badges.Badge(
|
return badges.Badge(
|
||||||
showBadge: value > 0,
|
showBadge: value > 0,
|
||||||
position: badges.BadgePosition.topEnd(top: 0, end: -5),
|
position: badges.BadgePosition.topEnd(top: -12, end: -5),
|
||||||
badgeContent: Text(
|
badgeContent: Text(
|
||||||
value.toString(),
|
value.toString(),
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
@@ -190,14 +191,14 @@ class _MainPageState extends State<MainPage> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 20),
|
||||||
getDefaultButton(
|
getDefaultButton(
|
||||||
'Anfahrtsbereich',
|
'Anfahrtsbereich',
|
||||||
image: Image.asset('assets/anfahrtsbereich.png', width: 30, height: 30),
|
image: Image.asset('assets/anfahrtsbereich.png', width: 30, height: 30),
|
||||||
() => {
|
() => {
|
||||||
//BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: const FinishedJobsPage())
|
//BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: const FinishedJobsPage())
|
||||||
}),
|
}),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 20),
|
||||||
getDefaultButton(
|
getDefaultButton(
|
||||||
'Abmelden',
|
'Abmelden',
|
||||||
image: Image.asset('assets/abmelden.png', width: 30, height: 30),
|
image: Image.asset('assets/abmelden.png', width: 30, height: 30),
|
||||||
@@ -260,7 +261,11 @@ class _MainPageState extends State<MainPage> {
|
|||||||
_refreshBadges();
|
_refreshBadges();
|
||||||
|
|
||||||
if (job.state == 0) {
|
if (job.state == 0) {
|
||||||
Util.logInfo("test");
|
_showAcceptanceDialog(job);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _showAcceptanceDialog(Job job) {
|
||||||
|
showAcceptJobPopup(context, job);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import 'package:isar/isar.dart';
|
||||||
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
|
|
||||||
|
part 'message.g.dart';
|
||||||
|
|
||||||
|
@collection
|
||||||
|
@JsonSerializable()
|
||||||
|
class Message {
|
||||||
|
late Id id;
|
||||||
|
|
||||||
|
late String time;
|
||||||
|
|
||||||
|
late String from;
|
||||||
|
|
||||||
|
late String subj;
|
||||||
|
|
||||||
|
late List<String> text;
|
||||||
|
|
||||||
|
Message();
|
||||||
|
|
||||||
|
factory Message.fromJson(Map<String, dynamic> json) => _$MessageFromJson(json);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => _$MessageToJson(this);
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,130 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:kumi_popup_window/kumi_popup_window.dart';
|
||||||
|
import 'package:stadtbote/main.dart';
|
||||||
|
import 'package:stadtbote/model/job.dart';
|
||||||
|
import 'package:stadtbote/tools/util.dart';
|
||||||
|
|
||||||
|
void showAcceptJobPopup(BuildContext context, Job job) async {
|
||||||
|
showPopupWindow(
|
||||||
|
context,
|
||||||
|
//childSize:Size(240, MediaQuery.of(context).size.width * 0.8),
|
||||||
|
gravity: KumiPopupGravity.center,
|
||||||
|
//curve: Curves.elasticOut,
|
||||||
|
bgColor: Colors.grey.withOpacity(0.5),
|
||||||
|
clickOutDismiss: true,
|
||||||
|
clickBackDismiss: true,
|
||||||
|
customAnimation: false,
|
||||||
|
customPop: false,
|
||||||
|
customPage: false,
|
||||||
|
// targetRenderBox: (btnKey.currentContext.findRenderObject() as RenderBox),
|
||||||
|
//needSafeDisplay: true,
|
||||||
|
underStatusBar: false,
|
||||||
|
underAppBar: false,
|
||||||
|
//offsetX: -180,
|
||||||
|
//offsetY: 50,
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
onShowStart: (pop) {},
|
||||||
|
onShowFinish: (pop) {},
|
||||||
|
onDismissStart: (pop) {},
|
||||||
|
onDismissFinish: (pop) {},
|
||||||
|
onClickOut: (pop) {},
|
||||||
|
onClickBack: (pop) {},
|
||||||
|
childFun: (pop) {
|
||||||
|
return SizedBox(
|
||||||
|
key: GlobalKey(),
|
||||||
|
height: MediaQuery.of(context).size.height * 0.5,
|
||||||
|
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: 0.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(12.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text(DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime)).toString(), textAlign: TextAlign.left),
|
||||||
|
Text('Auftragsnummer: ${job.id}'),
|
||||||
|
Text(job.tours[0].comp),
|
||||||
|
Text(job.tours[0].street),
|
||||||
|
Text(job.tours[0].city),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Container(
|
||||||
|
height: 200,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
color: const Color(0xfffff4e4),
|
||||||
|
border: Border.all(
|
||||||
|
color: Colors.grey,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: const SingleChildScrollView(
|
||||||
|
child: Text('asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd '),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: getDefaultButton(
|
||||||
|
'Ablehnen',
|
||||||
|
() => {_sendAnswer()}),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 20),
|
||||||
|
Expanded(
|
||||||
|
child: getDefaultButton(
|
||||||
|
'Annehmen',
|
||||||
|
() => {}),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
private void SendAnswer(int item)
|
||||||
|
{
|
||||||
|
JObject payloadObject;
|
||||||
|
|
||||||
|
var location = App.CurrentLocation;
|
||||||
|
if (location != null)
|
||||||
|
payloadObject = new JObject(
|
||||||
|
new JProperty("reaction", new JObject(
|
||||||
|
new JProperty("id", _jobViewModel.IdString),
|
||||||
|
new JProperty("ver", _jobViewModel.Version),
|
||||||
|
new JProperty("item", item),
|
||||||
|
new JProperty("track", new JObject(
|
||||||
|
new JProperty("time", DateTime.Now.ToString("o")),
|
||||||
|
new JProperty("pos", new JObject(
|
||||||
|
new JProperty("lat", location.Latitude),
|
||||||
|
new JProperty("long", location.Longitude),
|
||||||
|
new JProperty("acc", location.Accuracy))))))));
|
||||||
|
else
|
||||||
|
payloadObject = new JObject(
|
||||||
|
new JProperty("reaction", new JObject(
|
||||||
|
new JProperty("id", _jobViewModel.IdString),
|
||||||
|
new JProperty("ver", _jobViewModel.Version),
|
||||||
|
new JProperty("item", item),
|
||||||
|
new JProperty("track", new JObject(
|
||||||
|
new JProperty("time", DateTime.Now.ToString("o")))))));
|
||||||
|
|
||||||
|
App.Core.SendJsonMessageAsync("job", payloadObject);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
_sendAnswer() {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ class Constants {
|
|||||||
static const String messageTopicSessionInfoUpdate = "status_info_updated";
|
static const String messageTopicSessionInfoUpdate = "status_info_updated";
|
||||||
static const String messageTopicStatusInfoUpdate = "session_info_updated";
|
static const String messageTopicStatusInfoUpdate = "session_info_updated";
|
||||||
static const String messageTopicJobReceived = "job_received";
|
static const String messageTopicJobReceived = "job_received";
|
||||||
|
static const String messageTopicMessageReceived = "message_received";
|
||||||
static const String messageTopicPushContentView = "push_content_view";
|
static const String messageTopicPushContentView = "push_content_view";
|
||||||
static const String messageTopicPopContentView = "pop_content_view";
|
static const String messageTopicPopContentView = "pop_content_view";
|
||||||
static const String messageTopicReplaceContentView = "replace_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/bootstrap_response_payload.dart';
|
||||||
import 'package:stadtbote/model/device_object.dart';
|
import 'package:stadtbote/model/device_object.dart';
|
||||||
import 'package:stadtbote/model/job.dart';
|
import 'package:stadtbote/model/job.dart';
|
||||||
|
import 'package:stadtbote/model/message.dart';
|
||||||
import 'package:stadtbote/model/start_session_message.dart';
|
import 'package:stadtbote/model/start_session_message.dart';
|
||||||
import 'package:stadtbote/tools/connection_status.dart';
|
import 'package:stadtbote/tools/connection_status.dart';
|
||||||
import 'package:stadtbote/tools/messages/job_received_message.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:stadtbote/tools/messages/session_info_update.dart';
|
||||||
import 'package:typed_data/typed_buffers.dart';
|
import 'package:typed_data/typed_buffers.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
@@ -131,6 +133,10 @@ class MqttCore {
|
|||||||
_jobMessageReceived(payloadData);
|
_jobMessageReceived(payloadData);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "mssg":
|
||||||
|
_messageMessageReceived(payloadData);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Util.logInfo('Unknown topic: $payloadEntry');
|
Util.logInfo('Unknown topic: $payloadEntry');
|
||||||
break;
|
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() {
|
void _startReconnectTimer() {
|
||||||
Util.logInfo("_startReconnectTimer called");
|
Util.logInfo("_startReconnectTimer called");
|
||||||
|
|
||||||
|
|||||||
+37
-4
@@ -177,15 +177,16 @@ class Util {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget getDefaultButton(String text, Function() onPressed, {Image? image, double? buttonHeight}) {
|
Widget getDefaultButton(String text, Function() onPressed, {Image? image, double? buttonHeight}) {
|
||||||
return SizedBox(
|
/*return SizedBox(
|
||||||
height: buttonHeight ?? 60,
|
height: buttonHeight ?? 60,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Padding(
|
||||||
child: Padding(
|
padding: const EdgeInsets.all(0),
|
||||||
padding: const EdgeInsets.all(8.0),
|
child: Expanded(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 60,
|
height: 60,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
@@ -211,6 +212,38 @@ Widget getDefaultButton(String text, Function() onPressed, {Image? image, double
|
|||||||
Positioned(left: 20, top: 15, child: Center(child: image))
|
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