Commit b1f7f4c2 by Daniel Dahan

updated bundle reference for CocoaPods

parent bcd19bd8
...@@ -52,25 +52,20 @@ class AppSearchBarController: SearchBarController { ...@@ -52,25 +52,20 @@ class AppSearchBarController: SearchBarController {
override func viewWillAppear(animated: Bool) { override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
searchBar.statusBarStyle = .Default searchBar.statusBarStyle = .Default
searchBar.textField.becomeFirstResponder()
sideNavigationController?.delegate = self
sideNavigationController?.enabled = false sideNavigationController?.enabled = false
} }
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
searchBar.textField.becomeFirstResponder()
}
/// Toggle SideSearchViewController left UIViewController. /// Toggle SideSearchViewController left UIViewController.
internal func handleBackButton() { internal func handleBackButton() {
searchBar.textField.resignFirstResponder() searchBar.textField.resignFirstResponder()
dismissViewControllerAnimated(true, completion: nil) dismissViewControllerAnimated(true, completion: nil)
} }
/// Toggle SideSearchViewController right UIViewController.
internal func handleMoreButton() {
searchBar.textField.resignFirstResponder()
print(presentingViewController?.view.layer.zPosition)
sideNavigationController?.enabledRightView = true
sideNavigationController?.toggleRightView()
}
/// Prepares view. /// Prepares view.
override func prepareView() { override func prepareView() {
super.prepareView() super.prepareView()
...@@ -131,9 +126,3 @@ extension AppSearchBarController: TextFieldDelegate { ...@@ -131,9 +126,3 @@ extension AppSearchBarController: TextFieldDelegate {
print("End searching....") print("End searching....")
} }
} }
extension AppSearchBarController: SideNavigationControllerDelegate {
func sideNavigationDidClose(sideNavigationController: SideNavigationController, position: SideNavigationPosition) {
sideNavigationController.enabled = false
}
}
...@@ -10,4 +10,7 @@ Pod::Spec.new do |s| ...@@ -10,4 +10,7 @@ Pod::Spec.new do |s|
s.ios.deployment_target = '8.0' s.ios.deployment_target = '8.0'
s.source_files = 'Sources/*.swift' s.source_files = 'Sources/*.swift'
s.requires_arc = true s.requires_arc = true
s.resource_bundles = {
'io.cosmicmind.Material' => ['Sources/Assets.xcassets/**/*.png']
}
end end
...@@ -341,6 +341,13 @@ ...@@ -341,6 +341,13 @@
name = Grid; name = Grid;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
9666D3961C99297000F50E0E /* Assets */ = {
isa = PBXGroup;
children = (
);
name = Assets;
sourceTree = "<group>";
};
966F57B61C226D65009185B7 /* Text */ = { 966F57B61C226D65009185B7 /* Text */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -402,6 +409,7 @@ ...@@ -402,6 +409,7 @@
96D88BF41C1328D800B91418 /* Sources */ = { 96D88BF41C1328D800B91418 /* Sources */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9666D3961C99297000F50E0E /* Assets */,
96D88BFD1C1328D800B91418 /* LICENSE */, 96D88BFD1C1328D800B91418 /* LICENSE */,
96D88BFC1C1328D800B91418 /* Info.plist */, 96D88BFC1C1328D800B91418 /* Info.plist */,
96D88C091C1328D800B91418 /* Material.h */, 96D88C091C1328D800B91418 /* Material.h */,
......
...@@ -35,10 +35,10 @@ public struct MaterialColor { ...@@ -35,10 +35,10 @@ public struct MaterialColor {
public static let clear: UIColor = UIColor.clearColor() public static let clear: UIColor = UIColor.clearColor()
// white // white
public static let white: UIColor = UIColor(red: 255/255, green: 255/255, blue: 255/255, alpha: 1) public static let white: UIColor = UIColor.whiteColor()
// black // black
public static let black: UIColor = UIColor(red: 0/255, green: 0/255, blue: 0/255, alpha: 1) public static let black: UIColor = UIColor.blackColor()
// red // red
public struct red { public struct red {
......
...@@ -297,7 +297,6 @@ public class NavigationBar : UINavigationBar { ...@@ -297,7 +297,6 @@ public class NavigationBar : UINavigationBar {
item.titleView = UIView(frame: CGRectMake(0, contentInset.top, MaterialDevice.width < MaterialDevice.height ? MaterialDevice.height : MaterialDevice.width, intrinsicContentSize().height - contentInset.top - contentInset.bottom)) item.titleView = UIView(frame: CGRectMake(0, contentInset.top, MaterialDevice.width < MaterialDevice.height ? MaterialDevice.height : MaterialDevice.width, intrinsicContentSize().height - contentInset.top - contentInset.bottom))
item.titleView!.autoresizingMask = [.FlexibleWidth] item.titleView!.autoresizingMask = [.FlexibleWidth]
item.titleView!.grid.axis.direction = .Vertical item.titleView!.grid.axis.direction = .Vertical
item.titleView!.backgroundColor = MaterialColor.green.base
// TitleView alignment. // TitleView alignment.
if let t: UILabel = item.titleLabel { if let t: UILabel = item.titleLabel {
......
...@@ -211,7 +211,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -211,7 +211,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
A Boolean property that triggers the status bar to be hidden A Boolean property that triggers the status bar to be hidden
when the leftView is opened. Defaults to true. when the leftView is opened. Defaults to true.
*/ */
@IBInspectable public var hideStatusBar: Bool = true @IBInspectable public var enableHideStatusbar: Bool = true
/** /**
A MaterialDepth property that is used to set the depth of the A MaterialDepth property that is used to set the depth of the
...@@ -305,6 +305,18 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -305,6 +305,18 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
layoutSubviews() layoutSubviews()
} }
public override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
if !MaterialDevice.landscape && .iPhone == MaterialDevice.type {
hideStatusBar()
} else {
showStatusBar()
}
if let v: MaterialView = rightView {
v.x = size.width - (openedRightView ? rightViewWidth : 0)
}
}
/** /**
A method to swap mainViewController objects. A method to swap mainViewController objects.
- Parameter toViewController: The UIViewController to swap - Parameter toViewController: The UIViewController to swap
...@@ -497,7 +509,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -497,7 +509,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
public func openLeftView(velocity: CGFloat = 0) { public func openLeftView(velocity: CGFloat = 0) {
if enabledLeftView { if enabledLeftView {
if let v: MaterialView = leftView { if let v: MaterialView = leftView {
toggleStatusBar(true) hideStatusBar()
showView(v) showView(v)
delegate?.sideNavigationWillOpen?(self, position: .Left) delegate?.sideNavigationWillOpen?(self, position: .Left)
...@@ -521,7 +533,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -521,7 +533,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
public func openRightView(velocity: CGFloat = 0) { public func openRightView(velocity: CGFloat = 0) {
if enabledRightView { if enabledRightView {
if let v: MaterialView = rightView { if let v: MaterialView = rightView {
toggleStatusBar(true) hideStatusBar()
showView(v) showView(v)
delegate?.sideNavigationWillOpen?(self, position: .Right) delegate?.sideNavigationWillOpen?(self, position: .Right)
...@@ -551,8 +563,8 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -551,8 +563,8 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
animations: { animations: {
v.position.x = -v.width / 2 v.position.x = -v.width / 2
}) { [unowned self] _ in }) { [unowned self] _ in
self.toggleStatusBar(MaterialDevice.landscape && .iPhone == MaterialDevice.type)
self.hideView(v) self.hideView(v)
self.toggleStatusBar()
self.delegate?.sideNavigationDidClose?(self, position: .Left) self.delegate?.sideNavigationDidClose?(self, position: .Left)
} }
} }
...@@ -574,8 +586,8 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -574,8 +586,8 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
animations: { [unowned self] in animations: { [unowned self] in
v.position.x = self.view.bounds.width + v.width / 2 v.position.x = self.view.bounds.width + v.width / 2
}) { [unowned self] _ in }) { [unowned self] _ in
self.toggleStatusBar(MaterialDevice.landscape && .iPhone == MaterialDevice.type)
self.hideView(v) self.hideView(v)
self.toggleStatusBar()
self.delegate?.sideNavigationDidClose?(self, position: .Right) self.delegate?.sideNavigationDidClose?(self, position: .Right)
} }
} }
...@@ -612,7 +624,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -612,7 +624,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
case .Began: case .Began:
originalX = v.position.x originalX = v.position.x
toggleStatusBar(true) hideStatusBar()
showView(v) showView(v)
delegate?.sideNavigationPanDidBegin?(self, point: point, position: .Right) delegate?.sideNavigationPanDidBegin?(self, point: point, position: .Right)
...@@ -649,7 +661,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -649,7 +661,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
case .Began: case .Began:
originalX = v.position.x originalX = v.position.x
toggleStatusBar(true) hideStatusBar()
showView(v) showView(v)
delegate?.sideNavigationPanDidBegin?(self, point: point, position: .Left) delegate?.sideNavigationPanDidBegin?(self, point: point, position: .Left)
...@@ -819,32 +831,45 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -819,32 +831,45 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
} }
} }
/** /// Shows the statusBar.
A method to toggle the status bar from a reveal state to private func showStatusBar() {
hidden state. The hideStatusBar property needs to be set userInteractionEnabled = false
to true in order for this method to have any affect. UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration),
- Parameter hide: A Boolean indicating to show or hide animations: { [weak self] in
the status bar. self?.setNeedsStatusBarAppearanceUpdate()
*/ MaterialDevice.statusBarHidden = false
private func toggleStatusBar(hide: Bool = false) { }) { [weak self] _ in
// if hideStatusBar { if false == self?.opened {
// userInteractionEnabled = false self?.userInteractionEnabled = true
// let hidden: Bool = opened ? true : hide }
// UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration), }
// animations: { [weak self] in delegate?.sideNavigationStatusBarHiddenState?(self, hidden: false)
// self?.setNeedsStatusBarAppearanceUpdate()
// MaterialDevice.statusBarHidden = hidden
// }) { [weak self] _ in
// if false == self?.opened {
// self?.userInteractionEnabled = true
// }
// }
// delegate?.sideNavigationStatusBarHiddenState?(self, hidden: hidden)
// }
} }
public override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation { /// Hides the statusBar.
return .Fade private func hideStatusBar() {
if enableHideStatusbar {
userInteractionEnabled = false
UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration),
animations: { [weak self] in
self?.setNeedsStatusBarAppearanceUpdate()
MaterialDevice.statusBarHidden = true
}) { [weak self] _ in
if false == self?.opened {
self?.userInteractionEnabled = true
}
}
delegate?.sideNavigationStatusBarHiddenState?(self, hidden: true)
}
}
/// Toggles the statusBar
private func toggleStatusBar() {
if MaterialDevice.landscape && .iPhone == MaterialDevice.type {
hideStatusBar()
} else {
showStatusBar()
}
} }
/** /**
...@@ -909,7 +934,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -909,7 +934,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
/// Layout subviews. /// Layout subviews.
private func layoutSubviews() { private func layoutSubviews() {
toggleStatusBar(MaterialDevice.landscape && .iPhone == MaterialDevice.type) toggleStatusBar()
if let v: MaterialView = leftView { if let v: MaterialView = leftView {
v.width = leftViewWidth v.width = leftViewWidth
......
...@@ -521,7 +521,7 @@ public class TextField : UITextField { ...@@ -521,7 +521,7 @@ public class TextField : UITextField {
public func reloadView() { public func reloadView() {
/// Prepare the clearButton. /// Prepare the clearButton.
if let v: UIButton = clearButton { if let v: UIButton = clearButton {
v.frame = CGRectMake(0, 0, height, height) v.frame = CGRectMake(width - height, 0, height, height)
} }
} }
......
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