Skip to content

Commit

Permalink
Replace presentingController with provider in PhotosInputCameraPicker
Browse files Browse the repository at this point in the history
  • Loading branch information
wiruzx committed Mar 13, 2019
1 parent 0fe6cc2 commit 9c44d4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@
import UIKit

final class PhotosInputCameraPicker: ImagePickerDelegate {
private weak var presentingController: UIViewController?
private let presentingControllerProvider: () -> UIViewController?
private var imagePicker: ImagePicker?
private var completionBlocks: (onImageTaken: (UIImage?) -> Void, onCameraPickerDismissed: () -> Void)?

init(presentingController: UIViewController?) {
self.presentingController = presentingController
convenience init(presentingController: UIViewController?) {
self.init(presentingControllerProvider: { [weak presentingController] in presentingController })
}

init(presentingControllerProvider: @escaping () -> UIViewController?) {
self.presentingControllerProvider = presentingControllerProvider
}

func presentCameraPicker(onImageTaken: @escaping (UIImage?) -> Void, onCameraPickerDismissed: @escaping () -> Void) {
guard let presentingController = self.presentingController,
guard let presentingController = self.presentingControllerProvider(),
let imagePicker = ImagePickerStore.factory.makeImagePicker(delegate: self) else {
onImageTaken(nil)
onCameraPickerDismissed()
Expand Down
2 changes: 1 addition & 1 deletion ChattoAdditions/Source/Input/Photos/PhotosInputView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public final class PhotosInputView: UIView, PhotosInputViewProtocol {
}

fileprivate lazy var cameraPicker: PhotosInputCameraPicker = {
return PhotosInputCameraPicker(presentingController: self.presentingController)
return PhotosInputCameraPicker(presentingControllerProvider: self.presentingControllerProvider)
}()

fileprivate lazy var liveCameraPresenter: LiveCameraCellPresenter = {
Expand Down

0 comments on commit 9c44d4a

Please sign in to comment.