feat: Separate usecases (decouple microphone, video, photo) (#168)
* Add props * add props (iOS) * Add use-cases conditionally * Update CameraView+RecordVideo.swift * Update RecordingSession.swift * reconfigure on change * Throw correct errors * Check for audio permission * Move `#if` outward * Throw appropriate errors * Update CameraView+RecordVideo.swift * fix Splashscreen * Dynamic filePath * Fix video extension * add `avci` and `m4v` file types * Fix RecordVideo errors * Fix audio setup * Enable `photo`, `video` and `audio` * Check for `video={true}` in frameProcessor * format * Remove unused DispatchQueue * Update docs * Add `supportsPhotoAndVideoCapture` * Fix view manager * Fix error not being propagated * Catch normal errors too * Update DEVICES.mdx * Update CAPTURING.mdx * Update classdocs
This commit is contained in:
38
ios/React Utils/Callback.swift
Normal file
38
ios/React Utils/Callback.swift
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Callback.swift
|
||||
// VisionCamera
|
||||
//
|
||||
// Created by Marc Rousavy on 07.06.21.
|
||||
// Copyright © 2021 mrousavy. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
/**
|
||||
Represents a callback to JavaScript. Syntax is the same as with Promise.
|
||||
*/
|
||||
class Callback {
|
||||
init(_ callback: @escaping RCTResponseSenderBlock) {
|
||||
self.callback = callback
|
||||
}
|
||||
|
||||
func reject(error: CameraError, cause: NSError?) {
|
||||
callback([NSNull(), makeReactError(error, cause: cause)])
|
||||
}
|
||||
|
||||
func reject(error: CameraError) {
|
||||
reject(error: error, cause: nil)
|
||||
}
|
||||
|
||||
func resolve(_ value: Any?) {
|
||||
callback([value, NSNull()])
|
||||
}
|
||||
|
||||
func resolve() {
|
||||
resolve(nil)
|
||||
}
|
||||
|
||||
// MARK: Private
|
||||
|
||||
private let callback: RCTResponseSenderBlock
|
||||
}
|
Reference in New Issue
Block a user