From 3afec7ca1cbde9ff3261517aba752859abb31f03 Mon Sep 17 00:00:00 2001 From: yaso Date: Mon, 25 Nov 2024 16:14:05 +0200 Subject: [PATCH] scanner fix --- .../lib/mih_packages/mih_home/mih_home.dart | 53 +++++++++++++++++++ .../mzansi_wallet/loyalty_cards.dart | 30 +++++++---- 2 files changed, 72 insertions(+), 11 deletions(-) diff --git a/Frontend/lib/mih_packages/mih_home/mih_home.dart b/Frontend/lib/mih_packages/mih_home/mih_home.dart index 19323030..e84484c6 100644 --- a/Frontend/lib/mih_packages/mih_home/mih_home.dart +++ b/Frontend/lib/mih_packages/mih_home/mih_home.dart @@ -5,6 +5,8 @@ import 'package:flutter/services.dart'; import 'package:flutter_swipe_detector/flutter_swipe_detector.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:google_nav_bar/google_nav_bar.dart'; +import 'package:simple_barcode_scanner/screens/web.dart'; +import 'package:simple_barcode_scanner/simple_barcode_scanner.dart'; import '../../main.dart'; //import 'package:supertokens_flutter/http.dart' as http; import "package:universal_html/html.dart" as html; @@ -333,6 +335,57 @@ class _MIHHomeState extends State { void setAppsDev(List tileList) { if (AppEnviroment.getEnv() == "Dev") { + tileList.add(MIHTile( + onTap: () async { + showDialog( + barrierDismissible: false, + context: context, + builder: (context) { + // return const MIHErrorMessage(errorType: "Input Error"); + // return const MIHErrorMessage(errorType: "Password Requirements"); + // return const MIHErrorMessage(errorType: "Invalid Username"); + // return const MIHErrorMessage(errorType: "Invalid Email"); + // return const MIHErrorMessage(errorType: "User Exists"); + // return const MIHErrorMessage(errorType: "Password Match"); + // return const MIHErrorMessage(errorType: "Invalid Credentials"); + return MIHWindow( + fullscreen: false, + windowTitle: + "Test Window title that is too large for mobile devices", + windowBody: [ + SizedBox( + height: 700, + child: BarcodeScanner( + lineColor: "#ff6666", + cancelButtonText: "Cancel", + isShowFlashIcon: false, + scanType: ScanType.qr, + cameraFace: CameraFace.back, + //barcodeAppBar: barcodeAppBar, + delayMillis: 500, + scanFormat: ScanFormat.ALL_FORMATS, + onScanned: (res) => Navigator.pop(context, res), + //child: child, + ), + ), + ], + windowTools: [], + onWindowTapClose: () { + Navigator.pop(context); + }, + ); + }, + ); + }, + tileName: "Scanner - Dev", + tileIcon: Icon( + Icons.scanner, + color: getSec(), + size: 230, + ), + p: getPrim(), + s: getSec(), + )); tileList.add(MIHTile( onTap: () { showDialog( diff --git a/Frontend/lib/mih_packages/mzansi_wallet/loyalty_cards.dart b/Frontend/lib/mih_packages/mzansi_wallet/loyalty_cards.dart index 923c7582..1d1f8dc8 100644 --- a/Frontend/lib/mih_packages/mzansi_wallet/loyalty_cards.dart +++ b/Frontend/lib/mih_packages/mzansi_wallet/loyalty_cards.dart @@ -104,17 +104,25 @@ class _LoyaltyCardsState extends State { ), const SizedBox(width: 10), MIHButton( - onTap: () { - _qrBarCodeScannerDialogPlugin.getPlatformVersion().then((v) { - print(v); - }); - _qrBarCodeScannerDialogPlugin.getScannedQrBarCode( - context: context, - onCode: (code) { - setState(() { - this.code = code; - }); - }); + onTap: () async { + String? res = await SimpleBarcodeScanner.scanBarcode( + context, + barcodeAppBar: const BarcodeAppBar( + appBarTitle: 'Test', + centerTitle: false, + enableBackButton: true, + backButtonIcon: Icon(Icons.arrow_back_ios), + ), + isShowFlashIcon: true, + delayMillis: 500, + cameraFace: CameraFace.back, + scanFormat: ScanFormat.ONLY_BARCODE, + ); + if (res != null) { + setState(() { + cardNumberController.text = res; + }); + } }, buttonText: "Scan", buttonColor: