Skip to content

Commit

Permalink
Patch 2.0.0
Browse files Browse the repository at this point in the history
feat:
- (BREAKING) CameraManager must now be declared in the view containing the MCameraController
- Added attribute to indicate whether the user has blocked screen rotation

fix:
- Fixed a problem with screen rotation (#15)
- Video mirroring effect is now visible in the camera's live view
- Fixed a problem when app goes into the background and returns to the foreground (#26)
- Fixed an issue with a library causing the application to crash at random moments (#26)
- Fixed an issue with an error screen not displaying when permissions were rejected during the first launch (#26)
- Fixed other minor UI problems
  • Loading branch information
FulcrumOne authored Jul 12, 2024
1 parent 2d5ada3 commit b32a48e
Show file tree
Hide file tree
Showing 11 changed files with 394 additions and 300 deletions.
2 changes: 1 addition & 1 deletion MijickCameraView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Pod::Spec.new do |s|
CameraView is a free and open-source library dedicated for SwiftUI that allows you to create fully customisable camera view in no time. Keep your code clean.
DESC

s.version = '1.2.0'
s.version = '2.0.0'
s.ios.deployment_target = '14.0'
s.swift_version = '5.10'

Expand Down
76 changes: 39 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@
</p>

<p align="center">
<img alt="Popup Examples" src="https://github.com/Mijick/Assets/blob/main/CameraView/GIFs/CameraView-1.gif" width="30%"/>
<img alt="Popup Examples" src="https://github.com/Mijick/Assets/blob/main/CameraView/GIFs/CameraView-2.gif" width="30%"/>
<img alt="Popup Examples" src="https://github.com/Mijick/Assets/blob/main/CameraView/GIFs/CameraView-3.gif" width="30%"/>
<img alt="Popup Examples" src="https://github.com/Mijick/Assets/blob/main/CameraView/GIFs/CameraView-1.gif" width="24.5%"/>
<img alt="Popup Examples" src="https://github.com/Mijick/Assets/blob/main/CameraView/GIFs/CameraView-2.gif" width="24.5%"/>
<img alt="Popup Examples" src="https://github.com/Mijick/Assets/blob/main/CameraView/GIFs/CameraView-3.gif" width="24.5%"/>
<img alt="Popup Examples" src="https://github.com/Mijick/Assets/blob/main/CameraView/GIFs/CameraView-4.gif" width="24.5%"/>
</p>

<br>
Expand Down Expand Up @@ -112,31 +113,57 @@ Open the info.plist file of your project. Add two new keys: `Privacy - Microphon
![CleanShot 2024-05-06 at 13 41 25](https://github.com/Mijick/CameraView/assets/23524947/5da706bd-1d16-49f9-8e58-3a416872bb68)


### 2. Insert MCameraController into the selected view
### 2. Create a new CameraManager object
Create a camera manager object in the view structure to contain MCameraController. It can be initialized with attributes, with which you will start an instance of your camera.
```Swift
struct CameraView: View {
@ObservedObject private var manager: CameraManager = .init(
outputType: .photo,
cameraPosition: .back,
cameraFilters: [.init(name: "CISepiaTone")!],
flashMode: .off,
isGridVisible: true,
focusImageColor: .blue,
focusImageSize: 100
)

(...)

var body: some View {
(...)
}

(...)
}
```


### 3. Insert MCameraController into the selected view
MCameraController contains three screens - `CameraView`, `CameraPreview` (which can be turned off) and `CameraErrorView`. Therefore, we advise that there should be no other elements in the view where you declare `MCameraController`. We’ve designed this system around the experience and needs of ourselves and the developers we know. However, if your preferences are different, we are happy to meet your expectations and adapt our library. Share them with us by creating an [issue][AddIssue] for this project.
```Swift
struct CameraView: View {
@ObservedObject private var manager: CameraManager = (...)

(...)

var body: some View {
MCameraController()
MCameraController(manager: manager)
}

(...)
}
```


### 3. Declare `onImageCaptured`, `onVideoCaptured`, `afterMediaCaptured` and `onCloseController`
### 4. Declare `onImageCaptured`, `onVideoCaptured`, `afterMediaCaptured` and `onCloseController`
The above functions define what happens after a given action and are optional; for example, if your application only captures images, you don't need to declare onVideoCaptured and so on.
```Swift
struct CameraView: View {

(...)

var body: some View {
MCameraController()
MCameraController(manager: manager)
.onImageCaptured { data in
print("IMAGE CAPTURED")
}
Expand All @@ -156,7 +183,7 @@ struct CameraView: View {
```


### 4. (Optional) Block screen rotation for MCameraController
### 5. (Optional) Block screen rotation for MCameraController
CameraView library by Mijick, allows you to lock the screen rotation for `MCameraController`, even if a **device rotation is unlocked**.
To achieve it, create an AppDelegate class conforming to `MApplicationDelegate`, declare `@UIApplicationDelegateAdaptor` in `@main struct` and set `lockOrientation(AppDelegate.self)` for `MCameraController`.
```Swift
Expand All @@ -183,39 +210,14 @@ struct CameraView: View {
(...)

var body: some View {
MCameraController()
MCameraController(manager: manager)
.lockOrientation(AppDelegate.self)
}

(...)
}
```


### 5. (Optional) Change the initial camera settings
You can change the initial camera settings using the modifiers from the list below:
```Swift
struct CameraView: View {

(...)

var body: some View {
MCameraController()
.outputType(.video)
.cameraPosition(.front)
.flashMode(.auto)
.gridVisible(false)
.focusImage(.init(named: "icon-focus")!)
.focusImageColor(.blue)
.focusImageSize(120)
.changeCameraFilters([.init(name: "CISepiaTone")!])
}

(...)
}
```


### 6. (Optional) Change CameraView UI
You can change the appearance of the `CameraView` by creating a new structure, conforming to `MCameraView` and using the `cameraScreen` modifier.
```Swift
Expand Down Expand Up @@ -253,7 +255,7 @@ struct CameraView: View {
(...)

var body: some View {
MCameraController()
MCameraController(manager: manager)
.cameraScreen(CustomCameraView.init)
}

Expand Down Expand Up @@ -317,7 +319,7 @@ struct CameraView: View {
(...)

var body: some View {
MCameraController()
MCameraController(manager: manager)
.mediaPreviewScreen(CustomCameraPreview.init)
}

Expand Down Expand Up @@ -346,7 +348,7 @@ struct CameraView: View {
(...)

var body: some View {
MCameraController()
MCameraController(manager: manager)
.errorScreen(CustomCameraErrorView.init)
}

Expand Down
Loading

0 comments on commit b32a48e

Please sign in to comment.