Skip to content

Commit

Permalink
Merge branch 'release/2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
msaps committed Nov 24, 2017
2 parents 814f1ac + fdfcabf commit 3d7dbd5
Show file tree
Hide file tree
Showing 15 changed files with 190 additions and 131 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
`Pageboy` adheres to [Semantic Versioning](http://semver.org/).

#### 2.x Releases
- `2.1.x` Releases - [2.1.0](#210)
- `2.0.x` Releases - [2.0.0](#200) | [2.0.1](#201) | [2.0.2](#202) | [2.0.3](#203) | [2.0.4](#204)

#### 1.x Releases
Expand All @@ -17,6 +18,17 @@ All notable changes to this project will be documented in this file.

---

## [2.1.0](https://github.com/uias/Pageboy/releases/tag/2.1.0)
Released on 2017-11-24

#### Added
- [#116](https://github.com/uias/Pageboy/issues/116) Support for built-in `UIPageViewController` page control.
- by [msaps](https://github.com/msaps).
- [#116](https://github.com/uias/Pageboy/issues/116) `showsPageControl` to `PageboyViewController`.
- by [msaps](https://github.com/msaps).

---

## [2.0.4](https://github.com/uias/Pageboy/releases/tag/2.0.4)
Released on 2017-11-11

Expand Down
4 changes: 2 additions & 2 deletions Example/Pageboy-Example/ChildViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class ChildViewController: UIViewController {
super.viewDidLoad()

if let index = self.index {
self.label.text = "Page " + String(index)
self.promptLabel.isHidden = index != 1
label.text = "Page " + String(index)
promptLabel.isHidden = index != 1
}
}
}
26 changes: 13 additions & 13 deletions Example/Pageboy-Example/GradientView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,48 +68,48 @@ import UIKit
animation.isRemovedOnCompletion = true
animation.fillMode = kCAFillModeForwards
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
self.gradientLayer?.add(animation, forKey: "colors")
gradientLayer?.add(animation, forKey: "colors")
}
}

// MARK: Gradient

func updateGradient() {
guard let colors = self.colors else {
self.gradientLayer?.colors = []
gradientLayer?.colors = []
return
}

var colorRefs = [CGColor]()
for color in colors {
colorRefs.append(color.cgColor)
}
self.gradientLayer?.colors = colorRefs
gradientLayer?.colors = colorRefs

if let locations = self.locations {
var locationNumbers = [NSNumber]()
for location in locations {
locationNumbers.append(NSNumber(value: location))
}
self.gradientLayer?.locations = locationNumbers
gradientLayer?.locations = locationNumbers
}

switch self.direction {
switch direction {
case .topToBottom:
self.gradientLayer?.startPoint = CGPoint(x: 0.5, y: 0.0)
self.gradientLayer?.endPoint = CGPoint(x: 0.5, y: 1.0)
gradientLayer?.startPoint = CGPoint(x: 0.5, y: 0.0)
gradientLayer?.endPoint = CGPoint(x: 0.5, y: 1.0)

case .leftToRight:
self.gradientLayer?.startPoint = CGPoint(x: 0.0, y: 0.5)
self.gradientLayer?.endPoint = CGPoint(x: 1.0, y: 0.5)
gradientLayer?.startPoint = CGPoint(x: 0.0, y: 0.5)
gradientLayer?.endPoint = CGPoint(x: 1.0, y: 0.5)

case .rightToLeft:
self.gradientLayer?.startPoint = CGPoint(x: 1.0, y: 0.5)
self.gradientLayer?.endPoint = CGPoint(x: 0.0, y: 0.5)
gradientLayer?.startPoint = CGPoint(x: 1.0, y: 0.5)
gradientLayer?.endPoint = CGPoint(x: 0.0, y: 0.5)

case .bottomToTop:
self.gradientLayer?.startPoint = CGPoint(x: 0.5, y: 1.0)
self.gradientLayer?.endPoint = CGPoint(x: 0.5, y: 0.0)
gradientLayer?.startPoint = CGPoint(x: 0.5, y: 1.0)
gradientLayer?.endPoint = CGPoint(x: 0.5, y: 0.0)
}
}
}
16 changes: 8 additions & 8 deletions Example/Pageboy-Example/PageViewController+Appearance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ extension PageViewController {

let previousBarButton = UIBarButtonItem(title: "Previous", style: .plain, target: self, action: #selector(previousPage(_:)))
let nextBarButton = UIBarButtonItem(title: "Next", style: .plain, target: self, action: #selector(nextPage(_:)))
self.navigationItem.setLeftBarButton(previousBarButton, animated: false)
self.navigationItem.setRightBarButton(nextBarButton, animated: false)
navigationItem.setLeftBarButton(previousBarButton, animated: false)
navigationItem.setRightBarButton(nextBarButton, animated: false)
self.previousBarButton = previousBarButton
self.nextBarButton = nextBarButton

self.updateBarButtonStates(index: self.currentIndex ?? 0)
updateBarButtonStates(index: currentIndex ?? 0)
}

func updateBarButtonStates(index: Int) {
self.previousBarButton?.isEnabled = index != 0
self.nextBarButton?.isEnabled = index != (self.pageCount ?? 0) - 1
self.nextBarButton?.isEnabled = index != (pageCount ?? 0) - 1
}


Expand All @@ -44,8 +44,8 @@ extension PageViewController {
let lowerIndex = Int(floor(pageOffset))
let upperIndex = Int(ceil(pageOffset))

let lowerGradient = self.gradient(forIndex: lowerIndex)
let upperGradient = self.gradient(forIndex: upperIndex)
let lowerGradient = gradient(forIndex: lowerIndex)
let upperGradient = gradient(forIndex: upperIndex)

if let topColor = interpolate(betweenColor: lowerGradient.topColor,
and: upperGradient.topColor,
Expand All @@ -59,11 +59,11 @@ extension PageViewController {
}

func gradient(forIndex index: Int) -> GradientConfig {
guard index >= 0 && index < self.gradients.count else {
guard index >= 0 && index < gradients.count else {
return .defaultGradient
}

return self.gradients[index]
return gradients[index]
}

func interpolate(betweenColor colorA: UIColor,
Expand Down
25 changes: 12 additions & 13 deletions Example/Pageboy-Example/PageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ class PageViewController: PageboyViewController {

override func viewDidLoad() {
super.viewDidLoad()
self.addBarButtons()
self.view.sendSubview(toBack: self.gradientView)
addBarButtons()
view.sendSubview(toBack: gradientView)

self.dataSource = self
self.delegate = self
dataSource = self
delegate = self

self.updateGradient(for: self.currentPosition?.x ?? 0.0)
self.updateStatusLabels()
self.updateBarButtonStates(index: self.currentIndex ?? 0)
updateGradient(for: currentPosition?.x ?? 0.0)
updateStatusLabels()
updateBarButtonStates(index: currentIndex ?? 0)
}

func updateStatusLabels() {
Expand All @@ -70,11 +70,11 @@ class PageViewController: PageboyViewController {
// MARK: Actions

@objc func nextPage(_ sender: UIBarButtonItem) {
self.scrollToPage(.next, animated: true)
scrollToPage(.next, animated: true)
}

@objc func previousPage(_ sender: UIBarButtonItem) {
self.scrollToPage(.previous, animated: true)
scrollToPage(.previous, animated: true)
}
}

Expand Down Expand Up @@ -124,10 +124,9 @@ extension PageViewController: PageboyViewControllerDelegate {
animated: Bool) {
// print("didScrollToPageAtIndex: \(index)")

self.updateGradient(for: CGFloat(index))
self.updateStatusLabels()

self.updateBarButtonStates(index: index)
updateGradient(for: CGFloat(index))
updateStatusLabels()
updateBarButtonStates(index: index)
}

func pageboyViewController(_ pageboyViewController: PageboyViewController,
Expand Down
6 changes: 3 additions & 3 deletions Example/Pageboy-Example/TransparentNavigationBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ class TransparentNavigationBar: UINavigationBar {
override func layoutSubviews() {
super.layoutSubviews()

self.separatorView.frame = CGRect(x: 0.0,
y: self.bounds.size.height - 1.0,
width: self.bounds.size.width, height: 0.5)
separatorView.frame = CGRect(x: 0.0,
y: self.bounds.size.height - 1.0,
width: self.bounds.size.width, height: 0.5)
}

}
2 changes: 1 addition & 1 deletion Pageboy.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Pod::Spec.new do |s|

s.requires_arc = true

s.version = "2.0.4"
s.version = "2.1.0"
s.summary = "A simple, highly informative page view controller."
s.description = <<-DESC
A page view controller that provides simplified data source management, enhanced delegation and other useful features.
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ func defaultPage(for pageboyViewController: PageboyViewController) -> PageboyVie

### Delegation

`UIPageViewController` doesn't provide the most useful delegate methods for detecting where you are when paging; this is where Pageboy comes in. `PageboyViewControllerDelegate` provides a number of functions for being able to detect where the page view controller is, and where it's headed.
Unfortunately, `UIPageViewController` doesn't provide the most useful delegate methods for detecting positional data. `PageboyViewControllerDelegate` provides a number of functions for being able to detect where the page view controller is, and where it's headed.

#### willScrollToPageAtIndex
Called when the page view controller is about to embark on a transition to a new page.
The page view controller is about to embark on a transition to a new page.

```swift
func pageboyViewController(_ pageboyViewController: PageboyViewController,
Expand All @@ -96,7 +96,7 @@ func pageboyViewController(_ pageboyViewController: PageboyViewController,
```

#### didScrollToPosition
Called when the page view controller was scrolled to a relative position along the way transitioning to a new page. Also provided is the direction of the transition.
The page view controller was scrolled to a relative position along the way transitioning to a new page. Also provided is the direction of the transition.

```swift
func pageboyViewController(_ pageboyViewController: PageboyViewController,
Expand All @@ -106,7 +106,7 @@ func pageboyViewController(_ pageboyViewController: PageboyViewController,
```

#### didScrollToPage
Called when the page view controller did successfully complete a scroll transition to a page.
The page view controller has successfully completed a scroll transition to a page.

```swift
func pageboyViewController(_ pageboyViewController: PageboyViewController,
Expand All @@ -116,7 +116,7 @@ func pageboyViewController(_ pageboyViewController: PageboyViewController,
```

#### didReload
Called when the page view controller reloads its child view controllers.
The page view controller has reloaded its child view controllers.

```swift
func pageboyViewController(_ pageboyViewController: PageboyViewController,
Expand All @@ -143,6 +143,7 @@ func pageboyViewController(_ pageboyViewController: PageboyViewController,
- `currentViewController` - The currently visible view controller if it exists.
- `currentPosition` - The exact current relative position of the page view controller.
- `currentIndex` - The index of the currently visible page.
- `showsPageControl` - Whether to show the built-in page control.

### Transitioning
Pageboy also provides custom animated transition support. This can be customised via the `.transition` property on `PageboyViewController`.
Expand Down
12 changes: 12 additions & 0 deletions Sources/Pageboy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
4653DD551FC8333E00C4B758 /* PageboyViewControllerDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4653DD541FC8333E00C4B758 /* PageboyViewControllerDataSource.swift */; };
4653DD561FC8333E00C4B758 /* PageboyViewControllerDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4653DD541FC8333E00C4B758 /* PageboyViewControllerDataSource.swift */; };
4653DD581FC8335F00C4B758 /* PageboyViewControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4653DD571FC8335F00C4B758 /* PageboyViewControllerDelegate.swift */; };
4653DD591FC8335F00C4B758 /* PageboyViewControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4653DD571FC8335F00C4B758 /* PageboyViewControllerDelegate.swift */; };
466A76B61FB38B32000B5C1C /* PageboyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D623B1D11E1D2DF200527F3D /* PageboyViewController.swift */; };
466A76B71FB38B32000B5C1C /* PageboyViewController+Management.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6CC557C1ECCC55F00A7FBB4 /* PageboyViewController+Management.swift */; };
466A76B81FB38B32000B5C1C /* PageboyViewController+ScrollDetection.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6CC557D1ECCC55F00A7FBB4 /* PageboyViewController+ScrollDetection.swift */; };
Expand Down Expand Up @@ -61,6 +65,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
4653DD541FC8333E00C4B758 /* PageboyViewControllerDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageboyViewControllerDataSource.swift; sourceTree = "<group>"; };
4653DD571FC8335F00C4B758 /* PageboyViewControllerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageboyViewControllerDelegate.swift; sourceTree = "<group>"; };
D623B1B71E1D0C6A00527F3D /* Pageboy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pageboy.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D623B1BA1E1D0C6A00527F3D /* Pageboy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Pageboy.h; sourceTree = "<group>"; };
D623B1BB1E1D0C6A00527F3D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -146,6 +152,8 @@
children = (
D623B1BA1E1D0C6A00527F3D /* Pageboy.h */,
D623B1D11E1D2DF200527F3D /* PageboyViewController.swift */,
4653DD571FC8335F00C4B758 /* PageboyViewControllerDelegate.swift */,
4653DD541FC8333E00C4B758 /* PageboyViewControllerDataSource.swift */,
D6CC55791ECCC54100A7FBB4 /* Extensions */,
D6CC55781ECCC54100A7FBB4 /* Components */,
D6ECCEC01E51AFDB00E9D5B3 /* Utilities */,
Expand Down Expand Up @@ -423,12 +431,14 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4653DD551FC8333E00C4B758 /* PageboyViewControllerDataSource.swift in Sources */,
D6F6F8FC1EF6DC49006397D0 /* UIViewController+PageboyExtras.swift in Sources */,
D6CC557B1ECCC55300A7FBB4 /* PageboyAutoScroller.swift in Sources */,
D6CC557E1ECCC55F00A7FBB4 /* PageboyViewController+Management.swift in Sources */,
D67E6FDD1F1E58EE0019AB74 /* TransitionOperation.swift in Sources */,
D623B1D21E1D2DF200527F3D /* PageboyViewController.swift in Sources */,
D67E6FDE1F1E58EE0019AB74 /* UIView+AutoLayout.swift in Sources */,
4653DD581FC8335F00C4B758 /* PageboyViewControllerDelegate.swift in Sources */,
D67E6FDC1F1E58EE0019AB74 /* TransitionOperation+Action.swift in Sources */,
D67E6FE61F1E59160019AB74 /* WeakWrapper.swift in Sources */,
D67E6FE11F1E58FE0019AB74 /* UIPageViewController+ScrollView.swift in Sources */,
Expand Down Expand Up @@ -461,12 +471,14 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4653DD561FC8333E00C4B758 /* PageboyViewControllerDataSource.swift in Sources */,
466A76BD1FB38B32000B5C1C /* TransitionOperation+Action.swift in Sources */,
466A76B81FB38B32000B5C1C /* PageboyViewController+ScrollDetection.swift in Sources */,
466A76BB1FB38B32000B5C1C /* UIViewController+PageboyExtras.swift in Sources */,
466A76C01FB38B32000B5C1C /* UIView+Localization.swift in Sources */,
466A76BC1FB38B32000B5C1C /* PageboyAutoScroller.swift in Sources */,
466A76B61FB38B32000B5C1C /* PageboyViewController.swift in Sources */,
4653DD591FC8335F00C4B758 /* PageboyViewControllerDelegate.swift in Sources */,
466A76BF1FB38B32000B5C1C /* UIView+AutoLayout.swift in Sources */,
466A76C31FB38B32000B5C1C /* WeakWrapper.swift in Sources */,
466A76BA1FB38B32000B5C1C /* PageboyViewController+Extras.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ extension PageboyViewController: UIPageViewControllerDelegate, UIScrollViewDeleg
}
}

public func presentationCount(for pageViewController: UIPageViewController) -> Int {
guard showsPageControl else {
return -1
}
return pageCount ?? 0
}

public func presentationIndex(for pageViewController: UIPageViewController) -> Int {
guard showsPageControl else {
return -1
}
return targetIndex ?? 0
}

// MARK: UIScrollViewDelegate

public func scrollViewDidScroll(_ scrollView: UIScrollView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ internal extension PageboyViewController {
completion: @escaping TransitionOperation.Completion) {
guard animated == true else { return }
guard self.activeTransition == nil else { return }
guard let pageViewController = self.pageViewController else { return }
guard let scrollView = self.pageViewController?.scrollView else { return }

prepareForTransition()

Expand All @@ -113,7 +113,7 @@ internal extension PageboyViewController {
self.transitionDisplayLink?.isPaused = false

// start transition
self.activeTransition?.start(on: pageViewController.view.layer,
self.activeTransition?.start(on: scrollView.layer,
completion: completion)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Pageboy/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>2.0.4</string>
<string>2.1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
Loading

0 comments on commit 3d7dbd5

Please sign in to comment.