iOS: Autofix in SwiftLint
This commit is contained in:
parent
d601a8dcc9
commit
d1a2eddf47
@ -9,7 +9,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
extension CameraView {
|
extension CameraView {
|
||||||
|
|
||||||
func focus(point: CGPoint, promise: Promise) {
|
func focus(point: CGPoint, promise: Promise) {
|
||||||
withPromise(promise) {
|
withPromise(promise) {
|
||||||
guard let device = self.videoDeviceInput?.device else {
|
guard let device = self.videoDeviceInput?.device else {
|
||||||
@ -18,20 +18,20 @@ extension CameraView {
|
|||||||
if !device.isFocusPointOfInterestSupported {
|
if !device.isFocusPointOfInterestSupported {
|
||||||
throw CameraError.device(DeviceError.focusNotSupported)
|
throw CameraError.device(DeviceError.focusNotSupported)
|
||||||
}
|
}
|
||||||
|
|
||||||
let normalizedPoint = self.videoPreviewLayer.captureDevicePointConverted(fromLayerPoint: point)
|
let normalizedPoint = self.videoPreviewLayer.captureDevicePointConverted(fromLayerPoint: point)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
try device.lockForConfiguration()
|
try device.lockForConfiguration()
|
||||||
|
|
||||||
device.focusPointOfInterest = normalizedPoint
|
device.focusPointOfInterest = normalizedPoint
|
||||||
device.focusMode = .continuousAutoFocus
|
device.focusMode = .continuousAutoFocus
|
||||||
|
|
||||||
if device.isExposurePointOfInterestSupported {
|
if device.isExposurePointOfInterestSupported {
|
||||||
device.exposurePointOfInterest = normalizedPoint
|
device.exposurePointOfInterest = normalizedPoint
|
||||||
device.exposureMode = .continuousAutoExposure
|
device.exposureMode = .continuousAutoExposure
|
||||||
}
|
}
|
||||||
|
|
||||||
device.unlockForConfiguration()
|
device.unlockForConfiguration()
|
||||||
return nil
|
return nil
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -40,7 +40,7 @@ final class CameraViewManager: RCTViewManager {
|
|||||||
) as! CameraView
|
) as! CameraView
|
||||||
component.stopRecording(promise: Promise(resolver: resolve, rejecter: reject))
|
component.stopRecording(promise: Promise(resolver: resolve, rejecter: reject))
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
final func takePhoto(_ node: NSNumber, options: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
final func takePhoto(_ node: NSNumber, options: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
||||||
let component = bridge.uiManager.view(
|
let component = bridge.uiManager.view(
|
||||||
@ -48,7 +48,7 @@ final class CameraViewManager: RCTViewManager {
|
|||||||
) as! CameraView
|
) as! CameraView
|
||||||
component.takePhoto(options: options, promise: Promise(resolver: resolve, rejecter: reject))
|
component.takePhoto(options: options, promise: Promise(resolver: resolve, rejecter: reject))
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
final func focus(_ node: NSNumber, point: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
final func focus(_ node: NSNumber, point: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
||||||
let promise = Promise(resolver: resolve, rejecter: reject)
|
let promise = Promise(resolver: resolve, rejecter: reject)
|
||||||
|
@ -18,8 +18,7 @@ extension AVCaptureDevice.Format {
|
|||||||
// compare still image dimensions
|
// compare still image dimensions
|
||||||
let leftDimensions = highResolutionStillImageDimensions
|
let leftDimensions = highResolutionStillImageDimensions
|
||||||
let rightDimensions = other.highResolutionStillImageDimensions
|
let rightDimensions = other.highResolutionStillImageDimensions
|
||||||
if leftDimensions.height * leftDimensions.width > rightDimensions.height * rightDimensions.width
|
if leftDimensions.height * leftDimensions.width > rightDimensions.height * rightDimensions.width {
|
||||||
{
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,16 +26,14 @@ extension AVCaptureDevice.Format {
|
|||||||
// compare video dimensions
|
// compare video dimensions
|
||||||
let leftVideo = self.formatDescription.presentationDimensions()
|
let leftVideo = self.formatDescription.presentationDimensions()
|
||||||
let rightVideo = other.formatDescription.presentationDimensions()
|
let rightVideo = other.formatDescription.presentationDimensions()
|
||||||
if leftVideo.height * leftVideo.width > rightVideo.height * rightVideo.width
|
if leftVideo.height * leftVideo.width > rightVideo.height * rightVideo.width {
|
||||||
{
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// compare max fps
|
// compare max fps
|
||||||
if let leftMaxFps = videoSupportedFrameRateRanges.max(by: { $0.maxFrameRate > $1.maxFrameRate }),
|
if let leftMaxFps = videoSupportedFrameRateRanges.max(by: { $0.maxFrameRate > $1.maxFrameRate }),
|
||||||
let rightMaxFps = other.videoSupportedFrameRateRanges.max(by: { $0.maxFrameRate > $1.maxFrameRate })
|
let rightMaxFps = other.videoSupportedFrameRateRanges.max(by: { $0.maxFrameRate > $1.maxFrameRate }) {
|
||||||
{
|
|
||||||
if leftMaxFps.maxFrameRate > rightMaxFps.maxFrameRate {
|
if leftMaxFps.maxFrameRate > rightMaxFps.maxFrameRate {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@
|
|||||||
isa = PBXNativeTarget;
|
isa = PBXNativeTarget;
|
||||||
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "VisionCamera" */;
|
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "VisionCamera" */;
|
||||||
buildPhases = (
|
buildPhases = (
|
||||||
B81F6C7625E515810008974A /* ShellScript */,
|
B81F6C7625E515810008974A /* Run SwiftLint */,
|
||||||
58B511D71A9E6C8500147676 /* Sources */,
|
58B511D71A9E6C8500147676 /* Sources */,
|
||||||
58B511D81A9E6C8500147676 /* Frameworks */,
|
58B511D81A9E6C8500147676 /* Frameworks */,
|
||||||
58B511D91A9E6C8500147676 /* CopyFiles */,
|
58B511D91A9E6C8500147676 /* CopyFiles */,
|
||||||
@ -242,7 +242,7 @@
|
|||||||
/* End PBXProject section */
|
/* End PBXProject section */
|
||||||
|
|
||||||
/* Begin PBXShellScriptBuildPhase section */
|
/* Begin PBXShellScriptBuildPhase section */
|
||||||
B81F6C7625E515810008974A /* ShellScript */ = {
|
B81F6C7625E515810008974A /* Run SwiftLint */ = {
|
||||||
isa = PBXShellScriptBuildPhase;
|
isa = PBXShellScriptBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
@ -251,13 +251,14 @@
|
|||||||
);
|
);
|
||||||
inputPaths = (
|
inputPaths = (
|
||||||
);
|
);
|
||||||
|
name = "Run SwiftLint";
|
||||||
outputFileListPaths = (
|
outputFileListPaths = (
|
||||||
);
|
);
|
||||||
outputPaths = (
|
outputPaths = (
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
|
shellScript = "if which swiftlint >/dev/null; then\n swiftlint autocorrect && swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
|
||||||
};
|
};
|
||||||
/* End PBXShellScriptBuildPhase section */
|
/* End PBXShellScriptBuildPhase section */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user