Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions DualCameraDemo/DualCameraDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSCameraUsageDescription = "This app uses your cameras to demo dual camera capture functionality";
INFOPLIST_KEY_NSPhotoLibraryAddUsageDescription = "Allow this app to save photos to your library so you can view them later.";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
Expand Down
39 changes: 25 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# DualCameraKit


![Swift](https://img.shields.io/badge/Swift-5.9-orange?logo=swift)
![SPM Compatible](https://img.shields.io/badge/SPM-Compatible-brightgreen)
![iOS](https://img.shields.io/badge/iOS-17+-lightgrey?logo=apple)
![WIP](https://img.shields.io/badge/status-WIP-yellow)
![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)


Simultaneous front & back iOS camera capture made simple.

<table>
Expand Down Expand Up @@ -92,10 +90,22 @@ targets: [

## OS/Requirements:

- Add camera permissions to your app's `Info.plist` - `Privacy - Camera Usage Description`
<img src="https://github.com/user-attachments/assets/1ef0ae3e-683c-444c-9276-4684efb08e5c" width=550 />
### Permissions

- [Required] Add camera permissions to your app's `Info.plist` - `Privacy - Camera Usage Description`
<img src="./DocumentationAssets/Setup_Permissions_Camera_Usage.png" width=550 />
- This camera permission is required because this library needs to access cameras in order to be useful.
- [Optional] Add photo library permissions to your app's `Info.plist` - `Privacy - Photo Library Additions Usage Description`
<img src="./DocumentationAssets/Setup_Permissions_Photo_Library_Additions.png" width=550 />
- This photo library addition permission is optional because you don't need to save to the user's media library after capture.
- See `videoSaveStrategy` and `photoSaveStrategy` for customizing this behavior.

- Live, nonsimulator device, iOS 17+ for camera usage (simulator uses mocked camera).
### Device

- Live, nonsimulator device, iOS 17+ for camera usage.
- The simulator uses a mocked camera.

## Importing DualCameraKit

After installation, you can import the library in your Swift files:

Expand Down Expand Up @@ -175,19 +185,19 @@ struct ContentView: View {

## `DualCameraScreen` - Parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| Parameter | Type | Default | Description |
| ----------- | --------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| `viewModel` | `DualCameraViewModel` | `.default()` | Provides complete configuration for the camera screen including layout, video recording options, and media saving strategies. |

## `DualCameraViewModel` Configuration

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `dualCameraController` | `DualCameraControlling` | Device-specific controller | Core camera controller. Uses `DualCameraMockController` on simulator and `DualCameraController` on device. |
| `layout` | `DualCameraLayout` | `.piP(miniCamera: .front, miniCameraPosition: .bottomTrailing)` | Determines how cameras are displayed (picture-in-picture, side-by-side, or stacked). |
| `videoRecorderMode` | `DualCameraVideoRecordingMode` | `.cpuBased(.init(photoCaptureMode: .fullScreen))` | Configures video recording strategy and quality. |
| `videoSaveStrategy` | `VideoSaveStrategy` | `.videoLibrary(service: CurrentDualCameraEnvironment.mediaLibraryService)` | Strategy for saving recorded videos. |
| `photoSaveStrategy` | `PhotoSaveStrategy` | `.photoLibrary(service: CurrentDualCameraEnvironment.mediaLibraryService)` | Strategy for saving captured photos. |
| Parameter | Type | Default | Description |
| ---------------------- | ------------------------------ | -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `dualCameraController` | `DualCameraControlling` | Device-specific controller | Core camera controller. Uses `DualCameraMockController` on simulator and `DualCameraController` on device. |
| `layout` | `DualCameraLayout` | `.piP(miniCamera: .front, miniCameraPosition: .bottomTrailing)` | Determines how cameras are displayed (picture-in-picture, side-by-side, or stacked). |
| `videoRecorderMode` | `DualCameraVideoRecordingMode` | `.cpuBased(.init(photoCaptureMode: .fullScreen))` | Configures video recording strategy and quality. |
| `videoSaveStrategy` | `VideoSaveStrategy` | `.videoLibrary(service: CurrentDualCameraEnvironment.mediaLibraryService)` | Strategy for saving recorded videos. |
| `photoSaveStrategy` | `PhotoSaveStrategy` | `.photoLibrary(service: CurrentDualCameraEnvironment.mediaLibraryService)` | Strategy for saving captured photos. |

> Note on Default Media Handling: By default, all photos and videos are saved to the device's photo library. This requires the user to grant permission when first capturing media. The default implementation handles permission requests, file cleanup, and provides success feedback. When using custom strategies, you'll need to implement these aspects yourself if needed.

Expand Down Expand Up @@ -260,6 +270,7 @@ public enum DualCameraLayout {
- iOS only. iPad support is a future enhancement. Other platforms only have one camera

# API Reference

🚧

# References
Expand Down
Loading