Commit 75665e13 by Daniel Dahan

updated NavigationBar

parent febee7ec
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
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 /* ItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9511C7A751D00AF0965 /* ItemViewController.swift */; }; 9663F9521C7A751D00AF0965 /* ItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9511C7A751D00AF0965 /* ItemViewController.swift */; };
96AC822A1C97DE25007654F0 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AC82291C97DE25007654F0 /* Material.framework */; };
96AC822B1C97DE25007654F0 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96AC82291C97DE25007654F0 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96CC08881C7FEBD60034FF84 /* RecipesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */; }; 96CC08881C7FEBD60034FF84 /* RecipesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */; };
96F2F1B11C979D3B00A5FE27 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96F2F1B01C979D3B00A5FE27 /* Material.framework */; };
96F2F1B21C979D3B00A5FE27 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96F2F1B01C979D3B00A5FE27 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96F2F1B21C979D3B00A5FE27 /* Material.framework in Embed Frameworks */, 96AC822B1C97DE25007654F0 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -49,8 +49,8 @@ ...@@ -49,8 +49,8 @@
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 /* ItemViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemViewController.swift; sourceTree = "<group>"; }; 9663F9511C7A751D00AF0965 /* ItemViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemViewController.swift; sourceTree = "<group>"; };
96AC82291C97DE25007654F0 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecipesViewController.swift; sourceTree = "<group>"; }; 96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecipesViewController.swift; sourceTree = "<group>"; };
96F2F1B01C979D3B00A5FE27 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96F2F1B11C979D3B00A5FE27 /* Material.framework in Frameworks */, 96AC822A1C97DE25007654F0 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
9663F9251C7A744500AF0965 = { 9663F9251C7A744500AF0965 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96F2F1B01C979D3B00A5FE27 /* Material.framework */, 96AC82291C97DE25007654F0 /* Material.framework */,
9663F9301C7A744600AF0965 /* App */, 9663F9301C7A744600AF0965 /* App */,
9663F92F1C7A744600AF0965 /* Products */, 9663F92F1C7A744600AF0965 /* Products */,
); );
......
...@@ -92,8 +92,9 @@ class AppMenuViewController: MenuViewController { ...@@ -92,8 +92,9 @@ class AppMenuViewController: MenuViewController {
/// Prepares the add button. /// Prepares the add button.
private func prepareMenuView() { private func prepareMenuView() {
var image: UIImage? = UIImage(named: "ic_add_white") var image: UIImage? = MaterialIcon.add
let menuButton: FabButton = FabButton() let menuButton: FabButton = FabButton()
menuButton.tintColor = MaterialColor.white
menuButton.setImage(image, forState: .Normal) menuButton.setImage(image, forState: .Normal)
menuButton.setImage(image, forState: .Highlighted) menuButton.setImage(image, forState: .Highlighted)
menuButton.addTarget(self, action: "handleMenu", forControlEvents: .TouchUpInside) menuButton.addTarget(self, action: "handleMenu", forControlEvents: .TouchUpInside)
......
...@@ -45,12 +45,14 @@ class AppSearchBarController: SearchBarController { ...@@ -45,12 +45,14 @@ class AppSearchBarController: SearchBarController {
override func viewWillDisappear(animated: Bool) { override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated) super.viewWillDisappear(animated)
searchBar.textField.resignFirstResponder()
sideNavigationController?.enabled = true sideNavigationController?.enabled = true
} }
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?.delegate = self
sideNavigationController?.enabled = false sideNavigationController?.enabled = false
} }
...@@ -87,7 +89,7 @@ class AppSearchBarController: SearchBarController { ...@@ -87,7 +89,7 @@ class AppSearchBarController: SearchBarController {
clearButton.setImage(image, forState: .Highlighted) clearButton.setImage(image, forState: .Highlighted)
// Back button. // Back button.
image = MaterialIcon.arrowDownward image = MaterialIcon.arrowBack
let backButton: FlatButton = FlatButton() let backButton: FlatButton = FlatButton()
backButton.pulseScale = false backButton.pulseScale = false
backButton.pulseColor = MaterialColor.grey.darken4 backButton.pulseColor = MaterialColor.grey.darken4
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile1.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" : "Profile2.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" : "Profile3.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" : "Profile4.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" : "Profile5.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" : "Profile6.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" : "Profile7.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" : "Profile8.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" : "ic_add_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_add_white_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_add_white_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_close_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_close_white_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_close_white_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_menu_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_menu_white_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_menu_white_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_more_horiz_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_more_horiz_white_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_more_horiz_white_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_search_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_search_white_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_search_white_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_share_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_share_white_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_share_white_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
...@@ -147,14 +147,9 @@ class ItemViewController: UIViewController { ...@@ -147,14 +147,9 @@ class ItemViewController: UIViewController {
imageCardView.detailView = detailLabel imageCardView.detailView = detailLabel
imageCardView.detailViewInset.top = 52 imageCardView.detailViewInset.top = 52
// Asynchronously the load image. if let v: CGFloat = view.bounds.width {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)) { [weak self] in let image: UIImage? = UIImage(named: data["image"] as! String)?.resize(toWidth: v)?.crop(toWidth: v, toHeight: height)
if let v: CGFloat = self?.view.bounds.width { imageCardView.image = image
let image: UIImage? = UIImage(named: data["image"] as! String)?.resize(toWidth: v)?.crop(toWidth: v, toHeight: height)
dispatch_sync(dispatch_get_main_queue()) { [weak self] in
self?.imageCardView.image = image
}
}
} }
view.addSubview(imageCardView) view.addSubview(imageCardView)
......
...@@ -84,7 +84,7 @@ class RecipesViewController: UIViewController { ...@@ -84,7 +84,7 @@ class RecipesViewController: UIViewController {
// Hide the menuView. // Hide the menuView.
menuViewController?.menuView.animate(MaterialAnimation.animationGroup([ menuViewController?.menuView.animate(MaterialAnimation.animationGroup([
MaterialAnimation.rotate(rotation: 3), MaterialAnimation.rotate(rotation: 3),
MaterialAnimation.translateY(100) MaterialAnimation.translateY(150)
])) ]))
} }
...@@ -96,10 +96,13 @@ class RecipesViewController: UIViewController { ...@@ -96,10 +96,13 @@ class RecipesViewController: UIViewController {
/// Handles the searchButton. /// Handles the searchButton.
internal func handleSearchButton() { internal func handleSearchButton() {
var recommended: Array<MaterialDataSourceItem> = Array<MaterialDataSourceItem>() var recommended: Array<MaterialDataSourceItem> = Array<MaterialDataSourceItem>()
recommended.append(dataSourceItems[0])
recommended.append(dataSourceItems[1]) recommended.append(dataSourceItems[1])
recommended.append(dataSourceItems[2]) recommended.append(dataSourceItems[3])
navigationController?.presentViewController(AppSearchBarController(mainViewController: RecommendationViewController(dataSourceItems: recommended)), animated: true, completion: nil) recommended.append(dataSourceItems[5])
let vc: AppSearchBarController = AppSearchBarController(mainViewController: RecommendationViewController(dataSourceItems: recommended))
vc.modalTransitionStyle = .CrossDissolve
navigationController?.presentViewController(vc, animated: true, completion: nil)
} }
/// Prepares the items Array. /// Prepares the items Array.
......
...@@ -79,7 +79,7 @@ class AppSearchBarController: SearchBarController { ...@@ -79,7 +79,7 @@ class AppSearchBarController: SearchBarController {
var image: UIImage? = MaterialIcon.close var image: UIImage? = MaterialIcon.close
let clearButton: FlatButton = FlatButton() let clearButton: FlatButton = FlatButton()
// clearButton.pulseColor = nil clearButton.pulseColor = nil
clearButton.pulseScale = false clearButton.pulseScale = false
clearButton.tintColor = MaterialColor.blueGrey.darken4 clearButton.tintColor = MaterialColor.blueGrey.darken4
clearButton.setImage(image, forState: .Normal) clearButton.setImage(image, forState: .Normal)
...@@ -89,7 +89,7 @@ class AppSearchBarController: SearchBarController { ...@@ -89,7 +89,7 @@ class AppSearchBarController: SearchBarController {
// Back button. // Back button.
image = MaterialIcon.arrowBack image = MaterialIcon.arrowBack
let backButton: FlatButton = FlatButton() let backButton: FlatButton = FlatButton()
// backButton.pulseColor = nil backButton.pulseColor = nil
backButton.pulseScale = false backButton.pulseScale = false
backButton.tintColor = MaterialColor.blueGrey.darken4 backButton.tintColor = MaterialColor.blueGrey.darken4
backButton.setImage(image, forState: .Normal) backButton.setImage(image, forState: .Normal)
...@@ -99,7 +99,7 @@ class AppSearchBarController: SearchBarController { ...@@ -99,7 +99,7 @@ class AppSearchBarController: SearchBarController {
// More button. // More button.
image = MaterialIcon.moreHorizontal image = MaterialIcon.moreHorizontal
let moreButton: FlatButton = FlatButton() let moreButton: FlatButton = FlatButton()
// moreButton.pulseColor = nil moreButton.pulseColor = nil
moreButton.pulseScale = false moreButton.pulseScale = false
moreButton.tintColor = MaterialColor.blueGrey.darken4 moreButton.tintColor = MaterialColor.blueGrey.darken4
moreButton.setImage(image, forState: .Normal) moreButton.setImage(image, forState: .Normal)
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_menu_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_menu_white@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_menu_white@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_search_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_search_white@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_search_white@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
...@@ -74,6 +74,7 @@ class ViewController: UIViewController { ...@@ -74,6 +74,7 @@ class ViewController: UIViewController {
let menuButton: FlatButton = FlatButton() let menuButton: FlatButton = FlatButton()
menuButton.pulseScale = false menuButton.pulseScale = false
menuButton.pulseColor = MaterialColor.white menuButton.pulseColor = MaterialColor.white
menuButton.tintColor = MaterialColor.white
menuButton.setImage(image, forState: .Normal) menuButton.setImage(image, forState: .Normal)
menuButton.setImage(image, forState: .Highlighted) menuButton.setImage(image, forState: .Highlighted)
...@@ -81,10 +82,11 @@ class ViewController: UIViewController { ...@@ -81,10 +82,11 @@ class ViewController: UIViewController {
let switchControl: MaterialSwitch = MaterialSwitch(state: .Off, style: .LightContent, size: .Small) let switchControl: MaterialSwitch = MaterialSwitch(state: .Off, style: .LightContent, size: .Small)
// Search button. // Search button.
image = UIImage(named: "ic_search_white") image = MaterialIcon.search
let searchButton: FlatButton = FlatButton() let searchButton: FlatButton = FlatButton()
searchButton.pulseScale = false searchButton.pulseScale = false
searchButton.pulseColor = MaterialColor.white searchButton.pulseColor = MaterialColor.white
searchButton.tintColor = MaterialColor.white
searchButton.setImage(image, forState: .Normal) searchButton.setImage(image, forState: .Normal)
searchButton.setImage(image, forState: .Highlighted) searchButton.setImage(image, forState: .Highlighted)
...@@ -94,7 +96,6 @@ class ViewController: UIViewController { ...@@ -94,7 +96,6 @@ class ViewController: UIViewController {
to your info.plist file and set the following property. to your info.plist file and set the following property.
*/ */
toolbar.statusBarStyle = .LightContent toolbar.statusBarStyle = .LightContent
toolbar.backgroundColor = MaterialColor.blue.base toolbar.backgroundColor = MaterialColor.blue.base
toolbar.titleLabel = titleLabel toolbar.titleLabel = titleLabel
toolbar.detailLabel = detailLabel toolbar.detailLabel = detailLabel
......
...@@ -97,6 +97,7 @@ class AppToolbarController: ToolbarController { ...@@ -97,6 +97,7 @@ class AppToolbarController: ToolbarController {
let menuButton: FlatButton = FlatButton() let menuButton: FlatButton = FlatButton()
menuButton.pulseColor = nil menuButton.pulseColor = nil
menuButton.pulseScale = false menuButton.pulseScale = false
menuButton.tintColor = MaterialColor.white
menuButton.setImage(image, forState: .Normal) menuButton.setImage(image, forState: .Normal)
menuButton.setImage(image, forState: .Highlighted) menuButton.setImage(image, forState: .Highlighted)
menuButton.addTarget(self, action: "handleMenuButton", forControlEvents: .TouchUpInside) menuButton.addTarget(self, action: "handleMenuButton", forControlEvents: .TouchUpInside)
...@@ -106,10 +107,11 @@ class AppToolbarController: ToolbarController { ...@@ -106,10 +107,11 @@ class AppToolbarController: ToolbarController {
switchControl.delegate = self switchControl.delegate = self
// Search button. // Search button.
image = UIImage(named: "ic_search_white") image = MaterialIcon.search
let searchButton: FlatButton = FlatButton() let searchButton: FlatButton = FlatButton()
searchButton.pulseColor = nil searchButton.pulseColor = nil
searchButton.pulseScale = false searchButton.pulseScale = false
searchButton.tintColor = MaterialColor.white
searchButton.setImage(image, forState: .Normal) searchButton.setImage(image, forState: .Normal)
searchButton.setImage(image, forState: .Highlighted) searchButton.setImage(image, forState: .Highlighted)
searchButton.addTarget(self, action: "handleSearchButton", forControlEvents: .TouchUpInside) searchButton.addTarget(self, action: "handleSearchButton", forControlEvents: .TouchUpInside)
......
...@@ -38,6 +38,47 @@ public enum MaterialDeviceType { ...@@ -38,6 +38,47 @@ public enum MaterialDeviceType {
} }
public struct MaterialDevice { public struct MaterialDevice {
/// Gets the model name for the device.
public static var model: String {
var systemInfo: utsname = utsname()
uname(&systemInfo)
let machineMirror: Mirror = Mirror(reflecting: systemInfo.machine)
let identifier: String = machineMirror.children.reduce("") { (identifier, element) in
guard let value = element.value as? Int8 where value != 0 else {
return identifier
}
return identifier + String(UnicodeScalar(UInt8(value)))
}
switch identifier {
case "iPod5,1": return "iPod Touch 5"
case "iPod7,1": return "iPod Touch 6"
case "iPhone3,1", "iPhone3,2", "iPhone3,3": return "iPhone 4"
case "iPhone4,1": return "iPhone 4s"
case "iPhone5,1", "iPhone5,2": return "iPhone 5"
case "iPhone5,3", "iPhone5,4": return "iPhone 5c"
case "iPhone6,1", "iPhone6,2": return "iPhone 5s"
case "iPhone7,2": return "iPhone 6"
case "iPhone7,1": return "iPhone 6 Plus"
case "iPhone8,1": return "iPhone 6s"
case "iPhone8,2": return "iPhone 6s Plus"
case "iPad2,1", "iPad2,2", "iPad2,3", "iPad2,4": return "iPad 2"
case "iPad3,1", "iPad3,2", "iPad3,3": return "iPad 3"
case "iPad3,4", "iPad3,5", "iPad3,6": return "iPad 4"
case "iPad4,1", "iPad4,2", "iPad4,3": return "iPad Air"
case "iPad5,3", "iPad5,4": return "iPad Air 2"
case "iPad2,5", "iPad2,6", "iPad2,7": return "iPad Mini"
case "iPad4,4", "iPad4,5", "iPad4,6": return "iPad Mini 2"
case "iPad4,7", "iPad4,8", "iPad4,9": return "iPad Mini 3"
case "iPad5,1", "iPad5,2": return "iPad Mini 4"
case "iPad6,7", "iPad6,8": return "iPad Pro"
case "AppleTV5,3": return "Apple TV"
case "i386", "x86_64": return "Simulator"
default: return identifier
}
}
/// Retrieves the current device type. /// Retrieves the current device type.
public static var type: MaterialDeviceType { public static var type: MaterialDeviceType {
switch UIDevice.currentDevice().userInterfaceIdiom { switch UIDevice.currentDevice().userInterfaceIdiom {
...@@ -62,6 +103,26 @@ public struct MaterialDevice { ...@@ -62,6 +103,26 @@ public struct MaterialDevice {
return UIApplication.sharedApplication().statusBarOrientation return UIApplication.sharedApplication().statusBarOrientation
} }
/// Retrieves the device status bar style.
public static var statusBarStyle: UIStatusBarStyle {
get {
return UIApplication.sharedApplication().statusBarStyle
}
set(value) {
UIApplication.sharedApplication().statusBarStyle = value
}
}
/// Retrieves the device status bar hidden state.
public static var statusBarHidden: Bool {
get {
return UIApplication.sharedApplication().statusBarHidden
}
set(value) {
UIApplication.sharedApplication().statusBarHidden = value
}
}
/// Retrieves the device bounds. /// Retrieves the device bounds.
public static var bounds: CGRect { public static var bounds: CGRect {
return UIScreen.mainScreen().bounds return UIScreen.mainScreen().bounds
...@@ -81,24 +142,4 @@ public struct MaterialDevice { ...@@ -81,24 +142,4 @@ public struct MaterialDevice {
public static var scale: CGFloat { public static var scale: CGFloat {
return UIScreen.mainScreen().scale return UIScreen.mainScreen().scale
} }
/// Retrieves the device status bar style.
public static var statusBarStyle: UIStatusBarStyle {
get {
return UIApplication.sharedApplication().statusBarStyle
}
set(value) {
UIApplication.sharedApplication().statusBarStyle = value
}
}
/// Retrieves the device status bar hidden state.
public static var statusBarHidden: Bool {
get {
return UIApplication.sharedApplication().statusBarHidden
}
set(value) {
UIApplication.sharedApplication().statusBarHidden = value
}
}
} }
\ No newline at end of file
...@@ -44,6 +44,12 @@ public extension UINavigationBar { ...@@ -44,6 +44,12 @@ public extension UINavigationBar {
@IBDesignable @IBDesignable
public class NavigationBar : UINavigationBar { public class NavigationBar : UINavigationBar {
/// Left spacer moves the items to the left edge of the NavigationBar.
private var leftSpacer: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .FixedSpace, target: nil, action: nil)
/// Right spacer moves the items to the right edge of the NavigationBar.
private var rightSpacer: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .FixedSpace, target: nil, action: nil)
/// Reference to the backButton. /// Reference to the backButton.
public private(set) lazy var backButton: FlatButton = FlatButton() public private(set) lazy var backButton: FlatButton = FlatButton()
...@@ -255,29 +261,13 @@ public class NavigationBar : UINavigationBar { ...@@ -255,29 +261,13 @@ public class NavigationBar : UINavigationBar {
public override func layoutSubviews() { public override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
if let v: UINavigationItem = topItem {
if let t: UILabel = topItem?.titleLabel { sizeNavigationItem(v)
t.grid.rows = 1
topItem?.titleView?.grid.views = [t]
if 32 >= height || nil == topItem?.detailLabel {
t.font = t.font.fontWithSize(20)
topItem?.titleView?.grid.axis.rows = 1
topItem?.detailLabel?.hidden = true
} else if let d: UILabel = topItem?.detailLabel {
d.grid.rows = 1
d.hidden = false
d.font = d.font.fontWithSize(12)
t.font = t.font.fontWithSize(17)
topItem?.titleView?.grid.axis.rows = 2
topItem?.titleView?.grid.views?.append(d)
}
} }
topItem?.titleView?.grid.reloadLayout() if let v: UINavigationItem = backItem {
sizeNavigationItem(v)
}
} }
public override func pushNavigationItem(item: UINavigationItem, animated: Bool) { public override func pushNavigationItem(item: UINavigationItem, animated: Bool) {
...@@ -289,53 +279,42 @@ public class NavigationBar : UINavigationBar { ...@@ -289,53 +279,42 @@ public class NavigationBar : UINavigationBar {
Lays out the UINavigationItem. Lays out the UINavigationItem.
- Parameter item: A UINavigationItem to layout. - Parameter item: A UINavigationItem to layout.
*/ */
public func layoutNavigationItem(item: UINavigationItem) { internal func layoutNavigationItem(item: UINavigationItem) {
prepareItem(item) prepareItem(item)
let h: CGFloat = intrinsicContentSize().height
let w: CGFloat = backButton.intrinsicContentSize().width
let inset: CGFloat = item.inset
// leftControls // leftControls
if let v: Array<UIControl> = item.leftControls { if let v: Array<UIControl> = item.leftControls {
var n: Array<UIBarButtonItem> = Array<UIBarButtonItem>() var n: Array<UIBarButtonItem> = Array<UIBarButtonItem>()
for c in v { for c in v {
if let b: UIButton = c as? UIButton {
b.contentEdgeInsets.top = 0
b.contentEdgeInsets.bottom = 0
}
c.bounds.size = c is MaterialSwitch ? CGSizeMake(w, h - contentInset.top - contentInset.bottom) : CGSizeMake(c.intrinsicContentSize().width, h - contentInset.top - contentInset.bottom)
n.append(UIBarButtonItem(customView: c)) n.append(UIBarButtonItem(customView: c))
} }
n.append(leftSpacer)
// The spacer moves the UIBarButtonItems to the edge of the UINavigationBar.
let spacer: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .FixedSpace, target: nil, action: nil)
spacer.width = inset + contentInset.left
n.append(spacer)
item.leftBarButtonItems = n.reverse() item.leftBarButtonItems = n.reverse()
} }
// Set the titleView if title is empty. // Set the titleView if title is empty.
if "" == item.title { if "" == item.title {
if nil == item.titleView { 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, h - 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 {
t.grid.rows = 1
item.titleView!.addSubview(t) item.titleView!.addSubview(t)
if let d: UILabel = item.detailLabel { if let d: UILabel = item.detailLabel {
d.hidden = false d.grid.rows = 1
item.titleView!.addSubview(d) item.titleView!.addSubview(d)
item.titleView!.grid.views = [t, d]
} else { } else {
item.detailLabel?.hidden = true item.titleView!.grid.views = [t]
} }
} else if let d: UIView = item.detailView { } else if let d: UIView = item.detailView {
d.grid.rows = 1
item.titleView!.addSubview(d) item.titleView!.addSubview(d)
item.titleView!.grid.views = [d]
} }
} }
...@@ -343,20 +322,67 @@ public class NavigationBar : UINavigationBar { ...@@ -343,20 +322,67 @@ public class NavigationBar : UINavigationBar {
if let v: Array<UIControl> = item.rightControls { if let v: Array<UIControl> = item.rightControls {
var n: Array<UIBarButtonItem> = Array<UIBarButtonItem>() var n: Array<UIBarButtonItem> = Array<UIBarButtonItem>()
for c in v { for c in v {
n.append(UIBarButtonItem(customView: c))
}
n.append(rightSpacer)
item.rightBarButtonItems = n.reverse()
}
sizeNavigationItem(item)
}
/**
Sizes the UINavigationItem.
- Parameter item: A UINavigationItem to size.
*/
internal func sizeNavigationItem(item: UINavigationItem) {
let h: CGFloat = intrinsicContentSize().height
let w: CGFloat = backButton.intrinsicContentSize().width
let inset: CGFloat = MaterialDevice.landscape ? item.landscapeInset : item.portraitInset
// leftControls
if let v: Array<UIControl> = item.leftControls {
for c in v {
if let b: UIButton = c as? UIButton { if let b: UIButton = c as? UIButton {
b.contentEdgeInsets.top = 0 b.contentEdgeInsets.top = 0
b.contentEdgeInsets.bottom = 0 b.contentEdgeInsets.bottom = 0
} }
c.bounds.size = c is MaterialSwitch ? CGSizeMake(w, h - contentInset.top - contentInset.bottom) : CGSizeMake(c.intrinsicContentSize().width, h - contentInset.top - contentInset.bottom) c.bounds.size = c is MaterialSwitch ? CGSizeMake(w, h - contentInset.top - contentInset.bottom) : CGSizeMake(c.intrinsicContentSize().width, h - contentInset.top - contentInset.bottom)
n.append(UIBarButtonItem(customView: c))
} }
leftSpacer.width = inset + contentInset.left
// The spacer moves the UIBarButtonItems to the edge of the UINavigationBar. }
let spacer: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .FixedSpace, target: nil, action: nil)
spacer.width = inset + contentInset.right item.titleView?.frame.size.height = height - contentInset.top - contentInset.bottom
n.append(spacer)
if let t: UILabel = item.titleLabel {
item.rightBarButtonItems = n.reverse() if 32 >= height || nil == item.detailLabel {
t.font = t.font.fontWithSize(20)
item.detailLabel?.hidden = true
item.titleView?.grid.axis.rows = 1
} else if let d: UILabel = item.detailLabel {
t.font = t.font.fontWithSize(17)
d.hidden = false
d.font = d.font.fontWithSize(12)
item.titleView?.grid.axis.rows = 2
}
} else if let _: UIView = item.detailView {
item.titleView?.grid.axis.rows = 1
}
// rightControls
if let v: Array<UIControl> = item.rightControls {
for c in v {
if let b: UIButton = c as? UIButton {
b.contentEdgeInsets.top = 0
b.contentEdgeInsets.bottom = 0
}
c.bounds.size = c is MaterialSwitch ? CGSizeMake(w, h - contentInset.top - contentInset.bottom) : CGSizeMake(c.intrinsicContentSize().width, h - contentInset.top - contentInset.bottom)
}
rightSpacer.width = inset + contentInset.right
} }
} }
......
...@@ -35,7 +35,9 @@ private var NavigationItemKey: UInt8 = 0 ...@@ -35,7 +35,9 @@ private var NavigationItemKey: UInt8 = 0
public class NavigationItem { public class NavigationItem {
/// Inset. /// Inset.
public var inset: CGFloat = -20 public var portraitInset: CGFloat
public var landscapeInset: CGFloat
/// Detail View. /// Detail View.
public var detailView: UIView? public var detailView: UIView?
...@@ -51,6 +53,11 @@ public class NavigationItem { ...@@ -51,6 +53,11 @@ public class NavigationItem {
/// Right controls. /// Right controls.
public var rightControls: Array<UIControl>? public var rightControls: Array<UIControl>?
public init(portraitInset: CGFloat, landscapeInset: CGFloat) {
self.portraitInset = portraitInset
self.landscapeInset = landscapeInset
}
} }
public extension UINavigationItem { public extension UINavigationItem {
...@@ -58,7 +65,7 @@ public extension UINavigationItem { ...@@ -58,7 +65,7 @@ public extension UINavigationItem {
public internal(set) var item: NavigationItem { public internal(set) var item: NavigationItem {
get { get {
return MaterialAssociatedObject(self, key: &NavigationItemKey) { return MaterialAssociatedObject(self, key: &NavigationItemKey) {
return NavigationItem() return NavigationItem(portraitInset: .iPad == MaterialDevice.type || "iPhone 6s Plus" == MaterialDevice.model || "iPhone 6 Plus" == MaterialDevice.model ? -20 : -16, landscapeInset: -20)
} }
} }
set(value) { set(value) {
...@@ -66,13 +73,23 @@ public extension UINavigationItem { ...@@ -66,13 +73,23 @@ public extension UINavigationItem {
} }
} }
/// Inset. /// Portrait inset.
public var inset: CGFloat { public var portraitInset: CGFloat {
get {
return item.portraitInset
}
set(value) {
item.portraitInset = value
}
}
/// Landscape inset.
public var landscapeInset: CGFloat {
get { get {
return item.inset return item.landscapeInset
} }
set(value) { set(value) {
item.inset = value item.landscapeInset = value
} }
} }
......
...@@ -305,12 +305,6 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -305,12 +305,6 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
layoutSubviews() layoutSubviews()
} }
public override func willRotateToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) {
if let v: MaterialView = rightView {
v.x = view.bounds.height - (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
...@@ -557,7 +551,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -557,7 +551,7 @@ 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() self.toggleStatusBar(MaterialDevice.landscape && .iPhone == MaterialDevice.type)
self.hideView(v) self.hideView(v)
self.delegate?.sideNavigationDidClose?(self, position: .Left) self.delegate?.sideNavigationDidClose?(self, position: .Left)
} }
...@@ -580,7 +574,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -580,7 +574,7 @@ 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() self.toggleStatusBar(MaterialDevice.landscape && .iPhone == MaterialDevice.type)
self.hideView(v) self.hideView(v)
self.delegate?.sideNavigationDidClose?(self, position: .Right) self.delegate?.sideNavigationDidClose?(self, position: .Right)
} }
...@@ -833,20 +827,20 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -833,20 +827,20 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
the status bar. the status bar.
*/ */
private func toggleStatusBar(hide: Bool = false) { private func toggleStatusBar(hide: Bool = false) {
if hideStatusBar { // if hideStatusBar {
userInteractionEnabled = false // userInteractionEnabled = false
let hidden: Bool = .iPhone == MaterialDevice.type && MaterialDevice.landscape || opened ? true : hide // let hidden: Bool = opened ? true : hide
UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration), // UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration),
animations: { [weak self] in // animations: { [weak self] in
self?.setNeedsStatusBarAppearanceUpdate() // self?.setNeedsStatusBarAppearanceUpdate()
MaterialDevice.statusBarHidden = hidden // MaterialDevice.statusBarHidden = hidden
}) { [weak self] _ in // }) { [weak self] _ in
if false == self?.opened { // if false == self?.opened {
self?.userInteractionEnabled = true // self?.userInteractionEnabled = true
} // }
} // }
delegate?.sideNavigationStatusBarHiddenState?(self, hidden: hidden) // delegate?.sideNavigationStatusBarHiddenState?(self, hidden: hidden)
} // }
} }
public override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation { public override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation {
...@@ -915,8 +909,8 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -915,8 +909,8 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
/// Layout subviews. /// Layout subviews.
private func layoutSubviews() { private func layoutSubviews() {
toggleStatusBar() toggleStatusBar(MaterialDevice.landscape && .iPhone == MaterialDevice.type)
if let v: MaterialView = leftView { if let v: MaterialView = leftView {
v.width = leftViewWidth v.width = leftViewWidth
v.height = view.bounds.height v.height = view.bounds.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