Skip to content

Commit

Permalink
Using custom collection view layout and new paging component (#54)
Browse files Browse the repository at this point in the history
* Removed class

* Updated Readme

* Increased version number
  • Loading branch information
MaherKSantina authored Dec 7, 2019
1 parent fb1a921 commit 62ef41f
Show file tree
Hide file tree
Showing 19 changed files with 725 additions and 789 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; };
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
607FACEC1AFB9204008FA782 /* HorizontalScrollDirectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* HorizontalScrollDirectionTests.swift */; };
69A57A2E20E39A1700D492D4 /* VerticalScrollDirectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69A57A2D20E39A1700D492D4 /* VerticalScrollDirectionTests.swift */; };
6CC61A01D070E53B5C9713D3 /* Pods_MSPeekCollectionViewDelegateImplementation_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D63706738AAABD8B65F2802 /* Pods_MSPeekCollectionViewDelegateImplementation_Example.framework */; };
/* End PBXBuildFile section */

Expand All @@ -40,8 +38,6 @@
607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
607FACE51AFB9204008FA782 /* MSPeekCollectionViewDelegateImplementation_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MSPeekCollectionViewDelegateImplementation_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
607FACEB1AFB9204008FA782 /* HorizontalScrollDirectionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HorizontalScrollDirectionTests.swift; sourceTree = "<group>"; };
69A57A2D20E39A1700D492D4 /* VerticalScrollDirectionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VerticalScrollDirectionTests.swift; sourceTree = "<group>"; };
6D62A78B4ED727736705D900 /* Pods-MSPeekCollectionViewDelegateImplementation_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MSPeekCollectionViewDelegateImplementation_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-MSPeekCollectionViewDelegateImplementation_Example/Pods-MSPeekCollectionViewDelegateImplementation_Example.release.xcconfig"; sourceTree = "<group>"; };
7C9735FF72CB49CDCEB9B535 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
A2049B1E9B6ED415F87F1C5A /* MSPeekCollectionViewDelegateImplementation.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = MSPeekCollectionViewDelegateImplementation.podspec; path = ../MSPeekCollectionViewDelegateImplementation.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
Expand Down Expand Up @@ -137,8 +133,6 @@
607FACE81AFB9204008FA782 /* Tests */ = {
isa = PBXGroup;
children = (
607FACEB1AFB9204008FA782 /* HorizontalScrollDirectionTests.swift */,
69A57A2D20E39A1700D492D4 /* VerticalScrollDirectionTests.swift */,
607FACE91AFB9204008FA782 /* Supporting Files */,
);
path = Tests;
Expand Down Expand Up @@ -334,8 +328,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
69A57A2E20E39A1700D492D4 /* VerticalScrollDirectionTests.swift in Sources */,
607FACEC1AFB9204008FA782 /* HorizontalScrollDirectionTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,23 @@ class ViewController: UIViewController {
@IBOutlet weak var numberOfItemsToShowSlider: UISlider!

@IBOutlet weak var collectionView: UICollectionView!
var peekImplementation: MSPeekCollectionViewDelegateImplementation!

var behavior: MSCollectionViewPeekingBehavior!

override func viewDidLoad() {
super.viewDidLoad()
peekImplementation = MSPeekCollectionViewDelegateImplementation()
peekImplementation.delegate = self
collectionView.configureForPeekingDelegate()
collectionView.delegate = peekImplementation
reloadDelegate()
collectionView.delegate = self
collectionView.dataSource = self

initSliderValues()
}

func initSliderValues() {
cellSpacingSlider.value = Float(peekImplementation.cellSpacing)
cellPeekWidthSlider.value = Float(peekImplementation.cellPeekWidth)
scrollThresholdSlider.value = Float(peekImplementation.scrollThreshold)
maximumItemsToScrollSlider.value = Float(peekImplementation.maximumItemsToScroll)
numberOfItemsToShowSlider.value = Float(peekImplementation.numberOfItemsToShow)
cellSpacingSlider.value = Float(behavior.cellSpacing)
cellPeekWidthSlider.value = Float(behavior.cellPeekWidth)
maximumItemsToScrollSlider.value = Float(behavior.maximumItemsToScroll ?? 1)
numberOfItemsToShowSlider.value = Float(behavior.numberOfItemsToShow)
}

@IBAction func sliderValueDidChange(_ slider: CustomSlider) {
Expand All @@ -66,9 +64,8 @@ class ViewController: UIViewController {
}

func reloadDelegate() {
peekImplementation = MSPeekCollectionViewDelegateImplementation(cellSpacing: CGFloat(cellSpacingSlider.value), cellPeekWidth: CGFloat(cellPeekWidthSlider.value), scrollThreshold: CGFloat(scrollThresholdSlider.value), maximumItemsToScroll: Int(maximumItemsToScrollSlider.value), numberOfItemsToShow: Int(numberOfItemsToShowSlider.value))
collectionView.delegate = peekImplementation
peekImplementation.delegate = self
behavior = MSCollectionViewPeekingBehavior(cellSpacing: CGFloat(cellSpacingSlider.value), cellPeekWidth: CGFloat(cellPeekWidthSlider.value), maximumItemsToScroll: Int(maximumItemsToScrollSlider.value), numberOfItemsToShow: Int(numberOfItemsToShowSlider.value), scrollDirection: .horizontal)
collectionView.configureForPeekingBehavior(behavior: behavior)
collectionView.reloadData()
}

Expand All @@ -91,13 +88,8 @@ extension ViewController: UICollectionViewDataSource {
}
}

extension ViewController: MSPeekImplementationDelegate {
func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation, didChangeActiveIndexTo activeIndex: Int) {
print("Changed active index to \(activeIndex)")
}

func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation, didSelectItemAt indexPath: IndexPath) {
print("Selected item at \(indexPath)")
extension ViewController: UICollectionViewDelegate {
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
behavior.scrollViewWillEndDragging(scrollView, withVelocity: velocity, targetContentOffset: targetContentOffset)
}
}

4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- MSPeekCollectionViewDelegateImplementation (2.0.0)
- MSPeekCollectionViewDelegateImplementation (3.0.0)

DEPENDENCIES:
- MSPeekCollectionViewDelegateImplementation (from `../`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
MSPeekCollectionViewDelegateImplementation: 3091e9512b3cd03facdea3c02e57673a4a06246a
MSPeekCollectionViewDelegateImplementation: e1c53a3d70dc37850d529f9fc9b07c29767fccf7

PODFILE CHECKSUM: 8d230cee08c8a8b7e62859eff8016277efe2311d

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 62ef41f

Please sign in to comment.