From 001124b271003064d609e85edf8d33acaa2a5d57 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 8 Nov 2020 12:36:34 +0200 Subject: [PATCH 1/2] make the scan using barcode and qr code --- ios/Runner/Info.plist | 2 ++ lib/pages/dashboard/dashboard_screen.dart | 35 +++++++++++++---------- pubspec.yaml | 3 ++ 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index b980cec..f4328ea 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -45,5 +45,7 @@ Needed to access location NSLocationWhenInUseUsageDescription Needed to access location + NSCameraUsageDescription + Camera permission is required for barcode scanning. diff --git a/lib/pages/dashboard/dashboard_screen.dart b/lib/pages/dashboard/dashboard_screen.dart index 581d1cf..d2f38ff 100644 --- a/lib/pages/dashboard/dashboard_screen.dart +++ b/lib/pages/dashboard/dashboard_screen.dart @@ -1,4 +1,3 @@ -import 'package:barcode_scan/platform_wrapper.dart'; import 'package:driverapp/config/config.dart'; import 'package:driverapp/config/size_config.dart'; import 'package:driverapp/core/enum/viewstate.dart'; @@ -17,6 +16,8 @@ import 'package:driverapp/widgets/others/app_scaffold_widget.dart'; import 'package:driverapp/widgets/others/network_base_view.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; @@ -564,20 +565,24 @@ class _DashboardScreenState extends State { } _scanQrAndGetPatient(BuildContext context, OrdersViewModel model) async { - /// When give qr we will change this method to get data - /// var result = await BarcodeScanner.scan(); - /// int patientID = get from qr result - var result = await BarcodeScanner.scan(); - // if (result.rawContent == "") { - List listOfParams = result.rawContent.split(','); - ScanQrRequestModel _scanQrRequestModel = ScanQrRequestModel( - deliveryOrderID: int.parse(listOfParams[0]), groupID: 0); - String patientType = "1"; - await model.insertOrder(_scanQrRequestModel); - if (model.state == ViewState.ErrorLocal) { - Utils.showErrorToast(model.error); - } else { - AppToast.showSuccessToast(message: "Order Added"); + String barcodeScanRes; + + try { + barcodeScanRes = await FlutterBarcodeScanner.scanBarcode( + "#ff6666", "Cancel", true, ScanMode.QR); + print(barcodeScanRes); + ScanQrRequestModel _scanQrRequestModel = ScanQrRequestModel( + deliveryOrderID: int.parse(barcodeScanRes), groupID: 0); + String patientType = "1"; + await model.insertOrder(_scanQrRequestModel); + if (model.state == ViewState.ErrorLocal) { + Utils.showErrorToast(model.error); + } else { + AppToast.showSuccessToast(message: "Order Added"); + } + } on PlatformException { + Utils.showErrorToast("Failed to get platform version."); + // barcodeScanRes = 'Failed to get platform version.'; } } } diff --git a/pubspec.yaml b/pubspec.yaml index 90596bc..f9cbf22 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -76,6 +76,9 @@ dependencies: gradient_app_bar: ^0.1.3 app_settings: ^4.0.3 + #Barcode Scanner + flutter_barcode_scanner: ^1.0.1 + From 53e444d5b468aab32c8409671d231a46370d36a4 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 8 Nov 2020 16:15:03 +0200 Subject: [PATCH 2/2] remove options from setting page --- lib/pages/setting/setting_page.dart | 144 +--------------------------- 1 file changed, 4 insertions(+), 140 deletions(-) diff --git a/lib/pages/setting/setting_page.dart b/lib/pages/setting/setting_page.dart index 860db75..a7f5389 100644 --- a/lib/pages/setting/setting_page.dart +++ b/lib/pages/setting/setting_page.dart @@ -26,13 +26,12 @@ class SettingPage extends StatelessWidget { isAppBarGradient: true, body: SingleChildScrollView( child: Container( + height: MediaQuery.of(context).size.height, decoration: BoxDecoration( gradient: LinearGradient( // 10% of the width, so there are ten blinds. - colors: [ - const Color(0xff45B7AE), - const Color(0xff119FA9) - ], //[const Color(0xff30B7B9), const Color(0xff3AB2AD)], // whitish to gray + colors: [const Color(0xff45B7AE), const Color(0xff119FA9)], + //[const Color(0xff30B7B9), const Color(0xff3AB2AD)], // whitish to gray tileMode: TileMode.clamp, // repeats the gradient over the canvas ), ), @@ -114,7 +113,7 @@ class SettingPage extends StatelessWidget { ), SizedBox( width: - MediaQuery.of(context).size.width * 0.05, + MediaQuery.of(context).size.width * 0.05, ), Text( TranslationBase.of(context).logout, @@ -140,141 +139,6 @@ class SettingPage extends StatelessWidget { ], ), ), - SizedBox( - height: MediaQuery.of(context).size.width * 0.05, - ), - InkWell( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(left: 15), - child: Row( - children: [ - Icon( - DriverApp.language_icon, - size: 40, - color: Colors.white, - ), - SizedBox( - width: - MediaQuery.of(context).size.width * 0.05, - ), - Text( - TranslationBase.of(context).languageText, - style: TextStyle( - fontWeight: FontWeight.w500, - color: Colors.white, - fontSize: 18), - ), - ], - ), - ), - SizedBox( - height: 10.0, - child: Center( - child: Container( - margin: EdgeInsetsDirectional.only( - start: 0, end: 30), - height: 1.0, - color: Colors.white, - ), - ), - ), - SizedBox( - height: MediaQuery.of(context).size.width * 0.05, - ), - ], - ), - ), - InkWell( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(left: 15), - child: Row( - children: [ - Icon( - DriverApp.settings_icon, - size: 40, - color: Colors.white, - ), - SizedBox( - width: - MediaQuery.of(context).size.width * 0.05, - ), - Text( - TranslationBase.of(context).settings, - style: TextStyle( - fontWeight: FontWeight.w500, - color: Colors.white, - fontSize: 18), - ), - ], - ), - ), - SizedBox( - height: 10.0, - child: Center( - child: Container( - margin: EdgeInsetsDirectional.only( - start: 0, end: 30), - height: 1.0, - color: Colors.white, - ), - ), - ), - SizedBox( - height: MediaQuery.of(context).size.width * 0.05, - ), - ], - ), - ), - InkWell( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(left: 15), - child: Row( - children: [ - Icon( - DriverApp.bell_icon, - size: 40, - color: Colors.white, - ), - SizedBox( - width: - MediaQuery.of(context).size.width * 0.05, - ), - Text( - TranslationBase.of(context).notification, - style: TextStyle( - fontWeight: FontWeight.w500, - color: Colors.white, - fontSize: 18), - ), - ], - ), - ), - SizedBox( - height: 10.0, - child: Center( - child: Container( - margin: EdgeInsetsDirectional.only( - start: 0, end: 30), - height: 1.0, - color: Colors.white, - ), - ), - ), - SizedBox( - height: MediaQuery.of(context).size.width * 0.05, - ), - ], - ), - ), ], ), ),