Commit 4d61e3f8 by Daniel Dahan

renamed TabsController to TabBarController

parent 0de308b9
...@@ -84,36 +84,36 @@ fileprivate extension ChipItem { ...@@ -84,36 +84,36 @@ fileprivate extension ChipItem {
} }
} }
@objc(ChipsDelegate) @objc(ChipBarDelegate)
public protocol ChipsDelegate { public protocol ChipBarDelegate {
/** /**
A delegation method that is executed when the chipItem will trigger the A delegation method that is executed when the chipItem will trigger the
animation to the next chip. animation to the next chip.
- Parameter chipBar: A Chips. - Parameter chipBar: A ChipBar.
- Parameter chipItem: A ChipItem. - Parameter chipItem: A ChipItem.
*/ */
@objc @objc
optional func chipBar(chipBar: Chips, willSelect chipItem: ChipItem) optional func chipBar(chipBar: ChipBar, willSelect chipItem: ChipItem)
/** /**
A delegation method that is executed when the chipItem did complete the A delegation method that is executed when the chipItem did complete the
animation to the next chip. animation to the next chip.
- Parameter chipBar: A Chips. - Parameter chipBar: A ChipBar.
- Parameter chipItem: A ChipItem. - Parameter chipItem: A ChipItem.
*/ */
@objc @objc
optional func chipBar(chipBar: Chips, didSelect chipItem: ChipItem) optional func chipBar(chipBar: ChipBar, didSelect chipItem: ChipItem)
} }
@objc(ChipsStyle) @objc(ChipBarStyle)
public enum ChipsStyle: Int { public enum ChipBarStyle: Int {
case auto case auto
case nonScrollable case nonScrollable
case scrollable case scrollable
} }
open class Chips: Bar { open class ChipBar: Bar {
/// A boolean indicating if the Chips line is in an animation state. /// A boolean indicating if the ChipBar is in an animation state.
open fileprivate(set) var isAnimating = false open fileprivate(set) var isAnimating = false
/// The total width of the chipItems. /// The total width of the chipItems.
...@@ -128,7 +128,7 @@ open class Chips: Bar { ...@@ -128,7 +128,7 @@ open class Chips: Bar {
} }
/// An enum that determines the chip bar style. /// An enum that determines the chip bar style.
open var chipBarStyle = ChipsStyle.auto { open var chipBarStyle = ChipBarStyle.auto {
didSet { didSet {
layoutSubviews() layoutSubviews()
} }
...@@ -148,7 +148,7 @@ open class Chips: Bar { ...@@ -148,7 +148,7 @@ open class Chips: Bar {
} }
/// A delegation reference. /// A delegation reference.
open weak var delegate: ChipsDelegate? open weak var delegate: ChipBarDelegate?
/// The currently selected chipItem. /// The currently selected chipItem.
open fileprivate(set) var selected: ChipItem? open fileprivate(set) var selected: ChipItem?
...@@ -330,7 +330,7 @@ open class Chips: Bar { ...@@ -330,7 +330,7 @@ open class Chips: Bar {
} }
} }
fileprivate extension Chips { fileprivate extension ChipBar {
/// Prepares the divider. /// Prepares the divider.
func prepareDivider() { func prepareDivider() {
dividerColor = Color.grey.lighten3 dividerColor = Color.grey.lighten3
...@@ -362,7 +362,7 @@ fileprivate extension Chips { ...@@ -362,7 +362,7 @@ fileprivate extension Chips {
} }
} }
fileprivate extension Chips { fileprivate extension ChipBar {
/// Handles the chipItem touch event. /// Handles the chipItem touch event.
@objc @objc
func handle(chipItem: ChipItem) { func handle(chipItem: ChipItem) {
...@@ -370,7 +370,7 @@ fileprivate extension Chips { ...@@ -370,7 +370,7 @@ fileprivate extension Chips {
} }
} }
extension Chips { extension ChipBar {
/** /**
Selects a given index from the chipItems array. Selects a given index from the chipItems array.
- Parameter at index: An Int. - Parameter at index: An Int.
...@@ -393,7 +393,7 @@ extension Chips { ...@@ -393,7 +393,7 @@ extension Chips {
} }
} }
fileprivate extension Chips { fileprivate extension ChipBar {
/** /**
Animates to a given chipItem. Animates to a given chipItem.
- Parameter to chipItem: A ChipItem. - Parameter to chipItem: A ChipItem.
......
/*
* Copyright (C) 2015 - 2017, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.com>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
fileprivate var ChipItemKey: UInt8 = 0
@objc(ChipBarAlignment)
public enum ChipBarAlignment: Int {
case top
case bottom
case hidden
}
extension UIViewController {
/**
A convenience property that provides access to the ChipBarController.
This is the recommended method of accessing the ChipBarController
through child UIViewControllers.
*/
public var chipsController: ChipBarController? {
return traverseViewControllerHierarchyForClassType()
}
}
open class ChipBarController: TransitionController {
/**
A Display value to indicate whether or not to
display the rootViewController to the full view
bounds, or up to the toolbar height.
*/
open var displayStyle = DisplayStyle.partial {
didSet {
layoutSubviews()
}
}
/// The ChipBar used to switch between view controllers.
@IBInspectable
open let chipBar = ChipBar()
/// The chipBar alignment.
open var chipBarAlignment = ChipBarAlignment.bottom {
didSet {
layoutSubviews()
}
}
open override func layoutSubviews() {
super.layoutSubviews()
chipBar.width = view.width
switch displayStyle {
case .partial:
let h = chipBar.height
container.y = h
container.height = view.height - h
case .full:
container.frame = view.bounds
}
rootViewController.view.frame = container.bounds
}
open override func prepare() {
super.prepare()
prepareChipBar()
}
}
fileprivate extension ChipBarController {
/// Prepares the ChipBar.
func prepareChipBar() {
chipBar.depthPreset = .depth1
view.addSubview(chipBar)
}
}
...@@ -31,13 +31,6 @@ ...@@ -31,13 +31,6 @@
import UIKit import UIKit
open class FABButton: Button { open class FABButton: Button {
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
depthPreset = .depth1 depthPreset = .depth1
......
...@@ -31,13 +31,6 @@ ...@@ -31,13 +31,6 @@
import UIKit import UIKit
open class FlatButton: Button { open class FlatButton: Button {
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
cornerRadiusPreset = .cornerRadius1 cornerRadiusPreset = .cornerRadius1
......
...@@ -31,14 +31,7 @@ ...@@ -31,14 +31,7 @@
import UIKit import UIKit
open class IconButton: Button { open class IconButton: Button {
/** open override func prepare() {
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() {
super.prepare() super.prepare()
pulseAnimation = .center pulseAnimation = .center
} }
......
...@@ -31,13 +31,6 @@ ...@@ -31,13 +31,6 @@
import UIKit import UIKit
open class RaisedButton: Button { open class RaisedButton: Button {
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
depthPreset = .depth1 depthPreset = .depth1
......
...@@ -153,13 +153,6 @@ open class SearchBar: Bar { ...@@ -153,13 +153,6 @@ open class SearchBar: Bar {
layoutClearButton() layoutClearButton()
} }
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
prepareTextField() prepareTextField()
......
...@@ -66,13 +66,6 @@ open class SearchBarController: StatusBarController { ...@@ -66,13 +66,6 @@ open class SearchBarController: StatusBarController {
rootViewController.view.frame = container.bounds rootViewController.view.frame = container.bounds
} }
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
displayStyle = .partial displayStyle = .partial
......
...@@ -80,11 +80,6 @@ open class StatusBarController: TransitionController { ...@@ -80,11 +80,6 @@ open class StatusBarController: TransitionController {
/// A reference to the statusBar. /// A reference to the statusBar.
open let statusBar = UIView() open let statusBar = UIView()
/**
To execute in the order of the layout chain, override this
method. LayoutSubviews should be called immediately, unless you
have a certain need.
*/
open override func layoutSubviews() { open override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
...@@ -106,13 +101,6 @@ open class StatusBarController: TransitionController { ...@@ -106,13 +101,6 @@ open class StatusBarController: TransitionController {
rootViewController.view.frame = container.bounds rootViewController.view.frame = container.bounds
} }
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
prepareStatusBar() prepareStatusBar()
......
...@@ -72,7 +72,7 @@ public enum TabBarStyle: Int { ...@@ -72,7 +72,7 @@ public enum TabBarStyle: Int {
} }
open class TabBar: Bar { open class TabBar: Bar {
/// A boolean indicating if the TabBar line is in an animation state. /// A boolean indicating if the TabBar is in an animation state.
open fileprivate(set) var isAnimating = false open fileprivate(set) var isAnimating = false
/// The total width of the tabItems. /// The total width of the tabItems.
......
...@@ -55,16 +55,16 @@ extension UIViewController { ...@@ -55,16 +55,16 @@ extension UIViewController {
extension UIViewController { extension UIViewController {
/** /**
A convenience property that provides access to the TabsController. A convenience property that provides access to the TabBarController.
This is the recommended method of accessing the TabsController This is the recommended method of accessing the TabBarController
through child UIViewControllers. through child UIViewControllers.
*/ */
public var tabsController: TabsController? { public var tabsController: TabBarController? {
return traverseViewControllerHierarchyForClassType() return traverseViewControllerHierarchyForClassType()
} }
} }
open class TabsController: UIViewController { open class TabBarController: UIViewController {
/// The TabBar used to switch between view controllers. /// The TabBar used to switch between view controllers.
@IBInspectable @IBInspectable
open let tabBar = TabBar() open let tabBar = TabBar()
...@@ -157,7 +157,7 @@ open class TabsController: UIViewController { ...@@ -157,7 +157,7 @@ open class TabsController: UIViewController {
} }
} }
fileprivate extension TabsController { fileprivate extension TabBarController {
/// Prepares the container view. /// Prepares the container view.
func prepareContainer() { func prepareContainer() {
view.addSubview(container) view.addSubview(container)
...@@ -218,7 +218,7 @@ fileprivate extension TabsController { ...@@ -218,7 +218,7 @@ fileprivate extension TabsController {
} }
} }
fileprivate extension TabsController { fileprivate extension TabBarController {
/// Layout the container view. /// Layout the container view.
func layoutContainer() { func layoutContainer() {
let p = tabBar.height let p = tabBar.height
...@@ -263,7 +263,7 @@ fileprivate extension TabsController { ...@@ -263,7 +263,7 @@ fileprivate extension TabsController {
} }
} }
fileprivate extension TabsController { fileprivate extension TabBarController {
/** /**
Removes the view controller as a child view controller with Removes the view controller as a child view controller with
the given index. the given index.
...@@ -290,7 +290,7 @@ fileprivate extension TabsController { ...@@ -290,7 +290,7 @@ fileprivate extension TabsController {
} }
} }
fileprivate extension TabsController { fileprivate extension TabBarController {
/** /**
Handles the tabItem. Handles the tabItem.
- Parameter tabItem: A TabItem. - Parameter tabItem: A TabItem.
......
...@@ -135,13 +135,6 @@ open class Toolbar: Bar { ...@@ -135,13 +135,6 @@ open class Toolbar: Bar {
} }
} }
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
contentViewAlignment = .center contentViewAlignment = .center
......
...@@ -67,13 +67,6 @@ open class ToolbarController: StatusBarController { ...@@ -67,13 +67,6 @@ open class ToolbarController: StatusBarController {
rootViewController.view.frame = container.bounds rootViewController.view.frame = container.bounds
} }
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
displayStyle = .partial displayStyle = .partial
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment