Skip to content

Commit

Permalink
fix: Issue #46
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanpe committed Mar 30, 2018
1 parent 6f628a3 commit 7e2849e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions Sources/Collections/CollectionSkeletonProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ protocol CollectionSkeleton {

func addDummyDataSource()
func removeDummyDataSource(reloadAfter: Bool)
func disableScrolling()
func enableScrolling()
func disableUserInteraction()
func enableUserInteraction()
}

extension CollectionSkeleton where Self: UIScrollView {
var estimatedNumberOfRows: Int { return 0 }
func addDummyDataSource() {}
func removeDummyDataSource(reloadAfter: Bool) {}
func disableScrolling() { isScrollEnabled = false }
func enableScrolling() { isScrollEnabled = true }

func disableUserInteraction() { isUserInteractionEnabled = false }
func enableUserInteraction() { isUserInteractionEnabled = true }
}
4 changes: 2 additions & 2 deletions Sources/Collections/UIView+CollectionSkeleton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ extension UIView {
func addDummyDataSourceIfNeeded() {
guard let collection = self as? CollectionSkeleton else { return }
collection.addDummyDataSource()
collection.disableScrolling()
collection.disableUserInteraction()
}

func removeDummyDataSourceIfNeeded(reloadAfter reload: Bool = true) {
guard let collection = self as? CollectionSkeleton else { return }
collection.removeDummyDataSource(reloadAfter: reload)
collection.enableScrolling()
collection.enableUserInteraction()
}
}

0 comments on commit 7e2849e

Please sign in to comment.