Skip to content

Commit

Permalink
更换扫码插件
Browse files Browse the repository at this point in the history
  • Loading branch information
simplezhli committed Mar 27, 2021
1 parent 2aa0681 commit 419fe19
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 73 deletions.
4 changes: 2 additions & 2 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The effect of some pages is as follows:
* Pull down to refresh + pull up to load more
* Check update
* PopupWindow
* Scan code(barcode_scan plugin)
* Scan code(qr_code_scanner plugin)
* Menu switching animation (circular diffusion, 3D flip)
* Sliding delete
* City selection
Expand Down Expand Up @@ -135,7 +135,7 @@ Web:https://simplezhli.github.io/flutter_deer/
| [date_utils](https://github.com/apptreesoftware/date_utils) | **Commonly used date tools** |
| [bezier_chart](https://github.com/aeyrium/bezier-chart) | **Bezier chart** |
| [sprintf](https://github.com/Naddiseo/dart-sprintf) | **Format String** |
| [barcode_scan](https://github.com/apptreesoftware/flutter_barcode_reader) | **Scan code** |
| [qr_code_scanner](https://github.com/juliuscanute/qr_code_scanner) | **Scan code** |
| [intl](https://github.com/dart-lang/intl) | **Localization** |
| [vibration](https://github.com/benjamindean/flutter_vibration) | **Vibration** |

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* 下拉刷新 + 上拉加载更多
* 应用检查更新
* PopupWindow
* 扫码功能(barcode_scan插件
* 扫码功能(qr_code_scanner插件
* 菜单切换动画(圆形扩散、3D翻转)
* 侧滑删除
* 城市选择
Expand Down Expand Up @@ -143,7 +143,7 @@ Web体验地址:https://simplezhli.github.io/flutter_deer/
| [date_utils](https://github.com/apptreesoftware/date_utils) | **常用的日期工具类** |
| [bezier_chart](https://github.com/aeyrium/bezier-chart) | **曲线图表** |
| [sprintf](https://github.com/Naddiseo/dart-sprintf) | **格式化String** |
| [barcode_scan](https://github.com/apptreesoftware/flutter_barcode_reader) | **扫码功能** |
| [qr_code_scanner](https://github.com/juliuscanute/qr_code_scanner) | **扫码功能** |
| [intl](https://github.com/dart-lang/intl) | **本地化** |
| [vibration](https://github.com/benjamindean/flutter_vibration) | **振动** |

Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelpe
flutter_ios_podfile_setup

target 'Runner' do
# use_frameworks!
use_frameworks!
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
Expand Down
103 changes: 72 additions & 31 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
7273ADFF2478E21800309008 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
7273AE092478E42B00309008 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7273AE072478E42B00309008 /* LaunchScreen.storyboard */; };
7273AE0A2478E42B00309008 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7273AE082478E42B00309008 /* Main.storyboard */; };
AF66A34CF69A0AD65A8B89D8 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BECCE2088C05C4D8D9015FA0 /* libPods-Runner.a */; };
BD4F247307C1B2EC10CEE075 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 242256812F0E5EC2FC55E432 /* Pods_Runner.framework */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -30,7 +30,11 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
0D45FAC02A7C4145DC023503 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
242256812F0E5EC2FC55E432 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
37E8FC7E71F65C9DD832AA03 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
42FEB795BCD522EBDFCE3114 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
7273ADEE2478DB7900309008 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
7273ADEF2478DB7900309008 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
7273ADF02478DB7900309008 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
Expand All @@ -43,38 +47,26 @@
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
B6743A8C17CF03C8D634C032 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
BD533B04B45BA6CDE9679991 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
BECCE2088C05C4D8D9015FA0 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
C5A3AE6BED88396E1F97AF4E /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
97C146EB1CF9000F007C117D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
AF66A34CF69A0AD65A8B89D8 /* libPods-Runner.a in Frameworks */,
BD4F247307C1B2EC10CEE075 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
5519C26671DDA0374F26E61C /* Frameworks */ = {
isa = PBXGroup;
children = (
BECCE2088C05C4D8D9015FA0 /* libPods-Runner.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
9707CA0EB99412E1173056F5 /* Pods */ = {
isa = PBXGroup;
children = (
B6743A8C17CF03C8D634C032 /* Pods-Runner.debug.xcconfig */,
C5A3AE6BED88396E1F97AF4E /* Pods-Runner.release.xcconfig */,
BD533B04B45BA6CDE9679991 /* Pods-Runner.profile.xcconfig */,
42FEB795BCD522EBDFCE3114 /* Pods-Runner.debug.xcconfig */,
37E8FC7E71F65C9DD832AA03 /* Pods-Runner.release.xcconfig */,
0D45FAC02A7C4145DC023503 /* Pods-Runner.profile.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
Expand All @@ -97,7 +89,7 @@
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
9707CA0EB99412E1173056F5 /* Pods */,
5519C26671DDA0374F26E61C /* Frameworks */,
EBF36AE8FFF8D2ECDFCC4D49 /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -124,21 +116,30 @@
path = Runner;
sourceTree = "<group>";
};
EBF36AE8FFF8D2ECDFCC4D49 /* Frameworks */ = {
isa = PBXGroup;
children = (
242256812F0E5EC2FC55E432 /* Pods_Runner.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
97C146ED1CF9000F007C117D /* Runner */ = {
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
4614B24191EBC1B6AD98CEF6 /* [CP] Check Pods Manifest.lock */,
C26F12588241FFAE76860EB0 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
1FC9CD116D60A071D396D7EB /* [CP] Copy Pods Resources */,
24202F6F610BDCB07C0B5A7A /* [CP] Copy Pods Resources */,
876E9B92C7728849627E2252 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -197,7 +198,7 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
1FC9CD116D60A071D396D7EB /* [CP] Copy Pods Resources */ = {
24202F6F610BDCB07C0B5A7A /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
Expand Down Expand Up @@ -229,26 +230,44 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin\n";
};
4614B24191EBC1B6AD98CEF6 /* [CP] Check Pods Manifest.lock */ = {
876E9B92C7728849627E2252 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework",
"${BUILT_PRODUCTS_DIR}/MTBBarcodeScanner/MTBBarcodeScanner.framework",
"${BUILT_PRODUCTS_DIR}/image_picker/image_picker.framework",
"${BUILT_PRODUCTS_DIR}/integration_test/integration_test.framework",
"${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework",
"${BUILT_PRODUCTS_DIR}/qr_code_scanner/qr_code_scanner.framework",
"${BUILT_PRODUCTS_DIR}/quick_actions/quick_actions.framework",
"${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework",
"${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework",
"${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework",
"${BUILT_PRODUCTS_DIR}/vibration/vibration.framework",
"${BUILT_PRODUCTS_DIR}/webview_flutter/webview_flutter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MTBBarcodeScanner.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_picker.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/integration_test.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/qr_code_scanner.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/quick_actions.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/vibration.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/webview_flutter.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
Expand All @@ -265,6 +284,28 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n";
};
C26F12588241FFAE76860EB0 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
5 changes: 4 additions & 1 deletion lib/goods/goods_router.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import 'package:fluro/fluro.dart';
import 'package:flutter_deer/goods/page/qr_code_scanner_page.dart';
import 'package:flutter_deer/routers/i_router.dart';

import 'page/goods_edit_page.dart';
Expand All @@ -16,7 +17,8 @@ class GoodsRouter implements IRouterProvider{
static String goodsSearchPage = '/goods/search';
static String goodsSizePage = '/goods/size';
static String goodsSizeEditPage = '/goods/sizeEdit';

static String qrCodeScannerPage = '/goods/qrCodeScanner';

@override
void initRouter(FluroRouter router) {
router.define(goodsPage, handler: Handler(handlerFunc: (_, __) => const GoodsPage()));
Expand All @@ -28,6 +30,7 @@ class GoodsRouter implements IRouterProvider{
router.define(goodsSearchPage, handler: Handler(handlerFunc: (_, __) => const GoodsSearchPage()));
router.define(goodsSizePage, handler: Handler(handlerFunc: (_, __) => const GoodsSizePage()));
router.define(goodsSizeEditPage, handler: Handler(handlerFunc: (_, __) => const GoodsSizeEditPage()));
router.define(qrCodeScannerPage, handler: Handler(handlerFunc: (_, __) => const QrCodeScannerPage()));
}

}
16 changes: 10 additions & 6 deletions lib/goods/page/goods_edit_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import 'package:flutter/material.dart';
import 'package:flutter_deer/goods/provider/goods_sort_provider.dart';
import 'package:flutter_deer/goods/widgets/goods_sort_bottom_sheet.dart';
import 'package:flutter_deer/routers/fluro_navigator.dart';
import 'package:flutter_deer/util/device_utils.dart';
import 'package:flutter_deer/util/theme_utils.dart';
import 'package:flutter_deer/util/other_utils.dart';
import 'package:flutter_deer/util/toast_utils.dart';
import 'package:flutter_deer/widgets/click_item.dart';
import 'package:flutter_deer/widgets/load_image.dart';
import 'package:flutter_deer/widgets/my_button.dart';
Expand Down Expand Up @@ -42,11 +43,14 @@ class _GoodsEditPageState extends State<GoodsEditPage> {
}
});
}

Future<void> _scan() async {
final code = await Utils.scan();
if (code != null) {
_codeController.text = code;

void _scan() {
if (Device.isMobile) {
NavigatorUtils.pushResult(context, GoodsRouter.qrCodeScannerPage, (Object code) {
_codeController.text = code.toString();
});
} else {
Toast.show('当前平台暂不支持');
}
}

Expand Down
73 changes: 73 additions & 0 deletions lib/goods/page/qr_code_scanner_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@


import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_deer/routers/fluro_navigator.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';

class QrCodeScannerPage extends StatefulWidget {

const QrCodeScannerPage({Key key}) : super(key: key);

@override
_QrCodeScannerPageState createState() => _QrCodeScannerPageState();
}

class _QrCodeScannerPageState extends State<QrCodeScannerPage> {
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
Barcode result;
QRViewController controller;

/// In order to get hot reload to work we need to pause the camera if the platform
/// is android, or resume the camera if the platform is iOS.
@override
void reassemble() {
super.reassemble();
if (Platform.isAndroid) {
controller.pauseCamera();
} else if (Platform.isIOS) {
controller.resumeCamera();
}
}

@override
Widget build(BuildContext context) {
final scanArea = (MediaQuery.of(context).size.width < 400 ||
MediaQuery.of(context).size.height < 400)
? 250.0
: 300.0;
return Scaffold(
body: Stack(
children: <Widget>[
Positioned.fill(
child: QRView(
key: qrKey,
onQRViewCreated: _onQRViewCreated,
overlay: QrScannerOverlayShape(
borderColor: Colors.red,
borderRadius: 10,
borderLength: 20,
borderWidth: 5,
cutOutSize: scanArea,
),
),
),
],
),
);
}

void _onQRViewCreated(QRViewController controller) {
this.controller = controller;
controller.scannedDataStream.listen((scanData) {
NavigatorUtils.goBackWithParams(context, result.code);
});
}

@override
void dispose() {
controller?.dispose();
super.dispose();
}
}
Loading

0 comments on commit 419fe19

Please sign in to comment.