Commit fa10e98d by Daniel Dahan

working copy of TabBar scrollable

parent d89f0976
...@@ -98,7 +98,6 @@ ...@@ -98,7 +98,6 @@
965E81211DD4D5C800D61E4B /* TextStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB79D1CB40DC500C806FE /* TextStorage.swift */; }; 965E81211DD4D5C800D61E4B /* TextStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB79D1CB40DC500C806FE /* TextStorage.swift */; };
965E81221DD4D5C800D61E4B /* TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB79E1CB40DC500C806FE /* TextView.swift */; }; 965E81221DD4D5C800D61E4B /* TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB79E1CB40DC500C806FE /* TextView.swift */; };
965E81261DD4D7C800D61E4B /* CharacterAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961276621DCD8B1800A7D920 /* CharacterAttribute.swift */; }; 965E81261DD4D7C800D61E4B /* CharacterAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961276621DCD8B1800A7D920 /* CharacterAttribute.swift */; };
966995491F1433C30064E7E4 /* PageTabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966995481F1433C30064E7E4 /* PageTabBarController.swift */; };
966C17731F0439F600D3E83C /* Material+MotionAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966C17721F0439F600D3E83C /* Material+MotionAnimation.swift */; }; 966C17731F0439F600D3E83C /* Material+MotionAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966C17721F0439F600D3E83C /* Material+MotionAnimation.swift */; };
9685D5AF1F0F04CB00AFEB79 /* CardCollectionViewCell.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9656895E1F002F16001C656D /* CardCollectionViewCell.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9685D5AF1F0F04CB00AFEB79 /* CardCollectionViewCell.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9656895E1F002F16001C656D /* CardCollectionViewCell.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9685D5B01F0F04CB00AFEB79 /* CardCollectionViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 965689601F002F4C001C656D /* CardCollectionViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9685D5B01F0F04CB00AFEB79 /* CardCollectionViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 965689601F002F4C001C656D /* CardCollectionViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
...@@ -205,7 +204,6 @@ ...@@ -205,7 +204,6 @@
96E3C39A1D3A1CC20086A024 /* ErrorTextField.swift in Headers */ = {isa = PBXBuildFile; fileRef = 961F18E71CD93E3E008927C5 /* ErrorTextField.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96E3C39A1D3A1CC20086A024 /* ErrorTextField.swift in Headers */ = {isa = PBXBuildFile; fileRef = 961F18E71CD93E3E008927C5 /* ErrorTextField.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96E3C39C1D3A1CC20086A024 /* Offset.swift in Headers */ = {isa = PBXBuildFile; fileRef = 968C99461D377849000074FF /* Offset.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96E3C39C1D3A1CC20086A024 /* Offset.swift in Headers */ = {isa = PBXBuildFile; fileRef = 968C99461D377849000074FF /* Offset.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96F1A5531F24F17A001D8CAF /* TabsController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96E09DC71F2287E50000B121 /* TabsController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96F1A5531F24F17A001D8CAF /* TabsController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96E09DC71F2287E50000B121 /* TabsController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96FE06C71F15348400E34953 /* PageTabBarController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 966995481F1433C30064E7E4 /* PageTabBarController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
...@@ -230,7 +228,6 @@ ...@@ -230,7 +228,6 @@
9656895E1F002F16001C656D /* CardCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardCollectionViewCell.swift; sourceTree = "<group>"; }; 9656895E1F002F16001C656D /* CardCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardCollectionViewCell.swift; sourceTree = "<group>"; };
965689601F002F4C001C656D /* CardCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardCollectionViewController.swift; sourceTree = "<group>"; }; 965689601F002F4C001C656D /* CardCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardCollectionViewController.swift; sourceTree = "<group>"; };
9658F2161CD6FA4700B902C1 /* IconButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IconButton.swift; sourceTree = "<group>"; }; 9658F2161CD6FA4700B902C1 /* IconButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IconButton.swift; sourceTree = "<group>"; };
966995481F1433C30064E7E4 /* PageTabBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageTabBarController.swift; sourceTree = "<group>"; };
966C17721F0439F600D3E83C /* Material+MotionAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+MotionAnimation.swift"; sourceTree = "<group>"; }; 966C17721F0439F600D3E83C /* Material+MotionAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+MotionAnimation.swift"; sourceTree = "<group>"; };
966ECF291CF4C20100BB0BDF /* CollectionReusableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionReusableView.swift; sourceTree = "<group>"; }; 966ECF291CF4C20100BB0BDF /* CollectionReusableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionReusableView.swift; sourceTree = "<group>"; };
967A48181D0F425A00B8CEB7 /* StatusBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarController.swift; sourceTree = "<group>"; }; 967A48181D0F425A00B8CEB7 /* StatusBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarController.swift; sourceTree = "<group>"; };
...@@ -512,14 +509,6 @@ ...@@ -512,14 +509,6 @@
name = CardCollectionView; name = CardCollectionView;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
966995471F1433640064E7E4 /* PageTabBar */ = {
isa = PBXGroup;
children = (
966995481F1433C30064E7E4 /* PageTabBarController.swift */,
);
name = PageTabBar;
sourceTree = "<group>";
};
966ECF2B1CF4C21B00BB0BDF /* Table */ = { 966ECF2B1CF4C21B00BB0BDF /* Table */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -570,7 +559,6 @@ ...@@ -570,7 +559,6 @@
96BCB8041CB40F6C00C806FE /* Layout */, 96BCB8041CB40F6C00C806FE /* Layout */,
96BCB8011CB40F1700C806FE /* Navigation */, 96BCB8011CB40F1700C806FE /* Navigation */,
961E6BEF1DDA4B04004E6C93 /* NavigationDrawer */, 961E6BEF1DDA4B04004E6C93 /* NavigationDrawer */,
966995471F1433640064E7E4 /* PageTabBar */,
9626CA951DAB5370003E2611 /* Root */, 9626CA951DAB5370003E2611 /* Root */,
961E6BE01DDA2ADD004E6C93 /* Screen */, 961E6BE01DDA2ADD004E6C93 /* Screen */,
963FBF031D6696EF008F8512 /* SearchBar */, 963FBF031D6696EF008F8512 /* SearchBar */,
...@@ -926,7 +914,6 @@ ...@@ -926,7 +914,6 @@
9685D5AF1F0F04CB00AFEB79 /* CardCollectionViewCell.swift in Headers */, 9685D5AF1F0F04CB00AFEB79 /* CardCollectionViewCell.swift in Headers */,
9685D5B01F0F04CB00AFEB79 /* CardCollectionViewController.swift in Headers */, 9685D5B01F0F04CB00AFEB79 /* CardCollectionViewController.swift in Headers */,
9685D5B11F0F04CB00AFEB79 /* Material+MotionAnimation.swift in Headers */, 9685D5B11F0F04CB00AFEB79 /* Material+MotionAnimation.swift in Headers */,
96FE06C71F15348400E34953 /* PageTabBarController.swift in Headers */,
96F1A5531F24F17A001D8CAF /* TabsController.swift in Headers */, 96F1A5531F24F17A001D8CAF /* TabsController.swift in Headers */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -1049,7 +1036,6 @@ ...@@ -1049,7 +1036,6 @@
965E811F1DD4D5C800D61E4B /* ErrorTextField.swift in Sources */, 965E811F1DD4D5C800D61E4B /* ErrorTextField.swift in Sources */,
965E81211DD4D5C800D61E4B /* TextStorage.swift in Sources */, 965E81211DD4D5C800D61E4B /* TextStorage.swift in Sources */,
965E81221DD4D5C800D61E4B /* TextView.swift in Sources */, 965E81221DD4D5C800D61E4B /* TextView.swift in Sources */,
966995491F1433C30064E7E4 /* PageTabBarController.swift in Sources */,
965E80E71DD4C55200D61E4B /* Material+UIView.swift in Sources */, 965E80E71DD4C55200D61E4B /* Material+UIView.swift in Sources */,
96DE3CD41F269BF00035F7AF /* MotionViewPropertyViewContext.swift in Sources */, 96DE3CD41F269BF00035F7AF /* MotionViewPropertyViewContext.swift in Sources */,
965E80E81DD4C55200D61E4B /* Material+CALayer.swift in Sources */, 965E80E81DD4C55200D61E4B /* Material+CALayer.swift in Sources */,
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>2.7.0</string> <string>2.8.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
/*
* 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
/// A memory reference to the PageTabBarItem instance for UIViewController extensions.
fileprivate var PageTabBarItemKey: UInt8 = 0
open class PageTabBarItem: FlatButton {
open override func prepare() {
super.prepare()
pulseAnimation = .none
}
}
open class PageTabBar: TabBar {
open override func prepare() {
super.prepare()
isLineAnimated = false
lineAlignment = .top
}
}
@objc(PageTabBarAlignment)
public enum PageTabBarAlignment: Int {
case top
case bottom
}
extension UIViewController {
/// Grid reference.
public private(set) var pageTabBarItem: PageTabBarItem {
get {
return AssociatedObject.get(base: self, key: &PageTabBarItemKey) {
return PageTabBarItem()
}
}
set(value) {
AssociatedObject.set(base: self, key: &PageTabBarItemKey, value: value)
}
}
}
extension UIViewController {
/**
A convenience property that provides access to the PageTabBarController.
This is the recommended method of accessing the PageTabBarController
through child UIViewControllers.
*/
public var pageTabBarController: PageTabBarController? {
var viewController: UIViewController? = self
while nil != viewController {
if viewController is PageTabBarController {
return viewController as? PageTabBarController
}
viewController = viewController?.parent
}
return nil
}
}
@objc(PageTabBarControllerDelegate)
public protocol PageTabBarControllerDelegate {
/**
A delegation method that is executed when a UIViewController did transition to.
- Parameter pageTabBarController: A PageTabBarController.
- Parameter willTransitionTo viewController: A UIViewController.
*/
@objc
optional func pageTabBarController(pageTabBarController: PageTabBarController, didTransitionTo viewController: UIViewController)
}
@objc(PageTabBarController)
open class PageTabBarController: RootController {
/// Reference to the PageTabBar.
@IBInspectable
open let pageTabBar = PageTabBar()
/// A boolean that indicates whether bounce is enabled.
open var isBounceEnabled: Bool {
didSet {
scrollView?.bounces = isBounceEnabled
}
}
/// Indicates that the tab has been pressed and animating.
open internal(set) var isTabSelectedAnimation = false
/// An internal reference to the selectedIndex.
fileprivate var internalSelectedIndex = 0
/// The currently selected UIViewController.
open var selectedIndex: Int {
get {
return internalSelectedIndex
}
set(value) {
setInternalSelectedIndex(index: value, animated: true)
}
}
/// PageTabBar alignment setting.
open var pageTabBarAlignment = PageTabBarAlignment.bottom
/// Delegation handler.
open weak var delegate: PageTabBarControllerDelegate?
/// A reference to the instance when it is a UIPageViewController.
open var pageViewController: UIPageViewController? {
return rootViewController as? UIPageViewController
}
/// A reference to the scrollView.
open var scrollView: UIScrollView? {
guard let v = pageViewController else {
return nil
}
for view in v.view.subviews {
if let v = view as? UIScrollView {
return v
}
}
return nil
}
/// A reference to the UIViewControllers.
open var viewControllers = [UIViewController]()
public required init?(coder aDecoder: NSCoder) {
isBounceEnabled = true
super.init(coder: aDecoder)
prepare()
}
public override init(rootViewController: UIViewController) {
isBounceEnabled = true
super.init(rootViewController: UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil))
viewControllers.append(rootViewController)
setInternalSelectedIndex(index: 0, animated: true)
prepare()
}
public init(viewControllers: [UIViewController], selectedIndex index: Int = 0) {
isBounceEnabled = true
super.init(rootViewController: UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil))
self.viewControllers.append(contentsOf: viewControllers)
setInternalSelectedIndex(index: index, animated: true)
prepare()
}
open override func layoutSubviews() {
super.layoutSubviews()
let p = pageTabBar.intrinsicContentSize.height + pageTabBar.layoutEdgeInsets.top + pageTabBar.layoutEdgeInsets.bottom
let y = view.height - p
pageTabBar.height = p
pageTabBar.width = view.width + pageTabBar.layoutEdgeInsets.left + pageTabBar.layoutEdgeInsets.right
rootViewController.view.height = y
switch pageTabBarAlignment {
case .top:
pageTabBar.y = 0
rootViewController.view.y = p
case .bottom:
pageTabBar.y = y
rootViewController.view.y = 0
}
}
/**
Sets the view controllers.
- Parameter _ viewController: An Array of UIViewControllers.
- Parameter direction: A UIPageViewControllerNavigationDirection enum value.
- Parameter animated: A boolean indicating to include animation.
- Parameter completion: An optional completion block.
*/
open func setViewControllers(_ viewControllers: [UIViewController], direction: UIPageViewControllerNavigationDirection, animated: Bool, completion: ((Bool) -> Void)? = nil) {
pageViewController?.setViewControllers(viewControllers, direction: direction, animated: animated, completion: completion)
}
/**
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()
preparePageTabBar()
prepareTabItems()
}
open override func prepareRootViewController() {
super.prepareRootViewController()
guard let v = pageViewController else {
return
}
v.delegate = self
v.dataSource = self
v.isDoubleSided = false
scrollView?.delegate = self
}
/// Prepares the pageTabBarItems.
open func prepareTabItems() {
pageTabBar.buttons.removeAll()
for x in viewControllers {
let button = x.pageTabBarItem as UIButton
pageTabBar.buttons.append(button)
button.removeTarget(self, action: #selector(handlePageTabBarButton(button:)), for: .touchUpInside)
button.addTarget(self, action: #selector(handlePageTabBarButton(button:)), for: .touchUpInside)
}
}
}
extension PageTabBarController {
/// Prepares the pageTabBar.
fileprivate func preparePageTabBar() {
pageTabBar.zPosition = 1000
pageTabBar.dividerColor = Color.grey.lighten3
view.addSubview(pageTabBar)
pageTabBar.select(at: internalSelectedIndex)
}
}
extension PageTabBarController {
/**
Handles the pageTabBarButton.
- Parameter button: A UIButton.
*/
@objc
fileprivate func handlePageTabBarButton(button: UIButton) {
guard let index = pageTabBar.buttons.index(of: button) else {
return
}
guard index != internalSelectedIndex else {
return
}
setInternalSelectedIndex(index: index, animated: true)
}
}
extension PageTabBarController {
/**
Internally sets the internalSelectedIndex value.
- Parameter index: Int.
- Parameter animated: Bool.
*/
fileprivate func setInternalSelectedIndex(index: Int, animated: Bool = false) {
guard animated else {
internalSelectedIndex = index
return
}
let direction: UIPageViewControllerNavigationDirection = index < internalSelectedIndex ? .reverse : .forward
isTabSelectedAnimation = true
internalSelectedIndex = index
pageTabBar.select(at: internalSelectedIndex)
setViewControllers([viewControllers[internalSelectedIndex]], direction: direction, animated: true) { [weak self] _ in
guard let s = self else {
return
}
s.isTabSelectedAnimation = false
s.delegate?.pageTabBarController?(pageTabBarController: s, didTransitionTo: s.viewControllers[s.internalSelectedIndex])
}
}
}
extension PageTabBarController: UIPageViewControllerDelegate {
open func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
guard let v = pageViewController.viewControllers?.first else {
return
}
guard let index = viewControllers.index(of: v) else {
return
}
setInternalSelectedIndex(index: index)
pageTabBar.select(at: index)
if finished && completed {
delegate?.pageTabBarController?(pageTabBarController: self, didTransitionTo: v)
}
}
}
extension PageTabBarController: UIPageViewControllerDataSource {
open func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
guard let current = viewControllers.index(of: viewController) else {
return nil
}
let previous = current - 1
guard previous >= 0 else {
return nil
}
return viewControllers[previous]
}
open func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
guard let current = viewControllers.index(of: viewController) else {
return nil
}
let next = current + 1
guard viewControllers.count > next else {
return nil
}
return viewControllers[next]
}
}
extension PageTabBarController: UIScrollViewDelegate {
open func scrollViewDidScroll(_ scrollView: UIScrollView) {
guard !pageTabBar.isAnimating else {
return
}
guard !isTabSelectedAnimation else {
return
}
guard let selected = pageTabBar.selected else {
return
}
guard 0 < view.width else {
return
}
let x = (scrollView.contentOffset.x - view.width) / CGFloat(viewControllers.count)
pageTabBar.line.center.x = selected.center.x + x
}
}
...@@ -59,7 +59,7 @@ public protocol TabBarDelegate { ...@@ -59,7 +59,7 @@ public protocol TabBarDelegate {
@objc(TabBarStyle) @objc(TabBarStyle)
public enum TabBarStyle: Int { public enum TabBarStyle: Int {
case normal case `default`
case scrollable case scrollable
} }
...@@ -78,7 +78,7 @@ open class TabBar: Bar { ...@@ -78,7 +78,7 @@ open class TabBar: Bar {
} }
/// An enum that determines the tab bar style. /// An enum that determines the tab bar style.
open var tabBarStyle = TabBarStyle.scrollable { open var tabBarStyle = TabBarStyle.default {
didSet { didSet {
layoutSubviews() layoutSubviews()
} }
...@@ -325,23 +325,25 @@ open class TabBar: Bar { ...@@ -325,23 +325,25 @@ open class TabBar: Bar {
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
contentEdgeInsetsPreset = .none contentEdgeInsetsPreset = .none
interimSpacePreset = .interimSpace5 interimSpacePreset = .interimSpace6
prepareContentView()
prepareScrollView() prepareScrollView()
prepareDivider() prepareDivider()
prepareLine() prepareLine()
} }
} }
extension TabBar { fileprivate extension TabBar {
// Prepares the line. // Prepares the line.
fileprivate func prepareLine() { func prepareLine() {
line.zPosition = 6000 line.zPosition = 10000
lineColor = Color.blue.base lineColor = Color.blue.base
lineHeight = 3 lineHeight = 3
} }
/// Prepares the divider. /// Prepares the divider.
fileprivate func prepareDivider() { func prepareDivider() {
dividerColor = Color.grey.lighten3
dividerAlignment = .top dividerAlignment = .top
} }
...@@ -349,13 +351,18 @@ extension TabBar { ...@@ -349,13 +351,18 @@ extension TabBar {
Prepares the line animation handlers. Prepares the line animation handlers.
- Parameter button: A UIButton. - Parameter button: A UIButton.
*/ */
fileprivate func prepareLineAnimationHandler(button: UIButton) { func prepareLineAnimationHandler(button: UIButton) {
removeLineAnimationHandler(button: button) removeLineAnimationHandler(button: button)
button.addTarget(self, action: #selector(handleLineAnimation(button:)), for: .touchUpInside) button.addTarget(self, action: #selector(handleLineAnimation(button:)), for: .touchUpInside)
} }
/// Prepares the contentView.
func prepareContentView() {
contentView.zPosition = 6000
}
/// Prepares the scroll view. /// Prepares the scroll view.
fileprivate func prepareScrollView() { func prepareScrollView() {
scrollView.isPagingEnabled = false scrollView.isPagingEnabled = false
scrollView.showsVerticalScrollIndicator = false scrollView.showsVerticalScrollIndicator = false
scrollView.showsHorizontalScrollIndicator = false scrollView.showsHorizontalScrollIndicator = false
...@@ -420,7 +427,7 @@ extension TabBar { ...@@ -420,7 +427,7 @@ extension TabBar {
line.animate(.duration(0.25), line.animate(.duration(0.25),
.size(CGSize(width: button.width, height: lineHeight)), .size(CGSize(width: button.width, height: lineHeight)),
.position(CGPoint(x: button.center.x, y: .bottom == lineAlignment ? height - lineHeight : 0)), .position(CGPoint(x: button.center.x, y: .bottom == lineAlignment ? height - lineHeight / 2 : lineHeight / 2)),
.completion { [weak self, isTriggeredByUserInteraction = isTriggeredByUserInteraction, button = button, completion = completion] _ in .completion { [weak self, isTriggeredByUserInteraction = isTriggeredByUserInteraction, button = button, completion = completion] _ in
guard let s = self else { guard let s = self else {
return return
......
...@@ -32,7 +32,12 @@ import UIKit ...@@ -32,7 +32,12 @@ import UIKit
fileprivate var TabItemKey: UInt8 = 0 fileprivate var TabItemKey: UInt8 = 0
open class TabItem: FlatButton {} open class TabItem: FlatButton {
open override func prepare() {
super.prepare()
pulseAnimation = .none
}
}
@objc(TabBarAlignment) @objc(TabBarAlignment)
public enum TabBarAlignment: Int { public enum TabBarAlignment: Int {
...@@ -307,7 +312,7 @@ fileprivate extension TabsController { ...@@ -307,7 +312,7 @@ fileprivate extension TabsController {
fileprivate extension TabsController { fileprivate extension TabsController {
/** /**
Handles the pageTabBarButton. Handles the tabItem.
- Parameter button: A UIButton. - Parameter button: A UIButton.
*/ */
@objc @objc
......
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