Commit 55c12730 by Daniel Dahan

minor updates

parent 23212a21
......@@ -328,7 +328,7 @@
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0640;
ORGANIZATIONNAME = "GraphKit Inc.";
ORGANIZATIONNAME = "GraphKit, Inc.";
TargetAttributes = {
963832351B88DFD80015F710 = {
CreatedOnToolsVersion = 6.4;
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.5.0</string>
<string>1.7.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -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]
parent.addConstraints(constraint("H:|[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]
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))
......
......@@ -174,7 +174,7 @@ public class MaterialButton : UIButton {
backgroundColorView.clipsToBounds = true
backgroundColorView.userInteractionEnabled = false
insertSubview(backgroundColorView, atIndex: 0)
Layout.expandToParentSize(self, child: backgroundColorView)
Layout.expandToParent(self, child: backgroundColorView)
}
//
......
......@@ -170,7 +170,7 @@ public class MaterialCard : UIView {
backgroundColorView.clipsToBounds = true
backgroundColorView.userInteractionEnabled = false
insertSubview(backgroundColorView, atIndex: 0)
Layout.expandToParentSize(self, child: backgroundColorView)
Layout.expandToParent(self, child: backgroundColorView)
}
//
......
......@@ -25,13 +25,32 @@ public enum SideNavState {
@objc(SideNavContainer)
public class SideNavContainer : Printable {
/**
:name: state
*/
public private(set) var state: SideNavState
/**
:name: point
*/
public private(set) var point: CGPoint
/**
:name: frame
*/
public private(set) var frame: CGRect
/**
:name: description
*/
public var description: String {
let s: String = .Opened == state ? "Opened" : "Closed"
return "(state: \(s), point: \(point), frame: \(frame))"
}
/**
:name: init
*/
public init(state: SideNavState, point: CGPoint, frame: CGRect) {
self.state = state
self.point = point
......@@ -76,7 +95,6 @@ public protocol SideNavDelegate {
@objc(SideNavController)
public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
/**
:name: default options
*/
......@@ -984,20 +1002,16 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
//
internal func handleBottomPanGesture(gesture: UIPanGestureRecognizer) {
if isLeftContainerOpened || isRightContainerOpened || isTopContainerOpened { return }
if .Began == gesture.state {
if let vc = bottomViewContainer {
if let c = bottomContainer {
if .Began == gesture.state {
addShadow(&bottomViewContainer)
toggleStatusBar(hide: true)
c.state = isBottomContainerOpened ? .Opened : .Closed
c.point = gesture.locationInView(view)
c.frame = vc.frame
delegate?.sideNavDidBeginBottomPan?(self, container: c)
}
}
} else if .Changed == gesture.state {
if let vc = bottomViewContainer {
if let c = bottomContainer {
c.point = gesture.translationInView(gesture.view!)
let r = (bottomOriginY - vc.frame.origin.y) / vc.frame.size.height
let m: CGFloat = bottomOriginY - vc.frame.size.height
......@@ -1005,11 +1019,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
vc.frame.origin.y = y > bottomOriginY ? bottomOriginY : y < m ? m : y
backdropViewContainer?.layer.opacity = Float(r * options.backdropOpacity)
delegate?.sideNavDidChangeBottomPan?(self, container: c)
}
}
} else {
if let vc = bottomViewContainer {
if let c = bottomContainer {
c.point = gesture.velocityInView(gesture.view)
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
......@@ -1039,20 +1049,16 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
//
internal func handleTopPanGesture(gesture: UIPanGestureRecognizer) {
if isLeftContainerOpened || isRightContainerOpened || isBottomContainerOpened { return }
if .Began == gesture.state {
if let vc = topViewContainer {
if let c = topContainer {
if .Began == gesture.state {
addShadow(&topViewContainer)
toggleStatusBar(hide: true)
c.state = isTopContainerOpened ? .Opened : .Closed
c.point = gesture.locationInView(view)
c.frame = vc.frame
delegate?.sideNavDidBeginTopPan?(self, container: c)
}
}
} else if .Changed == gesture.state {
if let vc = topViewContainer {
if let c = topContainer {
c.point = gesture.translationInView(gesture.view!)
let r = (topOriginY - vc.frame.origin.y) / vc.frame.size.height
let m: CGFloat = topOriginY + vc.frame.size.height
......@@ -1060,11 +1066,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
vc.frame.origin.y = y < topOriginY ? topOriginY : y < m ? y : m
backdropViewContainer?.layer.opacity = Float(abs(r) * options.backdropOpacity)
delegate?.sideNavDidChangeTopPan?(self, container: c)
}
}
} else {
if let vc = topViewContainer {
if let c = topContainer {
c.point = gesture.velocityInView(gesture.view)
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
......@@ -1299,7 +1301,7 @@ public class SideNavController: UIViewController, UIGestureRecognizerDelegate {
vc.view.setTranslatesAutoresizingMaskIntoConstraints(false)
addChildViewController(vc)
c.addSubview(vc.view)
Layout.expandToParentSize(c, child: vc.view)
Layout.expandToParent(c, child: vc.view)
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