Skip to content

Commit

Permalink
Inject configuration at init
Browse files Browse the repository at this point in the history
  • Loading branch information
onmyway133 committed Oct 4, 2017
1 parent 319b33d commit 1d05ccb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
3 changes: 1 addition & 2 deletions Demo/ImagePickerDemo/ImagePickerDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class ViewController: UIViewController, ImagePickerDelegate {
config.recordLocation = false
config.allowVideoSelection = true

let imagePicker = ImagePickerController()
imagePicker.configuration = config
let imagePicker = ImagePickerController(configuration: config)
imagePicker.delegate = self

present(imagePicker, animated: true, completion: nil)
Expand Down
16 changes: 5 additions & 11 deletions Source/ImagePickerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Photos

open class ImagePickerController: UIViewController {

open var configuration = Configuration()
let configuration: Configuration

struct GestureConstants {
static let maximumHeight: CGFloat = 200
Expand Down Expand Up @@ -91,19 +91,13 @@ open class ImagePickerController: UIViewController {

// MARK: - Initialization

public init(configuration: Configuration? = nil) {
if let configuration = configuration {
self.configuration = configuration
}
public required init(configuration: Configuration = Configuration()) {
self.configuration = configuration
super.init(nibName: nil, bundle: nil)
}

public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}

required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
public required init?(coder aDecoder: NSCoder) {
fatalError()
}

// MARK: - View lifecycle
Expand Down

0 comments on commit 1d05ccb

Please sign in to comment.