Skip to content

Commit

Permalink
Added Color Transition
Browse files Browse the repository at this point in the history
- Removed the extra delegation methods
  • Loading branch information
Minitour committed Apr 7, 2017
1 parent 08659ad commit 69a6984
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 45 deletions.
21 changes: 0 additions & 21 deletions SwiftyOnboard/SwiftyOnboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,13 @@ public protocol SwiftyOnboardDelegate: class {
func swiftyOnboard(_ swiftyOnboard: SwiftyOnboard, currentPage index: Int)
func swiftyOnboard(_ swiftyOnboard: SwiftyOnboard, leftEdge position: Double)
func swiftyOnboard(_ swiftyOnboard: SwiftyOnboard, tapped index: Int)
func swiftyOnboard(_ swiftyOnboard: SwiftyOnboard, didClickContinue button: UIButton,atIndex index: Int)
func swiftyOnboard(_ swiftyOnboard: SwiftyOnboard, didClickSkip button: UIButton, atIndex index: Int)

}

public extension SwiftyOnboardDelegate {
func swiftyOnboard(_ swiftyOnboard: SwiftyOnboard, currentPage index: Int) {}
func swiftyOnboard(_ swiftyOnboard: SwiftyOnboard, leftEdge position: Double) {}
func swiftyOnboard(_ swiftyOnboard: SwiftyOnboard, tapped index: Int) {}
func swiftyOnboard(_ swiftyOnboard: SwiftyOnboard, didClickSkip button: UIButton, atIndex index: Int){}
func swiftyOnboard(_ swiftyOnboard: SwiftyOnboard, didClickContinue button: UIButton,atIndex index: Int){
if let count = swiftyOnboard.dataSource?.swiftyOnboardNumberOfPages(swiftyOnboard){
if index < count - 1{
swiftyOnboard.goToPage(index: index + 1, animated: true)
}
}
}
}

public class SwiftyOnboard: UIView, UIScrollViewDelegate {
Expand Down Expand Up @@ -270,17 +260,6 @@ public class SwiftyOnboard: UIView, UIScrollViewDelegate {
}
}

extension SwiftyOnboard: SwiftyOnboardOverlayDelegate{

public func onboardOverlay(_ onboardOverlay: SwiftyOnboardOverlay, didClickSkip button: UIButton) {
self.delegate?.swiftyOnboard(self, didClickSkip: button, atIndex: currentPage)
}

public func onboardOverlay(_ onboardOverlay: SwiftyOnboardOverlay, didClickContinue button: UIButton) {
self.delegate?.swiftyOnboard(self, didClickContinue: button, atIndex: currentPage)
}
}

public enum SwiftyOnboardStyle {
case light
case dark
Expand Down
30 changes: 6 additions & 24 deletions SwiftyOnboard/SwiftyOnboardOverlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,26 @@

import UIKit

public protocol SwiftyOnboardOverlayDelegate{

func onboardOverlay(_ onboardOverlay: SwiftyOnboardOverlay,didClickContinue button: UIButton)

func onboardOverlay(_ onboardOverlay: SwiftyOnboardOverlay,didClickSkip button: UIButton)
}

open class SwiftyOnboardOverlay: UIView {

public var delegate: SwiftyOnboardOverlayDelegate?

public var pageControl: UIPageControl = {
open var pageControl: UIPageControl = {
let pageControl = UIPageControl()
pageControl.currentPage = 0
pageControl.pageIndicatorTintColor = UIColor.lightGray
return pageControl
}()

public var continueButton: UIButton = {
open var continueButton: UIButton = {
let button = UIButton(type: .system)
button.setTitle("Continue", for: .normal)
button.contentHorizontalAlignment = .center
button.addTarget(self, action: #selector(didClickContinue(sender:)), for: .touchUpInside)
return button
}()

public var skipButton: UIButton = {
open var skipButton: UIButton = {
let button = UIButton(type: .system)
button.setTitle("Skip", for: .normal)
button.contentHorizontalAlignment = .right
button.addTarget(self, action: #selector(didClickSkip(sender:)), for: .touchUpInside)
return button
}()

Expand All @@ -60,7 +49,7 @@ open class SwiftyOnboardOverlay: UIView {
return false
}

func set(style: SwiftyOnboardStyle) {
open func set(style: SwiftyOnboardStyle) {
switch style {
case .light:
continueButton.setTitleColor(.white, for: .normal)
Expand All @@ -73,11 +62,11 @@ open class SwiftyOnboardOverlay: UIView {
}
}

public func page(count: Int) {
open func page(count: Int) {
pageControl.numberOfPages = count
}

public func currentPage(index: Int) {
open func currentPage(index: Int) {
pageControl.currentPage = index
}

Expand All @@ -104,11 +93,4 @@ open class SwiftyOnboardOverlay: UIView {
skipButton.rightAnchor.constraint(equalTo: self.rightAnchor, constant: -20).isActive = true
}

func didClickContinue(sender: UIButton){
delegate?.onboardOverlay(self, didClickContinue: sender)
}

func didClickSkip(sender: UIButton){
delegate?.onboardOverlay(self, didClickSkip: sender)
}
}

0 comments on commit 69a6984

Please sign in to comment.