Navaron Bracke

forward the current torch state on iOS / MacOS

@@ -259,7 +259,7 @@ @@ -259,7 +259,7 @@
259 isa = PBXProject; 259 isa = PBXProject;
260 attributes = { 260 attributes = {
261 LastSwiftUpdateCheck = 0920; 261 LastSwiftUpdateCheck = 0920;
262 - LastUpgradeCheck = 1430; 262 + LastUpgradeCheck = 1510;
263 ORGANIZATIONNAME = ""; 263 ORGANIZATIONNAME = "";
264 TargetAttributes = { 264 TargetAttributes = {
265 331C80D4294CF70F00263BE5 = { 265 331C80D4294CF70F00263BE5 = {
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <Scheme 2 <Scheme
3 - LastUpgradeVersion = "1430" 3 + LastUpgradeVersion = "1510"
4 version = "1.3"> 4 version = "1.3">
5 <BuildAction 5 <BuildAction
6 parallelizeBuildables = "YES" 6 parallelizeBuildables = "YES"
@@ -283,13 +283,12 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega @@ -283,13 +283,12 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
283 // as this does not change the configuration of the hardware camera. 283 // as this does not change the configuration of the hardware camera.
284 let dimensions = CMVideoFormatDescriptionGetDimensions( 284 let dimensions = CMVideoFormatDescriptionGetDimensions(
285 device.activeFormat.formatDescription) 285 device.activeFormat.formatDescription)
286 - let hasTorch = device.hasTorch  
287 286
288 completion( 287 completion(
289 MobileScannerStartParameters( 288 MobileScannerStartParameters(
290 width: Double(dimensions.height), 289 width: Double(dimensions.height),
291 height: Double(dimensions.width), 290 height: Double(dimensions.width),
292 - hasTorch: hasTorch, 291 + currentTorchState: device.hasTorch ? device.torchMode.rawValue : -1,
293 textureId: self.textureId ?? 0 292 textureId: self.textureId ?? 0
294 ) 293 )
295 ) 294 )
@@ -459,7 +458,7 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega @@ -459,7 +458,7 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
459 struct MobileScannerStartParameters { 458 struct MobileScannerStartParameters {
460 var width: Double = 0.0 459 var width: Double = 0.0
461 var height: Double = 0.0 460 var height: Double = 0.0
462 - var hasTorch = false 461 + var currentTorchState: Int = -1
463 var textureId: Int64 = 0 462 var textureId: Int64 = 0
464 } 463 }
465 } 464 }
@@ -125,7 +125,8 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin { @@ -125,7 +125,8 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin {
125 result([ 125 result([
126 "textureId": parameters.textureId, 126 "textureId": parameters.textureId,
127 "size": ["width": parameters.width, "height": parameters.height], 127 "size": ["width": parameters.width, "height": parameters.height],
128 - "torchable": parameters.hasTorch]) 128 + "currentTorchState": parameters.currentTorchState,
  129 + ])
129 } 130 }
130 } 131 }
131 } catch MobileScannerError.alreadyStarted { 132 } catch MobileScannerError.alreadyStarted {
@@ -326,7 +326,12 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -326,7 +326,12 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
326 captureSession!.startRunning() 326 captureSession!.startRunning()
327 let dimensions = CMVideoFormatDescriptionGetDimensions(device.activeFormat.formatDescription) 327 let dimensions = CMVideoFormatDescriptionGetDimensions(device.activeFormat.formatDescription)
328 let size = ["width": Double(dimensions.width), "height": Double(dimensions.height)] 328 let size = ["width": Double(dimensions.width), "height": Double(dimensions.height)]
329 - let answer: [String : Any?] = ["textureId": textureId, "size": size, "torchable": device.hasTorch] 329 +
  330 + let answer: [String : Any?] = [
  331 + "textureId": textureId,
  332 + "size": size,
  333 + "currentTorchState": device.hasTorch ? device.torchMode.rawValue : -1,
  334 + ]
330 result(answer) 335 result(answer)
331 } 336 }
332 337