瀏覽代碼

flash light support added

flutter-beta
TheJuliuscanute 7 年之前
父節點
當前提交
7f431827c6
共有 7 個檔案被更改,包括 39 行新增6 行删除
  1. +4
    -0
      CHANGELOG.md
  2. +10
    -0
      android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt
  3. +3
    -3
      example/README.md
  4. +1
    -1
      example/lib/main.dart
  5. +15
    -1
      ios/Classes/QRView.swift
  6. +5
    -0
      lib/qr_code_scanner.dart
  7. +1
    -1
      pubspec.yaml

+ 4
- 0
CHANGELOG.md 查看文件

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

* flash light support added

## 0.0.6 ## 0.0.6


* camera flip added * camera flip added


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

@@ -80,6 +80,13 @@ class QRView(context: Context, private val registrar: PluginRegistry.Registrar,
barcodeView?.resume() barcodeView?.resume()
} }


fun flipFlash() {
barcodeView?.pause()
var settings = barcodeView?.cameraSettings
settings?.isAutoTorchEnabled = ! (settings?.isAutoTorchEnabled?:false)
barcodeView?.resume()
}



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




+ 3
- 3
example/README.md 查看文件

@@ -1,9 +1,9 @@
# qr_code_scanner # qr_code_scanner


Demonstrates how to use the qr_code_scanner plugin. Demonstrates how to use the qr_code_scanner plugin.
##iOS Support:


###info.plist
## iOS Support:
### info.plist
```xml ```xml
<dict> <dict>
<key>io.flutter.embedded_views_preview</key> <key>io.flutter.embedded_views_preview</key>
@@ -19,7 +19,7 @@ Demonstrates how to use the qr_code_scanner plugin.


``` ```


##Example:
## Example:
```dart ```dart
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';


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

@@ -36,7 +36,7 @@ class _QRViewExampleState extends State<QRViewExample> {
RaisedButton( RaisedButton(
onPressed: (){ onPressed: (){
if(controller != null){ if(controller != null){
controller.flipCamera();
controller.flipFlash();
} }
}, },
child: Text( child: Text(


+ 15
- 1
ios/Classes/QRView.swift 查看文件

@@ -48,6 +48,8 @@ public class QRView:NSObject,FlutterPlatformView {
self?.setDimensions(width: arguments["width"] ?? 0,height: arguments["height"] ?? 0) self?.setDimensions(width: arguments["width"] ?? 0,height: arguments["height"] ?? 0)
case "flipCamera": case "flipCamera":
self?.flipCamera() self?.flipCamera()
case "flipFlash":
self?.flipFlash()
default: default:
result(FlutterMethodNotImplemented) result(FlutterMethodNotImplemented)
return return
@@ -63,6 +65,18 @@ public class QRView:NSObject,FlutterPlatformView {
} }
func flipCamera(){ func flipCamera(){
scanner?.flipCamera()
if let sc: MTBBarcodeScanner = scanner {
if sc.hasOppositeCamera() {
sc.flipCamera()
}
}
}
func flipFlash(){
if let sc: MTBBarcodeScanner = scanner {
if sc.hasTorch() {
sc.toggleTorch()
}
}
} }
} }

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

@@ -86,4 +86,9 @@ class QRViewController {
void flipCamera(){ void flipCamera(){
channel.invokeMethod("flipCamera"); channel.invokeMethod("flipCamera");
} }

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

} }

+ 1
- 1
pubspec.yaml 查看文件

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




Loading…
取消
儲存