forked from yaso_meth/mih-project
Merge pull request #10 from yaso-meth/mzansi-wallet-scanner-fix
mobile scanner used
This commit is contained in:
@@ -5,8 +5,9 @@ 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 'package:mobile_scanner/mobile_scanner.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;
|
||||
@@ -78,6 +79,9 @@ class _MIHHomeState extends State<MIHHome> {
|
||||
String appSearch = "";
|
||||
int amount = 10;
|
||||
final baseAPI = AppEnviroment.baseApiUrl;
|
||||
final MobileScannerController scannerController = MobileScannerController(
|
||||
// required options for the scanner
|
||||
);
|
||||
|
||||
void setAppsNewPersonal(List<MIHTile> tileList) {
|
||||
if (widget.signedInUser.fname == "") {
|
||||
@@ -333,6 +337,14 @@ class _MIHHomeState extends State<MIHHome> {
|
||||
));
|
||||
}
|
||||
|
||||
void foundCode(BarcodeCapture bcode) {
|
||||
if (bcode.barcodes.first.rawValue != null) {
|
||||
print(bcode.barcodes.first.rawValue);
|
||||
scannerController.stop();
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
||||
void setAppsDev(List<MIHTile> tileList) {
|
||||
if (AppEnviroment.getEnv() == "Dev") {
|
||||
tileList.add(MIHTile(
|
||||
@@ -350,24 +362,15 @@ class _MIHHomeState extends State<MIHHome> {
|
||||
// return const MIHErrorMessage(errorType: "Invalid Credentials");
|
||||
return MIHWindow(
|
||||
fullscreen: false,
|
||||
windowTitle:
|
||||
"Test Window title that is too large for mobile devices",
|
||||
windowTitle: "Scanner",
|
||||
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,
|
||||
height: 1000,
|
||||
child: MobileScanner(
|
||||
controller: scannerController,
|
||||
onDetect: foundCode,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
windowTools: [],
|
||||
onWindowTapClose: () {
|
||||
|
||||
@@ -4,14 +4,15 @@ import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_dropdown_input.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_text_input.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_window.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_objects/app_user.dart';
|
||||
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/components/mih_card_display.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:qr_bar_code_scanner_dialog/qr_bar_code_scanner_dialog.dart';
|
||||
import 'package:simple_barcode_scanner/simple_barcode_scanner.dart';
|
||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||
// import 'package:simple_barcode_scanner/simple_barcode_scanner.dart';
|
||||
|
||||
class LoyaltyCards extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
@@ -30,8 +31,45 @@ class _LoyaltyCardsState extends State<LoyaltyCards> {
|
||||
late Future<List<MIHLoyaltyCard>> cardList;
|
||||
//bool showSelectedCardType = false;
|
||||
final ValueNotifier<String> shopName = ValueNotifier("");
|
||||
final _qrBarCodeScannerDialogPlugin = QrBarCodeScannerDialog();
|
||||
String? code;
|
||||
final MobileScannerController scannerController = MobileScannerController();
|
||||
|
||||
void foundCode(BarcodeCapture bcode) {
|
||||
if (bcode.barcodes.first.rawValue != null) {
|
||||
setState(() {
|
||||
cardNumberController.text = bcode.barcodes.first.rawValue!;
|
||||
});
|
||||
//print(bcode.barcodes.first.rawValue);
|
||||
scannerController.stop();
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
||||
void openscanner() {
|
||||
showDialog(
|
||||
barrierDismissible: false,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return MIHWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Scanner",
|
||||
windowBody: [
|
||||
SizedBox(
|
||||
height: 1000,
|
||||
child: MobileScanner(
|
||||
controller: scannerController,
|
||||
onDetect: foundCode,
|
||||
),
|
||||
)
|
||||
],
|
||||
windowTools: [],
|
||||
onWindowTapClose: () {
|
||||
scannerController.stop();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void addCardWindow(BuildContext ctxt) {
|
||||
showDialog(
|
||||
@@ -104,26 +142,29 @@ class _LoyaltyCardsState extends State<LoyaltyCards> {
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
MIHButton(
|
||||
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;
|
||||
});
|
||||
}
|
||||
onTap: () {
|
||||
openscanner();
|
||||
},
|
||||
// () async {
|
||||
// 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",
|
||||
buttonColor:
|
||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
@@ -138,13 +179,23 @@ class _LoyaltyCardsState extends State<LoyaltyCards> {
|
||||
height: 50,
|
||||
child: MIHButton(
|
||||
onTap: () {
|
||||
MIHMzansiWalletApis.addLoyaltyCardAPICall(
|
||||
widget.signedInUser,
|
||||
widget.signedInUser.app_id,
|
||||
shopController.text,
|
||||
cardNumberController.text,
|
||||
context,
|
||||
);
|
||||
if (shopController.text == "" ||
|
||||
cardNumberController.text == "") {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MIHErrorMessage(errorType: "Input Error");
|
||||
},
|
||||
);
|
||||
} else {
|
||||
MIHMzansiWalletApis.addLoyaltyCardAPICall(
|
||||
widget.signedInUser,
|
||||
widget.signedInUser.app_id,
|
||||
shopController.text,
|
||||
cardNumberController.text,
|
||||
context,
|
||||
);
|
||||
}
|
||||
},
|
||||
buttonText: "Add",
|
||||
buttonColor:
|
||||
|
||||
@@ -9,6 +9,7 @@ import app_links
|
||||
import device_info_plus
|
||||
import firebase_core
|
||||
import geolocator_apple
|
||||
import mobile_scanner
|
||||
import no_screenshot
|
||||
import path_provider_foundation
|
||||
import printing
|
||||
@@ -22,6 +23,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
|
||||
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
|
||||
MobileScannerPlugin.register(with: registry.registrar(forPlugin: "MobileScannerPlugin"))
|
||||
NoScreenshotPlugin.register(with: registry.registrar(forPlugin: "NoScreenshotPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
PrintingPlugin.register(with: registry.registrar(forPlugin: "PrintingPlugin"))
|
||||
|
||||
@@ -720,6 +720,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
mobile_scanner:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: mobile_scanner
|
||||
sha256: "728828a798d1a2ee506beb652ca23d974c542c96ed03dcbd5eaf97bef96cdaad"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.2"
|
||||
mutex:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -960,22 +968,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
qr_bar_code_scanner_dialog:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: qr_bar_code_scanner_dialog
|
||||
sha256: dcb937816d4e562141530265bd1ca39fe00f57000fd79e26c163c957d443e9e4
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.0.5"
|
||||
qr_code_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: qr_code_scanner
|
||||
sha256: f23b68d893505a424f0bd2e324ebea71ed88465d572d26bb8d2e78a4749591fd
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
realtime_client:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -63,7 +63,7 @@ dependencies:
|
||||
youtube_player_iframe: ^5.2.0
|
||||
syncfusion_flutter_barcodes: ^26.2.10
|
||||
simple_barcode_scanner: ^0.2.5
|
||||
qr_bar_code_scanner_dialog: ^0.0.5
|
||||
mobile_scanner: ^6.0.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user