feat: Add support for LiDAR, TrueDepth, External (USB) and Continuity Camera Devices (iOS 17) (#1824)
* feat: Add support for LiDAR, TrueDepth, External (USB) and Continuity Camera Devices (iOS 17) * Rename `devices` -> `physicalDevices` * fix: Comment out iOS 17 cameras for now * fix: Move `supportsDepthCapture` to `format` * fix: Fall back to `wide-angle-camera` for any unknown types * Update CameraPage.tsx * `descriptor` -> `physicalDeviceDescriptor` * Update CameraDevice.ts * Format * feat: Expose `userPreferredCameraDevice` Uses the new iOS 17 API where the user can prefer a default device, otherwise fall back to the first device of the available ones * fix: Expose as property * Add TODO comments * fix: Format code * fix: Compile below Swift 5.9
This commit is contained in:
@@ -73,7 +73,15 @@ class CameraDevicesManager(private val reactContext: ReactApplicationContext) :
|
||||
|
||||
override fun hasConstants(): Boolean = true
|
||||
|
||||
override fun getConstants(): MutableMap<String, Any> = mutableMapOf("availableCameraDevices" to getDevicesJson())
|
||||
override fun getConstants(): MutableMap<String, Any?> {
|
||||
val devices = getDevicesJson()
|
||||
val preferredDevice = if (devices.size() > 0) devices.getMap(0) else null
|
||||
|
||||
return mutableMapOf(
|
||||
"availableCameraDevices" to devices,
|
||||
"userPreferredCameraDevice" to preferredDevice
|
||||
)
|
||||
}
|
||||
|
||||
// Required for NativeEventEmitter, this is just a dummy implementation:
|
||||
@ReactMethod
|
||||
|
@@ -183,6 +183,7 @@ class CameraDeviceDetails(private val cameraManager: CameraManager, private val
|
||||
map.putDouble("fieldOfView", getFieldOfView())
|
||||
map.putBoolean("supportsVideoHDR", supportsVideoHdr)
|
||||
map.putBoolean("supportsPhotoHDR", supportsPhotoHdr)
|
||||
map.putBoolean("supportsDepthCapture", supportsDepthCapture)
|
||||
map.putString("autoFocusSystem", "contrast-detection") // TODO: Is this wrong?
|
||||
map.putArray("videoStabilizationModes", createStabilizationModes())
|
||||
map.putArray("pixelFormats", createPixelFormats(videoSize))
|
||||
@@ -192,14 +193,13 @@ class CameraDeviceDetails(private val cameraManager: CameraManager, private val
|
||||
fun toMap(): ReadableMap {
|
||||
val map = Arguments.createMap()
|
||||
map.putString("id", cameraId)
|
||||
map.putArray("devices", getDeviceTypes())
|
||||
map.putArray("physicalDevices", getDeviceTypes())
|
||||
map.putString("position", lensFacing.unionValue)
|
||||
map.putString("name", name)
|
||||
map.putBoolean("hasFlash", hasFlash)
|
||||
map.putBoolean("hasTorch", hasFlash)
|
||||
map.putBoolean("isMultiCam", isMultiCam)
|
||||
map.putBoolean("supportsRawCapture", supportsRawCapture)
|
||||
map.putBoolean("supportsDepthCapture", supportsDepthCapture)
|
||||
map.putBoolean("supportsLowLightBoost", supportsLowLightBoost)
|
||||
map.putBoolean("supportsFocus", true) // I believe every device here supports focussing
|
||||
map.putDouble("minZoom", minZoom)
|
||||
|
Reference in New Issue
Block a user