Commit dd913a42 by Daniel Dahan

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

parent 8152043b
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
9663F94E1C7A74EA00AF0965 /* AppLeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */; }; 9663F94E1C7A74EA00AF0965 /* AppLeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */; };
9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */; }; 9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */; };
9663F9521C7A751D00AF0965 /* FeedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9511C7A751D00AF0965 /* FeedViewController.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 */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppLeftViewController.swift; sourceTree = "<group>"; }; 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>"; }; 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>"; }; 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 */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */, 9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */,
9663F9331C7A744600AF0965 /* SearchListViewController.swift */, 9663F9331C7A744600AF0965 /* SearchListViewController.swift */,
9663F9511C7A751D00AF0965 /* FeedViewController.swift */, 9663F9511C7A751D00AF0965 /* FeedViewController.swift */,
96CC08871C7FEBD60034FF84 /* InboxViewController.swift */, 96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */,
9663F9381C7A744600AF0965 /* Assets.xcassets */, 9663F9381C7A744600AF0965 /* Assets.xcassets */,
9663F93A1C7A744600AF0965 /* LaunchScreen.storyboard */, 9663F93A1C7A744600AF0965 /* LaunchScreen.storyboard */,
9663F93D1C7A744600AF0965 /* Info.plist */, 9663F93D1C7A744600AF0965 /* Info.plist */,
...@@ -173,7 +173,7 @@ ...@@ -173,7 +173,7 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
9663F94A1C7A74B500AF0965 /* AppSearchBarViewController.swift in Sources */, 9663F94A1C7A74B500AF0965 /* AppSearchBarViewController.swift in Sources */,
96CC08881C7FEBD60034FF84 /* InboxViewController.swift in Sources */, 96CC08881C7FEBD60034FF84 /* RecipesViewController.swift in Sources */,
9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */, 9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */,
9663F9481C7A749400AF0965 /* AppNavigationController.swift in Sources */, 9663F9481C7A749400AF0965 /* AppNavigationController.swift in Sources */,
9663F9341C7A744600AF0965 /* SearchListViewController.swift in Sources */, 9663F9341C7A744600AF0965 /* SearchListViewController.swift in Sources */,
......
...@@ -76,7 +76,7 @@ class AppLeftViewController: UIViewController { ...@@ -76,7 +76,7 @@ class AppLeftViewController: UIViewController {
/// Prepares the items that are displayed within the tableView. /// Prepares the items that are displayed within the tableView.
private func prepareCells() { private func prepareCells() {
items.append(Item(text: "Feed", imageName: "ic_today")) 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. /// Prepares profile view.
......
...@@ -67,7 +67,7 @@ class AppRightViewController: UIViewController { ...@@ -67,7 +67,7 @@ class AppRightViewController: UIViewController {
/// Prepares the items that are displayed within the tableView. /// Prepares the items that are displayed within the tableView.
private func prepareCells() { 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: "Feed", imageName: "ic_today"))
items.append(Item(text: "Bookmarks", imageName: "ic_book")) items.append(Item(text: "Bookmarks", imageName: "ic_book"))
items.append(Item(text: "Work", imageName: "ic_work")) 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 { ...@@ -47,6 +47,9 @@ class FeedViewController: UIViewController {
/// MaterialCollectionView. /// MaterialCollectionView.
private var collectionView: MaterialCollectionView! private var collectionView: MaterialCollectionView!
/// Image thumbnail height.
private var thumbnailHieght: CGFloat = 112
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
prepareView() prepareView()
...@@ -70,8 +73,6 @@ class FeedViewController: UIViewController { ...@@ -70,8 +73,6 @@ class FeedViewController: UIViewController {
navigationbar.backgroundColor = MaterialColor.blue.base navigationbar.backgroundColor = MaterialColor.blue.base
navigationbar.backButton.tintColor = MaterialColor.white navigationbar.backButton.tintColor = MaterialColor.white
} }
collectionView.reloadData()
} }
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) { override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
...@@ -103,7 +104,7 @@ class FeedViewController: UIViewController { ...@@ -103,7 +104,7 @@ class FeedViewController: UIViewController {
/// Prepares the titleLabel. /// Prepares the titleLabel.
private func prepareTitleLabel() { private func prepareTitleLabel() {
titleLabel = UILabel() titleLabel = UILabel()
titleLabel.text = "Inbox" titleLabel.text = "Recipes"
titleLabel.textAlignment = .Left titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white titleLabel.textColor = MaterialColor.white
} }
...@@ -141,6 +142,7 @@ class FeedViewController: UIViewController { ...@@ -141,6 +142,7 @@ class FeedViewController: UIViewController {
collectionView.dataSource = self collectionView.dataSource = self
collectionView.delegate = self collectionView.delegate = self
collectionView.spacingPreset = .Spacing1 collectionView.spacingPreset = .Spacing1
collectionView.contentInsetPreset = .Square1
collectionView.registerClass(MaterialCollectionViewCell.self, forCellWithReuseIdentifier: "MaterialCollectionViewCell") collectionView.registerClass(MaterialCollectionViewCell.self, forCellWithReuseIdentifier: "MaterialCollectionViewCell")
// Layout the collectionView. // Layout the collectionView.
...@@ -158,49 +160,55 @@ extension FeedViewController: MaterialCollectionViewDataSource { ...@@ -158,49 +160,55 @@ extension FeedViewController: MaterialCollectionViewDataSource {
data: [ data: [
"title": "Summer BBQ", "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.", "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( MaterialDataSourceItem(
data: [ data: [
"title": "Birthday gift", "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.", "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( MaterialDataSourceItem(
data: [ data: [
"title": "Brunch this weekend?", "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.", "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( MaterialDataSourceItem(
data: [ data: [
"title": "Giants game", "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.", "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( MaterialDataSourceItem(
data: [ data: [
"title": "Recipe to try", "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.", "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( MaterialDataSourceItem(
data: [ data: [
"title": "Interview", "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.", "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 { ...@@ -217,42 +225,42 @@ extension FeedViewController: MaterialCollectionViewDataSource {
/// Retrieves a UICollectionViewCell. /// Retrieves a UICollectionViewCell.
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> 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] let item: MaterialDataSourceItem = items()[indexPath.item]
if let data: Dictionary<String, AnyObject> = item.data as? Dictionary<String, AnyObject> { 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. // Only build the template if the CardView doesn't exist.
if nil == cardView { if nil == cardView {
cardView = ImageCardView() cardView = CardView()
c.backgroundColor = nil cell.backgroundColor = nil
c.pulseColor = nil cell.pulseColor = nil
c.contentView.addSubview(cardView!) cell.contentView.addSubview(cardView!)
cardView!.pulseScale = false cardView!.pulseScale = false
cardView!.divider = false cardView!.divider = false
cardView!.depth = .None cardView!.depth = .None
cardView!.contentsGravityPreset = .Left
cardView!.contentInsetPreset = .Square3 cardView!.contentInsetPreset = .Square3
cardView!.contentInset.bottom /= 2 cardView!.contentInset.bottom /= 2
cardView!.cornerRadiusPreset = .None cardView!.cornerRadiusPreset = .Radius1
cardView!.rightButtonsInset.right = -8 cardView!.rightButtonsInset.right = -8
let titleLabel: UILabel = UILabel() let titleLabel: UILabel = UILabel()
titleLabel.textColor = MaterialColor.grey.darken4 titleLabel.textColor = MaterialColor.grey.darken4
titleLabel.font = RobotoFont.regularWithSize(18) titleLabel.font = RobotoFont.regularWithSize(18)
titleLabel.text = data["title"] as? String
cardView!.titleLabel = titleLabel cardView!.titleLabel = titleLabel
cardView!.titleLabelInset.left = 120
let detailLabel: UILabel = UILabel() let detailLabel: UILabel = UILabel()
detailLabel.numberOfLines = 2
detailLabel.textColor = MaterialColor.grey.darken2 detailLabel.textColor = MaterialColor.grey.darken2
detailLabel.font = RobotoFont.regular detailLabel.font = RobotoFont.regular
detailLabel.text = data["detail"] as? String
cardView!.detailView = detailLabel cardView!.detailView = detailLabel
cardView!.detailViewInset.left = 120
let image: UIImage? = UIImage(named: "ic_share_white_18pt")?.imageWithRenderingMode(.AlwaysTemplate) let image: UIImage? = UIImage(named: "ic_share_white_18pt")?.imageWithRenderingMode(.AlwaysTemplate)
...@@ -264,16 +272,27 @@ extension FeedViewController: MaterialCollectionViewDataSource { ...@@ -264,16 +272,27 @@ extension FeedViewController: MaterialCollectionViewDataSource {
shareButton.setImage(image, forState: .Highlighted) shareButton.setImage(image, forState: .Highlighted)
cardView!.rightButtons = [shareButton] cardView!.rightButtons = [shareButton]
c.contentView.addSubview(cardView!) cell.contentView.addSubview(cardView!)
} else { }
cardView?.titleLabel?.text = data["title"] as? String
(cardView?.detailView as? UILabel)?.text = data["detail"] as? String // 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 { ...@@ -281,6 +300,6 @@ extension FeedViewController: MaterialCollectionViewDataSource {
extension FeedViewController: MaterialCollectionViewDelegate { extension FeedViewController: MaterialCollectionViewDelegate {
/// Executed when an item is selected. /// Executed when an item is selected.
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { 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 { ...@@ -37,7 +37,7 @@ private struct Item {
var image: UIImage? var image: UIImage?
} }
class InboxViewController: UIViewController { class RecipesViewController: UIViewController {
/// NavigationBar title label. /// NavigationBar title label.
private var titleLabel: UILabel! private var titleLabel: UILabel!
...@@ -145,7 +145,7 @@ class InboxViewController: UIViewController { ...@@ -145,7 +145,7 @@ class InboxViewController: UIViewController {
} }
/// TableViewDataSource methods. /// TableViewDataSource methods.
extension InboxViewController: UITableViewDataSource { extension RecipesViewController: UITableViewDataSource {
/// Determines the number of rows in the tableView. /// Determines the number of rows in the tableView.
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count; return items.count;
...@@ -192,7 +192,7 @@ extension InboxViewController: UITableViewDataSource { ...@@ -192,7 +192,7 @@ extension InboxViewController: UITableViewDataSource {
} }
/// UITableViewDelegate methods. /// UITableViewDelegate methods.
extension InboxViewController: UITableViewDelegate { extension RecipesViewController: UITableViewDelegate {
/// Sets the tableView cell height. /// Sets the tableView cell height.
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 80 return 80
......
...@@ -70,7 +70,7 @@ class ViewController: UIViewController { ...@@ -70,7 +70,7 @@ class ViewController: UIViewController {
/// Prepares the titleLabel. /// Prepares the titleLabel.
private func prepareTitleLabel() { private func prepareTitleLabel() {
titleLabel = UILabel() titleLabel = UILabel()
titleLabel.text = "Inbox" titleLabel.text = "Recipes"
titleLabel.textAlignment = .Left titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white titleLabel.textColor = MaterialColor.white
} }
......
...@@ -110,15 +110,17 @@ public class ImageCardView : MaterialPulseView { ...@@ -110,15 +110,17 @@ public class ImageCardView : MaterialPulseView {
*/ */
public var maxImageHeight: CGFloat = 0 { public var maxImageHeight: CGFloat = 0 {
didSet { didSet {
if 0 < maxImageHeight { if let v: UIImage = image {
prepareImageLayer() if 0 < maxImageHeight {
let h: CGFloat = image!.size.height / contentsScale prepareImageLayer()
imageLayer?.frame.size.height = maxImageHeight < h ? maxImageHeight : h let h: CGFloat = v.size.height / contentsScale
} else { imageLayer?.frame.size.height = maxImageHeight < h ? maxImageHeight : h
maxImageHeight = 0 } else {
imageLayer?.frame.size.height = nil == image ? 0 : image!.size.height / contentsScale maxImageHeight = 0
imageLayer?.frame.size.height = nil == image ? 0 : v.size.height / contentsScale
}
reloadView()
} }
reloadView()
} }
} }
......
...@@ -530,7 +530,7 @@ public class MaterialButton : UIButton { ...@@ -530,7 +530,7 @@ public class MaterialButton : UIButton {
} }
pulseLayer.addAnimation(MaterialAnimation.scale(3 * d, duration: t), forKey: nil) pulseLayer.addAnimation(MaterialAnimation.scale(3 * d, duration: t), forKey: nil)
MaterialAnimation.delay(t) { [weak self] in 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: { MaterialAnimation.animateWithDuration(t, animations: {
pulseLayer.hidden = true pulseLayer.hidden = true
}) { }) {
......
...@@ -636,7 +636,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -636,7 +636,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
} }
pulseLayer.addAnimation(MaterialAnimation.scale(3 * d, duration: t), forKey: nil) pulseLayer.addAnimation(MaterialAnimation.scale(3 * d, duration: t), forKey: nil)
MaterialAnimation.delay(t) { [weak self] in 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: { MaterialAnimation.animateWithDuration(t, animations: {
pulseLayer.hidden = true pulseLayer.hidden = true
}) { }) {
......
...@@ -138,7 +138,7 @@ public class MaterialPulseView : MaterialView { ...@@ -138,7 +138,7 @@ public class MaterialPulseView : MaterialView {
} }
pulseLayer.addAnimation(MaterialAnimation.scale(3 * d, duration: t), forKey: nil) pulseLayer.addAnimation(MaterialAnimation.scale(3 * d, duration: t), forKey: nil)
MaterialAnimation.delay(t) { [weak self] in 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: { MaterialAnimation.animateWithDuration(t, animations: {
pulseLayer.hidden = true pulseLayer.hidden = true
}) { }) {
......
...@@ -480,7 +480,7 @@ public class MaterialTableViewCell: UITableViewCell { ...@@ -480,7 +480,7 @@ public class MaterialTableViewCell: UITableViewCell {
} }
pulseLayer.addAnimation(MaterialAnimation.scale(3 * d, duration: t), forKey: nil) pulseLayer.addAnimation(MaterialAnimation.scale(3 * d, duration: t), forKey: nil)
MaterialAnimation.delay(t) { [weak self] in 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: { MaterialAnimation.animateWithDuration(t, animations: {
pulseLayer.hidden = true pulseLayer.hidden = true
}) { }) {
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
import UIKit import UIKit
public class NavigationController : UINavigationController { public class NavigationController : UINavigationController, UIGestureRecognizerDelegate {
/** /**
An initializer that initializes the object with a NSCoder object. An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance. - Parameter aDecoder: A NSCoder instance.
...@@ -61,7 +61,32 @@ public class NavigationController : UINavigationController { ...@@ -61,7 +61,32 @@ public class NavigationController : UINavigationController {
super.viewDidLoad() super.viewDidLoad()
// This ensures the panning gesture is available when going back between views. // 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 { ...@@ -88,6 +113,10 @@ public class NavigationController : UINavigationController {
return true return true
} }
public func sideNavigationStatusBarHiddenState(sideNavigationViewController: SideNavigationViewController, hidden: Bool) {
print(hidden)
}
/// Handler for the back button. /// Handler for the back button.
internal func handleBackButton() { internal func handleBackButton() {
popViewControllerAnimated(true) popViewControllerAnimated(true)
......
...@@ -103,6 +103,12 @@ public protocol SideNavigationViewControllerDelegate { ...@@ -103,6 +103,12 @@ public protocol SideNavigationViewControllerDelegate {
SideNavigationViewController tap gesture executes. SideNavigationViewController tap gesture executes.
*/ */
optional func sideNavigationViewDidTap(sideNavigationViewController: SideNavigationViewController, point: CGPoint, position: SideNavigationPosition) 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) @objc(SideNavigationViewController)
...@@ -117,13 +123,13 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -117,13 +123,13 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
A UIPanGestureRecognizer property internally used for the A UIPanGestureRecognizer property internally used for the
pan gesture. pan gesture.
*/ */
private var panGesture: UIPanGestureRecognizer? internal var panGesture: UIPanGestureRecognizer?
/** /**
A UITapGestureRecognizer property internally used for the A UITapGestureRecognizer property internally used for the
tap gesture. tap gesture.
*/ */
private var tapGesture: UITapGestureRecognizer? internal var tapGesture: UITapGestureRecognizer?
/** /**
A CGFloat property that accesses the leftView threshold of A CGFloat property that accesses the leftView threshold of
...@@ -192,29 +198,13 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -192,29 +198,13 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
A Boolean property that enables and disables the leftView from A Boolean property that enables and disables the leftView from
opening and closing. Defaults to true. opening and closing. Defaults to true.
*/ */
public var enabledLeftView: Bool = false { public var enabledLeftView: Bool = false
didSet {
if enabledLeftView {
prepareGestures(panSelector: "handlePanGesture:", tapSelector: "handleTapGesture:")
} else if !enabledRightView {
removeGestures()
}
}
}
/** /**
A Boolean property that enables and disables the rightView from A Boolean property that enables and disables the rightView from
opening and closing. Defaults to true. opening and closing. Defaults to true.
*/ */
public var enabledRightView: Bool = false { public var enabledRightView: Bool = false
didSet {
if enabledRightView {
prepareGestures(panSelector: "handlePanGesture:", tapSelector: "handleTapGesture:")
} else if !enabledLeftView {
removeGestures()
}
}
}
/** /**
A Boolean property that triggers the status bar to be hidden A Boolean property that triggers the status bar to be hidden
...@@ -597,6 +587,12 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -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 { public func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
if gestureRecognizer == panGesture { if gestureRecognizer == panGesture {
return opened || isPointContainedWithinLeftViewThreshold(touch.locationInView(view)) || isPointContainedWithinRightViewThreshold(touch.locationInView(view)) return opened || isPointContainedWithinLeftViewThreshold(touch.locationInView(view)) || isPointContainedWithinRightViewThreshold(touch.locationInView(view))
...@@ -721,7 +717,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -721,7 +717,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
prepareRightView() prepareRightView()
prepareLeftViewController() prepareLeftViewController()
prepareRightViewController() prepareRightViewController()
enabled = true prepareGestures()
} }
/// A method that prepares the mainViewController. /// A method that prepares the mainViewController.
...@@ -799,20 +795,16 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -799,20 +795,16 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
/** /**
A method that prepares the gestures used within the A method that prepares the gestures used within the
SideNavigationViewController. 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 { if nil == panGesture {
panGesture = UIPanGestureRecognizer(target: self, action: panSelector) panGesture = UIPanGestureRecognizer(target: self, action: "handlePanGesture:")
panGesture!.delegate = self panGesture!.delegate = self
view.addGestureRecognizer(panGesture!) view.addGestureRecognizer(panGesture!)
} }
if nil == tapGesture { if nil == tapGesture {
tapGesture = UITapGestureRecognizer(target: self, action: tapSelector) tapGesture = UITapGestureRecognizer(target: self, action: "handleTapGesture:")
tapGesture!.cancelsTouchesInView = false tapGesture!.cancelsTouchesInView = false
tapGesture!.delegate = self tapGesture!.delegate = self
view.addGestureRecognizer(tapGesture!) view.addGestureRecognizer(tapGesture!)
...@@ -843,17 +835,25 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -843,17 +835,25 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
*/ */
private func toggleStatusBar(hide: Bool = false) { private func toggleStatusBar(hide: Bool = false) {
if hideStatusBar { if hideStatusBar {
UIView.animateWithDuration(0.25, animations: { [weak self] in userInteractionEnabled = false
// General alignment. let hidden: Bool = .iPhone == MaterialDevice.type && MaterialDevice.landscape || opened ? true : hide
if .iPhone == MaterialDevice.type && MaterialDevice.landscape { UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration),
UIApplication.sharedApplication().statusBarHidden = true animations: { [weak self] in
} else { self?.setNeedsStatusBarAppearanceUpdate()
UIApplication.sharedApplication().statusBarHidden = true == self?.opened ? true : hide 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 A method that determines whether the passed point is
contained within the bounds of the leftViewThreshold 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