Commit 58a5469c by Daniel Dahan Committed by GitHub

Merge branch 'development' into development

parents 9b743d59 98166c9a
......@@ -7,7 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
9606CFAC1E957AC3006B4E74 /* TabMenuController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9606CFAB1E957AC3006B4E74 /* TabMenuController.swift */; };
9606CFAC1E957AC3006B4E74 /* PageMenuController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9606CFAB1E957AC3006B4E74 /* PageMenuController.swift */; };
961409B01E43D15C00E7BA99 /* CollectionViewCard.swift in Headers */ = {isa = PBXBuildFile; fileRef = 961730591E145DE900A9A297 /* CollectionViewCard.swift */; settings = {ATTRIBUTES = (Public, ); }; };
961409B11E43D15C00E7BA99 /* FABMenu.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96A183621E0C6CE200083C30 /* FABMenu.swift */; settings = {ATTRIBUTES = (Public, ); }; };
961409B21E43D15C00E7BA99 /* FABMenuController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96A183641E0C6DD400083C30 /* FABMenuController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -23,7 +23,7 @@
9617B0871DFCA8CF00410F8F /* PageTabBarController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 963FBF071D669D14008F8512 /* PageTabBarController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0881DFCA8CF00410F8F /* PhotoLibrary.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B161DBE6B1800DA84DB /* PhotoLibrary.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0891DFCA8CF00410F8F /* PhotoLibraryController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B171DBE6B1800DA84DB /* PhotoLibraryController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B08A1DFCA8CF00410F8F /* Display.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9626CA961DAB53A8003E2611 /* Display.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B08A1DFCA8CF00410F8F /* DisplayStyle.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9626CA961DAB53A8003E2611 /* DisplayStyle.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B08B1DFCA8CF00410F8F /* Screen.swift in Headers */ = {isa = PBXBuildFile; fileRef = 961E6BE11DDA2AF3004E6C93 /* Screen.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B08C1DFCA8CF00410F8F /* SearchBar.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7951CB40DC500C806FE /* SearchBar.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B08D1DFCA8CF00410F8F /* SearchBarController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7961CB40DC500C806FE /* SearchBarController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -103,7 +103,7 @@
965E81131DD4D5C800D61E4B /* NavigationDrawerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7971CB40DC500C806FE /* NavigationDrawerController.swift */; };
965E81141DD4D5C800D61E4B /* PhotoLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96717B161DBE6B1800DA84DB /* PhotoLibrary.swift */; };
965E81151DD4D5C800D61E4B /* PhotoLibraryController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96717B171DBE6B1800DA84DB /* PhotoLibraryController.swift */; };
965E81161DD4D5C800D61E4B /* Display.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9626CA961DAB53A8003E2611 /* Display.swift */; };
965E81161DD4D5C800D61E4B /* DisplayStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9626CA961DAB53A8003E2611 /* DisplayStyle.swift */; };
965E81171DD4D5C800D61E4B /* RootController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7991CB40DC500C806FE /* RootController.swift */; };
965E81181DD4D5C800D61E4B /* Snackbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963FBEFC1D669510008F8512 /* Snackbar.swift */; };
965E81191DD4D5C800D61E4B /* SnackbarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961EFC571D738FF600E84652 /* SnackbarController.swift */; };
......@@ -190,7 +190,7 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
9606CFAB1E957AC3006B4E74 /* TabMenuController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TabMenuController.swift; sourceTree = "<group>"; };
9606CFAB1E957AC3006B4E74 /* PageMenuController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageMenuController.swift; sourceTree = "<group>"; };
961276621DCD8B1800A7D920 /* CharacterAttribute.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CharacterAttribute.swift; sourceTree = "<group>"; };
961730591E145DE900A9A297 /* CollectionViewCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewCard.swift; sourceTree = "<group>"; };
961E6BDE1DDA2A95004E6C93 /* Application.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Application.swift; sourceTree = "<group>"; };
......@@ -198,7 +198,7 @@
961EFC571D738FF600E84652 /* SnackbarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SnackbarController.swift; sourceTree = "<group>"; };
961F18E71CD93E3E008927C5 /* ErrorTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ErrorTextField.swift; sourceTree = "<group>"; };
96230AB71D6A520C00AF47DC /* Divider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Divider.swift; sourceTree = "<group>"; };
9626CA961DAB53A8003E2611 /* Display.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Display.swift; sourceTree = "<group>"; };
9626CA961DAB53A8003E2611 /* DisplayStyle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DisplayStyle.swift; sourceTree = "<group>"; };
9626CB9A1DAD3D1D003E2611 /* HeightPreset.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeightPreset.swift; sourceTree = "<group>"; };
962864591D53FE3E00690B69 /* Material+UIWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+UIWindow.swift"; sourceTree = "<group>"; };
9628645E1D540AF300690B69 /* DynamicFontType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicFontType.swift; sourceTree = "<group>"; };
......@@ -350,7 +350,7 @@
9626CA951DAB5370003E2611 /* Root */ = {
isa = PBXGroup;
children = (
9626CA961DAB53A8003E2611 /* Display.swift */,
9626CA961DAB53A8003E2611 /* DisplayStyle.swift */,
96BCB7991CB40DC500C806FE /* RootController.swift */,
);
name = Root;
......@@ -364,13 +364,13 @@
name = Height;
sourceTree = "<group>";
};
962DDD071D6FBBB7001C307C /* TabMenu */ = {
962DDD071D6FBBB7001C307C /* PageTabMenu */ = {
isa = PBXGroup;
children = (
963FBF071D669D14008F8512 /* PageTabBarController.swift */,
9606CFAB1E957AC3006B4E74 /* TabMenuController.swift */,
9606CFAB1E957AC3006B4E74 /* PageMenuController.swift */,
);
name = TabMenu;
name = PageTabMenu;
sourceTree = "<group>";
};
962DDD081D6FBBD0001C307C /* BottomTabBar */ = {
......@@ -530,7 +530,7 @@
96BCB8091CB4107700C806FE /* Motion */,
96BCB8011CB40F1700C806FE /* Navigation */,
961E6BEF1DDA4B04004E6C93 /* NavigationDrawer */,
962DDD071D6FBBB7001C307C /* TabMenu */,
962DDD071D6FBBB7001C307C /* PageTabMenu */,
96717B151DBE6B1800DA84DB /* Photos */,
96328B8F1E05B69A009A4C90 /* Reminders */,
9626CA951DAB5370003E2611 /* Root */,
......@@ -820,7 +820,7 @@
9617B0871DFCA8CF00410F8F /* PageTabBarController.swift in Headers */,
9617B0881DFCA8CF00410F8F /* PhotoLibrary.swift in Headers */,
9617B0891DFCA8CF00410F8F /* PhotoLibraryController.swift in Headers */,
9617B08A1DFCA8CF00410F8F /* Display.swift in Headers */,
9617B08A1DFCA8CF00410F8F /* DisplayStyle.swift in Headers */,
9617B08B1DFCA8CF00410F8F /* Screen.swift in Headers */,
9617B08C1DFCA8CF00410F8F /* SearchBar.swift in Headers */,
9617B08D1DFCA8CF00410F8F /* SearchBarController.swift in Headers */,
......@@ -943,7 +943,7 @@
965E81131DD4D5C800D61E4B /* NavigationDrawerController.swift in Sources */,
965E81141DD4D5C800D61E4B /* PhotoLibrary.swift in Sources */,
965E81151DD4D5C800D61E4B /* PhotoLibraryController.swift in Sources */,
965E81161DD4D5C800D61E4B /* Display.swift in Sources */,
965E81161DD4D5C800D61E4B /* DisplayStyle.swift in Sources */,
965E81171DD4D5C800D61E4B /* RootController.swift in Sources */,
965E81181DD4D5C800D61E4B /* Snackbar.swift in Sources */,
96328B911E05B6B5009A4C90 /* Reminders.swift in Sources */,
......@@ -995,7 +995,7 @@
965E80D81DD4C50600D61E4B /* Layer.swift in Sources */,
965E80D91DD4C50600D61E4B /* Layout.swift in Sources */,
965E80DA1DD4C50600D61E4B /* Border.swift in Sources */,
9606CFAC1E957AC3006B4E74 /* TabMenuController.swift in Sources */,
9606CFAC1E957AC3006B4E74 /* PageMenuController.swift in Sources */,
965E80DB1DD4C50600D61E4B /* InterimSpace.swift in Sources */,
965E80DC1DD4C50600D61E4B /* Depth.swift in Sources */,
965E80DD1DD4C50600D61E4B /* EdgeInsets.swift in Sources */,
......
......@@ -39,7 +39,7 @@ public enum ContentViewAlignment: Int {
open class Bar: View {
/// Will layout the view.
open var willLayout: Bool {
return 0 < width && 0 < height && nil != superview
return 0 < width && 0 < height && nil != superview && !grid.deferred
}
open override var intrinsicContentSize: CGSize {
......@@ -105,7 +105,7 @@ open class Bar: View {
}
/// ContentView that holds the any desired subviews.
open let contentView = UIView()
open let contentView = UIScrollView()
/// Left side UIViews.
open var leftViews: [UIView] {
......@@ -183,15 +183,6 @@ open class Bar: View {
return
}
guard !grid.deferred else {
return
}
reload()
}
/// Reloads the view.
open func reload() {
var lc = 0
var rc = 0
......@@ -281,5 +272,17 @@ open class Bar: View {
autoresizingMask = .flexibleWidth
interimSpacePreset = .interimSpace3
contentEdgeInsetsPreset = .square1
prepareContentView()
}
}
extension Bar {
/// Prepares the contentView.
fileprivate func prepareContentView() {
contentView.bounces = false
contentView.isPagingEnabled = true
contentView.showsVerticalScrollIndicator = false
contentView.showsHorizontalScrollIndicator = false
contentView.contentScaleFactor = Screen.scale
}
}
......@@ -72,7 +72,12 @@ open class BottomNavigationController: UITabBarController {
layoutSubviews()
}
open func layoutSubviews() {
/**
To execute in the order of the layout chain, override this
method. `layoutSubviews` should be called immediately, unless you
have a certain need.
*/
open func layoutSubviews() {
if let v = tabBar.items {
for item in v {
if .phone == Device.userInterfaceIdiom {
......
......@@ -71,7 +71,7 @@ open class CaptureController: ToolbarController {
*/
open override func prepare() {
super.prepare()
toolbarDisplay = .full
displayStyle = .full
view.backgroundColor = .black
prepareStatusBar()
......
......@@ -53,19 +53,7 @@ open class CollectionViewCard: Card {
@IBInspectable
open let collectionView = CollectionView()
open override func layoutSubviews() {
super.layoutSubviews()
reload()
}
open override func prepare() {
super.prepare()
pulseAnimation = .none
prepareCollectionView()
prepareContentView()
}
/// Reloads the view.
open override func reload() {
if 0 == collectionView.height {
var h: CGFloat = 0
......@@ -79,7 +67,22 @@ open class CollectionViewCard: Card {
collectionView.reloadData()
super.reload()
super.layoutSubviews()
}
/**
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()
pulseAnimation = .none
prepareCollectionView()
prepareContentView()
}
}
......
......@@ -30,8 +30,8 @@
import UIKit
@objc(Display)
public enum Display: Int {
@objc(DisplayStyle)
public enum DisplayStyle: Int {
case partial
case full
}
......@@ -42,7 +42,7 @@ open class ImageCard: Card {
display the imageView to the full view
bounds.
*/
open var imageViewDisplay = Display.partial {
open var displayStyle = DisplayStyle.partial {
didSet {
layoutSubviews()
}
......@@ -82,6 +82,7 @@ open class ImageCard: Card {
}
}
/// Reloads the view.
open override func reload() {
var h: CGFloat = 0
......
......@@ -95,7 +95,8 @@ fileprivate struct MotionInstance {
}
fileprivate struct MotionInstanceController {
fileprivate var isEnabled: Bool
fileprivate var isMotionEnabled: Bool
fileprivate var isInteractiveMotionEnabled: Bool
fileprivate weak var delegate: MotionDelegate?
}
......@@ -104,7 +105,7 @@ extension UIViewController: MotionDelegate, UIViewControllerTransitioningDelegat
fileprivate var motionInstanceController: MotionInstanceController {
get {
return AssociatedObject(base: self, key: &MotionInstanceControllerKey) {
return MotionInstanceController(isEnabled: false, delegate: nil)
return MotionInstanceController(isMotionEnabled: false, isInteractiveMotionEnabled: false, delegate: nil)
}
}
set(value) {
......@@ -115,18 +116,29 @@ extension UIViewController: MotionDelegate, UIViewControllerTransitioningDelegat
/// A boolean that indicates whether motion is enabled.
open var isMotionEnabled: Bool {
get {
return motionInstanceController.isEnabled
return motionInstanceController.isMotionEnabled
}
set(value) {
if value {
modalPresentationStyle = .custom
transitioningDelegate = self
motionDelegate = self
(self as? UINavigationController)?.delegate = self
(self as? UITabBarController)?.delegate = self
prepareMotionDelegation()
}
motionInstanceController.isEnabled = value
motionInstanceController.isMotionEnabled = value
}
}
/// A boolean that indicates whether interactive motion is enabled.
open var isInteractiveMotionEnabled: Bool {
get {
return motionInstanceController.isInteractiveMotionEnabled
}
set(value) {
if value {
prepareMotionDelegation()
motionInstanceController.isMotionEnabled = true
}
motionInstanceController.isInteractiveMotionEnabled = value
}
}
......@@ -139,28 +151,16 @@ extension UIViewController: MotionDelegate, UIViewControllerTransitioningDelegat
motionInstanceController.delegate = value
}
}
/**
Determines whether to use a Motion instance for transitions.
- Parameter _ navigationController: A UINavigationController.
- Parameter animationControllerFor operation: A UINavigationControllerOperation.
- Parameter from fromVC: A UIViewController that is being transitioned from.
- Parameter to toVC: A UIViewController that is being transitioned to.
- Returns: An optional UIViewControllerAnimatedTransitioning.
*/
open func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return fromVC.isMotionEnabled ? Motion(isPresenting: operation == .push, isContainer: true) : nil
}
/**
Determines whether to use a Motion instance for transitions.
- Parameter _ tabBarController: A UITabBarController.
- Parameter animationControllerForTransitionFrom fromVC: A UIViewController that is being transitioned from.
- Parameter to toVC: A UIViewController that is being transitioned to.
- Returns: An optional UIViewControllerAnimatedTransitioning.
*/
open func tabBarController(_ tabBarController: UITabBarController, animationControllerForTransitionFrom fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return fromVC.isMotionEnabled ? Motion(isPresenting: true, isContainer: true) : nil
}
extension UIViewController {
/// Prepares the motionDelegate.
fileprivate func prepareMotionDelegation() {
modalPresentationStyle = .custom
transitioningDelegate = self
motionDelegate = self
(self as? UINavigationController)?.delegate = self
(self as? UITabBarController)?.delegate = self
}
}
......@@ -173,7 +173,8 @@ extension UIViewController {
- Returns: An optional UIViewControllerAnimatedTransitioning.
*/
open func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return isMotionEnabled ? PresentingMotion(isPresenting: true, isContainer: false) : nil
print("animationController(forPresented")
return isMotionEnabled ? PresentingMotion(isPresenting: true) : nil
}
/**
......@@ -182,7 +183,8 @@ extension UIViewController {
- Returns: An optional UIViewControllerAnimatedTransitioning.
*/
open func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return isMotionEnabled ? DismissingMotion(isPresenting: true, isContainer: false) : nil
print("animationController(forDismissed")
return isMotionEnabled ? DismissingMotion(isPresenting: true) : nil
}
/**
......@@ -193,8 +195,46 @@ extension UIViewController {
- Returns: An optional UIPresentationController.
*/
open func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
print("presentationController:forPresented")
return isMotionEnabled ? MotionPresentationController(presentedViewController: presented, presenting: presenting) : nil
}
open func interactionControllerForPresentation(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
print("interactionControllerForPresentation")
return isInteractiveMotionEnabled ? InteractivePresentingMotion(animator: animator) : nil
}
open func interactionControllerForDismissal(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
print("interactionControllerForDismissal")
return isInteractiveMotionEnabled ? InteractiveDismissingMotion(animator: animator) : nil
}
}
extension UIViewController {
/**
Determines whether to use a Motion instance for transitions.
- Parameter _ navigationController: A UINavigationController.
- Parameter animationControllerFor operation: A UINavigationControllerOperation.
- Parameter from fromVC: A UIViewController that is being transitioned from.
- Parameter to toVC: A UIViewController that is being transitioned to.
- Returns: An optional UIViewControllerAnimatedTransitioning.
*/
open func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
print("navigationController(_ navigationController")
return fromVC.isMotionEnabled ? Motion(isPresenting: operation == .push) : nil
}
/**
Determines whether to use a Motion instance for transitions.
- Parameter _ tabBarController: A UITabBarController.
- Parameter animationControllerForTransitionFrom fromVC: A UIViewController that is being transitioned from.
- Parameter to toVC: A UIViewController that is being transitioned to.
- Returns: An optional UIViewControllerAnimatedTransitioning.
*/
open func tabBarController(_ tabBarController: UITabBarController, animationControllerForTransitionFrom fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
print("tabBarController(_ tabBarController")
return fromVC.isMotionEnabled ? Motion(isPresenting: true) : nil
}
}
extension UIView {
......@@ -348,9 +388,6 @@ open class MotionAnimator: NSObject {
/// A boolean indicating whether Motion is presenting a view controller.
open fileprivate(set) var isPresenting: Bool
/// A boolean indicating whether the view controller is a container.
open fileprivate(set) var isContainer: Bool
/**
An Array of UIView pairs with common motionIdentifiers in
the from and to view controllers.
......@@ -374,19 +411,19 @@ open class MotionAnimator: NSObject {
}
/// The transition context for the current transition.
open var transitionContext: UIViewControllerContextTransitioning!
open fileprivate(set) var transitionContext: UIViewControllerContextTransitioning!
/// The transition delay time.
open var delay: TimeInterval = 0
open fileprivate(set) var delay: TimeInterval = 0
/// The transition duration time.
open var duration: TimeInterval = 0.35
open fileprivate(set) var duration: TimeInterval = 0.35
/// The transition container view.
open var containerView: UIView!
open fileprivate(set) var containerView: UIView!
/// The view that is used to animate the transitions between view controllers.
open var transitionView = UIView()
open fileprivate(set) var transitionView = UIView()
/// The view that is being transitioned to.
open var toView: UIView {
......@@ -411,7 +448,6 @@ open class MotionAnimator: NSObject {
/// The default initializer.
public override init() {
isPresenting = false
isContainer = false
super.init()
}
......@@ -419,12 +455,9 @@ open class MotionAnimator: NSObject {
An initializer to modify the presenting and container state.
- Parameter isPresenting: A boolean value indicating if the
Motion instance is presenting the view controller.
- Parameter isContainer: A boolean value indicating if the
Motion instance is a container view controller.
*/
public init(isPresenting: Bool, isContainer: Bool) {
public init(isPresenting: Bool) {
self.isPresenting = isPresenting
self.isContainer = isContainer
super.init()
}
......@@ -835,5 +868,101 @@ open class DismissingMotion: Motion {
toView.setNeedsLayout()
toView.layoutIfNeeded()
}
}
open class InteractiveMotion: UIPercentDrivenInteractiveTransition {
/// A reference to the view controller that is being transitioned to.
open var toViewController: UIViewController {
return transitionContext.viewController(forKey: .to)!
}
/// A reference to the view controller that is being transitioned from.
open var fromViewController: UIViewController {
return transitionContext.viewController(forKey: .from)!
}
/// The transition context for the current transition.
open fileprivate(set) var transitionContext: UIViewControllerContextTransitioning!
/// A reference to the panGesture for transitions.
open fileprivate(set) var panGesture: UIPanGestureRecognizer!
/// The transition container view.
open fileprivate(set) var containerView: UIView!
open fileprivate(set) var animator: UIViewControllerAnimatedTransitioning!
/**
An initializer that accepts an animator object.
- Parameter animator: UIViewControllerAnimatedTransitioning.
*/
public init(animator: UIViewControllerAnimatedTransitioning) {
super.init()
self.animator = animator
}
open override func startInteractiveTransition(_ transitionContext: UIViewControllerContextTransitioning) {
super.startInteractiveTransition(transitionContext)
self.transitionContext = transitionContext
preparePanGesture()
prepareContainerView()
}
//
//
// optional public var completionSpeed: CGFloat { get }
//
// optional public var completionCurve: UIViewAnimationCurve { get }
//
//
// /// In 10.0, if an object conforming to UIViewControllerAnimatedTransitioning is
// /// known to be interruptible, it is possible to start it as if it was not
// /// interactive and then interrupt the transition and interact with it. In this
// /// case, implement this method and return NO. If an interactor does not
// /// implement this method, YES is assumed.
// @available(iOS 10.0, *)
// optional public var wantsInteractiveStart: Bool { get }
}
extension InteractiveMotion {
fileprivate func preparePanGesture() {
panGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePanUpdate(gestureRecognizer:)))
panGesture.maximumNumberOfTouches = 1
}
/// Prepares the containerView.
fileprivate func prepareContainerView() {
containerView = transitionContext.containerView
containerView.addGestureRecognizer(panGesture)
}
}
extension InteractiveMotion {
@objc
fileprivate func handlePanUpdate(gestureRecognizer: UIGestureRecognizer) {
switch gestureRecognizer.state {
case .began:
panGesture.setTranslation(.zero, in: containerView)
print("began")
case .changed:
let translation = panGesture.translation(in: containerView)
let percentage = fabs(translation.y / containerView.bounds.height)
update(percentage)
print("changed", percentage)
case .ended:
finish()
containerView.removeGestureRecognizer(panGesture)
print("ended")
default:break
}
}
}
open class InteractivePresentingMotion: InteractiveMotion {
}
open class InteractiveDismissingMotion: InteractiveMotion {
}
/*
* 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 PageMenuBarItem instance for UIViewController extensions.
fileprivate var PageMenuBarItemKey: UInt8 = 0
open class PageMenuBarItem: FlatButton {
open override func prepare() {
super.prepare()
pulseAnimation = .none
}
}
@objc(TabBarAlignment)
public enum TabBarAlignment: Int {
case top
case bottom
case hidden
}
extension UIViewController {
/// pageMenuBarItem reference.
public private(set) var pageMenuBarItem: PageMenuBarItem {
get {
return AssociatedObject(base: self, key: &PageMenuBarItemKey) {
return PageMenuBarItem()
}
}
set(value) {
AssociateObject(base: self, key: &PageMenuBarItemKey, value: value)
}
}
}
extension UIViewController {
/**
A convenience property that provides access to the PageMenuController.
This is the recommended method of accessing the PageMenuController
through child UIViewControllers.
*/
public var pageMenuController: PageMenuController? {
var viewController: UIViewController? = self
while nil != viewController {
if viewController is PageMenuController {
return viewController as? PageMenuController
}
viewController = viewController?.parent
}
return nil
}
}
open class PageMenuController: UIViewController {
/// A reference to the currently selected view controller index value.
@IBInspectable
open var selectedIndex = 0
/// Enables and disables bouncing when swiping.
open var isBounceEnabled: Bool {
get {
return scrollView.bounces
}
set(value) {
scrollView.bounces = value
}
}
/// The TabBar used to switch between view controllers.
@IBInspectable
open fileprivate(set) var tabBar: TabBar?
/// The UIScrollView used to pan the application pages.
@IBInspectable
open let scrollView = UIScrollView()
/// An Array of UIViewControllers.
open var viewControllers: [UIViewController] {
didSet {
oldValue.forEach { [weak self] in
self?.removeViewController(viewController: $0)
}
prepareViewControllers()
layoutSubviews()
}
}
open var tabBarAlignment = TabBarAlignment.bottom {
didSet {
layoutSubviews()
}
}
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
public required init?(coder aDecoder: NSCoder) {
viewControllers = []
super.init(coder: aDecoder)
}
/// Previous scroll view content offset.
fileprivate var previousContentOffset: CGFloat = 0
/// The number of views used in the scrollViewPool.
fileprivate let viewPoolCount = 3
/**
An initializer that accepts an Array of UIViewControllers.
- Parameter viewControllers: An Array of UIViewControllers.
*/
public init(viewControllers: [UIViewController], selectedIndex: Int = 0) {
self.viewControllers = viewControllers
self.selectedIndex = selectedIndex
super.init(nibName: nil, bundle: nil)
}
open override func viewDidLoad() {
super.viewDidLoad()
prepare()
}
open override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
layoutSubviews()
}
/**
To execute in the order of the layout chain, override this
method. `layoutSubviews` should be called immediately, unless you
have a certain need.
*/
open func layoutSubviews() {
layoutScrollView()
layoutViewControllers()
let p = (tabBar?.intrinsicContentSize.height ?? 0) + (tabBar?.layoutEdgeInsets.top ?? 0) + (tabBar?.layoutEdgeInsets.bottom ?? 0)
let y = view.height - p
tabBar?.height = p
tabBar?.width = view.width + (tabBar?.layoutEdgeInsets.left ?? 0) + (tabBar?.layoutEdgeInsets.right ?? 0)
switch tabBarAlignment {
case .top:
tabBar?.isHidden = false
tabBar?.y = 0
scrollView.y = p
scrollView.height = y
case .bottom:
tabBar?.isHidden = false
tabBar?.y = y
scrollView.y = 0
scrollView.height = y
case .hidden:
tabBar?.isHidden = true
scrollView.y = 0
scrollView.height = view.height
}
}
/**
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 func prepare() {
view.contentScaleFactor = Screen.scale
prepareScrollView()
prepareViewControllers()
}
}
extension PageMenuController {
/// Prepares the scrollView used to pan through view controllers.
fileprivate func prepareScrollView() {
scrollView.delegate = self
scrollView.bounces = false
scrollView.isPagingEnabled = true
scrollView.showsVerticalScrollIndicator = false
scrollView.showsHorizontalScrollIndicator = false
scrollView.contentScaleFactor = Screen.scale
view.addSubview(scrollView)
}
/// Prepares the view controllers.
fileprivate func prepareViewControllers() {
let n = viewControllers.count
guard 1 < n else {
if 1 == n {
prepareViewController(at: 0)
}
return
}
let m = viewPoolCount < n ? viewPoolCount : n
if 0 == selectedIndex {
for i in 0..<m {
prepareViewController(at: i)
}
} else if n - 1 == selectedIndex {
for i in 0..<m {
prepareViewController(at: selectedIndex - i)
}
} else {
prepareViewController(at: selectedIndex)
prepareViewController(at: selectedIndex - 1)
prepareViewController(at: selectedIndex + 1)
}
prepareTabBar()
}
/**
Prepares the tabBar buttons.
- Parameter _ buttons: An Array of UIButtons.
*/
fileprivate func prepareTabBarButtons(_ buttons: [UIButton]) {
guard let tb = tabBar else {
return
}
tb.buttons = buttons
for v in tb.buttons {
v.removeTarget(self, action: #selector(tb.handleButton(button:)), for: .touchUpInside)
v.removeTarget(self, action: #selector(handleTabBarButton(button:)), for: .touchUpInside)
v.addTarget(self, action: #selector(handleTabBarButton(button:)), for: .touchUpInside)
}
}
fileprivate func prepareTabBar() {
guard 0 < viewControllers.count else {
tabBar = nil
return
}
var buttons = [UIButton]()
for v in viewControllers {
let button = v.pageMenuBarItem as UIButton
buttons.append(button)
}
guard 0 < buttons.count else {
tabBar = nil
return
}
guard nil == tabBar else {
prepareTabBarButtons(buttons)
return
}
tabBar = TabBar()
tabBar?.isLineAnimated = false
tabBar?.lineAlignment = .top
view.addSubview(tabBar!)
prepareTabBarButtons(buttons)
}
/**
Loads a view controller based on its index in the viewControllers Array
and adds it as a child view controller.
- Parameter at index: An Int for the viewControllers index.
*/
fileprivate func prepareViewController(at index: Int) {
let vc = viewControllers[index]
guard !childViewControllers.contains(vc) else {
return
}
addChildViewController(vc)
vc.didMove(toParentViewController: self)
vc.view.clipsToBounds = true
vc.view.contentScaleFactor = Screen.scale
scrollView.addSubview(vc.view)
}
}
extension PageMenuController {
fileprivate func layoutScrollView() {
scrollView.frame = view.bounds
scrollView.contentSize = CGSize(width: scrollView.width * CGFloat(viewControllers.count), height: scrollView.height)
scrollView.contentOffset = CGPoint(x: scrollView.width * CGFloat(selectedIndex), y: 0)
}
fileprivate func layoutViewControllers() {
let n = viewControllers.count
scrollView.contentSize = CGSize(width: scrollView.width * CGFloat(n), height: scrollView.height)
guard 1 < n else {
layoutViewController(at: 0, position: 0)
return
}
let m = viewPoolCount < n ? viewPoolCount : n
if 0 == selectedIndex {
for i in 0..<m {
layoutViewController(at: i, position: i)
}
} else if n - 1 == selectedIndex {
var q = 0
for i in 0..<m {
q = selectedIndex - i
layoutViewController(at: q, position: q)
}
} else {
layoutViewController(at: selectedIndex, position: selectedIndex)
layoutViewController(at: selectedIndex - 1, position: selectedIndex - 1)
layoutViewController(at: selectedIndex + 1, position: selectedIndex + 1)
}
}
/**
Positions a view controller within the scrollView.
- Parameter position: An Int for the position of the view controller.
*/
fileprivate func layoutViewController(at index: Int, position: Int) {
viewControllers[index].view.frame = CGRect(x: CGFloat(position) * scrollView.width, y: 0, width: scrollView.width, height: scrollView.height)
}
}
extension PageMenuController {
/// Removes the view controllers not within the scrollView.
fileprivate func removeViewControllers() {
let n = viewControllers.count
guard 1 < n else {
return
}
if 0 == selectedIndex {
for i in 1..<n {
removeViewController(at: i)
}
} else if n - 1 == selectedIndex {
for i in 0..<n - 2 {
removeViewController(at: i)
}
} else {
for i in 0..<selectedIndex {
removeViewController(at: i)
}
let x = selectedIndex + 1
if x < n {
for i in x..<n {
removeViewController(at: i)
}
}
}
}
/**
Removes the view controller as a child view controller with
the given index.
- Parameter at index: An Int for the view controller position.
*/
fileprivate func removeViewController(at index: Int) {
let vc = viewControllers[index]
guard childViewControllers.contains(vc) else {
return
}
removeViewController(viewController: vc)
}
/**
Removes a given view controller from the childViewControllers array.
- Parameter at index: An Int for the view controller position.
*/
fileprivate func removeViewController(viewController: UIViewController) {
viewController.willMove(toParentViewController: nil)
viewController.view.removeFromSuperview()
viewController.removeFromParentViewController()
}
}
extension PageMenuController {
/**
Handles the pageTabBarButton.
- Parameter button: A UIButton.
*/
@objc
fileprivate func handleTabBarButton(button: UIButton) {
guard let tb = tabBar else {
return
}
guard let i = tb.buttons.index(of: button) else {
return
}
guard i != selectedIndex else {
return
}
selectedIndex = i
removeViewControllers()
prepareViewControllers()
layoutViewControllers()
}
}
extension PageMenuController: UIScrollViewDelegate {
@objc
open func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let w = scrollView.width
let p = Int(floor((scrollView.contentOffset.x - w / 2) / w) + 1)
selectedIndex = p
removeViewControllers()
prepareViewControllers()
layoutViewControllers()
}
}
......@@ -97,7 +97,6 @@ public protocol PageTabBarControllerDelegate {
optional func pageTabBarController(pageTabBarController: PageTabBarController, didTransitionTo viewController: UIViewController)
}
@objc(PageTabBarController)
open class PageTabBarController: RootController {
/// Reference to the PageTabBar.
@IBInspectable
......
......@@ -49,17 +49,6 @@ extension UIViewController {
}
open class SearchBarController: StatusBarController {
/**
A Display value to indicate whether or not to
display the rootViewController to the full view
bounds, or up to the searchBar height.
*/
open var searchBarDisplay = Display.partial {
didSet {
layoutSubviews()
}
}
/// Reference to the SearchBar.
@IBInspectable
open let searchBar = SearchBar()
......@@ -72,7 +61,7 @@ open class SearchBarController: StatusBarController {
searchBar.y = y
searchBar.width = view.width
switch searchBarDisplay {
switch displayStyle {
case .partial:
let h = y + searchBar.height
rootViewController.view.y = h
......@@ -91,6 +80,7 @@ open class SearchBarController: StatusBarController {
*/
open override func prepare() {
super.prepare()
displayStyle = .partial
prepareStatusBar()
prepareSearchBar()
}
......
......@@ -70,9 +70,11 @@ open class Snackbar: Bar {
return super.hitTest(point, with: event)
}
/// Reloads the view.
open override func reload() {
super.reload()
open override func layoutSubviews() {
super.layoutSubviews()
guard willLayout else {
return
}
centerViews = [textLabel]
}
......
......@@ -54,7 +54,7 @@ open class StatusBarController: RootController {
display the rootViewController to the full view
bounds, or up to the toolbar height.
*/
open var statusBarDisplay = Display.full {
open var displayStyle = DisplayStyle.full {
didSet {
layoutSubviews()
}
......@@ -100,7 +100,7 @@ open class StatusBarController: RootController {
statusBar.width = view.width
switch statusBarDisplay {
switch displayStyle {
case .partial:
let h = statusBar.height
rootViewController.view.y = h
......
......@@ -57,10 +57,33 @@ public protocol TabBarDelegate {
optional func tabBar(tabBar: TabBar, didSelect button: UIButton)
}
@objc(TabBarStyle)
public enum TabBarStyle: Int {
case normal
case scrollable
}
open class TabBar: Bar {
/// A boolean indicating if the TabBar line is in an animation state.
open internal(set) var isAnimating = false
/// Enables and disables bouncing when swiping.
open var isBounceEnabled: Bool {
get {
return contentView.bounces
}
set(value) {
contentView.bounces = value
}
}
/// An enum that determines the tab bar style.
open var tabBarStyle = TabBarStyle.scrollable {
didSet {
layoutSubviews()
}
}
/// A delegation reference.
open weak var delegate: TabBarDelegate?
......@@ -116,8 +139,6 @@ open class TabBar: Bar {
b.removeFromSuperview()
}
centerViews = buttons as [UIView]
layoutSubviews()
}
}
......@@ -186,9 +207,26 @@ open class TabBar: Bar {
}
}
contentView.grid.axis.columns = buttons.count
contentView.grid.reload()
if .scrollable == tabBarStyle {
var w: CGFloat = 0
for b in buttons {
let width = b.sizeThatFits(CGSize(width: CGFloat.greatestFiniteMagnitude, height: contentView.height)).width + interimSpace
contentView.addSubview(b)
b.height = contentView.height
b.width = width
b.x = w
w += width
}
print(w, contentView.width)
if w > contentView.width {
contentView.contentSize.width = w
}
} else {
contentView.grid.axis.columns = buttons.count
centerViews = buttons
}
if nil == selected {
selected = buttons.first
}
......@@ -205,8 +243,9 @@ open class TabBar: Bar {
*/
open override func prepare() {
super.prepare()
isBounceEnabled = true
contentEdgeInsetsPreset = .none
interimSpacePreset = .none
interimSpacePreset = .interimSpace5
prepareLine()
prepareDivider()
}
......
/*
* 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 TabMenuBarItem instance for UIViewController extensions.
fileprivate var TabMenuBarItemKey: UInt8 = 0
open class TabMenuBarItem: FlatButton {
open override func prepare() {
super.prepare()
pulseAnimation = .none
}
}
@objc(TabMenuAlignment)
public enum TabMenuAlignment: Int {
case top
case bottom
}
open class TabMenu: UIView {
@IBInspectable
open var tabBar = TabBar() {
didSet {
layoutSubviews()
}
}
open var viewControllers: [UIViewController]
open var selectedIndex: Int
public required init?(coder aDecoder: NSCoder) {
viewControllers = []
selectedIndex = 0
fatalError("init(coder:) has not been implemented")
}
public init(viewControllers: [UIViewController], selectedIndex: Int = 0) {
self.viewControllers = viewControllers
self.selectedIndex = selectedIndex
super.init(frame: .zero)
}
open override func layoutSubviews() {
super.layoutSubviews()
}
/**
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 func prepare() {
prepareTabBar()
}
}
extension TabMenu {
fileprivate func prepareTabBar() {
tabBar.isLineAnimated = false
tabBar.lineAlignment = .top
}
}
extension UIViewController {
/// tabMenuBarItem reference.
public private(set) var tabMenuBarItem: TabMenuBarItem {
get {
return AssociatedObject(base: self, key: &TabMenuBarItemKey) {
return TabMenuBarItem()
}
}
set(value) {
AssociateObject(base: self, key: &TabMenuBarItemKey, value: value)
}
}
}
extension UIViewController {
/**
A convenience property that provides access to the TabMenuController.
This is the recommended method of accessing the TabMenuController
through child UIViewControllers.
*/
public var tabMenuBarController: TabMenuController? {
var viewController: UIViewController? = self
while nil != viewController {
if viewController is TabMenuController {
return viewController as? TabMenuController
}
viewController = viewController?.parent
}
return nil
}
}
open class TabMenuController: UIViewController {
/// A reference to the TabMenu instance.
@IBInspectable
open let tabMenu: TabMenu
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
public required init?(coder aDecoder: NSCoder) {
tabMenu = TabMenu(viewControllers: [])
super.init(coder: aDecoder)
}
/**
An initializer that accepts an Array of UIViewControllers.
- Parameter viewControllers: An Array of UIViewControllers.
*/
public init(viewControllers: [UIViewController], selectedIndex: Int = 0) {
tabMenu = TabMenu(viewControllers: viewControllers, selectedIndex: selectedIndex)
super.init(nibName: nil, bundle: nil)
}
open override func viewDidLoad() {
super.viewDidLoad()
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 func prepare() {
}
}
......@@ -389,12 +389,16 @@ open class TextField: UITextField {
open override func layoutSubviews() {
super.layoutSubviews()
layoutShape()
reload()
layoutPlaceholderLabel()
layoutDetailLabel()
layoutButton(button: clearIconButton)
layoutButton(button: visibilityIconButton)
layoutDivider()
layoutLeftView()
}
open override func becomeFirstResponder() -> Bool {
setNeedsLayout()
layoutIfNeeded()
layoutSubviews()
return super.becomeFirstResponder()
}
......@@ -402,7 +406,10 @@ open class TextField: UITextField {
open var textInset: CGFloat = 0
open override func textRect(forBounds bounds: CGRect) -> CGRect {
return bounds.insetBy(dx: textInset, dy: 0)
var b = super.textRect(forBounds: bounds)
b.origin.x += textInset
b.size.width -= textInset
return b
}
open override func editingRect(forBounds bounds: CGRect) -> CGRect {
......@@ -430,16 +437,6 @@ open class TextField: UITextField {
prepareTargetHandlers()
prepareTextAlignment()
}
/// Ensures that the components are sized correctly.
open func reload() {
layoutPlaceholderLabel()
layoutDetailLabel()
layoutButton(button: clearIconButton)
layoutButton(button: visibilityIconButton)
layoutDivider()
layoutLeftView()
}
}
extension TextField {
......
......@@ -87,7 +87,6 @@ public protocol TextViewDelegate : UITextViewDelegate {
optional func textView(textView: TextView, didProcessEditing textStorage: TextStorage, text: String, range: NSRange)
}
@objc(TextView)
open class TextView: UITextView {
/// A boolean indicating whether the text is empty.
open var isEmpty: Bool {
......
......@@ -95,9 +95,11 @@ open class Toolbar: Bar {
contentViewAlignment = .center == titleLabel.textAlignment ? .center : .full
}
/// Reloads the view.
open override func reload() {
super.reload()
open override func layoutSubviews() {
super.layoutSubviews()
guard willLayout else {
return
}
if nil != title && "" != title {
if nil == titleLabel.superview {
......
......@@ -69,17 +69,6 @@ public protocol ToolbarControllerDelegate {
@objc(ToolbarController)
open class ToolbarController: StatusBarController {
/**
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 toolbarDisplay = Display.partial {
didSet {
layoutSubviews()
}
}
/// Reference to the Toolbar.
@IBInspectable
open let toolbar = Toolbar()
......@@ -186,7 +175,7 @@ open class ToolbarController: StatusBarController {
toolbar.y = y
toolbar.width = view.width
switch toolbarDisplay {
switch displayStyle {
case .partial:
let h = y + toolbar.height
rootViewController.view.y = h
......@@ -205,6 +194,7 @@ open class ToolbarController: StatusBarController {
*/
open override func prepare() {
super.prepare()
displayStyle = .partial
prepareStatusBar()
prepareToolbar()
}
......
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