diff --git a/CHANGELOG.md b/CHANGELOG.md index 51b2b71..9df0f11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.7 + +* flash light support added + ## 0.0.6 * camera flip added diff --git a/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt b/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt index ea54793..d6f39de 100644 --- a/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt +++ b/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() } + fun flipFlash() { + barcodeView?.pause() + var settings = barcodeView?.cameraSettings + settings?.isAutoTorchEnabled = ! (settings?.isAutoTorchEnabled?:false) + barcodeView?.resume() + } + override fun getView(): View { return initBarCodeView()?.apply { @@ -137,6 +144,9 @@ class QRView(context: Context, private val registrar: PluginRegistry.Registrar, "flipCamera" -> { flipCamera() } + "flipFlash" -> { + flipFlash() + } } } diff --git a/example/README.md b/example/README.md index 7eb0a06..2ec5a26 100644 --- a/example/README.md +++ b/example/README.md @@ -1,9 +1,9 @@ # qr_code_scanner Demonstrates how to use the qr_code_scanner plugin. -##iOS Support: -###info.plist +## iOS Support: +### info.plist ```xml io.flutter.embedded_views_preview @@ -19,7 +19,7 @@ Demonstrates how to use the qr_code_scanner plugin. ``` -##Example: +## Example: ```dart import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; diff --git a/example/lib/main.dart b/example/lib/main.dart index b4fde6a..1b39039 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -36,7 +36,7 @@ class _QRViewExampleState extends State { RaisedButton( onPressed: (){ if(controller != null){ - controller.flipCamera(); + controller.flipFlash(); } }, child: Text( diff --git a/ios/Classes/QRView.swift b/ios/Classes/QRView.swift index 121818a..76384b8 100644 --- a/ios/Classes/QRView.swift +++ b/ios/Classes/QRView.swift @@ -48,6 +48,8 @@ public class QRView:NSObject,FlutterPlatformView { self?.setDimensions(width: arguments["width"] ?? 0,height: arguments["height"] ?? 0) case "flipCamera": self?.flipCamera() + case "flipFlash": + self?.flipFlash() default: result(FlutterMethodNotImplemented) return @@ -63,6 +65,18 @@ public class QRView:NSObject,FlutterPlatformView { } 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() + } + } } } diff --git a/lib/qr_code_scanner.dart b/lib/qr_code_scanner.dart index 48ebbac..7c463a4 100644 --- a/lib/qr_code_scanner.dart +++ b/lib/qr_code_scanner.dart @@ -86,4 +86,9 @@ class QRViewController { void flipCamera(){ channel.invokeMethod("flipCamera"); } + + void flipFlash(){ + channel.invokeMethod("flipFlash"); + } + } diff --git a/pubspec.yaml b/pubspec.yaml index 6e7b112..f72b1d8 100644 --- a/pubspec.yaml +++ b/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.6 +version: 0.0.7 author: Julius Canute homepage: https://github.com/juliuscanute/qr_code_scanner