Commit d4a97c1e by Daniel Dahan

development: updated example projects and internals for PageTabBarController

parent 351c905f
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class ViewController: UIViewController { class ViewController: UIViewController {
override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib. // Do any additional setup after loading the view, typically from a nib.
} }
......
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class ViewController: UIViewController { class ViewController: UIViewController {
override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib. // Do any additional setup after loading the view, typically from a nib.
} }
......
...@@ -41,7 +41,7 @@ class RootViewController: UIViewController { ...@@ -41,7 +41,7 @@ class RootViewController: UIViewController {
/// A reference to the reminderMenuItem. /// A reference to the reminderMenuItem.
internal var reminderMenuItem: MenuItem! internal var reminderMenuItem: MenuItem!
override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten1 view.backgroundColor = Color.grey.lighten1
......
...@@ -32,7 +32,7 @@ import UIKit ...@@ -32,7 +32,7 @@ import UIKit
import Material import Material
class NextViewController: UIViewController { class NextViewController: UIViewController {
override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.base view.backgroundColor = Color.grey.base
......
...@@ -40,7 +40,7 @@ class RootViewController: UIViewController { ...@@ -40,7 +40,7 @@ class RootViewController: UIViewController {
/// Trigger to go to the next view controller. /// Trigger to go to the next view controller.
private var nextButton: FlatButton! private var nextButton: FlatButton!
override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten1 view.backgroundColor = Color.grey.lighten1
......
...@@ -32,7 +32,7 @@ import UIKit ...@@ -32,7 +32,7 @@ import UIKit
import Material import Material
class LeftViewController: UIViewController { class LeftViewController: UIViewController {
override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.blue.base view.backgroundColor = Color.blue.base
} }
......
...@@ -32,7 +32,7 @@ import UIKit ...@@ -32,7 +32,7 @@ import UIKit
import Material import Material
class RightViewController: UIViewController { class RightViewController: UIViewController {
override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.blue.base view.backgroundColor = Color.blue.base
} }
......
...@@ -32,7 +32,7 @@ import UIKit ...@@ -32,7 +32,7 @@ import UIKit
import Material import Material
class RootViewController: UIViewController { class RootViewController: UIViewController {
override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten1 view.backgroundColor = Color.grey.lighten1
} }
......
...@@ -8,10 +8,12 @@ ...@@ -8,10 +8,12 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
96784F021D9013E50061C06C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784F011D9013E50061C06C /* AppDelegate.swift */; }; 96784F021D9013E50061C06C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784F011D9013E50061C06C /* AppDelegate.swift */; };
96784F041D9013E50061C06C /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784F031D9013E50061C06C /* RootViewController.swift */; };
96784F091D9013E50061C06C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96784F081D9013E50061C06C /* Assets.xcassets */; }; 96784F091D9013E50061C06C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96784F081D9013E50061C06C /* Assets.xcassets */; };
96784F0C1D9013E50061C06C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96784F0A1D9013E50061C06C /* LaunchScreen.storyboard */; }; 96784F0C1D9013E50061C06C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96784F0A1D9013E50061C06C /* LaunchScreen.storyboard */; };
96784F261D901EC00061C06C /* AppPageTabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784F251D901EC00061C06C /* AppPageTabBarController.swift */; }; 96784F261D901EC00061C06C /* AppPageTabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784F251D901EC00061C06C /* AppPageTabBarController.swift */; };
96784FAD1D90257E0061C06C /* RedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784FAC1D90257E0061C06C /* RedViewController.swift */; };
96784FAF1D90258E0061C06C /* GreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784FAE1D90258E0061C06C /* GreenViewController.swift */; };
96784FB11D9025A60061C06C /* BlueViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784FB01D9025A60061C06C /* BlueViewController.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -30,11 +32,13 @@ ...@@ -30,11 +32,13 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
96784EFE1D9013E50061C06C /* PageTabBarController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PageTabBarController.app; sourceTree = BUILT_PRODUCTS_DIR; }; 96784EFE1D9013E50061C06C /* PageTabBarController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PageTabBarController.app; sourceTree = BUILT_PRODUCTS_DIR; };
96784F011D9013E50061C06C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 96784F011D9013E50061C06C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
96784F031D9013E50061C06C /* RootViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootViewController.swift; sourceTree = "<group>"; };
96784F081D9013E50061C06C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 96784F081D9013E50061C06C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96784F0B1D9013E50061C06C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 96784F0B1D9013E50061C06C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96784F0D1D9013E50061C06C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 96784F0D1D9013E50061C06C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96784F251D901EC00061C06C /* AppPageTabBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppPageTabBarController.swift; sourceTree = "<group>"; }; 96784F251D901EC00061C06C /* AppPageTabBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppPageTabBarController.swift; sourceTree = "<group>"; };
96784FAC1D90257E0061C06C /* RedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RedViewController.swift; sourceTree = "<group>"; };
96784FAE1D90258E0061C06C /* GreenViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GreenViewController.swift; sourceTree = "<group>"; };
96784FB01D9025A60061C06C /* BlueViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlueViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -69,7 +73,9 @@ ...@@ -69,7 +73,9 @@
children = ( children = (
96784F011D9013E50061C06C /* AppDelegate.swift */, 96784F011D9013E50061C06C /* AppDelegate.swift */,
96784F251D901EC00061C06C /* AppPageTabBarController.swift */, 96784F251D901EC00061C06C /* AppPageTabBarController.swift */,
96784F031D9013E50061C06C /* RootViewController.swift */, 96784FAC1D90257E0061C06C /* RedViewController.swift */,
96784FAE1D90258E0061C06C /* GreenViewController.swift */,
96784FB01D9025A60061C06C /* BlueViewController.swift */,
96784F081D9013E50061C06C /* Assets.xcassets */, 96784F081D9013E50061C06C /* Assets.xcassets */,
96784F0A1D9013E50061C06C /* LaunchScreen.storyboard */, 96784F0A1D9013E50061C06C /* LaunchScreen.storyboard */,
96784F0D1D9013E50061C06C /* Info.plist */, 96784F0D1D9013E50061C06C /* Info.plist */,
...@@ -149,9 +155,11 @@ ...@@ -149,9 +155,11 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96784F041D9013E50061C06C /* RootViewController.swift in Sources */, 96784FAD1D90257E0061C06C /* RedViewController.swift in Sources */,
96784F021D9013E50061C06C /* AppDelegate.swift in Sources */, 96784F021D9013E50061C06C /* AppDelegate.swift in Sources */,
96784F261D901EC00061C06C /* AppPageTabBarController.swift in Sources */, 96784F261D901EC00061C06C /* AppPageTabBarController.swift in Sources */,
96784FB11D9025A60061C06C /* BlueViewController.swift in Sources */,
96784FAF1D90258E0061C06C /* GreenViewController.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
......
...@@ -38,7 +38,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -38,7 +38,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func applicationDidFinishLaunching(_ application: UIApplication) { func applicationDidFinishLaunching(_ application: UIApplication) {
window = UIWindow(frame: Device.bounds) window = UIWindow(frame: Device.bounds)
window!.rootViewController = AppPageTabBarController(rootViewController: RootViewController()) window!.rootViewController = AppPageTabBarController(viewControllers: [RedViewController(), GreenViewController(), BlueViewController()], selectedIndex: 0)
window!.makeKeyAndVisible() window!.makeKeyAndVisible()
} }
......
...@@ -34,7 +34,19 @@ import Material ...@@ -34,7 +34,19 @@ import Material
class AppPageTabBarController: PageTabBarController { class AppPageTabBarController: PageTabBarController {
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
statusBarStyle = .default
delegate = self
preparePageTabBar()
}
/// Prepares the pageTabBar.
private func preparePageTabBar() {
pageTabBar.lineColor = Color.purple.base
} }
} }
extension AppPageTabBarController: PageTabBarControllerDelegate {
func pageTabBarController(pageTabBarController: PageTabBarController, didTransitionTo viewController: UIViewController) {
print("pageTabBarController", pageTabBarController, "didTransitionTo viewController:", viewController)
}
}
...@@ -31,10 +31,26 @@ ...@@ -31,10 +31,26 @@
import UIKit import UIKit
import Material import Material
class RootViewController: UIViewController { class BlueViewController: UIViewController {
override func viewDidLoad() { required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
preparePageTabBarItem()
}
init() {
super.init(nibName: nil, bundle: nil)
preparePageTabBarItem()
}
open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten1 view.backgroundColor = Color.blue.base
}
/// Prepares the pageTabBarItem.
internal func preparePageTabBarItem() {
pageTabBarItem.title = "Blue"
pageTabBarItem.titleColor = Color.blueGrey.base
} }
} }
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* 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
import Material
class GreenViewController: UIViewController {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
preparePageTabBarItem()
}
init() {
super.init(nibName: nil, bundle: nil)
preparePageTabBarItem()
}
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Color.green.base
}
/// Prepares the pageTabBarItem.
internal func preparePageTabBarItem() {
pageTabBarItem.title = "Green"
pageTabBarItem.titleColor = Color.blueGrey.base
}
}
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* 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
import Material
class RedViewController: UIViewController {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
preparePageTabBarItem()
}
init() {
super.init(nibName: nil, bundle: nil)
preparePageTabBarItem()
}
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Color.red.base
}
/// Prepares the pageTabBarItem.
internal func preparePageTabBarItem() {
pageTabBarItem.title = "Red"
pageTabBarItem.titleColor = Color.blueGrey.base
}
}
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class ViewController: UIViewController { class ViewController: UIViewController {
override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib. // Do any additional setup after loading the view, typically from a nib.
} }
......
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class ViewController: UIViewController { class ViewController: UIViewController {
override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib. // Do any additional setup after loading the view, typically from a nib.
} }
......
...@@ -32,9 +32,38 @@ import UIKit ...@@ -32,9 +32,38 @@ import UIKit
import Material import Material
class RootViewController: UIViewController { class RootViewController: UIViewController {
override func viewDidLoad() { /// SearchBar buttons.
private var menuButton: IconButton!
private var moreButton: IconButton!
open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten1 view.backgroundColor = Color.grey.lighten1
} }
open override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
prepareMenuButton()
prepareMoreButton()
prepareSearchBar()
}
private func prepareMenuButton() {
menuButton = IconButton(image: Icon.cm.menu, tintColor: Color.blue.base)
}
private func prepareMoreButton() {
moreButton = IconButton(image: Icon.cm.moreVertical, tintColor: Color.blue.base)
}
private func prepareSearchBar() {
guard let sc = searchBarController else {
return
}
sc.searchBar.leftViews = [menuButton]
sc.searchBar.rightViews = [moreButton]
}
} }
...@@ -35,7 +35,7 @@ class RootViewController: UIViewController { ...@@ -35,7 +35,7 @@ class RootViewController: UIViewController {
/// A reference to the Undo button. /// A reference to the Undo button.
private var undoButton: FlatButton! private var undoButton: FlatButton!
override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten1 view.backgroundColor = Color.grey.lighten1
......
...@@ -32,7 +32,7 @@ import UIKit ...@@ -32,7 +32,7 @@ import UIKit
import Material import Material
class RootViewController: UIViewController { class RootViewController: UIViewController {
override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten1 view.backgroundColor = Color.grey.lighten1
} }
......
...@@ -32,9 +32,47 @@ import UIKit ...@@ -32,9 +32,47 @@ import UIKit
import Material import Material
class RootViewController: UIViewController { class RootViewController: UIViewController {
override func viewDidLoad() { /// Toolbar buttons.
private var menuButton: IconButton!
private var starButton: IconButton!
private var searchButton: IconButton!
open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten1 view.backgroundColor = Color.grey.lighten1
} }
open override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
prepareMenuButton()
prepareStarButton()
prepareSearchButton()
prepareToolbar()
}
private func prepareMenuButton() {
menuButton = IconButton(image: Icon.cm.menu, tintColor: Color.blue.base)
}
private func prepareStarButton() {
starButton = IconButton(image: Icon.cm.star, tintColor: Color.blue.base)
}
private func prepareSearchButton() {
searchButton = IconButton(image: Icon.cm.search, tintColor: Color.blue.base)
}
private func prepareToolbar() {
guard let tc = toolbarController else {
return
}
tc.toolbar.title = "Marterial"
tc.toolbar.detail = "Build Beautiful Software"
tc.toolbar.leftViews = [menuButton]
tc.toolbar.rightViews = [starButton, searchButton]
}
} }
...@@ -97,18 +97,20 @@ public class NavigationItem: NSObject { ...@@ -97,18 +97,20 @@ public class NavigationItem: NSObject {
} }
/// Prepares the titleLabel. /// Prepares the titleLabel.
private func prepareTitleLabel() { private func prepareTitleLabel() {
titleLabel.font = RobotoFont.medium(with: 17) titleLabel.textAlignment = .center
titleLabel.textAlignment = .center titleLabel.contentScaleFactor = Device.scale
titleLabel.font = RobotoFont.medium(with: 17)
titleLabel.textColor = Color.darkText.primary titleLabel.textColor = Color.darkText.primary
addObserver(self, forKeyPath: "titleLabel.textAlignment", options: [], context: &NavigationItemContext) addObserver(self, forKeyPath: "titleLabel.textAlignment", options: [], context: &NavigationItemContext)
} }
/// Prepares the detailLabel. /// Prepares the detailLabel.
private func prepareDetailLabel() { private func prepareDetailLabel() {
detailLabel.textAlignment = .center
titleLabel.contentScaleFactor = Device.scale
detailLabel.font = RobotoFont.regular(with: 12) detailLabel.font = RobotoFont.regular(with: 12)
detailLabel.textColor = Color.darkText.secondary detailLabel.textColor = Color.darkText.secondary
detailLabel.textAlignment = .center
} }
} }
......
...@@ -125,19 +125,22 @@ open class PageTabBarController: RootController { ...@@ -125,19 +125,22 @@ open class PageTabBarController: RootController {
public required init?(coder aDecoder: NSCoder) { public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) super.init(coder: aDecoder)
prepare()
} }
public override init(rootViewController: UIViewController) { public override init(rootViewController: UIViewController) {
super.init(rootViewController: UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)) super.init(rootViewController: UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil))
viewControllers.append(rootViewController) viewControllers.append(rootViewController)
setViewControllers(viewControllers, direction: .forward, animated: true) setViewControllers(viewControllers, direction: .forward, animated: true)
prepare()
} }
public init(viewControllers: [UIViewController], selectedIndex: Int, direction: UIPageViewControllerNavigationDirection, animated: Bool) { public init(viewControllers: [UIViewController], selectedIndex: Int) {
super.init(rootViewController: UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)) super.init(rootViewController: UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil))
self.selectedIndex = selectedIndex self.selectedIndex = selectedIndex
self.viewControllers.append(contentsOf: viewControllers) self.viewControllers.append(contentsOf: viewControllers)
setViewControllers([self.viewControllers[selectedIndex]], direction: direction, animated: animated) setViewControllers([self.viewControllers[selectedIndex]], direction: .forward, animated: true)
prepare()
} }
/** /**
...@@ -175,7 +178,7 @@ open class PageTabBarController: RootController { ...@@ -175,7 +178,7 @@ open class PageTabBarController: RootController {
*/ */
open func setViewControllers(_ viewControllers: [UIViewController], direction: UIPageViewControllerNavigationDirection, animated: Bool, completion: ((Bool) -> Void)? = nil) { open func setViewControllers(_ viewControllers: [UIViewController], direction: UIPageViewControllerNavigationDirection, animated: Bool, completion: ((Bool) -> Void)? = nil) {
pageViewController?.setViewControllers(viewControllers, direction: direction, animated: animated, completion: completion) pageViewController?.setViewControllers(viewControllers, direction: direction, animated: animated, completion: completion)
preparePageTabBarItems() prepare()
} }
/** /**
...@@ -188,6 +191,7 @@ open class PageTabBarController: RootController { ...@@ -188,6 +191,7 @@ open class PageTabBarController: RootController {
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
preparePageTabBar() preparePageTabBar()
preparePageTabBarItems()
} }
override func prepareRootViewController() { override func prepareRootViewController() {
......
...@@ -157,17 +157,19 @@ open class Toolbar: BarView { ...@@ -157,17 +157,19 @@ open class Toolbar: BarView {
} }
/// Prepares the titleLabel. /// Prepares the titleLabel.
private func prepareTitleLabel() { private func prepareTitleLabel() {
titleLabel.textAlignment = .center
titleLabel.contentScaleFactor = Device.scale titleLabel.contentScaleFactor = Device.scale
titleLabel.font = RobotoFont.medium(with: 17) titleLabel.font = RobotoFont.medium(with: 17)
titleLabel.textAlignment = .center titleLabel.textColor = Color.darkText.primary
addObserver(self, forKeyPath: "titleLabel.textAlignment", options: [], context: &ToolbarContext) addObserver(self, forKeyPath: "titleLabel.textAlignment", options: [], context: &ToolbarContext)
} }
/// Prepares the detailLabel. /// Prepares the detailLabel.
private func prepareDetailLabel() { private func prepareDetailLabel() {
detailLabel.textAlignment = .center
detailLabel.contentScaleFactor = Device.scale detailLabel.contentScaleFactor = Device.scale
detailLabel.font = RobotoFont.regular(with: 12) detailLabel.font = RobotoFont.regular(with: 12)
detailLabel.textAlignment = .center detailLabel.textColor = Color.darkText.secondary
} }
} }
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