Skip to content

Commit

Permalink
Fix minor issues & update podspec
Browse files Browse the repository at this point in the history
  • Loading branch information
nrlnishan committed Apr 13, 2019
1 parent 11fb1dc commit b911be5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ViewPager-Swift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'ViewPager-Swift'
s.version = '1.2.1'
s.version = '2.0.0'
s.summary = 'Simple View Pager library for swift using UIPageViewController and Scroll View.'

s.description = <<-DESC
Expand Down
14 changes: 6 additions & 8 deletions ViewPager-Swift/Core/ViewPagerOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class ViewPagerOptions {
public var tabViewTextFont:UIFont = UIFont.systemFont(ofSize: 14, weight: .medium)

public var tabViewImageSize:CGSize = CGSize(width: 20, height: 20)
public var tabViewImageMarginTop:CGFloat = 5
public var tabViewImageMarginTop:CGFloat = 10
public var tabViewImageMarginBottom:CGFloat = 5

public var shadowColor: UIColor = UIColor.black
Expand All @@ -57,23 +57,21 @@ public class ViewPagerOptions {
public var tabIndicatorViewHeight:CGFloat = 3
public var tabIndicatorViewBackgroundColor:UIColor = Color.tabIndicator


// ViewPager
public var viewPagerTransitionStyle:UIPageViewController.TransitionStyle = .scroll


public init() {
// Initialization
}

fileprivate struct Color {

static let tabViewBackground = UIColor.white
static let tabViewHighlight = UIColor.groupTableViewBackground
static let tabViewBackground = UIColor(red: 23 / 255.0, green: 26/255.0, blue: 33/255.0, alpha: 1.0)
static let tabViewHighlight = tabViewBackground.withAlphaComponent(0.8)

static let textDefault = UIColor.darkText
static let textHighlight = UIColor.darkText
static let textDefault = UIColor.white
static let textHighlight = UIColor.white

static let tabIndicator = UIColor(red: 36 / 255.0, green: 90/255.0, blue: 153/255.0, alpha: 1.0)
static let tabIndicator = UIColor(red: 214 / 255.0, green: 73/255.0, blue: 51/255.0, alpha: 1.0)
}
}
9 changes: 9 additions & 0 deletions ViewPager-Swift/ItemViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,14 @@ class ItemViewController: UIViewController {

itemLabel.text = itemText
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

// Access the navigation controller if you want from child
if let parentPageViewController = self.parent {
parentPageViewController.parent?.navigationItem.title = itemText
}
}
}

12 changes: 12 additions & 0 deletions ViewPager-Swift/TestViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ import UIKit

class TestViewController: UIViewController {

let tabs2 = [
ViewPagerTab(title: "Cheese", image: UIImage(named: "cheese")),
ViewPagerTab(title: "Cupcake", image: UIImage(named: "cupcake")),
ViewPagerTab(title: "Doughnut", image: UIImage(named: "doughnut")),
ViewPagerTab(title: "Fish", image: UIImage(named: "fish")),
ViewPagerTab(title: "Meat", image: UIImage(named: "meat")),
ViewPagerTab(title: "Milk", image: UIImage(named: "milk")),
ViewPagerTab(title: "Water", image: UIImage(named: "water"))
]

var tabs = [ViewPagerTab]()

var options: ViewPagerOptions?
Expand All @@ -33,8 +43,10 @@ class TestViewController: UIViewController {
pager?.setDataSource(dataSource: self)
pager?.setDelegate(delegate: self)
pager?.build()

}


deinit {
print("Memory Deallocation")
}
Expand Down
5 changes: 2 additions & 3 deletions ViewPager-Swift/ViewPager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class ViewPager: NSObject {
tabContainer.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(tabContainer)

tabContainer.backgroundColor = UIColor.white
tabContainer.backgroundColor = options.tabViewBackgroundDefaultColor
tabContainer.isScrollEnabled = true
tabContainer.showsVerticalScrollIndicator = false
tabContainer.showsHorizontalScrollIndicator = false
Expand Down Expand Up @@ -312,7 +312,6 @@ public class ViewPager: NSObject {
}



/// Returns UIViewController for page at provided index.
fileprivate func getPageItemViewController(atIndex index:Int) -> UIViewController? {

Expand Down Expand Up @@ -361,7 +360,7 @@ public class ViewPager: NSObject {
}

/// Invalidate the current tab layout and causes the layout to be drawn again.
public func invalidateTabs() {
public func invalidateCurrentTabs() {

// Removing all the tabs from tabContainer
_ = tabsViewList.map({ $0.removeFromSuperview() })
Expand Down

0 comments on commit b911be5

Please sign in to comment.