Erweiterungen
This commit is contained in:
1 parent
e0d66ce3b1
commit
5c095fb969
10 files changed
+507
-415
No files matched your search
@@ -1,21 +1,19 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_broadcast_receiver/flutter_broadcast_receiver.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stadtbote/content_views/accepted_jobs_page.dart';
|
||||
import 'package:stadtbote/content_views/assigned_jobs_page.dart';
|
||||
import 'package:stadtbote/content_views/finished_jobs_page.dart';
|
||||
import 'package:stadtbote/content_views/messages_page.dart';
|
||||
import 'package:stadtbote/content_views/utils/content_view_widget.dart';
|
||||
import 'package:stadtbote/content_views/utils/header_info.dart';
|
||||
import 'package:stadtbote/model/job.dart';
|
||||
import 'package:stadtbote/model/status.dart';
|
||||
import 'package:stadtbote/popups/infos_popup.dart';
|
||||
import 'package:stadtbote/tools/session_info_update.dart';
|
||||
import 'package:badges/badges.dart' as badges;
|
||||
|
||||
import '../main.dart';
|
||||
import '../model/job.dart';
|
||||
import '../tools/constants.dart';
|
||||
import '../tools/util.dart';
|
||||
|
||||
@@ -78,10 +76,16 @@ class MainPage extends ContentViewWidget {
|
||||
}
|
||||
|
||||
class _MainPageState extends State<MainPage> {
|
||||
final ValueNotifier<int> _assignedJobsValueNotifier = ValueNotifier<int>(0);
|
||||
final ValueNotifier<int> _acceptedJobsValueNotifier = ValueNotifier<int>(0);
|
||||
final ValueNotifier<int> _messagesValueNotifier = ValueNotifier<int>(0);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_initBadges();
|
||||
|
||||
_initMessages();
|
||||
}
|
||||
|
||||
@@ -96,25 +100,94 @@ class _MainPageState extends State<MainPage> {
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
getDefaultButton(
|
||||
'Zugewiesene Aufträge',
|
||||
image: Image.asset('assets/zugewiesene_auftraege.png', width: 30, height: 30),
|
||||
() => {BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: const AssignedJobsPage())}),
|
||||
ValueListenableBuilder<int>(
|
||||
valueListenable: _assignedJobsValueNotifier,
|
||||
builder: (context, value, child) {
|
||||
return badges.Badge(
|
||||
showBadge: value > 0,
|
||||
position: badges.BadgePosition.topEnd(top: 0, end: -5),
|
||||
badgeContent: Text(
|
||||
value.toString(),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 13.0,
|
||||
),
|
||||
),
|
||||
badgeStyle: badges.BadgeStyle(
|
||||
badgeColor: Colors.red,
|
||||
padding: const EdgeInsets.all(10),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
borderSide: const BorderSide(color: Colors.white, width: 0),
|
||||
elevation: 0,
|
||||
),
|
||||
child: getDefaultButton(
|
||||
'Zugewiesene Aufträge',
|
||||
image: Image.asset('assets/zugewiesene_auftraege.png', width: 30, height: 30),
|
||||
() => {BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: const AssignedJobsPage())})
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
getDefaultButton(
|
||||
'Angenommene Aufträge',
|
||||
image: Image.asset('assets/angenommene_auftraege.png', width: 30, height: 30),
|
||||
() => {BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: const AcceptedJobsPage())}),
|
||||
ValueListenableBuilder<int>(
|
||||
valueListenable: _acceptedJobsValueNotifier,
|
||||
builder: (context, value, child) {
|
||||
return badges.Badge(
|
||||
showBadge: value > 0,
|
||||
position: badges.BadgePosition.topEnd(top: 0, end: -5),
|
||||
badgeContent: Text(
|
||||
value.toString(),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 13.0,
|
||||
),
|
||||
),
|
||||
badgeStyle: badges.BadgeStyle(
|
||||
badgeColor: Colors.red,
|
||||
padding: const EdgeInsets.all(10),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
borderSide: const BorderSide(color: Colors.white, width: 0),
|
||||
elevation: 0,
|
||||
),
|
||||
child: getDefaultButton(
|
||||
'Angenommene Aufträge',
|
||||
image: Image.asset('assets/angenommene_auftraege.png', width: 30, height: 30),
|
||||
() => {BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: const AssignedJobsPage())})
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
getDefaultButton(
|
||||
'Erledigte Aufträge',
|
||||
image: Image.asset('assets/erledigte_auftraege.png', width: 30, height: 30),
|
||||
() => {BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: const FinishedJobsPage())}),
|
||||
const SizedBox(height: 10),
|
||||
getDefaultButton(
|
||||
'Nachrichten',
|
||||
image: Image.asset('assets/nachrichten.png', width: 30, height: 30),
|
||||
() => {BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: const MessagesPage())}),
|
||||
ValueListenableBuilder<int>(
|
||||
valueListenable: _messagesValueNotifier,
|
||||
builder: (context, value, child) {
|
||||
return badges.Badge(
|
||||
showBadge: value > 0,
|
||||
position: badges.BadgePosition.topEnd(top: 0, end: -5),
|
||||
badgeContent: Text(
|
||||
value.toString(),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 13.0,
|
||||
),
|
||||
),
|
||||
badgeStyle: badges.BadgeStyle(
|
||||
badgeColor: Colors.red,
|
||||
padding: const EdgeInsets.all(10),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
borderSide: const BorderSide(color: Colors.white, width: 0),
|
||||
elevation: 0,
|
||||
),
|
||||
child: getDefaultButton(
|
||||
'Nachrichten',
|
||||
image: Image.asset('assets/nachrichten.png', width: 30, height: 30),
|
||||
() => {BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: const MessagesPage())})
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
getDefaultButton(
|
||||
'Anfahrtsbereich',
|
||||
@@ -126,10 +199,7 @@ class _MainPageState extends State<MainPage> {
|
||||
getDefaultButton(
|
||||
'Abmelden',
|
||||
image: Image.asset('assets/abmelden.png', width: 30, height: 30),
|
||||
() => {
|
||||
_test()
|
||||
//BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: const FinishedJobsPage())
|
||||
}),
|
||||
() => {BroadcastReceiver().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: const FinishedJobsPage())}),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
@@ -153,7 +223,7 @@ class _MainPageState extends State<MainPage> {
|
||||
);
|
||||
}
|
||||
|
||||
_test() async {
|
||||
/*_test() async {
|
||||
var json = await rootBundle.loadString('assets/job.json');
|
||||
var jsonMap = jsonDecode(json);
|
||||
var payload = jsonMap["payload"];
|
||||
@@ -167,11 +237,16 @@ class _MainPageState extends State<MainPage> {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
_initMessages() {
|
||||
BroadcastReceiver().subscribe<StatusInfoUpdate>(Constants.messageTopicStatusInfoUpdate, (statusInfoUpdate) {
|
||||
widget._sidValueNotifier.value = statusInfoUpdate.status.sid;
|
||||
});
|
||||
}
|
||||
|
||||
void _initBadges() async {
|
||||
_assignedJobsValueNotifier.value = await MyApp.isarInstance.jobs.filter().stateEqualTo(0).count();
|
||||
_acceptedJobsValueNotifier.value = await MyApp.isarInstance.jobs.filter().stateEqualTo(1).count();
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import 'package:stadtbote/content_views/utils/header_info.dart';
|
||||
import 'package:stadtbote/model/job_tour.dart';
|
||||
import 'package:stadtbote/popups/tasks_popups/arrived_popup.dart';
|
||||
import 'package:stadtbote/popups/tasks_popups/commision_number_popup.dart';
|
||||
import 'package:stadtbote/popups/tasks_popups/pickup_delivery_status_popup.dart';
|
||||
import 'package:stadtbote/popups/tasks_popups/receipt_giver_popup.dart';
|
||||
import 'package:stadtbote/popups/tasks_popups/scan_barcodes_popup.dart';
|
||||
import 'package:stadtbote/popups/tasks_popups/signature_popup.dart';
|
||||
@@ -217,6 +218,10 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
case 9:
|
||||
_processCommissionNumber(taskInfo);
|
||||
break;
|
||||
|
||||
case 11:
|
||||
_processPickupDeliveryStatusTask(taskInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,6 +317,16 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void _processPickupDeliveryStatusTask(TaskInfo taskInfo) {
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
_popup = showPickupDeliveryStatusPopup(context, taskInfo, () => {
|
||||
_popup.dismiss(context),
|
||||
|
||||
taskInfo.completed = true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void _processSignature(TaskInfo taskInfo) {
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft]);
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class _TourListPageState extends State<TourListPage> {
|
||||
late List<Widget> jobWidgets = _createjobWidgets();
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(18.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
|
||||
Reference in new issue
Block a user