This commit is contained in:
1 parent
d7b49e2b66
commit
e003c508f3
5 files changed
+181
-138
No files matched your search
+151
-126
@@ -6,154 +6,179 @@ import 'package:stadtbote/protocoll_messages/accept_job_message.dart';
|
||||
import 'package:stadtbote/model/job.dart';
|
||||
import 'package:stadtbote/protocoll_messages/fin_task_message.dart';
|
||||
import 'package:stadtbote/tools/constants.dart';
|
||||
import 'package:stadtbote/tools/message_service.dart';
|
||||
import 'package:stadtbote/tools/messages/job_deleted_message.dart';
|
||||
import 'package:stadtbote/tools/messages/job_received_message.dart';
|
||||
import 'package:stadtbote/tools/mqtt_core.dart';
|
||||
import 'package:stadtbote/tools/util.dart';
|
||||
import 'package:badges/badges.dart' as badges;
|
||||
|
||||
Future<void> showAcceptJobsPopup(BuildContext context, List<Job> jobs) async {
|
||||
Future<void> showAcceptJobsPopup(BuildContext context, List<Job> jobs, Function onFinished) async {
|
||||
var jobsSet = jobs.toSet();
|
||||
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
shadowColor: Colors.transparent,
|
||||
backgroundColor: Colors.white,
|
||||
content: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||
if (jobsSet.isEmpty) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
Navigator.of(context).pop();
|
||||
|
||||
return SizedBox(
|
||||
key: GlobalKey(),
|
||||
height: MediaQuery.of(context).size.height * 1,
|
||||
width: MediaQuery.of(context).size.width * 1.2,
|
||||
child: Container(
|
||||
height: 100,
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: ListView.builder(
|
||||
itemCount: jobsSet.length,
|
||||
itemBuilder: (_, i) {
|
||||
var job = jobsSet.toList()[i];
|
||||
onFinished();
|
||||
|
||||
String remarkString = '';
|
||||
for (var remark in job.rem) {
|
||||
remarkString += '$remark\n';
|
||||
}
|
||||
remarkString = remarkString.trim();
|
||||
return true;
|
||||
}, // False will prevent and true will allow to dismiss
|
||||
child: AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
shadowColor: Colors.transparent,
|
||||
backgroundColor: Colors.white,
|
||||
content: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||
if (jobsSet.isEmpty) {
|
||||
Navigator.of(context).pop();
|
||||
|
||||
return ExpandableNotifier(
|
||||
child: ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||
title: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
color: Constants.colorPrimary,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: badges.Badge(
|
||||
position: badges.BadgePosition.topEnd(top: -13, end: -5),
|
||||
showBadge: false,
|
||||
badgeContent: const Text(
|
||||
'Neu',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18.0,
|
||||
onFinished();
|
||||
}
|
||||
|
||||
MessageService().subscribe<JobDeletedMessage>(Constants.messageTopicJobDeleted, jobsSet, (jobDeletedMessage) async {
|
||||
jobsSet.removeWhere((element) => element.id == jobDeletedMessage.jobId);
|
||||
|
||||
setState(() {});
|
||||
});
|
||||
|
||||
MessageService().subscribe<JobReceivedMessage>(Constants.messageTopicJobReceived, jobsSet, (jobdMessage) async {
|
||||
jobsSet.add(jobdMessage.job);
|
||||
|
||||
setState(() {});
|
||||
});
|
||||
|
||||
return SizedBox(
|
||||
key: GlobalKey(),
|
||||
height: MediaQuery.of(context).size.height * 1,
|
||||
width: MediaQuery.of(context).size.width * 1.2,
|
||||
child: Container(
|
||||
height: 100,
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: ListView.builder(
|
||||
itemCount: jobsSet.length,
|
||||
itemBuilder: (_, i) {
|
||||
var job = jobsSet.toList()[i];
|
||||
|
||||
String remarkString = '';
|
||||
for (var remark in job.rem) {
|
||||
remarkString += '$remark\n';
|
||||
}
|
||||
remarkString = remarkString.trim();
|
||||
|
||||
return ExpandableNotifier(
|
||||
child: ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||
title: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
color: Constants.colorPrimary,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
badgeStyle: badges.BadgeStyle(
|
||||
shape: badges.BadgeShape.square,
|
||||
badgeColor: Constants.colorPrimary,
|
||||
padding: const EdgeInsets.all(5),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
borderSide: const BorderSide(color: Constants.colorPrimary, width: 0),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime).toLocal()).toString(),
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(backgroundColor: isJobInFuture(job) ? Colors.yellow : Colors.transparent),
|
||||
),
|
||||
child: badges.Badge(
|
||||
position: badges.BadgePosition.topEnd(top: -13, end: -5),
|
||||
showBadge: false,
|
||||
badgeContent: const Text(
|
||||
'Neu',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18.0,
|
||||
),
|
||||
SizedBox(width: double.infinity, child: Text('Auftragsnummer: ${job.id}', textAlign: TextAlign.left)),
|
||||
SizedBox(width: double.infinity, child: Text(job.tours[0].comp, textAlign: TextAlign.left)),
|
||||
SizedBox(width: double.infinity, child: Text(job.tours[0].street, textAlign: TextAlign.left)),
|
||||
SizedBox(width: double.infinity, child: Text(job.tours[0].city, textAlign: TextAlign.left)),
|
||||
Row(
|
||||
),
|
||||
badgeStyle: badges.BadgeStyle(
|
||||
shape: badges.BadgeShape.square,
|
||||
badgeColor: Constants.colorPrimary,
|
||||
padding: const EdgeInsets.all(5),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
borderSide: const BorderSide(color: Constants.colorPrimary, width: 0),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Image.asset("assets/${mapVehicleTypeToImageName(job.vhtId)}", width: 60, height: 60),
|
||||
const SizedBox(width: 10),
|
||||
Text(mapVehicleTypeToText(job.vhtId)),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
ScrollOnExpand(
|
||||
scrollOnExpand: true,
|
||||
scrollOnCollapse: false,
|
||||
child: ExpandablePanel(
|
||||
theme: const ExpandableThemeData(
|
||||
headerAlignment: ExpandablePanelHeaderAlignment.center,
|
||||
tapBodyToCollapse: true,
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime).toLocal()).toString(),
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(backgroundColor: isJobInFuture(job) ? Colors.yellow : Colors.transparent),
|
||||
),
|
||||
),
|
||||
header: const Padding(
|
||||
padding: EdgeInsets.all(0),
|
||||
child: Text(
|
||||
"Weitere Infos....",
|
||||
style: TextStyle(fontSize: 15, color: Colors.black, fontWeight: FontWeight.bold),
|
||||
)),
|
||||
collapsed: const SizedBox(),
|
||||
expanded: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: 200,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: const Color(0xfffff4e4),
|
||||
border: Border.all(
|
||||
color: Colors.grey,
|
||||
width: 0.5,
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(remarkString),
|
||||
),
|
||||
),
|
||||
SizedBox(width: double.infinity, child: Text('Auftragsnummer: ${job.id}', textAlign: TextAlign.left)),
|
||||
SizedBox(width: double.infinity, child: Text(job.tours[0].comp, textAlign: TextAlign.left)),
|
||||
SizedBox(width: double.infinity, child: Text(job.tours[0].street, textAlign: TextAlign.left)),
|
||||
SizedBox(width: double.infinity, child: Text(job.tours[0].city, textAlign: TextAlign.left)),
|
||||
Row(
|
||||
children: [
|
||||
Image.asset("assets/${mapVehicleTypeToImageName(job.vhtId)}", width: 60, height: 60),
|
||||
const SizedBox(width: 10),
|
||||
Text(mapVehicleTypeToText(job.vhtId)),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
ScrollOnExpand(
|
||||
scrollOnExpand: true,
|
||||
scrollOnCollapse: false,
|
||||
child: ExpandablePanel(
|
||||
theme: const ExpandableThemeData(
|
||||
headerAlignment: ExpandablePanelHeaderAlignment.center,
|
||||
tapBodyToCollapse: true,
|
||||
),
|
||||
header: const Padding(
|
||||
padding: EdgeInsets.all(0),
|
||||
child: Text(
|
||||
"Weitere Infos....",
|
||||
style: TextStyle(fontSize: 15, color: Colors.black, fontWeight: FontWeight.bold),
|
||||
)),
|
||||
collapsed: const SizedBox(),
|
||||
expanded: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: 200,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: const Color(0xfffff4e4),
|
||||
border: Border.all(
|
||||
color: Colors.grey,
|
||||
width: 0.5,
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(remarkString),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(children: [
|
||||
Expanded(
|
||||
child: getDefaultButton(!job.global ? 'Ablehnen' : 'Ignorieren',
|
||||
() => {_sendAnswer(job, !job.global ? 2 : 3), jobsSet.remove(job), setState(() {})}),
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Expanded(
|
||||
child: getDefaultButton('Annehmen', () => {_sendAnswer(job, 1), jobsSet.remove(job), setState(() {})}),
|
||||
)
|
||||
])
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(children: [
|
||||
Expanded(
|
||||
child: getDefaultButton(!job.global ? 'Ablehnen' : 'Ignorieren',
|
||||
() => {_sendAnswer(job, !job.global ? 2 : 3), jobsSet.remove(job), setState(() {})}),
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Expanded(
|
||||
child: getDefaultButton('Annehmen', () => {_sendAnswer(job, 1), jobsSet.remove(job), setState(() {})}),
|
||||
)
|
||||
])
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
)),
|
||||
);
|
||||
}));
|
||||
);
|
||||
},
|
||||
)),
|
||||
);
|
||||
})));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user