Skip to content

Commit

Permalink
Merge branch 'release/1.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
bbriatte committed Feb 10, 2017
2 parents 678958e + 57f887e commit 7ab50ac
Show file tree
Hide file tree
Showing 10 changed files with 257 additions and 28 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.3](https://github.com/Digipolitan/collection-view-paginable-behavior/releases/tag/v1.0.3)

updated samples
added endpoint to reload data and fetched indexes

---

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

update const
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.2"
s.version = "1.0.3"
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 @@ -31,6 +31,7 @@
A3D8B9C31E2E64E000D6B661 /* UserItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3D8B9BB1E2E64E000D6B661 /* UserItemCell.swift */; };
A3D8B9C41E2E64E000D6B661 /* UserItemCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = A3D8B9BC1E2E64E000D6B661 /* UserItemCell.xib */; };
A3D8B9C61E2E655000D6B661 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A3D8B9C51E2E655000D6B661 /* Main.storyboard */; };
AE7DFC651E4DD4AB0051267D /* PullToRefreshViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE7DFC641E4DD4AB0051267D /* PullToRefreshViewController.swift */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -78,6 +79,7 @@
A3D8B9BB1E2E64E000D6B661 /* UserItemCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserItemCell.swift; sourceTree = "<group>"; };
A3D8B9BC1E2E64E000D6B661 /* UserItemCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = UserItemCell.xib; sourceTree = "<group>"; };
A3D8B9C51E2E655000D6B661 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
AE7DFC641E4DD4AB0051267D /* PullToRefreshViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PullToRefreshViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -141,6 +143,7 @@
children = (
A3D8B9A71E2E647F00D6B661 /* OriginalViewController.swift */,
A3D8B9A21E2E645800D6B661 /* Raw */,
AE7DFC631E4DD48E0051267D /* PullToRefresh */,
A3D8B9A11E2E644E00D6B661 /* MultipleSections */,
A3D8B9A01E2E644600D6B661 /* ManualMode */,
A3D8B99F1E2E643600D6B661 /* LoadingError */,
Expand Down Expand Up @@ -238,6 +241,14 @@
name = Manual;
sourceTree = "<group>";
};
AE7DFC631E4DD48E0051267D /* PullToRefresh */ = {
isa = PBXGroup;
children = (
AE7DFC641E4DD4AB0051267D /* PullToRefreshViewController.swift */,
);
name = PullToRefresh;
sourceTree = "<group>";
};
B8FF5AA30A09A2E69BAC9EB0 /* Pods */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -390,6 +401,7 @@
A3D8B9B41E2E64CF00D6B661 /* ClassicViewController.swift in Sources */,
A3D8B99C1E2E641B00D6B661 /* User.swift in Sources */,
A3D8B9AE1E2E649F00D6B661 /* LoadingErrorManualViewController.swift in Sources */,
AE7DFC651E4DD4AB0051267D /* PullToRefreshViewController.swift in Sources */,
A3D8B9C31E2E64E000D6B661 /* UserItemCell.swift in Sources */,
A3D8B9A61E2E647700D6B661 /* RawViewController.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import DGCollectionViewPaginableBehavior
class ClassicViewController: OriginalViewController {
var users: [User] = [User]()
let behavior: DGCollectionViewPaginableBehavior = DGCollectionViewPaginableBehavior()

let control = UIRefreshControl()
var refreshing: Bool = false
override func viewDidLoad() {
super.viewDidLoad()

Expand All @@ -22,6 +23,26 @@ class ClassicViewController: OriginalViewController {
self.collectionView.delegate = self.behavior
self.collectionView.dataSource = self
self.behavior.delegate = self

self.control.addTarget(self, action: #selector(refresh), for: UIControlEvents.valueChanged)
if #available(iOS 10.0, *) {
self.collectionView.refreshControl = self.control
} else {
// Fallback on earlier versions
}
}

func refresh() {
self.refreshing = true
self.users.removeAll()
self.behavior.reloadData()
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
self.control.endRefreshing()
self.refreshing = false
self.behavior.fetchNextData(forSection: 0) {
self.collectionView.reloadData()
}
}
}
}

Expand All @@ -33,7 +54,9 @@ extension ClassicViewController: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard indexPath.row < self.users.count else {
let cell: LoadingItemCell = (collectionView.dequeueReusableCell(withReuseIdentifier: LoadingItemCell.Identifier, for: indexPath) as? LoadingItemCell)!
cell.set(moreToLoad: !self.behavior.sectionStatus(forSection: indexPath.section).done)
if !self.refreshing {
cell.set(moreToLoad: !self.behavior.sectionStatus(forSection: indexPath.section).done)
}
return cell
}

Expand Down
Loading

0 comments on commit 7ab50ac

Please sign in to comment.