Skip to content

Commit

Permalink
Fixed issues which inhibited subclassing. (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
tladesignz authored and mats-claassen committed Jan 31, 2019
1 parent b34870f commit 6ae9c08
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
20 changes: 15 additions & 5 deletions Sources/ImagePickerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
import Eureka
import Foundation

public protocol ImagePickerProtocol: class {
var allowEditor: Bool { get set }

var imageURL: URL? { get set }

var useEditedImage: Bool { get set }

var userPickerInfo: [UIImagePickerController.InfoKey:Any]? { get set }
}

/// Selector Controller used to pick an image
open class ImagePickerController: UIImagePickerController, TypedRowControllerType, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

Expand All @@ -40,15 +50,15 @@ open class ImagePickerController: UIImagePickerController, TypedRowControllerTyp

open override func viewDidLoad() {
super.viewDidLoad()
allowsEditing = (row as? ImageRow)?.allowEditor ?? false
allowsEditing = (row as? ImagePickerProtocol)?.allowEditor ?? false
delegate = self
}

open func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
(row as? ImageRow)?.imageURL = info[UIImagePickerController.InfoKey.referenceURL] as? URL
row.value = info[ (row as? ImageRow)?.useEditedImage ?? false ? UIImagePickerController.InfoKey.editedImage : UIImagePickerController.InfoKey.originalImage] as? UIImage
(row as? ImageRow)?.userPickerInfo = info
(row as? ImagePickerProtocol)?.imageURL = info[UIImagePickerController.InfoKey.referenceURL] as? URL

row.value = info[ (row as? ImagePickerProtocol)?.useEditedImage ?? false ? UIImagePickerController.InfoKey.editedImage : UIImagePickerController.InfoKey.originalImage] as? UIImage
(row as? ImagePickerProtocol)?.userPickerInfo = info
onDismissCallback?(self)
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/ImageRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ public enum ImageClearAction {
case yes(style: UIAlertAction.Style)
}

protocol ImageRowProtocol {
public protocol ImageRowProtocol {
var placeholderImage: UIImage? { get }
}

//MARK: Row

open class _ImageRow<Cell: CellType>: OptionsRow<Cell>, PresenterRowType, ImageRowProtocol where Cell: BaseCell, Cell.Value == UIImage {
open class _ImageRow<Cell: CellType>: OptionsRow<Cell>, PresenterRowType, ImageRowProtocol, ImagePickerProtocol where Cell: BaseCell, Cell.Value == UIImage {
public typealias PresenterRow = ImagePickerController

/// Defines how the view controller will be presented, pushed, etc.
Expand Down

0 comments on commit 6ae9c08

Please sign in to comment.