瀏覽代碼

camera flip addition

flutter-beta
TheJuliuscanute 7 年之前
父節點
當前提交
06bb45d4d9
共有 14 個文件被更改,包括 139 次插入77 次删除
  1. +8
    -0
      .packages
  2. +4
    -0
      CHANGELOG.md
  3. +0
    -1
      README.md
  4. +3
    -8
      android/src/main/kotlin/net/touchcapture/qr/flutterqr/FlutterQrPlugin.kt
  5. +17
    -0
      android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt
  6. +18
    -1
      example/README.md
  7. +41
    -48
      example/ios/Runner.xcodeproj/project.pbxproj
  8. +1
    -1
      example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
  9. +9
    -9
      example/ios/Runner/Info.plist
  10. +18
    -1
      example/lib/main.dart
  11. +13
    -5
      ios/Classes/QRView.swift
  12. +2
    -2
      ios/Classes/SwiftFlutterQrPlugin.swift
  13. +4
    -0
      lib/qr_code_scanner.dart
  14. +1
    -1
      pubspec.yaml

+ 8
- 0
.packages 查看文件

@@ -0,0 +1,8 @@
# Generated by pub on 2019-06-17 18:43:06.495486.
collection:file:///Users/juliuscanute/Library/CrossPlatform/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib/
flutter:file:///Users/juliuscanute/Library/CrossPlatform/flutter/packages/flutter/lib/
meta:file:///Users/juliuscanute/Library/CrossPlatform/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.6/lib/
sky_engine:file:///Users/juliuscanute/Library/CrossPlatform/flutter/bin/cache/pkg/sky_engine/lib/
typed_data:file:///Users/juliuscanute/Library/CrossPlatform/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib/
vector_math:file:///Users/juliuscanute/Library/CrossPlatform/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/
qr_code_scanner:lib/

+ 4
- 0
CHANGELOG.md 查看文件

@@ -1,3 +1,7 @@
## 0.0.6

* camera flip added

## 0.0.5

* preview stretching after change screen orientation fix


+ 0
- 1
README.md 查看文件

@@ -7,6 +7,5 @@ This package wires the PlatformView corresponding to iOS and Android inside flut
* Special Thanks To: LeonDevLifeLog for his contributions towards improving this package.

#TODO'S:
* Add support to flip camera view.
* iOS Native embedding is written to match what is supported in the framework as of the date of publication of this package. It needs to be improved as the framework support improves.
* Finally, I welcome PR's to make it better :), thanks

+ 3
- 8
android/src/main/kotlin/net/touchcapture/qr/flutterqr/FlutterQrPlugin.kt 查看文件

@@ -1,10 +1,6 @@
package net.touchcapture.qr.flutterqr

import android.app.Activity
import android.app.Application
import android.os.Bundle
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result
import io.flutter.plugin.common.PluginRegistry.Registrar
@@ -21,10 +17,9 @@ class FlutterQrPlugin : MethodCallHandler {
}

override fun onMethodCall(call: MethodCall, result: Result) {
if (call.method == "getPlatformVersion") {
result.success("Android ${android.os.Build.VERSION.RELEASE}")
} else {
result.notImplemented()
when {
call.method == "getPlatformVersion" -> result.success("Android ${android.os.Build.VERSION.RELEASE}")
else -> result.notImplemented()
}
}
}

+ 17
- 0
android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt 查看文件

@@ -10,6 +10,7 @@ import android.os.Build
import android.os.Bundle
import android.view.View
import com.google.zxing.ResultPoint
import android.hardware.Camera.CameraInfo
import com.journeyapps.barcodescanner.BarcodeCallback
import com.journeyapps.barcodescanner.BarcodeResult
import com.journeyapps.barcodescanner.BarcodeView
@@ -66,6 +67,19 @@ class QRView(context: Context, private val registrar: PluginRegistry.Registrar,
})
}

fun flipCamera() {
barcodeView?.pause()
var settings = barcodeView?.cameraSettings

if(settings?.requestedCameraId == CameraInfo.CAMERA_FACING_FRONT)
settings?.requestedCameraId = CameraInfo.CAMERA_FACING_BACK
else
settings?.requestedCameraId = CameraInfo.CAMERA_FACING_FRONT

barcodeView?.cameraSettings = settings
barcodeView?.resume()
}


