Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
Add multiple selection settings
Browse files Browse the repository at this point in the history
  • Loading branch information
floriangbh committed Jun 22, 2017
1 parent a5c223e commit 6e08e55
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
Binary file not shown.
6 changes: 5 additions & 1 deletion Example/GBHFacebookImagePicker/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ class ViewController: UIViewController {

// Selected border width
GBHFacebookImagePicker.pickerConfig.uiConfig.selectedBorderWidth = 4.0

// Maximum selected pictures
GBHFacebookImagePicker.pickerConfig.maximumSelectedPictures = 4
}

// MARK: - Action
Expand All @@ -101,9 +104,10 @@ class ViewController: UIViewController {

// Allow multiple selection (false by default)
GBHFacebookImagePicker.pickerConfig.allowMultipleSelection = true
GBHFacebookImagePicker.pickerConfig.maximumSelectedPictures = 4

// Make some customisation
//self.someCustomisation()
// self.someCustomisation()

// Present picker
picker.presentFacebookAlbumImagePicker(from: self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ extension GBHPhotoPickerViewController: UICollectionViewDataSource, UICollection
if GBHFacebookImagePicker.pickerConfig.maximumSelectedPictures == nil {
self.selectedImages.append(imageModel)
} else {
if self.selectedImages.count < GBHFacebookImagePicker.pickerConfig.maximumSelectedPictures! {
let maximum = GBHFacebookImagePicker.pickerConfig.maximumSelectedPictures ?? 1
if self.selectedImages.count < maximum {
self.selectedImages.append(imageModel)
} else {
if let cell = collectionView.cellForItem(at: indexPath) as? GBHPhotoCollectionViewCell {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public struct GBHFacebookPickerConfig {
public var title: String = NSLocalizedString("Album(s)",
comment: "")

// The picture corner radius. Used for display album cover and album's picture.
/// The picture corner radius. Used for display album cover and album's picture.
public var pictureCornerRadius: CGFloat = 2.0

// Allow multiple pictures selection
/// Allow multiple pictures selection
public var allowMultipleSelection: Bool = false
// Maximum selected pictures

/// Maximum selected pictures
public var maximumSelectedPictures: Int?

/// UI-specific configuration.
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ GBHFacebookImagePicker.pickerConfig.uiConfig.selectedBorderColor = UIColor.red

// Selected border width
GBHFacebookImagePicker.pickerConfig.uiConfig.selectedBorderWidth = 4.0

// Maximum selected pictures
GBHFacebookImagePicker.pickerConfig.maximumSelectedPictures = 4
```


Expand Down

0 comments on commit 6e08e55

Please sign in to comment.