Skip to content

Commit

Permalink
Merge pull request #308 from halfvim/flashlight
Browse files Browse the repository at this point in the history
Fix bug of flashlight button disappearing when flip camera twice
  • Loading branch information
s4cha committed Apr 28, 2019
2 parents 6d457ec + f7cea7d commit 8fd8931
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions Source/Pages/Photo/YPCameraVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ public class YPCameraVC: UIViewController, UIGestureRecognizerDelegate, YPPermis
@objc
func flipButtonTapped() {
doAfterPermissionCheck { [weak self] in
self?.photoCapture.flipCamera()
DispatchQueue.main.async {
self?.photoCapture.flipCamera {
self?.refreshFlashButton()
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Pages/Photo/YPPhotoCapture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protocol YPPhotoCapture: class {
func tryToggleFlash()
var hasFlash: Bool { get }
var currentFlashMode: YPFlashMode { get }
func flipCamera()
func flipCamera(completion: @escaping () -> Void)
func shoot(completion: @escaping (Data) -> Void)
var videoLayer: AVCaptureVideoPreviewLayer! { get set }
var device: AVCaptureDevice? { get }
Expand Down
5 changes: 4 additions & 1 deletion Source/Pages/Photo/YPPhotoCaptureDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,12 @@ extension YPPhotoCapture {

// MARK: - Flip

func flipCamera() {
func flipCamera(completion: @escaping () -> Void) {
sessionQueue.async { [weak self] in
self?.flip()
DispatchQueue.main.async {
completion()
}
}
}

Expand Down

0 comments on commit 8fd8931

Please sign in to comment.