Commit dd913a42 by Daniel Dahan

updated App project and fixed pan gesture issue when swiping back in NavigationController

parent 8152043b
......@@ -19,7 +19,7 @@
9663F94E1C7A74EA00AF0965 /* AppLeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */; };
9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */; };
9663F9521C7A751D00AF0965 /* FeedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9511C7A751D00AF0965 /* FeedViewController.swift */; };
96CC08881C7FEBD60034FF84 /* InboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08871C7FEBD60034FF84 /* InboxViewController.swift */; };
96CC08881C7FEBD60034FF84 /* RecipesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -50,7 +50,7 @@
9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppLeftViewController.swift; sourceTree = "<group>"; };
9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppRightViewController.swift; sourceTree = "<group>"; };
9663F9511C7A751D00AF0965 /* FeedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedViewController.swift; sourceTree = "<group>"; };
96CC08871C7FEBD60034FF84 /* InboxViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InboxViewController.swift; sourceTree = "<group>"; };
96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecipesViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -93,7 +93,7 @@
9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */,
9663F9331C7A744600AF0965 /* SearchListViewController.swift */,
9663F9511C7A751D00AF0965 /* FeedViewController.swift */,
96CC08871C7FEBD60034FF84 /* InboxViewController.swift */,
96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */,
9663F9381C7A744600AF0965 /* Assets.xcassets */,
9663F93A1C7A744600AF0965 /* LaunchScreen.storyboard */,
9663F93D1C7A744600AF0965 /* Info.plist */,
......@@ -173,7 +173,7 @@
buildActionMask = 2147483647;
files = (
9663F94A1C7A74B500AF0965 /* AppSearchBarViewController.swift in Sources */,
96CC08881C7FEBD60034FF84 /* InboxViewController.swift in Sources */,
96CC08881C7FEBD60034FF84 /* RecipesViewController.swift in Sources */,
9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */,
9663F9481C7A749400AF0965 /* AppNavigationController.swift in Sources */,
9663F9341C7A744600AF0965 /* SearchListViewController.swift in Sources */,
......
......@@ -76,7 +76,7 @@ class AppLeftViewController: UIViewController {
/// Prepares the items that are displayed within the tableView.
private func prepareCells() {
items.append(Item(text: "Feed", imageName: "ic_today"))
items.append(Item(text: "Inbox", imageName: "ic_inbox"))
items.append(Item(text: "Recipes", imageName: "ic_inbox"))
}
/// Prepares profile view.
......
......@@ -67,7 +67,7 @@ class AppRightViewController: UIViewController {
/// Prepares the items that are displayed within the tableView.
private func prepareCells() {
items.append(Item(text: "Inbox", imageName: "ic_inbox"))
items.append(Item(text: "Recipes", imageName: "ic_inbox"))
items.append(Item(text: "Feed", imageName: "ic_today"))
items.append(Item(text: "Bookmarks", imageName: "ic_book"))
items.append(Item(text: "Work", imageName: "ic_work"))
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "AssortmentOfDessert.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "AssortmentOfFood.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "AvocadoIceCream.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "HeartCookies.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "VeganCakeFull.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "VeganHempBalls.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "VeganPieAbove.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -47,6 +47,9 @@ class FeedViewController: UIViewController {
/// MaterialCollectionView.
private var collectionView: MaterialCollectionView!
/// Image thumbnail height.
private var thumbnailHieght: CGFloat = 112
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
......@@ -70,8 +73,6 @@ class FeedViewController: UIViewController {
navigationbar.backgroundColor = MaterialColor.blue.base
navigationbar.backButton.tintColor = MaterialColor.white
}
collectionView.reloadData()
}
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
......@@ -103,7 +104,7 @@ class FeedViewController: UIViewController {
/// Prepares the titleLabel.
private func prepareTitleLabel() {
titleLabel = UILabel()
titleLabel.text = "Inbox"
titleLabel.text = "Recipes"
titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white
}
......@@ -141,6 +142,7 @@ class FeedViewController: UIViewController {
collectionView.dataSource = self
collectionView.delegate = self
collectionView.spacingPreset = .Spacing1
collectionView.contentInsetPreset = .Square1
collectionView.registerClass(MaterialCollectionViewCell.self, forCellWithReuseIdentifier: "MaterialCollectionViewCell")
// Layout the collectionView.
......@@ -158,49 +160,55 @@ extension FeedViewController: MaterialCollectionViewDataSource {
data: [
"title": "Summer BBQ",
"detail": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"date": "February 26, 2016"
"date": "February 26, 2016",
"image": "AssortmentOfDessert"
],
height: 158
height: thumbnailHieght
),
MaterialDataSourceItem(
data: [
"title": "Birthday gift",
"detail": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"date": "February 26, 2016"
"date": "February 26, 2016",
"image": "AssortmentOfFood"
],
height: 158
height: thumbnailHieght
),
MaterialDataSourceItem(
data: [
"title": "Brunch this weekend?",
"detail": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"date": "February 26, 2016"
"date": "February 26, 2016",
"image": "AvocadoIceCream"
],
height: 158
height: thumbnailHieght
),
MaterialDataSourceItem(
data: [
"title": "Giants game",
"detail": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"date": "February 26, 2016"
"date": "February 26, 2016",
"image": "HeartCookies"
],
height: 158
height: thumbnailHieght
),
MaterialDataSourceItem(
data: [
"title": "Recipe to try",
"detail": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"date": "February 26, 2016"
"date": "February 26, 2016",
"image": "VeganHempBalls"
],
height: 158
height: thumbnailHieght
),
MaterialDataSourceItem(
data: [
"title": "Interview",
"detail": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"date": "February 26, 2016"
"date": "February 26, 2016",
"image": "VeganPieAbove"
],
height: 158
height: thumbnailHieght
)
]
}
......@@ -217,42 +225,42 @@ extension FeedViewController: MaterialCollectionViewDataSource {
/// Retrieves a UICollectionViewCell.
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let c: MaterialCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("MaterialCollectionViewCell", forIndexPath: indexPath) as! MaterialCollectionViewCell
let cell: MaterialCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("MaterialCollectionViewCell", forIndexPath: indexPath) as! MaterialCollectionViewCell
let item: MaterialDataSourceItem = items()[indexPath.item]
if let data: Dictionary<String, AnyObject> = item.data as? Dictionary<String, AnyObject> {
var cardView: ImageCardView? = c.contentView.subviews.first as? ImageCardView
var cardView: CardView? = cell.contentView.subviews.first as? CardView
// Only build the template if the CardView doesn't exist.
if nil == cardView {
cardView = ImageCardView()
cardView = CardView()
c.backgroundColor = nil
c.pulseColor = nil
c.contentView.addSubview(cardView!)
cell.backgroundColor = nil
cell.pulseColor = nil
cell.contentView.addSubview(cardView!)
cardView!.pulseScale = false
cardView!.divider = false
cardView!.depth = .None
cardView!.contentsGravityPreset = .Left
cardView!.contentInsetPreset = .Square3
cardView!.contentInset.bottom /= 2
cardView!.cornerRadiusPreset = .None
cardView!.cornerRadiusPreset = .Radius1
cardView!.rightButtonsInset.right = -8
let titleLabel: UILabel = UILabel()
titleLabel.textColor = MaterialColor.grey.darken4
titleLabel.font = RobotoFont.regularWithSize(18)
titleLabel.text = data["title"] as? String
cardView!.titleLabel = titleLabel
cardView!.titleLabelInset.left = 120
let detailLabel: UILabel = UILabel()
detailLabel.numberOfLines = 2
detailLabel.textColor = MaterialColor.grey.darken2
detailLabel.font = RobotoFont.regular
detailLabel.text = data["detail"] as? String
cardView!.detailView = detailLabel
cardView!.detailViewInset.left = 120
let image: UIImage? = UIImage(named: "ic_share_white_18pt")?.imageWithRenderingMode(.AlwaysTemplate)
......@@ -264,16 +272,27 @@ extension FeedViewController: MaterialCollectionViewDataSource {
shareButton.setImage(image, forState: .Highlighted)
cardView!.rightButtons = [shareButton]
c.contentView.addSubview(cardView!)
} else {
cardView?.titleLabel?.text = data["title"] as? String
(cardView?.detailView as? UILabel)?.text = data["detail"] as? String
cell.contentView.addSubview(cardView!)
}
// Add the data to the cardView.
cardView?.titleLabel?.text = data["title"] as? String
(cardView?.detailView as? UILabel)?.text = data["detail"] as? String
// Asynchronously the load image.
let height: CGFloat = thumbnailHieght
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)) {
let image: UIImage? = UIImage(named: data["image"] as! String)?.resize(toHeight: height)?.crop(toWidth: height, toHeight: height)
dispatch_sync(dispatch_get_main_queue()) {
cardView?.image = image
}
}
cardView!.frame = c.bounds
// Adjust the cardView size.
cardView?.frame = cell.bounds
}
return c
return cell
}
}
......@@ -281,6 +300,6 @@ extension FeedViewController: MaterialCollectionViewDataSource {
extension FeedViewController: MaterialCollectionViewDelegate {
/// Executed when an item is selected.
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
navigationController?.pushViewController(InboxViewController(), animated: true)
navigationController?.pushViewController(RecipesViewController(), animated: true)
}
}
\ No newline at end of file
......@@ -37,7 +37,7 @@ private struct Item {
var image: UIImage?
}
class InboxViewController: UIViewController {
class RecipesViewController: UIViewController {
/// NavigationBar title label.
private var titleLabel: UILabel!
......@@ -145,7 +145,7 @@ class InboxViewController: UIViewController {
}
/// TableViewDataSource methods.
extension InboxViewController: UITableViewDataSource {
extension RecipesViewController: UITableViewDataSource {
/// Determines the number of rows in the tableView.
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count;
......@@ -192,7 +192,7 @@ extension InboxViewController: UITableViewDataSource {
}
/// UITableViewDelegate methods.
extension InboxViewController: UITableViewDelegate {
extension RecipesViewController: UITableViewDelegate {
/// Sets the tableView cell height.
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 80
......
......@@ -70,7 +70,7 @@ class ViewController: UIViewController {
/// Prepares the titleLabel.
private func prepareTitleLabel() {
titleLabel = UILabel()
titleLabel.text = "Inbox"
titleLabel.text = "Recipes"
titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white
}
......
......@@ -110,15 +110,17 @@ public class ImageCardView : MaterialPulseView {
*/
public var maxImageHeight: CGFloat = 0 {
didSet {
if 0 < maxImageHeight {
prepareImageLayer()
let h: CGFloat = image!.size.height / contentsScale
imageLayer?.frame.size.height = maxImageHeight < h ? maxImageHeight : h
} else {
maxImageHeight = 0
imageLayer?.frame.size.height = nil == image ? 0 : image!.size.height / contentsScale
if let v: UIImage = image {
if 0 < maxImageHeight {
prepareImageLayer()
let h: CGFloat = v.size.height / contentsScale
imageLayer?.frame.size.height = maxImageHeight < h ? maxImageHeight : h
} else {
maxImageHeight = 0
imageLayer?.frame.size.height = nil == image ? 0 : v.size.height / contentsScale
}
reloadView()
}
reloadView()
}
}
......
......@@ -530,7 +530,7 @@ public class MaterialButton : UIButton {
}
pulseLayer.addAnimation(MaterialAnimation.scale(3 * d, duration: t), forKey: nil)
MaterialAnimation.delay(t) { [weak self] in
if nil != self && nil != self!.pulseColor && 0 < self!.pulseColorOpacity {
if nil != self?.pulseColor && 0 < self?.pulseColorOpacity {
MaterialAnimation.animateWithDuration(t, animations: {
pulseLayer.hidden = true
}) {
......
......@@ -636,7 +636,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
}
pulseLayer.addAnimation(MaterialAnimation.scale(3 * d, duration: t), forKey: nil)
MaterialAnimation.delay(t) { [weak self] in
if nil != self && nil != self!.pulseColor && 0 < self!.pulseColorOpacity {
if nil != self?.pulseColor && 0 < self?.pulseColorOpacity {
MaterialAnimation.animateWithDuration(t, animations: {
pulseLayer.hidden = true
}) {
......
......@@ -138,7 +138,7 @@ public class MaterialPulseView : MaterialView {
}
pulseLayer.addAnimation(MaterialAnimation.scale(3 * d, duration: t), forKey: nil)
MaterialAnimation.delay(t) { [weak self] in
if nil != self && nil != self!.pulseColor && 0 < self!.pulseColorOpacity {
if nil != self?.pulseColor && 0 < self?.pulseColorOpacity {
MaterialAnimation.animateWithDuration(t, animations: {
pulseLayer.hidden = true
}) {
......
......@@ -480,7 +480,7 @@ public class MaterialTableViewCell: UITableViewCell {
}
pulseLayer.addAnimation(MaterialAnimation.scale(3 * d, duration: t), forKey: nil)
MaterialAnimation.delay(t) { [weak self] in
if nil != self && nil != self!.pulseColor && 0 < self!.pulseColorOpacity {
if nil != self?.pulseColor && 0 < self?.pulseColorOpacity {
MaterialAnimation.animateWithDuration(t, animations: {
pulseLayer.hidden = true
}) {
......
......@@ -30,7 +30,7 @@
import UIKit
public class NavigationController : UINavigationController {
public class NavigationController : UINavigationController, UIGestureRecognizerDelegate {
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
......@@ -61,7 +61,32 @@ public class NavigationController : UINavigationController {
super.viewDidLoad()
// This ensures the panning gesture is available when going back between views.
interactivePopGestureRecognizer?.delegate = nil
if let v: UIGestureRecognizer = interactivePopGestureRecognizer {
v.enabled = true
v.delegate = self
}
}
public override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
if let v: UIGestureRecognizer = interactivePopGestureRecognizer {
if let x: SideNavigationViewController = sideNavigationViewController {
if let p: UIPanGestureRecognizer = x.panGesture {
p.requireGestureRecognizerToFail(v)
}
}
}
}
/**
Detects the gesture recognizer being used. This is necessary when using
SideNavigationViewController. It eliminates the conflict in panning.
- Parameter gestureRecognizer: A UIGestureRecognizer to detect.
- Parameter touch: The UITouch event.
- Returns: A Boolean of whether to continue the gesture or not, true yes, false no.
*/
public func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
return interactivePopGestureRecognizer == gestureRecognizer && nil != navigationBar.backItem
}
/**
......@@ -88,6 +113,10 @@ public class NavigationController : UINavigationController {
return true
}
public func sideNavigationStatusBarHiddenState(sideNavigationViewController: SideNavigationViewController, hidden: Bool) {
print(hidden)
}
/// Handler for the back button.
internal func handleBackButton() {
popViewControllerAnimated(true)
......
......@@ -103,6 +103,12 @@ public protocol SideNavigationViewControllerDelegate {
SideNavigationViewController tap gesture executes.
*/
optional func sideNavigationViewDidTap(sideNavigationViewController: SideNavigationViewController, point: CGPoint, position: SideNavigationPosition)
/**
An optional delegation method that is fired when the
status bar is about to change display, hidden or not.
*/
optional func sideNavigationStatusBarHiddenState(sideNavigationViewController: SideNavigationViewController, hidden: Bool)
}
@objc(SideNavigationViewController)
......@@ -117,13 +123,13 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
A UIPanGestureRecognizer property internally used for the
pan gesture.
*/
private var panGesture: UIPanGestureRecognizer?
internal var panGesture: UIPanGestureRecognizer?
/**
A UITapGestureRecognizer property internally used for the
tap gesture.
*/
private var tapGesture: UITapGestureRecognizer?
internal var tapGesture: UITapGestureRecognizer?
/**
A CGFloat property that accesses the leftView threshold of
......@@ -192,29 +198,13 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
A Boolean property that enables and disables the leftView from
opening and closing. Defaults to true.
*/
public var enabledLeftView: Bool = false {
didSet {
if enabledLeftView {
prepareGestures(panSelector: "handlePanGesture:", tapSelector: "handleTapGesture:")
} else if !enabledRightView {
removeGestures()
}
}
}
public var enabledLeftView: Bool = false
/**
A Boolean property that enables and disables the rightView from
opening and closing. Defaults to true.
*/
public var enabledRightView: Bool = false {
didSet {
if enabledRightView {
prepareGestures(panSelector: "handlePanGesture:", tapSelector: "handleTapGesture:")
} else if !enabledLeftView {
removeGestures()
}
}
}
public var enabledRightView: Bool = false
/**
A Boolean property that triggers the status bar to be hidden
......@@ -597,6 +587,12 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
}
/**
Detects the gesture recognizer being used.
- Parameter gestureRecognizer: A UIGestureRecognizer to detect.
- Parameter touch: The UITouch event.
- Returns: A Boolean of whether to continue the gesture or not.
*/
public func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
if gestureRecognizer == panGesture {
return opened || isPointContainedWithinLeftViewThreshold(touch.locationInView(view)) || isPointContainedWithinRightViewThreshold(touch.locationInView(view))
......@@ -721,7 +717,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
prepareRightView()
prepareLeftViewController()
prepareRightViewController()
enabled = true
prepareGestures()
}
/// A method that prepares the mainViewController.
......@@ -799,20 +795,16 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
/**
A method that prepares the gestures used within the
SideNavigationViewController.
- Parameter panSelector: A Selector that is fired when the
pan gesture is recognized.
- Parameter tapSelector: A Selector that is fired when the
tap gesture is recognized.
*/
private func prepareGestures(panSelector panSelector: Selector, tapSelector: Selector) {
private func prepareGestures() {
if nil == panGesture {
panGesture = UIPanGestureRecognizer(target: self, action: panSelector)
panGesture = UIPanGestureRecognizer(target: self, action: "handlePanGesture:")
panGesture!.delegate = self
view.addGestureRecognizer(panGesture!)
}
if nil == tapGesture {
tapGesture = UITapGestureRecognizer(target: self, action: tapSelector)
tapGesture = UITapGestureRecognizer(target: self, action: "handleTapGesture:")
tapGesture!.cancelsTouchesInView = false
tapGesture!.delegate = self
view.addGestureRecognizer(tapGesture!)
......@@ -843,17 +835,25 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
*/
private func toggleStatusBar(hide: Bool = false) {
if hideStatusBar {
UIView.animateWithDuration(0.25, animations: { [weak self] in
// General alignment.
if .iPhone == MaterialDevice.type && MaterialDevice.landscape {
UIApplication.sharedApplication().statusBarHidden = true
} else {
UIApplication.sharedApplication().statusBarHidden = true == self?.opened ? true : hide
userInteractionEnabled = false
let hidden: Bool = .iPhone == MaterialDevice.type && MaterialDevice.landscape || opened ? true : hide
UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration),
animations: { [weak self] in
self?.setNeedsStatusBarAppearanceUpdate()
UIApplication.sharedApplication().statusBarHidden = hidden
}) { [weak self] _ in
if false == self?.opened {
self?.userInteractionEnabled = true
}
}
})
delegate?.sideNavigationStatusBarHiddenState?(self, hidden: hidden)
}
}
public override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation {
return .Fade
}
/**
A method that determines whether the passed point is
contained within the bounds of the leftViewThreshold
......
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