Commit 55c12730 by Daniel Dahan

minor updates

parent 23212a21
...@@ -328,7 +328,7 @@ ...@@ -328,7 +328,7 @@
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0640; LastUpgradeCheck = 0640;
ORGANIZATIONNAME = "GraphKit Inc."; ORGANIZATIONNAME = "GraphKit, Inc.";
TargetAttributes = { TargetAttributes = {
963832351B88DFD80015F710 = { 963832351B88DFD80015F710 = {
CreatedOnToolsVersion = 6.4; CreatedOnToolsVersion = 6.4;
......
...@@ -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>1.5.0</string> <string>1.7.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -46,18 +46,32 @@ public struct Layout { ...@@ -46,18 +46,32 @@ public struct Layout {
} }
/** /**
:name: expandToParentSize :name: expandToParent
*/ */
public static func expandToParentSize(parent: UIView, child: UIView) { public static func expandToParent(parent: UIView, child: UIView) {
let views: Dictionary<String, AnyObject> = ["child" : child] let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:|[child]|", options: nil, metrics: nil, views: views)) parent.addConstraints(constraint("H:|[child]|", options: nil, metrics: nil, views: views))
parent.addConstraints(constraint("V:|[child]|", options: nil, metrics: nil, views: views)) parent.addConstraints(constraint("V:|[child]|", options: nil, metrics: nil, views: views))
} }
/** /**
:name: expandToParentSizeWithPad :name: expandToParentHorizontallyWithPad
*/ */
public static func expandToParentSizeWithPad(parent: UIView, child: UIView, left: CGFloat, bottom: CGFloat, right: CGFloat, top: CGFloat) { public static func expandToParentHorizontallyWithPad(parent: UIView, child: UIView, left: CGFloat, right: CGFloat) {
parent.addConstraints(constraint("H:|-(left)-[child]-(right)-|", options: nil, metrics: ["left": left, "right": right], views: ["child" : child]))
}
/**
:name: expandToParentVerticallyWithPad
*/
public static func expandToParentVerticallyWithPad(parent: UIView, child: UIView, top: CGFloat, bottom: CGFloat) {
parent.addConstraints(constraint("V:|-(top)-[child]-(bottom)-|", options: nil, metrics: ["bottom": bottom, "top": top], views: ["child" : child]))
}
/**
:name: expandToParentWithPad
*/
public static func expandToParentWithPad(parent: UIView, child: UIView, left: CGFloat, bottom: CGFloat, right: CGFloat, top: CGFloat) {
let views: Dictionary<String, AnyObject> = ["child" : child] let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:|-(left)-[child]-(right)-|", options: nil, metrics: ["left": left, "right": right], views: views)) parent.addConstraints(constraint("H:|-(left)-[child]-(right)-|", options: nil, metrics: ["left": left, "right": right], views: views))
parent.addConstraints(constraint("V:|-(top)-[child]-(bottom)-|", options: nil, metrics: ["bottom": bottom, "top": top], views: views)) parent.addConstraints(constraint("V:|-(top)-[child]-(bottom)-|", options: nil, metrics: ["bottom": bottom, "top": top], views: views))
......
...@@ -174,7 +174,7 @@ public class MaterialButton : UIButton { ...@@ -174,7 +174,7 @@ public class MaterialButton : UIButton {
backgroundColorView.clipsToBounds = true backgroundColorView.clipsToBounds = true
backgroundColorView.userInteractionEnabled = false backgroundColorView.userInteractionEnabled = false
insertSubview(backgroundColorView, atIndex: 0) insertSubview(backgroundColorView, atIndex: 0)
Layout.expandToParentSize(self, child: backgroundColorView) Layout.expandToParent(self, child: backgroundColorView)
} }
// //
......
...@@ -170,7 +170,7 @@ public class MaterialCard : UIView { ...@@ -170,7 +170,7 @@ public class MaterialCard : UIView {
backgroundColorView.clipsToBounds = true backgroundColorView.clipsToBounds = true
backgroundColorView.userInteractionEnabled = false backgroundColorView.userInteractionEnabled = false
insertSubview(backgroundColorView, atIndex: 0) insertSubview(backgroundColorView, atIndex: 0)
Layout.expandToParentSize(self, child: backgroundColorView) Layout.expandToParent(self, child: backgroundColorView)
} }
// //
......
...@@ -25,13 +25,32 @@ public enum SideNavState { ...@@ -25,13 +25,32 @@ public enum SideNavState {
@objc(SideNavContainer) @objc(SideNavContainer)
public class SideNavContainer : Printable { public class SideNavContainer : Printable {
/**
:name: state
*/
public private(set) var state: SideNavState public private(set) var state: SideNavState
/**
:name: point
*/
public private(set) var point: CGPoint public private(set) var point: CGPoint
/**
:name: frame
*/
public private(set) var frame: CGRect public private(set) var frame: CGRect
/**
:name: description
*/
public var description: String { public var description: String {
let s: String = .Opened == state ? "Opened" : "Closed" let s: String = .Opened == state ? "Opened" : "Closed"
return "(state: \(s), point: \(point), frame: \(frame))" return "(state: \(s), point: \(point), frame: \(frame))"
} }
/**
:name: init
*/
public init(state: SideNavState, point: CGPoint, frame: CGRect) { public init(state: SideNavState, point: CGPoint, frame: CGRect) {
self.state = state self.state = state
self.point = point self.point = point
...@@ -76,9 +95,8 @@ public protocol SideNavDelegate { ...@@ -76,9 +95,8 @@ public protocol SideNavDelegate {
@objc(SideNavController) @objc(SideNavController)
public class SideNavController: UIViewController, UIGestureRecognizerDelegate { public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
/** /**
:name: default options :name: default options
*/ */
public struct defaultOptions { public struct defaultOptions {
public static var bezelWidth: CGFloat = 48 public static var bezelWidth: CGFloat = 48
...@@ -161,7 +179,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -161,7 +179,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
} }
/** /**
:name: isTopContainerOpened :name: isTopContainerOpened
*/ */
public var isTopContainerOpened: Bool { public var isTopContainerOpened: Bool {
if let c = topViewContainer { if let c = topViewContainer {
...@@ -208,7 +226,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -208,7 +226,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
public private(set) var bottomViewContainer: UIView? public private(set) var bottomViewContainer: UIView?
/** /**
:name: bottomViewContainer :name: bottomViewContainer
*/ */
public private(set) var topViewContainer: UIView? public private(set) var topViewContainer: UIView?
...@@ -223,12 +241,12 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -223,12 +241,12 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
public private(set) var rightContainer: SideNavContainer? public private(set) var rightContainer: SideNavContainer?
/** /**
:name: bottomContainer :name: bottomContainer
*/ */
public private(set) var bottomContainer: SideNavContainer? public private(set) var bottomContainer: SideNavContainer?
/** /**
:name: topContainer :name: topContainer
*/ */
public private(set) var topContainer: SideNavContainer? public private(set) var topContainer: SideNavContainer?
...@@ -248,12 +266,12 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -248,12 +266,12 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
public var rightViewController: UIViewController? public var rightViewController: UIViewController?
/** /**
:name: leftViewController :name: leftViewController
*/ */
public var bottomViewController: UIViewController? public var bottomViewController: UIViewController?
/** /**
:name: topViewController :name: topViewController
*/ */
public var topViewController: UIViewController? public var topViewController: UIViewController?
...@@ -278,7 +296,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -278,7 +296,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
public var bottomTapGesture: UITapGestureRecognizer? public var bottomTapGesture: UITapGestureRecognizer?
/** /**
:name: topTapGesture :name: topTapGesture
*/ */
public var topTapGesture: UITapGestureRecognizer? public var topTapGesture: UITapGestureRecognizer?
...@@ -293,7 +311,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -293,7 +311,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
public var bottomPanGesture: UIPanGestureRecognizer? public var bottomPanGesture: UIPanGestureRecognizer?
/** /**
:name: rightPanGesture :name: rightPanGesture
*/ */
public var topPanGesture: UIPanGestureRecognizer? public var topPanGesture: UIPanGestureRecognizer?
...@@ -373,7 +391,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -373,7 +391,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
} }
/** /**
:name: init :name: init
*/ */
public convenience init(mainViewController: UIViewController, topViewController: UIViewController) { public convenience init(mainViewController: UIViewController, topViewController: UIViewController) {
self.init() self.init()
...@@ -412,7 +430,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -412,7 +430,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
} }
/** /**
:name: init :name: init
*/ */
public convenience init(mainViewController: UIViewController, leftViewController: UIViewController, bottomViewController: UIViewController, rightViewController: UIViewController, topViewController: UIViewController) { public convenience init(mainViewController: UIViewController, leftViewController: UIViewController, bottomViewController: UIViewController, rightViewController: UIViewController, topViewController: UIViewController) {
self.init() self.init()
...@@ -429,7 +447,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -429,7 +447,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
} }
/** /**
:name: init :name: init
*/ */
public convenience init(mainViewController: UIViewController, bottomViewController: UIViewController, rightViewController: UIViewController) { public convenience init(mainViewController: UIViewController, bottomViewController: UIViewController, rightViewController: UIViewController) {
self.init() self.init()
...@@ -442,7 +460,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -442,7 +460,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
} }
/** /**
:name: init :name: init
*/ */
public convenience init(mainViewController: UIViewController, bottomViewController: UIViewController, topViewController: UIViewController) { public convenience init(mainViewController: UIViewController, bottomViewController: UIViewController, topViewController: UIViewController) {
self.init() self.init()
...@@ -455,7 +473,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -455,7 +473,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
} }
/** /**
:name: init :name: init
*/ */
public convenience init(mainViewController: UIViewController, rightViewController: UIViewController, topViewController: UIViewController) { public convenience init(mainViewController: UIViewController, rightViewController: UIViewController, topViewController: UIViewController) {
self.init() self.init()
...@@ -512,14 +530,14 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -512,14 +530,14 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
} }
/** /**
:name: toggleBottomViewContainer :name: toggleBottomViewContainer
*/ */
public func toggleBottomViewContainer(velocity: CGFloat = 0) { public func toggleBottomViewContainer(velocity: CGFloat = 0) {
isBottomContainerOpened ? closeBottomViewContainer(velocity: velocity) : openBottomViewContainer(velocity: velocity) isBottomContainerOpened ? closeBottomViewContainer(velocity: velocity) : openBottomViewContainer(velocity: velocity)
} }
/** /**
:name: toggleTopViewContainer :name: toggleTopViewContainer
*/ */
public func toggleTopViewContainer(velocity: CGFloat = 0) { public func toggleTopViewContainer(velocity: CGFloat = 0) {
isTopContainerOpened ? closeTopViewContainer(velocity: velocity) : openTopViewContainer(velocity: velocity) isTopContainerOpened ? closeTopViewContainer(velocity: velocity) : openTopViewContainer(velocity: velocity)
...@@ -574,7 +592,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -574,7 +592,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
} }
/** /**
:name: openBottomViewContainer :name: openBottomViewContainer
*/ */
public func openBottomViewContainer(velocity: CGFloat = 0) { public func openBottomViewContainer(velocity: CGFloat = 0) {
if let vc = bottomViewContainer { if let vc = bottomViewContainer {
...@@ -598,7 +616,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -598,7 +616,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
} }
/** /**
:name: openTopViewContainer :name: openTopViewContainer
*/ */
public func openTopViewContainer(velocity: CGFloat = 0) { public func openTopViewContainer(velocity: CGFloat = 0) {
if let vc = topViewContainer { if let vc = topViewContainer {
...@@ -697,7 +715,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -697,7 +715,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
} }
/** /**
:name: closeBottomViewContainer :name: closeBottomViewContainer
*/ */
public func closeTopViewContainer(velocity: CGFloat = 0) { public func closeTopViewContainer(velocity: CGFloat = 0) {
if let vc = topViewContainer { if let vc = topViewContainer {
...@@ -772,7 +790,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -772,7 +790,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
} }
/** /**
:name: switchTopViewController :name: switchTopViewController
*/ */
public func switchTopViewController(viewController: UIViewController, closeTopViewContainerViewContainer: Bool) { public func switchTopViewController(viewController: UIViewController, closeTopViewContainerViewContainer: Bool) {
removeViewController(&topViewController) removeViewController(&topViewController)
...@@ -984,44 +1002,36 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -984,44 +1002,36 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
// //
internal func handleBottomPanGesture(gesture: UIPanGestureRecognizer) { internal func handleBottomPanGesture(gesture: UIPanGestureRecognizer) {
if isLeftContainerOpened || isRightContainerOpened || isTopContainerOpened { return } if isLeftContainerOpened || isRightContainerOpened || isTopContainerOpened { return }
if .Began == gesture.state { if let vc = bottomViewContainer {
if let vc = bottomViewContainer { if let c = bottomContainer {
if let c = bottomContainer { if .Began == gesture.state {
addShadow(&bottomViewContainer) addShadow(&bottomViewContainer)
toggleStatusBar(hide: true) toggleStatusBar(hide: true)
c.state = isBottomContainerOpened ? .Opened : .Closed c.state = isBottomContainerOpened ? .Opened : .Closed
c.point = gesture.locationInView(view) c.point = gesture.locationInView(view)
c.frame = vc.frame c.frame = vc.frame
delegate?.sideNavDidBeginBottomPan?(self, container: c) delegate?.sideNavDidBeginBottomPan?(self, container: c)
} } else if .Changed == gesture.state {
} c.point = gesture.translationInView(gesture.view!)
} else if .Changed == gesture.state { let r = (bottomOriginY - vc.frame.origin.y) / vc.frame.size.height
if let vc = bottomViewContainer { let m: CGFloat = bottomOriginY - vc.frame.size.height
if let c = bottomContainer { let y: CGFloat = c.frame.origin.y + c.point.y
c.point = gesture.translationInView(gesture.view!) vc.frame.origin.y = y > bottomOriginY ? bottomOriginY : y < m ? m : y
let r = (bottomOriginY - vc.frame.origin.y) / vc.frame.size.height backdropViewContainer?.layer.opacity = Float(r * options.backdropOpacity)
let m: CGFloat = bottomOriginY - vc.frame.size.height delegate?.sideNavDidChangeBottomPan?(self, container: c)
let y: CGFloat = c.frame.origin.y + c.point.y } else {
vc.frame.origin.y = y > bottomOriginY ? bottomOriginY : y < m ? m : y c.point = gesture.velocityInView(gesture.view)
backdropViewContainer?.layer.opacity = Float(r * options.backdropOpacity) let y: CGFloat = c.point.y <= -1000 || c.point.y >= 1000 ? c.point.y : 0
delegate?.sideNavDidChangeBottomPan?(self, container: c) c.state = vc.frame.origin.y >= CGFloat(floor(bottomOriginY) - options.verticalThreshold) || c.point.y >= 1000 ? .Closed : .Opened
} if .Closed == c.state {
} closeBottomViewContainer(velocity: y)
} else { } else {
if let vc = bottomViewContainer { openBottomViewContainer(velocity: y)
if let c = bottomContainer { }
c.point = gesture.velocityInView(gesture.view) delegate?.sideNavDidEndBottomPan?(self, container: c)
let y: CGFloat = c.point.y <= -1000 || c.point.y >= 1000 ? c.point.y : 0 }
c.state = vc.frame.origin.y >= CGFloat(floor(bottomOriginY) - options.verticalThreshold) || c.point.y >= 1000 ? .Closed : .Opened }
if .Closed == c.state { }
closeBottomViewContainer(velocity: y)
} else {
openBottomViewContainer(velocity: y)
}
delegate?.sideNavDidEndBottomPan?(self, container: c)
}
}
}
} }
// //
...@@ -1039,44 +1049,36 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -1039,44 +1049,36 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
// //
internal func handleTopPanGesture(gesture: UIPanGestureRecognizer) { internal func handleTopPanGesture(gesture: UIPanGestureRecognizer) {
if isLeftContainerOpened || isRightContainerOpened || isBottomContainerOpened { return } if isLeftContainerOpened || isRightContainerOpened || isBottomContainerOpened { return }
if .Began == gesture.state { if let vc = topViewContainer {
if let vc = topViewContainer { if let c = topContainer {
if let c = topContainer { if .Began == gesture.state {
addShadow(&topViewContainer) addShadow(&topViewContainer)
toggleStatusBar(hide: true) toggleStatusBar(hide: true)
c.state = isTopContainerOpened ? .Opened : .Closed c.state = isTopContainerOpened ? .Opened : .Closed
c.point = gesture.locationInView(view) c.point = gesture.locationInView(view)
c.frame = vc.frame c.frame = vc.frame
delegate?.sideNavDidBeginTopPan?(self, container: c) delegate?.sideNavDidBeginTopPan?(self, container: c)
} } else if .Changed == gesture.state {
} c.point = gesture.translationInView(gesture.view!)
} else if .Changed == gesture.state { let r = (topOriginY - vc.frame.origin.y) / vc.frame.size.height
if let vc = topViewContainer { let m: CGFloat = topOriginY + vc.frame.size.height
if let c = topContainer { let y: CGFloat = c.frame.origin.y + c.point.y // increase origin y
c.point = gesture.translationInView(gesture.view!) vc.frame.origin.y = y < topOriginY ? topOriginY : y < m ? y : m
let r = (topOriginY - vc.frame.origin.y) / vc.frame.size.height backdropViewContainer?.layer.opacity = Float(abs(r) * options.backdropOpacity)
let m: CGFloat = topOriginY + vc.frame.size.height delegate?.sideNavDidChangeTopPan?(self, container: c)
let y: CGFloat = c.frame.origin.y + c.point.y // increase origin y } else {
vc.frame.origin.y = y < topOriginY ? topOriginY : y < m ? y : m c.point = gesture.velocityInView(gesture.view)
backdropViewContainer?.layer.opacity = Float(abs(r) * options.backdropOpacity) let y: CGFloat = c.point.y <= -1000 || c.point.y >= 1000 ? c.point.y : 0
delegate?.sideNavDidChangeTopPan?(self, container: c) c.state = vc.frame.origin.y >= CGFloat(floor(topOriginY) + options.verticalThreshold) || c.point.y >= 1000 ? .Opened : .Closed
} if .Closed == c.state {
} closeTopViewContainer(velocity: y)
} else { } else {
if let vc = topViewContainer { openTopViewContainer(velocity: y)
if let c = topContainer { }
c.point = gesture.velocityInView(gesture.view) delegate?.sideNavDidEndTopPan?(self, container: c)
let y: CGFloat = c.point.y <= -1000 || c.point.y >= 1000 ? c.point.y : 0 }
c.state = vc.frame.origin.y >= CGFloat(floor(topOriginY) + options.verticalThreshold) || c.point.y >= 1000 ? .Opened : .Closed }
if .Closed == c.state { }
closeTopViewContainer(velocity: y)
} else {
openTopViewContainer(velocity: y)
}
delegate?.sideNavDidEndTopPan?(self, container: c)
}
}
}
} }
// //
...@@ -1299,7 +1301,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate { ...@@ -1299,7 +1301,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
vc.view.setTranslatesAutoresizingMaskIntoConstraints(false) vc.view.setTranslatesAutoresizingMaskIntoConstraints(false)
addChildViewController(vc) addChildViewController(vc)
c.addSubview(vc.view) c.addSubview(vc.view)
Layout.expandToParentSize(c, child: vc.view) Layout.expandToParent(c, child: vc.view)
vc.didMoveToParentViewController(self) vc.didMoveToParentViewController(self)
} }
} }
......
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