override fun getView(): View {
return initBarCodeView()?.apply {
@@ -120,6 +134,9 @@ class QRView(context: Context, private val registrar: PluginRegistry.Registrar,
"checkAndRequestPermission" -> {
checkAndRequestPermission(result)
}
"flipCamera" -> {
flipCamera()
}
}
}



+ 18
- 1
example/README.md 查看文件

@@ -39,6 +39,7 @@ class QRViewExample extends StatefulWidget {
class _QRViewExampleState extends State<QRViewExample> {
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
var qrText = "";
QRViewController controller;
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -52,7 +53,22 @@ class _QRViewExampleState extends State<QRViewExample> {
flex: 4,
),
Expanded(
child: Text("This is the result of scan: $qrText"),
child: Column(children:
<Widget>[
Text("This is the result of scan: $qrText"),
RaisedButton(
onPressed: (){
if(controller != null){
controller.flipCamera();
}
},
child: Text(
'Flip',
style: TextStyle(fontSize: 20)
),
)
],
),
flex: 1,
)
],
@@ -63,6 +79,7 @@ class _QRViewExampleState extends State<QRViewExample> {
void _onQRViewCreated(QRViewController controller) {
final channel = controller.channel;
controller.init(qrKey);
this.controller = controller;
channel.setMethodCallHandler((MethodCall call) async {
switch (call.method) {
case "onRecognizeQR":


+ 41
- 48
example/ios/Runner.xcodeproj/project.pbxproj 查看文件

@@ -8,13 +8,11 @@

/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
72CA4F8FC83C02C1B0C5292A /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D115C5DD3945F9758AB33CE2 /* Pods_Runner.framework */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
875CEA4621CCA9620072C5B9 /* MTBBarcodeScanner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 875CEA4521CCA9620072C5B9 /* MTBBarcodeScanner.framework */; };
90416EE8981E3A39D474076A /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18FDEF8746A8853DC11EEA49 /* Pods_Runner.framework */; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
@@ -40,15 +38,11 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
18FDEF8746A8853DC11EEA49 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
875CEA4221CCA33A0072C5B9 /* MTBBarcodeScanner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MTBBarcodeScanner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
875CEA4521CCA9620072C5B9 /* MTBBarcodeScanner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MTBBarcodeScanner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
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>"; };
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
@@ -57,6 +51,7 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
D115C5DD3945F9758AB33CE2 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
@@ -64,29 +59,25 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
875CEA4621CCA9620072C5B9 /* MTBBarcodeScanner.framework in Frameworks */,
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
90416EE8981E3A39D474076A /* Pods_Runner.framework in Frameworks */,
72CA4F8FC83C02C1B0C5292A /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
59377A0B384FA8EFF7C11C6F /* Frameworks */ = {
0972BCF1757D16A75C3EC240 /* Pods */ = {
isa = PBXGroup;
children = (
875CEA4521CCA9620072C5B9 /* MTBBarcodeScanner.framework */,
18FDEF8746A8853DC11EEA49 /* Pods_Runner.framework */,
);
name = Frameworks;
name = Pods;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
@@ -100,12 +91,11 @@
97C146E51CF9000F007C117D = {
isa = PBXGroup;
children = (
875CEA4221CCA33A0072C5B9 /* MTBBarcodeScanner.framework */,
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
E0C0CF8E7F3368743823A4D6 /* Pods */,
59377A0B384FA8EFF7C11C6F /* Frameworks */,
0972BCF1757D16A75C3EC240 /* Pods */,
EA94796F93C587B741C39DDE /* Frameworks */,
);
sourceTree = "<group>";
};
@@ -140,11 +130,12 @@
name = "Supporting Files";
sourceTree = "<group>";
};
E0C0CF8E7F3368743823A4D6 /* Pods */ = {
EA94796F93C587B741C39DDE /* Frameworks */ = {
isa = PBXGroup;
children = (
D115C5DD3945F9758AB33CE2 /* Pods_Runner.framework */,
);
name = Pods;
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
@@ -154,14 +145,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
0F3EF80A2505CFA7161E4046 /* [CP] Check Pods Manifest.lock */,
3C208BB7148E708611B40C3B /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
5694CD6E1A5E2C175A82230C /* [CP] Embed Pods Frameworks */,
826384570F6676587F6C98F0 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@@ -178,19 +169,19 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1010;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "The Chromium Authors";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = W5L5PDU89L;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
};
};
};
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
@@ -214,7 +205,6 @@
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -222,43 +212,43 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
0F3EF80A2505CFA7161E4046 /* [CP] Check Pods Manifest.lock */ = {
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
name = "Thin Binary";
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;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
3C208BB7148E708611B40C3B /* [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 = (
);
name = "Thin Binary";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
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;
};
5694CD6E1A5E2C175A82230C /* [CP] Embed Pods Frameworks */ = {
826384570F6676587F6C98F0 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
@@ -269,7 +259,7 @@
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
"${BUILT_PRODUCTS_DIR}/MTBBarcodeScanner/MTBBarcodeScanner.framework",
"${BUILT_PRODUCTS_DIR}/flutter_qr/flutter_qr.framework",
"${BUILT_PRODUCTS_DIR}/qr_code_scanner/qr_code_scanner.framework",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
@@ -277,7 +267,7 @@
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MTBBarcodeScanner.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_qr.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/qr_code_scanner.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -337,6 +327,7 @@
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
@@ -400,9 +391,9 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = net.touchcapture;
PRODUCT_BUNDLE_IDENTIFIER = net.touch.capture;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
};
name = Profile;
@@ -412,6 +403,7 @@
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
@@ -468,6 +460,7 @@
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
@@ -533,11 +526,11 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = net.touchcapture;
PRODUCT_BUNDLE_IDENTIFIER = net.touch.capture;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
@@ -561,10 +554,10 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = net.touchcapture;
PRODUCT_BUNDLE_IDENTIFIER = net.touch.capture;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;


+ 1
- 1
example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme 查看文件

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"


+ 9
- 9
example/ios/Runner/Info.plist 查看文件

@@ -2,15 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSCameraUsageDescription</key>
<string>Can we access your camera in order to scan barcodes?</string>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
<key>io.flutter.embedded_views_preview</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
@@ -31,6 +22,13 @@
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>Can we access your camera in order to scan barcodes?</string>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
@@ -50,5 +48,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>io.flutter.embedded_views_preview</key>
<true/>
</dict>
</plist>

+ 18
- 1
example/lib/main.dart 查看文件

@@ -16,6 +16,7 @@ class QRViewExample extends StatefulWidget {
class _QRViewExampleState extends State<QRViewExample> {
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
var qrText = "";
QRViewController controller;
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -29,7 +30,22 @@ class _QRViewExampleState extends State<QRViewExample> {
flex: 4,
),
Expanded(
child: Text("This is the result of scan: $qrText"),
child: Column(children:
<Widget>[
Text("This is the result of scan: $qrText"),
RaisedButton(
onPressed: (){
if(controller != null){
controller.flipCamera();
}
},
child: Text(
'Flip',
style: TextStyle(fontSize: 20)
),
)
],
),
flex: 1,
)
],
@@ -40,6 +56,7 @@ class _QRViewExampleState extends State<QRViewExample> {
void _onQRViewCreated(QRViewController controller) {
final channel = controller.channel;
controller.init(qrKey);
this.controller = controller;
channel.setMethodCallHandler((MethodCall call) async {
switch (call.method) {
case "onRecognizeQR":


+ 13
- 5
ios/Classes/QRView.swift 查看文件

@@ -42,12 +42,16 @@ public class QRView:NSObject,FlutterPlatformView {
public func view() -> UIView {
channel.setMethodCallHandler({
[weak self] (call: FlutterMethodCall, result: FlutterResult) -> Void in
guard call.method == "setDimensions" else {
result(FlutterMethodNotImplemented)
return
switch(call.method){
case "setDimensions":
var arguments = call.arguments as! Dictionary<String, Double>
self?.setDimensions(width: arguments["width"] ?? 0,height: arguments["height"] ?? 0)
case "flipCamera":
self?.flipCamera()
default:
result(FlutterMethodNotImplemented)
return
}
var arguments = call.arguments as! Dictionary<String, Double>
self?.setDimensions(width: arguments["width"] ?? 0,height: arguments["height"] ?? 0)
})
return previewView
}
@@ -57,4 +61,8 @@ public class QRView:NSObject,FlutterPlatformView {
scanner = MTBBarcodeScanner(previewView: previewView)
MTBBarcodeScanner.requestCameraPermission(success: isCameraAvailable)
}
func flipCamera(){
scanner?.flipCamera()
}
}

+ 2
- 2
ios/Classes/SwiftFlutterQrPlugin.swift 查看文件

@@ -2,6 +2,7 @@ import Flutter
import UIKit

public class SwiftFlutterQrPlugin: NSObject, FlutterPlugin {

var factory: QRViewFactory
public init(with registrar: FlutterPluginRegistrar) {
self.factory = QRViewFactory(withRegistrar: registrar)
@@ -13,10 +14,9 @@ public class SwiftFlutterQrPlugin: NSObject, FlutterPlugin {
}
public func applicationDidEnterBackground(_ application: UIApplication) {
}

public func applicationWillTerminate(_ application: UIApplication) {
}

}

+ 4
- 0
lib/qr_code_scanner.dart 查看文件

@@ -82,4 +82,8 @@ class QRViewController {
{"width": renderBox.size.width, "height": renderBox.size.height});
}
}

void flipCamera(){
channel.invokeMethod("flipCamera");
}
}

+ 1
- 1
pubspec.yaml 查看文件

@@ -1,6 +1,6 @@
name: qr_code_scanner
description: QR code scanner that can be embedded inside flutter. It uses zxing in Android and MTBBarcode scanner in iOS.
version: 0.0.5
version: 0.0.6
author: Julius Canute<juliuscanute[*]touchcapture.net>
homepage: https://github.com/juliuscanute/qr_code_scanner



Loading…
取消
儲存