Merge branch 'barcode_scanner' into 'master'

Barcode scanner

See merge request Cloud_Solution/driver-app!119
nav_issue
Elham 5 years ago
commit 38a57ad7c4

@ -45,5 +45,7 @@
<string>Needed to access location</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Needed to access location</string>
<key>NSCameraUsageDescription</key>
<string>Camera permission is required for barcode scanning.</string>
</dict>
</plist>

@ -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<DashboardScreen> {
}
_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<String> 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.';
}
}
}

@ -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: <Widget>[
Container(
margin: EdgeInsets.only(left: 15),
child: Row(
children: <Widget>[
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: <Widget>[
Container(
margin: EdgeInsets.only(left: 15),
child: Row(
children: <Widget>[
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: <Widget>[
Container(
margin: EdgeInsets.only(left: 15),
child: Row(
children: <Widget>[
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,
),
],
),
),
],
),
),

@ -76,6 +76,9 @@ dependencies:
gradient_app_bar: ^0.1.3
app_settings: ^4.0.3
#Barcode Scanner
flutter_barcode_scanner: ^1.0.1

Loading…
Cancel
Save