Skip to content

Commit

Permalink
Merge pull request hyperoslo#193 from cemaleker/master
Browse files Browse the repository at this point in the history
Added ability to provide a preferred image size
  • Loading branch information
zenangst authored Aug 28, 2016
2 parents 72b2998 + 6e89178 commit 49f60f6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Source/ImagePickerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class ImagePickerController: UIViewController {
public weak var delegate: ImagePickerDelegate?
public var stack = ImageStack()
public var imageLimit = 0
public var preferredImageSize: CGSize?
var totalSize: CGSize { return UIScreen.mainScreen().bounds.size }
var initialFrame: CGRect?
var initialContentOffset: CGPoint?
Expand Down Expand Up @@ -331,7 +332,13 @@ extension ImagePickerController: BottomContainerViewDelegate {
}

func doneButtonDidPress() {
let images = AssetManager.resolveAssets(stack.assets)
var images: [UIImage]
if let preferredImageSize = preferredImageSize {
images = AssetManager.resolveAssets(stack.assets, size: preferredImageSize)
} else {
images = AssetManager.resolveAssets(stack.assets)
}

delegate?.doneButtonDidPress(self, images: images)
}

Expand All @@ -341,7 +348,13 @@ extension ImagePickerController: BottomContainerViewDelegate {
}

func imageStackViewDidPress() {
let images = AssetManager.resolveAssets(stack.assets)
var images: [UIImage]
if let preferredImageSize = preferredImageSize {
images = AssetManager.resolveAssets(stack.assets, size: preferredImageSize)
} else {
images = AssetManager.resolveAssets(stack.assets)
}

delegate?.wrapperDidPress(self, images: images)
}
}
Expand Down

0 comments on commit 49f60f6

Please sign in to comment.