Skip to content

Adds the other part of the README to resolve assets #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@
INFOPLIST_FILE = ImagePickerDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = no.ImagePicker.hyper;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -426,6 +427,7 @@
INFOPLIST_FILE = ImagePickerDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = no.ImagePicker.hyper;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion Demo/ImagePickerDemo/ImagePickerDemo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>no.ImagePicker.hyper</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ func doneButtonDidPress(images: [UIImage])
func cancelButtonDidPress()
```

As said before, **ImagePicker** works with referenced images, that is really powerful because it lets you download the asset and choose the size you want. If you want to change the default implementation, just add a variable in your controller.

```swift
public var imageAssets: [UIImage] {
return ImagePicker.resolveAssets(imagePicker.stack.assets)
}
```

And when you call any delegate method that returns images, add in the first line:

```swift
let images = imageAssets
```

## Installation

**ImagePicker** is available through [CocoaPods](http://cocoapods.org). To install
Expand Down
2 changes: 1 addition & 1 deletion Source/BottomView/StackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ extension ImageStackView {

for (index, view) in views.enumerate() {
if index <= photos.count - 1 {
Photos.resolveAsset(photos[index], size: CGSize(width: Dimensions.imageSize, height: Dimensions.imageSize)) { image in
ImagePicker.resolveAsset(photos[index], size: CGSize(width: Dimensions.imageSize, height: Dimensions.imageSize)) { image in
view.image = image
}
view.alpha = 1
Expand Down
4 changes: 2 additions & 2 deletions Source/ImageGallery/ImageGalleryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public class ImageGalleryView: UIView {
// MARK: - Photos handler

func fetchPhotos(completion: (() -> Void)? = nil) {
Photos.fetch { assets in
ImagePicker.fetch { assets in
self.assets.removeAll()
self.assets.appendContentsOf(assets)
self.collectionView.reloadData()
Expand Down Expand Up @@ -250,7 +250,7 @@ extension ImageGalleryView: UICollectionViewDelegate {

let asset = assets[indexPath.row]

Photos.resolveAsset(asset) { image in
ImagePicker.resolveAsset(asset) { image in
guard let _ = image else { return }

if cell.selectedImageView.image != nil {
Expand Down
2 changes: 1 addition & 1 deletion Source/ImageGallery/ImageGalleryViewDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extension ImageGalleryView: UICollectionViewDataSource {

let asset = assets[indexPath.row]

Photos.resolveAsset(asset, size: CGSize(width: 160, height: 240)) { image in
ImagePicker.resolveAsset(asset, size: CGSize(width: 160, height: 240)) { image in
if let image = image {
cell.configureCell(image)

Expand Down
4 changes: 2 additions & 2 deletions Source/ImagePickerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ extension ImagePickerController: BottomContainerViewDelegate {
}

func doneButtonDidPress() {
let images = Photos.resolveAssets(stack.assets)
let images = ImagePicker.resolveAssets(stack.assets)
delegate?.doneButtonDidPress(images)
}

Expand All @@ -229,7 +229,7 @@ extension ImagePickerController: BottomContainerViewDelegate {
}

func imageStackViewDidPress() {
let images = Photos.resolveAssets(stack.assets)
let images = ImagePicker.resolveAssets(stack.assets)
delegate?.wrapperDidPress(images)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Photos.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Photos
import AssetsLibrary

public struct Photos {
public struct ImagePicker {

public static func fetch(completion: (assets: [PHAsset]) -> Void) {
let fetchOptions = PHFetchOptions()
Expand Down