Skip to content

Commit

Permalink
Merge branch 'release/1.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
bbriatte committed Feb 14, 2017
2 parents 7ab50ac + f9878fc commit c7befac
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 11 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
`collection-view-paginable-behavior-swift` adheres to [Semantic Versioning](http://semver.org/).
---

## [1.0.4](https://github.com/Digipolitan/collection-view-paginable-behavior/releases/tag/v1.0.4)

updated Samples
fixed index calculation where initial data stored in the collection in manual mode wasn't handled properly

---

## [1.0.3](https://github.com/Digipolitan/collection-view-paginable-behavior/releases/tag/v1.0.3)

updated samples
Expand Down
2 changes: 1 addition & 1 deletion DGCollectionViewPaginableBehavior.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DGCollectionViewPaginableBehavior"
s.version = "1.0.3"
s.version = "1.0.4"
s.summary = "Allows you to paginate your collection of data with only few lines of code"
s.homepage = "https://github.com/Digipolitan/collection-view-paginable-behavior-swift"
s.authors = "Digipolitan"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ It's the direct instance interacting with the collection View.
If your custom layout needs a delegate with specific methods, just extend the behavior of the Paginable component.
**/
extension DGCollectionViewPaginableBehavior: DGCollectionViewGridLayoutDelegate {
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: DGCollectionViewGridLayout, heightForItemAtIndexPath indexPath: IndexPath, columnWidth: CGFloat) -> CGFloat {
return 90
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: DGCollectionViewGridLayout, heightForItemAt indexPath: IndexPath, columnWidth: CGFloat) -> CGFloat {
return 150
}

public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: DGCollectionViewGridLayout, heightForHeaderInSection section: Int) -> CGFloat {
return 42
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: DGCollectionViewGridLayout, heightForFooterIn section: Int) -> CGFloat {
return 90
}

public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: DGCollectionViewGridLayout, heightForFooterInSection section: Int) -> CGFloat {
return 90
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: DGCollectionViewGridLayout, heightForHeaderIn section: Int) -> CGFloat {
return 42
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,13 @@ class UserItemCell: UICollectionViewCell {
func set(user: User) {
self.nameLabel.text = "\(user.firstName) \(user.lastName)"
self.companyLabel.text = user.company
let htmlString = "<h1>Header</h1><h2>Subheader</h2><p>Some <em>text</em></p><img src='http://68.media.tumblr.com/c06b9a1fb051899055827ee8c7503cef/tumblr_ol2c7iyO261v1wvcuo1_1280.jpg' width=70 height=100 />"
do {
let attributedString = try NSAttributedString(data: htmlString.data(using: .unicode, allowLossyConversion: true)!,
options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil)
self.nameLabel.attributedText = attributedString
}
catch {}

}
}
14 changes: 12 additions & 2 deletions Sources/DGCollectionViewPaginableBehavior.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ open class DGCollectionViewPaginableBehavior: NSObject {
public var error: Error?
public var index: Int

init(fetching: Bool = false, done: Bool = false, error: Error? = nil) {
init(index: Int = 0, fetching: Bool = false, done: Bool = false, error: Error? = nil) {
self.fetching = fetching
self.done = done
self.error = error
self.index = 0
self.index = index
}

public var description: String {
Expand Down Expand Up @@ -106,6 +106,16 @@ open class DGCollectionViewPaginableBehavior: NSObject {

public func fetchNextData(forSection section: Int, completionHandler: @escaping (Void) -> Void) {
var sectionStatus = self.sectionStatuses[section] ?? SectionStatus()

if self.sectionStatuses[section] == nil {
guard let collectionView = self.collectionView else {
return
}

let index = collectionView.dataSource?.collectionView(collectionView, numberOfItemsInSection: section) ?? 0
sectionStatus = SectionStatus(index: index)
}

let count = self.delegate?.paginableBehavior?(self, countPerPageInSection: section) ?? self.options.countPerPage

guard !sectionStatus.fetching && !sectionStatus.done else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.3</string>
<string>1.0.4</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSPrincipalClass</key>
Expand Down
2 changes: 1 addition & 1 deletion Tests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.3</string>
<string>1.0.4</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
Expand Down

0 comments on commit c7befac

Please sign in to comment.