Skip to content

Commit 62ef41f

Browse files
Using custom collection view layout and new paging component (#54)
* Removed class * Updated Readme * Increased version number
1 parent fb1a921 commit 62ef41f

File tree

19 files changed

+725
-789
lines changed

19 files changed

+725
-789
lines changed

Example/MSPeekCollectionViewDelegateImplementation.xcodeproj/project.pbxproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; };
1414
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
1515
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
16-
607FACEC1AFB9204008FA782 /* HorizontalScrollDirectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* HorizontalScrollDirectionTests.swift */; };
17-
69A57A2E20E39A1700D492D4 /* VerticalScrollDirectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69A57A2D20E39A1700D492D4 /* VerticalScrollDirectionTests.swift */; };
1816
6CC61A01D070E53B5C9713D3 /* Pods_MSPeekCollectionViewDelegateImplementation_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D63706738AAABD8B65F2802 /* Pods_MSPeekCollectionViewDelegateImplementation_Example.framework */; };
1917
/* End PBXBuildFile section */
2018

@@ -40,8 +38,6 @@
4038
607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
4139
607FACE51AFB9204008FA782 /* MSPeekCollectionViewDelegateImplementation_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MSPeekCollectionViewDelegateImplementation_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
4240
607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
43-
607FACEB1AFB9204008FA782 /* HorizontalScrollDirectionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HorizontalScrollDirectionTests.swift; sourceTree = "<group>"; };
44-
69A57A2D20E39A1700D492D4 /* VerticalScrollDirectionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VerticalScrollDirectionTests.swift; sourceTree = "<group>"; };
4541
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>"; };
4642
7C9735FF72CB49CDCEB9B535 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
4743
A2049B1E9B6ED415F87F1C5A /* MSPeekCollectionViewDelegateImplementation.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = MSPeekCollectionViewDelegateImplementation.podspec; path = ../MSPeekCollectionViewDelegateImplementation.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
@@ -137,8 +133,6 @@
137133
607FACE81AFB9204008FA782 /* Tests */ = {
138134
isa = PBXGroup;
139135
children = (
140-
607FACEB1AFB9204008FA782 /* HorizontalScrollDirectionTests.swift */,
141-
69A57A2D20E39A1700D492D4 /* VerticalScrollDirectionTests.swift */,
142136
607FACE91AFB9204008FA782 /* Supporting Files */,
143137
);
144138
path = Tests;
@@ -334,8 +328,6 @@
334328
isa = PBXSourcesBuildPhase;
335329
buildActionMask = 2147483647;
336330
files = (
337-
69A57A2E20E39A1700D492D4 /* VerticalScrollDirectionTests.swift in Sources */,
338-
607FACEC1AFB9204008FA782 /* HorizontalScrollDirectionTests.swift in Sources */,
339331
);
340332
runOnlyForDeploymentPostprocessing = 0;
341333
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>BuildSystemType</key>
6+
<string>Original</string>
7+
<key>PreviewsEnabled</key>
8+
<false/>
9+
</dict>
10+
</plist>

Example/MSPeekCollectionViewDelegateImplementation/ViewController.swift

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,23 @@ class ViewController: UIViewController {
3535
@IBOutlet weak var numberOfItemsToShowSlider: UISlider!
3636

3737
@IBOutlet weak var collectionView: UICollectionView!
38-
var peekImplementation: MSPeekCollectionViewDelegateImplementation!
38+
39+
var behavior: MSCollectionViewPeekingBehavior!
3940

4041
override func viewDidLoad() {
4142
super.viewDidLoad()
42-
peekImplementation = MSPeekCollectionViewDelegateImplementation()
43-
peekImplementation.delegate = self
44-
collectionView.configureForPeekingDelegate()
45-
collectionView.delegate = peekImplementation
43+
reloadDelegate()
44+
collectionView.delegate = self
4645
collectionView.dataSource = self
4746

4847
initSliderValues()
4948
}
5049

5150
func initSliderValues() {
52-
cellSpacingSlider.value = Float(peekImplementation.cellSpacing)
53-
cellPeekWidthSlider.value = Float(peekImplementation.cellPeekWidth)
54-
scrollThresholdSlider.value = Float(peekImplementation.scrollThreshold)
55-
maximumItemsToScrollSlider.value = Float(peekImplementation.maximumItemsToScroll)
56-
numberOfItemsToShowSlider.value = Float(peekImplementation.numberOfItemsToShow)
51+
cellSpacingSlider.value = Float(behavior.cellSpacing)
52+
cellPeekWidthSlider.value = Float(behavior.cellPeekWidth)
53+
maximumItemsToScrollSlider.value = Float(behavior.maximumItemsToScroll ?? 1)
54+
numberOfItemsToShowSlider.value = Float(behavior.numberOfItemsToShow)
5755
}
5856

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

6866
func reloadDelegate() {
69-
peekImplementation = MSPeekCollectionViewDelegateImplementation(cellSpacing: CGFloat(cellSpacingSlider.value), cellPeekWidth: CGFloat(cellPeekWidthSlider.value), scrollThreshold: CGFloat(scrollThresholdSlider.value), maximumItemsToScroll: Int(maximumItemsToScrollSlider.value), numberOfItemsToShow: Int(numberOfItemsToShowSlider.value))
70-
collectionView.delegate = peekImplementation
71-
peekImplementation.delegate = self
67+
behavior = MSCollectionViewPeekingBehavior(cellSpacing: CGFloat(cellSpacingSlider.value), cellPeekWidth: CGFloat(cellPeekWidthSlider.value), maximumItemsToScroll: Int(maximumItemsToScrollSlider.value), numberOfItemsToShow: Int(numberOfItemsToShowSlider.value), scrollDirection: .horizontal)
68+
collectionView.configureForPeekingBehavior(behavior: behavior)
7269
collectionView.reloadData()
7370
}
7471

@@ -91,13 +88,8 @@ extension ViewController: UICollectionViewDataSource {
9188
}
9289
}
9390

94-
extension ViewController: MSPeekImplementationDelegate {
95-
func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation, didChangeActiveIndexTo activeIndex: Int) {
96-
print("Changed active index to \(activeIndex)")
97-
}
98-
99-
func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation, didSelectItemAt indexPath: IndexPath) {
100-
print("Selected item at \(indexPath)")
91+
extension ViewController: UICollectionViewDelegate {
92+
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
93+
behavior.scrollViewWillEndDragging(scrollView, withVelocity: velocity, targetContentOffset: targetContentOffset)
10194
}
10295
}
103-

Example/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- MSPeekCollectionViewDelegateImplementation (2.0.0)
2+
- MSPeekCollectionViewDelegateImplementation (3.0.0)
33

44
DEPENDENCIES:
55
- MSPeekCollectionViewDelegateImplementation (from `../`)
@@ -9,7 +9,7 @@ EXTERNAL SOURCES:
99
:path: "../"
1010

1111
SPEC CHECKSUMS:
12-
MSPeekCollectionViewDelegateImplementation: 3091e9512b3cd03facdea3c02e57673a4a06246a
12+
MSPeekCollectionViewDelegateImplementation: e1c53a3d70dc37850d529f9fc9b07c29767fccf7
1313

1414
PODFILE CHECKSUM: 8d230cee08c8a8b7e62859eff8016277efe2311d
1515

Example/Pods/Local Podspecs/MSPeekCollectionViewDelegateImplementation.podspec.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Manifest.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)