add android and IOS check before scanner
This commit is contained in:
@@ -11,8 +11,6 @@ import 'package:Mzansi_Innovation_Hub/mih_objects/loyalty_card.dart';
|
|||||||
import 'package:Mzansi_Innovation_Hub/mih_packages/mzansi_wallet/builder/build_loyalty_card_list.dart';
|
import 'package:Mzansi_Innovation_Hub/mih_packages/mzansi_wallet/builder/build_loyalty_card_list.dart';
|
||||||
import 'package:Mzansi_Innovation_Hub/mih_packages/mzansi_wallet/components/mih_card_display.dart';
|
import 'package:Mzansi_Innovation_Hub/mih_packages/mzansi_wallet/components/mih_card_display.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
// import 'package:flutter/services.dart';
|
|
||||||
// import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart';
|
|
||||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||||
import 'package:simple_barcode_scanner/simple_barcode_scanner.dart';
|
import 'package:simple_barcode_scanner/simple_barcode_scanner.dart';
|
||||||
|
|
||||||
@@ -33,7 +31,10 @@ class _LoyaltyCardsState extends State<LoyaltyCards> {
|
|||||||
late Future<List<MIHLoyaltyCard>> cardList;
|
late Future<List<MIHLoyaltyCard>> cardList;
|
||||||
//bool showSelectedCardType = false;
|
//bool showSelectedCardType = false;
|
||||||
final ValueNotifier<String> shopName = ValueNotifier("");
|
final ValueNotifier<String> shopName = ValueNotifier("");
|
||||||
final MobileScannerController scannerController = MobileScannerController();
|
final MobileScannerController scannerController = MobileScannerController(
|
||||||
|
detectionSpeed: DetectionSpeed.unrestricted,
|
||||||
|
);
|
||||||
|
final boxFit = BoxFit.contain;
|
||||||
|
|
||||||
void foundCode(BarcodeCapture bcode) {
|
void foundCode(BarcodeCapture bcode) {
|
||||||
if (bcode.barcodes.first.rawValue != null) {
|
if (bcode.barcodes.first.rawValue != null) {
|
||||||
@@ -46,31 +47,39 @@ class _LoyaltyCardsState extends State<LoyaltyCards> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void openscanner() {
|
void openscanner() async {
|
||||||
showDialog(
|
if (MzanziInnovationHub.of(context)!.theme.getPlatform() == "Web") {
|
||||||
barrierDismissible: false,
|
print("================ Web ====================");
|
||||||
context: context,
|
print("here 1");
|
||||||
builder: (context) {
|
try {
|
||||||
return MIHWindow(
|
String? res = await SimpleBarcodeScanner.scanBarcode(
|
||||||
fullscreen: false,
|
context,
|
||||||
windowTitle: "Scanner",
|
barcodeAppBar: const BarcodeAppBar(
|
||||||
windowBody: [
|
appBarTitle: 'Scan Barcode',
|
||||||
Expanded(
|
centerTitle: true,
|
||||||
child: MobileScanner(
|
enableBackButton: true,
|
||||||
controller: scannerController,
|
backButtonIcon: Icon(Icons.arrow_back),
|
||||||
onDetect: foundCode,
|
|
||||||
),
|
),
|
||||||
),
|
isShowFlashIcon: true,
|
||||||
],
|
delayMillis: 500,
|
||||||
windowTools: [],
|
cameraFace: CameraFace.back,
|
||||||
onWindowTapClose: () {
|
scanFormat: ScanFormat.ONLY_BARCODE,
|
||||||
scannerController.stop();
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
},
|
if (res != null) {
|
||||||
|
setState(() {
|
||||||
|
cardNumberController.text = res;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
print(error);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pushNamed(
|
||||||
|
'/scanner',
|
||||||
|
arguments: cardNumberController,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void addCardWindow(BuildContext ctxt) {
|
void addCardWindow(BuildContext ctxt) {
|
||||||
showDialog(
|
showDialog(
|
||||||
@@ -145,48 +154,8 @@ class _LoyaltyCardsState extends State<LoyaltyCards> {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
MIHButton(
|
MIHButton(
|
||||||
onTap:
|
onTap: () async {
|
||||||
// () async {
|
openscanner();
|
||||||
// String bcodeScanResults;
|
|
||||||
// try {
|
|
||||||
// bcodeScanResults = await FlutterBarcodeScanner.scanBarcode(
|
|
||||||
// '#ff6666',
|
|
||||||
// 'Cancel',
|
|
||||||
// true,
|
|
||||||
// ScanMode.BARCODE,
|
|
||||||
// );
|
|
||||||
// } on PlatformException {
|
|
||||||
// bcodeScanResults = "Platform not supported";
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (!mounted) return;
|
|
||||||
// setState(() {
|
|
||||||
// cardNumberController.text = bcodeScanResults;
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
// () {
|
|
||||||
// openscanner();
|
|
||||||
// },
|
|
||||||
() async {
|
|
||||||
print("here");
|
|
||||||
String? res = await SimpleBarcodeScanner.scanBarcode(
|
|
||||||
context,
|
|
||||||
barcodeAppBar: const BarcodeAppBar(
|
|
||||||
appBarTitle: 'Scan Bardcode',
|
|
||||||
centerTitle: true,
|
|
||||||
enableBackButton: true,
|
|
||||||
backButtonIcon: Icon(Icons.arrow_back),
|
|
||||||
),
|
|
||||||
isShowFlashIcon: true,
|
|
||||||
delayMillis: 500,
|
|
||||||
cameraFace: CameraFace.back,
|
|
||||||
scanFormat: ScanFormat.ONLY_BARCODE,
|
|
||||||
);
|
|
||||||
if (res != null) {
|
|
||||||
setState(() {
|
|
||||||
cardNumberController.text = res;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
buttonText: "Scan",
|
buttonText: "Scan",
|
||||||
buttonColor:
|
buttonColor:
|
||||||
|
|||||||
Reference in New Issue
Block a user