summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrik@amftech.nl>2023-06-09 23:13:41 +0200
committerAldrik Ramaekers <aldrik@amftech.nl>2023-06-09 23:13:41 +0200
commit4eef6fe17a48e535c902336fad4ea7aab1963ce1 (patch)
treed5b7d9db094f87d170fec901899d212e75f2df6f /lib
parent629db8d6250bfbab82508e3ab1f083c0e38f605b (diff)
show qr
Diffstat (limited to 'lib')
-rw-r--r--lib/RoutingExample.dart3
-rw-r--r--lib/navigation/baseNavigation.dart103
-rw-r--r--lib/pages/navigation_page.dart125
-rw-r--r--lib/route.dart4
4 files changed, 149 insertions, 86 deletions
diff --git a/lib/RoutingExample.dart b/lib/RoutingExample.dart
index 23b0be3..2ab5193 100644
--- a/lib/RoutingExample.dart
+++ b/lib/RoutingExample.dart
@@ -284,7 +284,8 @@ class RoutingExample {
postalcodeNumeric: item.postalCodeNumeric,
postalcodeAlpha: item.postalCodeAlpha,
houseNumberWithExtra:
- item.houseNumber! + (item.houseNumberAddition ?? '')),
+ item.houseNumber! + (item.houseNumberAddition ?? ''),
+ pid: item.pid),
);
_destinationCoords.add(destinationGeoCoordinates);
diff --git a/lib/navigation/baseNavigation.dart b/lib/navigation/baseNavigation.dart
index 1aed658..94b73ed 100644
--- a/lib/navigation/baseNavigation.dart
+++ b/lib/navigation/baseNavigation.dart
@@ -1,15 +1,20 @@
import 'dart:async';
+import 'dart:io';
+import 'dart:typed_data';
+import 'package:barcode_image/barcode_image.dart';
import 'package:flutter/material.dart';
+import 'package:image/image.dart' as img;
+import 'package:side_sheet/side_sheet.dart';
import 'package:training_planner/events/NextStopLoadedEvent.dart';
import 'package:training_planner/events/StopCompletedEvent.dart';
import 'package:training_planner/main.dart';
-
import '../route.dart' as DHLRoute;
import 'package:training_planner/services/iblacklist_provider_service.dart';
class DestinationPin {
final int numberOfParcels;
final int sequenceNumber;
+ final String? pid;
final DHLCoordinates coords;
final String? postalcodeNumeric;
final String? postalcodeAlpha;
@@ -24,7 +29,8 @@ class DestinationPin {
required this.isDoublePlannedAddress,
required this.postalcodeNumeric,
required this.postalcodeAlpha,
- required this.houseNumberWithExtra});
+ required this.houseNumberWithExtra,
+ required this.pid});
}
class DHLCoordinates {
@@ -93,6 +99,19 @@ abstract class BaseNavigationState extends State<BaseNavigation> {
});
}
+ buildBarcode(String pid) {
+ // Create an image
+ final image = img.Image((MediaQuery.of(context).size.width * 1).round(),
+ (MediaQuery.of(context).size.height * 1).round());
+
+ // Fill it with a solid color (white)
+ img.fill(image, 0xFFFFFF);
+
+ // Draw the barcode
+ drawBarcode(image, Barcode.pdf417(), pid);
+ return Uint8List.fromList(img.encodePng(image));
+ }
+
void flyTo(DHLCoordinates coords);
void changeZoom(double newVal);
Future<void> addRoute(DHLRoute.Route route);
@@ -114,42 +133,51 @@ abstract class BaseNavigationState extends State<BaseNavigation> {
width: 2),
),
child: GestureDetector(
+ onTap: () async {
+ SideSheet.right(
+ body: Transform.rotate(
+ angle: -3.1415 / 2,
+ child: Container(
+ child: Image.memory(buildBarcode(pin.pid ?? ''))),
+ ),
+ context: context);
+ },
child: Row(
- children: [
- Container(
- padding: EdgeInsets.all(3),
- decoration: BoxDecoration(
- color: Color.fromARGB(255, 0, 0, 0),
- borderRadius: BorderRadius.circular(10),
- shape: BoxShape.rectangle,
- ),
- child: RichText(
- text: TextSpan(children: [
- TextSpan(
- text: pin.sequenceNumber.toString(),
- style: TextStyle(
- fontSize: 20.0,
- color: Color.fromARGB(255, 255, 255, 255)),
+ children: [
+ Container(
+ padding: EdgeInsets.all(3),
+ decoration: BoxDecoration(
+ color: Color.fromARGB(255, 0, 0, 0),
+ borderRadius: BorderRadius.circular(10),
+ shape: BoxShape.rectangle,
+ ),
+ child: RichText(
+ text: TextSpan(children: [
+ TextSpan(
+ text: pin.sequenceNumber.toString(),
+ style: TextStyle(
+ fontSize: 20.0,
+ color: Color.fromARGB(255, 255, 255, 255)),
+ ),
+ if (pin.numberOfParcels > 1)
+ TextSpan(
+ text: ' ' + pin.numberOfParcels.toString(),
+ style: TextStyle(
+ fontSize: 12.0,
+ color: Color.fromARGB(255, 255, 255, 255)),
+ )
+ ]),
+ ),
+ ),
+ Container(
+ padding: EdgeInsets.all(3),
+ child: Text(
+ pin.houseNumberWithExtra ?? 'Zie pakket',
+ style: TextStyle(fontSize: 20.0),
),
- if (pin.numberOfParcels > 1)
- TextSpan(
- text: ' ' + pin.numberOfParcels.toString(),
- style: TextStyle(
- fontSize: 12.0,
- color: Color.fromARGB(255, 255, 255, 255)),
- )
- ]),
- ),
- ),
- Container(
- padding: EdgeInsets.all(3),
- child: Text(
- pin.houseNumberWithExtra ?? 'Zie pakket',
- style: TextStyle(fontSize: 20.0),
- ),
- ),
- ],
- )),
+ ),
+ ],
+ )),
);
}
@@ -288,7 +316,8 @@ abstract class BaseNavigationState extends State<BaseNavigation> {
postalcodeNumeric: item.postalCodeNumeric,
postalcodeAlpha: item.postalCodeAlpha,
houseNumberWithExtra:
- item.houseNumber! + (item.houseNumberAddition ?? '')),
+ item.houseNumber! + (item.houseNumberAddition ?? ''),
+ pid: item.pid!),
);
widget.destinationCoords.add(destinationGeoCoordinates);
diff --git a/lib/pages/navigation_page.dart b/lib/pages/navigation_page.dart
index 9fcc9ae..0f8b454 100644
--- a/lib/pages/navigation_page.dart
+++ b/lib/pages/navigation_page.dart
@@ -1,6 +1,7 @@
import 'dart:async';
import 'package:auto_orientation/auto_orientation.dart';
import 'package:flutter/services.dart';
+import 'package:side_sheet/side_sheet.dart';
import 'package:training_planner/navigation/HERENavigation.dart';
import 'package:training_planner/navigation/baseNavigation.dart';
import 'package:training_planner/navigation/openstreetmapNavigation.dart';
@@ -69,6 +70,7 @@ class _NavigationPageState extends State<NavigationPage> {
SystemChrome.setPreferredOrientations([]);
Wakelock.enable();
+ SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
AutoOrientation.portraitDownMode();
_handleLocationPermission();
@@ -106,65 +108,94 @@ class _NavigationPageState extends State<NavigationPage> {
eventBus.fire(StopIncompletedEvent());
}
+ Future<bool> showExitPopup() async {
+ return await showDialog(
+ //show confirm dialogue
+ //the return value will be from "Yes" or "No" options
+ context: context,
+ builder: (context) => AlertDialog(
+ title: Text('Terug'),
+ content: Text('Terug naar vorig scherm?'),
+ actions: [
+ ElevatedButton(
+ onPressed: () => Navigator.of(context).pop(false),
+ //return false when click on "NO"
+ child: Text('Nee'),
+ ),
+ ElevatedButton(
+ onPressed: () => Navigator.of(context).pop(true),
+ //return true when click on "Yes"
+ child: Text('Ja'),
+ ),
+ ],
+ ),
+ ) ??
+ false; //if showDialouge had returned null, then return false
+ }
+
@override
Widget build(BuildContext context) {
if (navigation == null) {
navigation = HERENavigation(route: widget.route);
}
- return Scaffold(
- floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
- floatingActionButton: Padding(
- padding: const EdgeInsets.all(8.0),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- InkWell(
- splashColor: Colors.blue,
- onLongPress: () => _mockStopInComplete(),
- child: FloatingActionButton(
- onPressed: () => _mockStopComplete(),
- child: Icon(Icons.check_circle),
+ return WillPopScope(
+ onWillPop: showExitPopup, //call function on back button press
+ child: Scaffold(
+ floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
+ floatingActionButton: Padding(
+ padding: const EdgeInsets.all(8.0),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: <Widget>[
+ InkWell(
+ splashColor: Colors.blue,
+ onLongPress: () => _mockStopInComplete(),
+ child: FloatingActionButton(
+ onPressed: () => _mockStopComplete(),
+ child: Icon(Icons.check_circle),
+ ),
),
- ),
- Visibility(
- visible: navigation == null ? false : navigation!.isLookingAround,
- child: FloatingActionButton(
- backgroundColor: Colors.green,
- child: const Icon(Icons.center_focus_strong),
- onPressed: () => {
- changeIsLookingAround(false),
- eventBus.fire(FlyToEvent(navigation!.lastPosition))
- },
+ Visibility(
+ visible:
+ navigation == null ? false : navigation!.isLookingAround,
+ child: FloatingActionButton(
+ backgroundColor: Colors.green,
+ child: const Icon(Icons.center_focus_strong),
+ onPressed: () => {
+ changeIsLookingAround(false),
+ eventBus.fire(FlyToEvent(navigation!.lastPosition))
+ },
+ ),
+ ),
+ Padding(padding: EdgeInsets.all(5)),
+ FloatingActionButton(
+ onPressed: () => _zoomOut(),
+ child: Icon(Icons.zoom_out),
+ ),
+ Padding(padding: EdgeInsets.all(2)),
+ FloatingActionButton(
+ onPressed: () => _zoomIn(),
+ child: Icon(Icons.zoom_in),
),
+ ],
+ ),
+ ),
+ body: Column(
+ children: [
+ _createNextDropInfoWidget(),
+ Container(
+ decoration: BoxDecoration(color: Colors.black),
+ height: 2,
),
- Padding(padding: EdgeInsets.all(5)),
- FloatingActionButton(
- onPressed: () => _zoomOut(),
- child: Icon(Icons.zoom_out),
+ Expanded(
+ child: Stack(
+ children: [navigation!],
+ ),
),
- Padding(padding: EdgeInsets.all(2)),
- FloatingActionButton(
- onPressed: () => _zoomIn(),
- child: Icon(Icons.zoom_in),
- )
],
),
),
- body: Column(
- children: [
- _createNextDropInfoWidget(),
- Container(
- decoration: BoxDecoration(color: Colors.black),
- height: 2,
- ),
- Expanded(
- child: Stack(
- children: [navigation!],
- ),
- ),
- ],
- ),
);
}
@@ -251,6 +282,8 @@ class _NavigationPageState extends State<NavigationPage> {
taskLoadedEvent?.cancel();
Wakelock.disable();
AutoOrientation.portraitUpMode();
+ SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
+ overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom]);
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
super.dispose();
diff --git a/lib/route.dart b/lib/route.dart
index e622c12..4531f9b 100644
--- a/lib/route.dart
+++ b/lib/route.dart
@@ -137,8 +137,8 @@ class Task {
String? beginDeliveryPickupWindow;
String? endDeliveryPickupWindow;
String? deliveryInstruction;
- Null? parcelDeliveryRemark;
- Null? courierRemark;
+ dynamic? parcelDeliveryRemark;
+ dynamic? courierRemark;
String? serviceType;
bool? servicepointParcel;
String? servicepointid;