Navaron Bracke

forward the current torch state on iOS / MacOS

... ... @@ -259,7 +259,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C80D4294CF70F00263BE5 = {
... ...
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
... ...
... ... @@ -283,13 +283,12 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
// as this does not change the configuration of the hardware camera.
let dimensions = CMVideoFormatDescriptionGetDimensions(
device.activeFormat.formatDescription)
let hasTorch = device.hasTorch
completion(
MobileScannerStartParameters(
width: Double(dimensions.height),
height: Double(dimensions.width),
hasTorch: hasTorch,
currentTorchState: device.hasTorch ? device.torchMode.rawValue : -1,
textureId: self.textureId ?? 0
)
)
... ... @@ -459,7 +458,7 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
struct MobileScannerStartParameters {
var width: Double = 0.0
var height: Double = 0.0
var hasTorch = false
var currentTorchState: Int = -1
var textureId: Int64 = 0
}
}
... ...
... ... @@ -125,7 +125,8 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin {
result([
"textureId": parameters.textureId,
"size": ["width": parameters.width, "height": parameters.height],
"torchable": parameters.hasTorch])
"currentTorchState": parameters.currentTorchState,
])
}
}
} catch MobileScannerError.alreadyStarted {
... ...
... ... @@ -326,7 +326,12 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
captureSession!.startRunning()
let dimensions = CMVideoFormatDescriptionGetDimensions(device.activeFormat.formatDescription)
let size = ["width": Double(dimensions.width), "height": Double(dimensions.height)]
let answer: [String : Any?] = ["textureId": textureId, "size": size, "torchable": device.hasTorch]
let answer: [String : Any?] = [
"textureId": textureId,
"size": size,
"currentTorchState": device.hasTorch ? device.torchMode.rawValue : -1,
]
result(answer)
}
... ...