From 01912b53af32f72f202a19bece4c3bd5c481dd90 Mon Sep 17 00:00:00 2001 From: Sven Carstensen Date: Tue, 14 Nov 2023 20:07:15 +0100 Subject: [PATCH] Erweiterungen --- lib/content_views/task_list_page.dart | 18 +++++ lib/popups/tasks_popups/signature_popup.dart | 82 ++++++++++++++++++++ pubspec.lock | 72 +++++++++++++++++ pubspec.yaml | 1 + 4 files changed, 173 insertions(+) create mode 100644 lib/popups/tasks_popups/signature_popup.dart diff --git a/lib/content_views/task_list_page.dart b/lib/content_views/task_list_page.dart index f43cc13..ccc88c3 100644 --- a/lib/content_views/task_list_page.dart +++ b/lib/content_views/task_list_page.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:isar/isar.dart'; import 'package:kumi_popup_window/kumi_popup_window.dart'; import 'package:stadtbote/content_views/utils/content_view_widget.dart'; @@ -8,6 +9,7 @@ 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/receipt_giver_popup.dart'; import 'package:stadtbote/popups/tasks_popups/scan_barcodes_popup.dart'; +import 'package:stadtbote/popups/tasks_popups/signature_popup.dart'; import 'package:stadtbote/popups/tasks_popups/station_notice_popup.dart'; import 'package:stadtbote/popups/tasks_popups/take_photos_popup.dart'; @@ -180,6 +182,10 @@ class _TaskListPageState extends State { void _processTask(TaskInfo taskInfo) { switch(taskInfo.task.type) { + case 2: + _processSignature(taskInfo); + break; + case 3: _processTaskArrivedOrFinished(taskInfo); break; @@ -241,4 +247,16 @@ class _TaskListPageState extends State { _popup.dismiss(context) }); } + + void _processSignature(TaskInfo taskInfo) { + SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft]); + + Future.delayed(const Duration(seconds: 1), () async { + _popup = showSignaturePopup(context, taskInfo, () => { + _popup.dismiss(context), + + SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]) + }); + }); + } } diff --git a/lib/popups/tasks_popups/signature_popup.dart b/lib/popups/tasks_popups/signature_popup.dart new file mode 100644 index 0000000..0a721b7 --- /dev/null +++ b/lib/popups/tasks_popups/signature_popup.dart @@ -0,0 +1,82 @@ +import 'dart:math'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart'; +import 'package:kumi_popup_window/kumi_popup_window.dart'; +import 'package:signature/signature.dart'; +import 'package:stadtbote/model/task_info.dart'; +import 'package:stadtbote/tools/util.dart'; + +KumiPopupWindow showSignaturePopup(BuildContext context, TaskInfo taskInfo, Function() onFinished) { + return 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: false, + 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) { + final SignatureController controller = SignatureController(); + + var popupHeight = MediaQuery.of(context).size.height * 0.85; + var popupWidth = MediaQuery.of(context).size.width * 0.85; + + return SizedBox( + key: GlobalKey(), + height: popupHeight, + width: popupWidth, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 0.5, + ), + ), + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + children: [ + Text(taskInfo.task.topic), + const SizedBox(height: 20), + Expanded( + child: Signature( + controller: controller, + width: 500, + height: 200, + backgroundColor: Colors.lightBlueAccent, + ), + ), + getDefaultButton('Übernehmen', buttonHeight: 50, () => { + onFinished() + }) + ], + ), + ), + ) + ); + }, + ); +} + +/* + + */ \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 232e2f8..9d5a095 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -390,6 +390,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.17" + flutter_svg: + dependency: transitive + description: + name: flutter_svg + sha256: f991fdb1533c3caeee0cdc14b04f50f0c3916f0dbcbc05237ccbe4e3c6b93f3f + url: "https://pub.dev" + source: hosted + version: "2.0.5" flutter_test: dependency: "direct dev" description: flutter @@ -456,6 +464,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + image: + dependency: transitive + description: + name: image + sha256: "028f61960d56f26414eb616b48b04eb37d700cbe477b7fb09bf1d7ce57fd9271" + url: "https://pub.dev" + source: hosted + version: "4.1.3" image_picker: dependency: "direct main" description: @@ -704,6 +720,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.2" + path_parsing: + dependency: transitive + description: + name: path_parsing + sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf + url: "https://pub.dev" + source: hosted + version: "1.0.1" path_provider: dependency: "direct main" description: @@ -792,6 +816,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.1.3" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: "49392a45ced973e8d94a85fdb21293fbb40ba805fc49f2965101ae748a3683b4" + url: "https://pub.dev" + source: hosted + version: "5.1.0" platform: dependency: transitive description: @@ -936,6 +968,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.4" + signature: + dependency: "direct main" + description: + name: signature + sha256: d95143b8e310b395ea0be59a46bb69fa24106cb6ec79815fc56fd320268e24e6 + url: "https://pub.dev" + source: hosted + version: "5.4.0" sky_engine: dependency: transitive description: flutter @@ -1133,6 +1173,30 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.7" + vector_graphics: + dependency: transitive + description: + name: vector_graphics + sha256: ea8d3fc7b2e0f35de38a7465063ecfcf03d8217f7962aa2a6717132cb5d43a79 + url: "https://pub.dev" + source: hosted + version: "1.1.5" + vector_graphics_codec: + dependency: transitive + description: + name: vector_graphics_codec + sha256: a5eaa5d19e123ad4f61c3718ca1ed921c4e6254238d9145f82aa214955d9aced + url: "https://pub.dev" + source: hosted + version: "1.1.5" + vector_graphics_compiler: + dependency: transitive + description: + name: vector_graphics_compiler + sha256: "15edc42f7eaa478ce854eaf1fbb9062a899c0e4e56e775dd73b7f4709c97c4ca" + url: "https://pub.dev" + source: hosted + version: "1.1.5" vector_math: dependency: transitive description: @@ -1181,6 +1245,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.3" + xml: + dependency: transitive + description: + name: xml + sha256: "979ee37d622dec6365e2efa4d906c37470995871fe9ae080d967e192d88286b5" + url: "https://pub.dev" + source: hosted + version: "6.2.2" xxh3: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 9822007..0473466 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -62,6 +62,7 @@ dependencies: latlong2: ^0.8.2 flutter_barcode_scanner: ^2.0.0 carousel_slider: ^4.2.1 + signature: ^5.4.0 dev_dependencies: flutter_test: