Commit 4dbaa51d by Daniel Dahan

adjusted sizing for NavigationBar

parent beff5c45
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
96162C6C1CA71C8700E3A235 /* VideoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96162C6B1CA71C8700E3A235 /* VideoViewController.swift */; }; 96162C6C1CA71C8700E3A235 /* VideoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96162C6B1CA71C8700E3A235 /* VideoViewController.swift */; };
96162C6E1CA7274E00E3A235 /* PhotoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96162C6D1CA7274E00E3A235 /* PhotoViewController.swift */; }; 96162C6E1CA7274E00E3A235 /* PhotoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96162C6D1CA7274E00E3A235 /* PhotoViewController.swift */; };
961F192F1CE14C3E008927C5 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 961F192E1CE14C3E008927C5 /* Material.framework */; }; 961F19321CE2579D008927C5 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 961F19311CE2579D008927C5 /* Material.framework */; };
961F19301CE14C3E008927C5 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 961F192E1CE14C3E008927C5 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 961F19331CE2579D008927C5 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 961F19311CE2579D008927C5 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9663F9321C7A744600AF0965 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9311C7A744600AF0965 /* AppDelegate.swift */; }; 9663F9321C7A744600AF0965 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9311C7A744600AF0965 /* AppDelegate.swift */; };
9663F9341C7A744600AF0965 /* RecommendationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9331C7A744600AF0965 /* RecommendationViewController.swift */; }; 9663F9341C7A744600AF0965 /* RecommendationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9331C7A744600AF0965 /* RecommendationViewController.swift */; };
9663F9391C7A744600AF0965 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9663F9381C7A744600AF0965 /* Assets.xcassets */; }; 9663F9391C7A744600AF0965 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9663F9381C7A744600AF0965 /* Assets.xcassets */; };
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
961F19301CE14C3E008927C5 /* Material.framework in Embed Frameworks */, 961F19331CE2579D008927C5 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
96162C6B1CA71C8700E3A235 /* VideoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoViewController.swift; sourceTree = "<group>"; }; 96162C6B1CA71C8700E3A235 /* VideoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoViewController.swift; sourceTree = "<group>"; };
96162C6D1CA7274E00E3A235 /* PhotoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotoViewController.swift; sourceTree = "<group>"; }; 96162C6D1CA7274E00E3A235 /* PhotoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotoViewController.swift; sourceTree = "<group>"; };
961F192E1CE14C3E008927C5 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-bshwisidfobstlbomegqyybbrygh/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; }; 961F19311CE2579D008927C5 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/CosmicMind-hgvxkqfizbxkrsfcxbtlafgqkbve/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
9663F92E1C7A744600AF0965 /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; }; 9663F92E1C7A744600AF0965 /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; };
9663F9311C7A744600AF0965 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 9663F9311C7A744600AF0965 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
9663F9331C7A744600AF0965 /* RecommendationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendationViewController.swift; sourceTree = "<group>"; }; 9663F9331C7A744600AF0965 /* RecommendationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendationViewController.swift; sourceTree = "<group>"; };
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
961F192F1CE14C3E008927C5 /* Material.framework in Frameworks */, 961F19321CE2579D008927C5 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
9663F9251C7A744500AF0965 = { 9663F9251C7A744500AF0965 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
961F192E1CE14C3E008927C5 /* Material.framework */, 961F19311CE2579D008927C5 /* Material.framework */,
9663F9301C7A744600AF0965 /* App */, 9663F9301C7A744600AF0965 /* App */,
9663F92F1C7A744600AF0965 /* Products */, 9663F92F1C7A744600AF0965 /* Products */,
); );
......
...@@ -66,7 +66,6 @@ class ItemViewController: UIViewController { ...@@ -66,7 +66,6 @@ class ItemViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
prepareView() prepareView()
prepareTitleLabel()
prepareShareButton() prepareShareButton()
prepareNavigationItem() prepareNavigationItem()
prepareScrollView() prepareScrollView()
...@@ -101,22 +100,6 @@ class ItemViewController: UIViewController { ...@@ -101,22 +100,6 @@ class ItemViewController: UIViewController {
automaticallyAdjustsScrollViewInsets = false automaticallyAdjustsScrollViewInsets = false
} }
/// Prepares the titleLabel.
private func prepareTitleLabel() {
titleLabel = UILabel()
titleLabel.text = "Item"
titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white
}
/// Prepares the detailLabel.
private func prepareDetailLabel() {
detailLabel = UILabel()
detailLabel.text = "January 22, 2016"
detailLabel.textAlignment = .Left
detailLabel.textColor = MaterialColor.white
}
/// Prepares the shareButton. /// Prepares the shareButton.
private func prepareShareButton() { private func prepareShareButton() {
let image: UIImage? = MaterialIcon.cm.share let image: UIImage? = MaterialIcon.cm.share
...@@ -128,8 +111,14 @@ class ItemViewController: UIViewController { ...@@ -128,8 +111,14 @@ class ItemViewController: UIViewController {
/// Prepares the navigationItem. /// Prepares the navigationItem.
private func prepareNavigationItem() { private func prepareNavigationItem() {
navigationItem.titleLabel = titleLabel navigationItem.title = "Item"
navigationItem.detailLabel = detailLabel navigationItem.titleLabel.textAlignment = .Left
navigationItem.titleLabel.textColor = MaterialColor.white
navigationItem.detail = "January 22, 2016"
navigationItem.detailLabel.textAlignment = .Left
navigationItem.detailLabel.textColor = MaterialColor.white
navigationItem.rightControls = [shareButton] navigationItem.rightControls = [shareButton]
} }
...@@ -163,8 +152,8 @@ class ItemViewController: UIViewController { ...@@ -163,8 +152,8 @@ class ItemViewController: UIViewController {
detailLabel.font = RobotoFont.regular detailLabel.font = RobotoFont.regular
detailLabel.numberOfLines = 0 detailLabel.numberOfLines = 0
imageCardView.detailView = detailLabel imageCardView.contentView = detailLabel
imageCardView.detailViewInset.top = 52 imageCardView.contentViewInset.top = 52
let image: UIImage? = UIImage(named: data["image"] as! String) let image: UIImage? = UIImage(named: data["image"] as! String)
imageCardView.image = image imageCardView.image = image
......
...@@ -54,7 +54,6 @@ class RecipesViewController: UIViewController { ...@@ -54,7 +54,6 @@ class RecipesViewController: UIViewController {
super.viewDidLoad() super.viewDidLoad()
prepareView() prepareView()
prepareItems() prepareItems()
prepareTitleLabel()
prepareMenuButton() prepareMenuButton()
prepareSwitchControl() prepareSwitchControl()
prepareSearchButton() prepareSearchButton()
...@@ -218,14 +217,6 @@ class RecipesViewController: UIViewController { ...@@ -218,14 +217,6 @@ class RecipesViewController: UIViewController {
view.backgroundColor = MaterialColor.white view.backgroundColor = MaterialColor.white
} }
/// Prepares the titleLabel.
private func prepareTitleLabel() {
titleLabel = UILabel()
titleLabel.text = "Recipes"
titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white
}
/// Prepares the menuButton. /// Prepares the menuButton.
private func prepareMenuButton() { private func prepareMenuButton() {
let image: UIImage? = MaterialIcon.cm.menu let image: UIImage? = MaterialIcon.cm.menu
...@@ -253,7 +244,10 @@ class RecipesViewController: UIViewController { ...@@ -253,7 +244,10 @@ class RecipesViewController: UIViewController {
/// Prepares the navigationItem. /// Prepares the navigationItem.
private func prepareNavigationItem() { private func prepareNavigationItem() {
navigationItem.titleLabel = titleLabel navigationItem.title = "Recipes"
navigationItem.titleLabel.textAlignment = .Left
navigationItem.titleLabel.textColor = MaterialColor.white
navigationItem.leftControls = [menuButton] navigationItem.leftControls = [menuButton]
navigationItem.rightControls = [switchControl, searchButton] navigationItem.rightControls = [switchControl, searchButton]
} }
......
...@@ -61,7 +61,7 @@ class ViewController: UIViewController { ...@@ -61,7 +61,7 @@ class ViewController: UIViewController {
let detailLabel: UILabel = UILabel() let detailLabel: UILabel = UILabel()
detailLabel.text = "It’s been a while, have you read any new books lately?" detailLabel.text = "It’s been a while, have you read any new books lately?"
detailLabel.numberOfLines = 0 detailLabel.numberOfLines = 0
cardView.detailView = detailLabel cardView.contentView = detailLabel
// Yes button. // Yes button.
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
...@@ -106,7 +106,7 @@ class ViewController: UIViewController { ...@@ -106,7 +106,7 @@ class ViewController: UIViewController {
detailLabel.text = "Beautiful Material Design" detailLabel.text = "Beautiful Material Design"
detailLabel.textColor = MaterialColor.white detailLabel.textColor = MaterialColor.white
detailLabel.numberOfLines = 0 detailLabel.numberOfLines = 0
cardView.detailView = detailLabel cardView.contentView = detailLabel
// Share button. // Share button.
let img1: UIImage? = MaterialIcon.cm.share let img1: UIImage? = MaterialIcon.cm.share
...@@ -147,7 +147,7 @@ class ViewController: UIViewController { ...@@ -147,7 +147,7 @@ class ViewController: UIViewController {
detailLabel.text = "Data-Driven Framework" detailLabel.text = "Data-Driven Framework"
detailLabel.textColor = MaterialColor.white detailLabel.textColor = MaterialColor.white
detailLabel.numberOfLines = 0 detailLabel.numberOfLines = 0
cardView.detailView = detailLabel cardView.contentView = detailLabel
// Share button. // Share button.
let img1: UIImage? = MaterialIcon.cm.share let img1: UIImage? = MaterialIcon.cm.share
......
...@@ -65,7 +65,7 @@ class ViewController: UIViewController { ...@@ -65,7 +65,7 @@ class ViewController: UIViewController {
let detailLabel: UILabel = UILabel() let detailLabel: UILabel = UILabel()
detailLabel.text = "It’s been a while, have you read any new books lately?" detailLabel.text = "It’s been a while, have you read any new books lately?"
detailLabel.numberOfLines = 0 detailLabel.numberOfLines = 0
imageCardView.detailView = detailLabel imageCardView.contentView = detailLabel
// Yes button. // Yes button.
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
*/ */
/* /*
The following is an example of setting a UITableView as the detailView for a The following is an example of setting a UITableView as the contentView for a
CardView. CardView.
*/ */
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
*/ */
/* /*
The following is an example of setting a UITableView as the detailView for a The following is an example of setting a UITableView as the contentView for a
CardView. CardView.
*/ */
...@@ -91,7 +91,7 @@ class ViewController: UIViewController { ...@@ -91,7 +91,7 @@ class ViewController: UIViewController {
cardView.contentInsetPreset = .None cardView.contentInsetPreset = .None
cardView.leftButtonsInsetPreset = .Square2 cardView.leftButtonsInsetPreset = .Square2
cardView.rightButtonsInsetPreset = .Square2 cardView.rightButtonsInsetPreset = .Square2
cardView.detailViewInsetPreset = .None cardView.contentViewInsetPreset = .None
let titleLabel: UILabel = UILabel() let titleLabel: UILabel = UILabel()
titleLabel.font = RobotoFont.mediumWithSize(20) titleLabel.font = RobotoFont.mediumWithSize(20)
...@@ -113,7 +113,7 @@ class ViewController: UIViewController { ...@@ -113,7 +113,7 @@ class ViewController: UIViewController {
// Use MaterialLayout to easily align the tableView. // Use MaterialLayout to easily align the tableView.
cardView.titleLabel = titleLabel cardView.titleLabel = titleLabel
cardView.detailView = tableView cardView.contentView = tableView
cardView.leftButtons = [closeButton] cardView.leftButtons = [closeButton]
cardView.rightButtons = [settingButton] cardView.rightButtons = [settingButton]
......
...@@ -60,7 +60,7 @@ class ViewController: UIViewController { ...@@ -60,7 +60,7 @@ class ViewController: UIViewController {
let detailLabel: UILabel = UILabel() let detailLabel: UILabel = UILabel()
detailLabel.text = "It’s been a while, have you read any new books lately?" detailLabel.text = "It’s been a while, have you read any new books lately?"
detailLabel.numberOfLines = 0 detailLabel.numberOfLines = 0
topCardView.detailView = detailLabel topCardView.contentView = detailLabel
// Yes button. // Yes button.
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
...@@ -91,7 +91,7 @@ class ViewController: UIViewController { ...@@ -91,7 +91,7 @@ class ViewController: UIViewController {
let detailLabel: UILabel = UILabel() let detailLabel: UILabel = UILabel()
detailLabel.text = "It’s been a while, have you read any new books lately?" detailLabel.text = "It’s been a while, have you read any new books lately?"
detailLabel.numberOfLines = 0 detailLabel.numberOfLines = 0
bottomCardView.detailView = detailLabel bottomCardView.contentView = detailLabel
// Yes button. // Yes button.
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
......
...@@ -119,29 +119,29 @@ public class CardView : MaterialPulseView { ...@@ -119,29 +119,29 @@ public class CardView : MaterialPulseView {
} }
/** /**
:name: detailViewInsets :name: contentViewInsets
*/ */
public var detailViewInsetPreset: MaterialEdgeInset = .Square2 { public var contentViewInsetPreset: MaterialEdgeInset = .Square2 {
didSet { didSet {
detailViewInset = MaterialEdgeInsetToValue(detailViewInsetPreset) contentViewInset = MaterialEdgeInsetToValue(contentViewInsetPreset)
} }
} }
/** /**
:name: detailViewInset :name: contentViewInset
*/ */
@IBInspectable public var detailViewInset: UIEdgeInsets = MaterialEdgeInsetToValue(.Square2) { @IBInspectable public var contentViewInset: UIEdgeInsets = MaterialEdgeInsetToValue(.Square2) {
didSet { didSet {
reloadView() reloadView()
} }
} }
/** /**
:name: detailView :name: contentView
*/ */
@IBInspectable public var detailView: UIView? { @IBInspectable public var contentView: UIView? {
didSet { didSet {
detailView?.translatesAutoresizingMaskIntoConstraints = false contentView?.translatesAutoresizingMaskIntoConstraints = false
reloadView() reloadView()
} }
} }
...@@ -234,9 +234,9 @@ public class CardView : MaterialPulseView { ...@@ -234,9 +234,9 @@ public class CardView : MaterialPulseView {
/** /**
:name: init :name: init
*/ */
public convenience init?(image: UIImage? = nil, titleLabel: UILabel? = nil, detailView: UIView? = nil, leftButtons: Array<UIButton>? = nil, rightButtons: Array<UIButton>? = nil) { public convenience init?(image: UIImage? = nil, titleLabel: UILabel? = nil, contentView: UIView? = nil, leftButtons: Array<UIButton>? = nil, rightButtons: Array<UIButton>? = nil) {
self.init(frame: CGRectZero) self.init(frame: CGRectZero)
prepareProperties(image, titleLabel: titleLabel, detailView: detailView, leftButtons: leftButtons, rightButtons: rightButtons) prepareProperties(image, titleLabel: titleLabel, contentView: contentView, leftButtons: leftButtons, rightButtons: rightButtons)
} }
/** /**
...@@ -279,9 +279,9 @@ public class CardView : MaterialPulseView { ...@@ -279,9 +279,9 @@ public class CardView : MaterialPulseView {
if nil != titleLabel { if nil != titleLabel {
verticalFormat += "-(insetTop)" verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInset.top + titleLabelInset.top metrics["insetTop"] = contentInset.top + titleLabelInset.top
} else if nil != detailView { } else if nil != contentView {
verticalFormat += "-(insetTop)" verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInset.top + detailViewInset.top metrics["insetTop"] = contentInset.top + contentViewInset.top
} }
// title // title
...@@ -295,20 +295,20 @@ public class CardView : MaterialPulseView { ...@@ -295,20 +295,20 @@ public class CardView : MaterialPulseView {
} }
// detail // detail
if let v: UIView = detailView { if let v: UIView = contentView {
addSubview(v) addSubview(v)
if nil == titleLabel { if nil == titleLabel {
metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + detailViewInset.top metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + contentViewInset.top
} else { } else {
verticalFormat += "-(insetB)" verticalFormat += "-(insetB)"
metrics["insetB"] = titleLabelInset.bottom + detailViewInset.top metrics["insetB"] = titleLabelInset.bottom + contentViewInset.top
} }
verticalFormat += "-[detailView]" verticalFormat += "-[contentView]"
views["detailView"] = v views["contentView"] = v
MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInset.left + detailViewInset.left, right: contentInset.right + detailViewInset.right) MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInset.left + contentViewInset.left, right: contentInset.right + contentViewInset.right)
} }
// leftButtons // leftButtons
...@@ -382,11 +382,11 @@ public class CardView : MaterialPulseView { ...@@ -382,11 +382,11 @@ public class CardView : MaterialPulseView {
metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom
} }
if nil != detailView { if nil != contentView {
if nil == metrics["insetC"] { if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInset.bottom + detailViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0) metrics["insetBottom"] = contentInset.bottom + contentViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} else { } else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0) metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} }
} else if nil != titleLabel { } else if nil != titleLabel {
if nil == metrics["insetC"] { if nil == metrics["insetC"] {
...@@ -430,10 +430,10 @@ public class CardView : MaterialPulseView { ...@@ -430,10 +430,10 @@ public class CardView : MaterialPulseView {
/** /**
:name: prepareProperties :name: prepareProperties
*/ */
internal func prepareProperties(image: UIImage?, titleLabel: UILabel?, detailView: UIView?, leftButtons: Array<UIButton>?, rightButtons: Array<UIButton>?) { internal func prepareProperties(image: UIImage?, titleLabel: UILabel?, contentView: UIView?, leftButtons: Array<UIButton>?, rightButtons: Array<UIButton>?) {
self.image = image self.image = image
self.titleLabel = titleLabel self.titleLabel = titleLabel
self.detailView = detailView self.contentView = contentView
self.leftButtons = leftButtons self.leftButtons = leftButtons
self.rightButtons = rightButtons self.rightButtons = rightButtons
} }
......
...@@ -196,12 +196,6 @@ public class ControlView : MaterialView { ...@@ -196,12 +196,6 @@ public class ControlView : MaterialView {
prepareContentView() prepareContentView()
} }
/// Prepares the contentView.
public func prepareContentView() {
contentView.backgroundColor = nil
addSubview(contentView)
}
/** /**
Used to trigger property changes that initializers avoid. Used to trigger property changes that initializers avoid.
- Parameter leftControls: An Array of UIControls that go on the left side. - Parameter leftControls: An Array of UIControls that go on the left side.
...@@ -211,4 +205,10 @@ public class ControlView : MaterialView { ...@@ -211,4 +205,10 @@ public class ControlView : MaterialView {
self.leftControls = leftControls self.leftControls = leftControls
self.rightControls = rightControls self.rightControls = rightControls
} }
/// Prepares the contentView.
private func prepareContentView() {
contentView.backgroundColor = nil
addSubview(contentView)
}
} }
...@@ -212,29 +212,29 @@ public class ImageCardView : MaterialPulseView { ...@@ -212,29 +212,29 @@ public class ImageCardView : MaterialPulseView {
} }
/** /**
:name: detailViewInsets :name: contentViewInsets
*/ */
public var detailViewInsetPreset: MaterialEdgeInset = .Square2 { public var contentViewInsetPreset: MaterialEdgeInset = .Square2 {
didSet { didSet {
detailViewInset = MaterialEdgeInsetToValue(detailViewInsetPreset) contentViewInset = MaterialEdgeInsetToValue(contentViewInsetPreset)
} }
} }
/** /**
:name: detailViewInset :name: contentViewInset
*/ */
@IBInspectable public var detailViewInset: UIEdgeInsets = MaterialEdgeInsetToValue(.Square2) { @IBInspectable public var contentViewInset: UIEdgeInsets = MaterialEdgeInsetToValue(.Square2) {
didSet { didSet {
reloadView() reloadView()
} }
} }
/** /**
:name: detailView :name: contentView
*/ */
@IBInspectable public var detailView: UIView? { @IBInspectable public var contentView: UIView? {
didSet { didSet {
detailView?.translatesAutoresizingMaskIntoConstraints = false contentView?.translatesAutoresizingMaskIntoConstraints = false
reloadView() reloadView()
} }
} }
...@@ -327,9 +327,9 @@ public class ImageCardView : MaterialPulseView { ...@@ -327,9 +327,9 @@ public class ImageCardView : MaterialPulseView {
/** /**
:name: init :name: init
*/ */
public convenience init?(image: UIImage? = nil, titleLabel: UILabel? = nil, detailView: UIView? = nil, leftButtons: Array<UIButton>? = nil, rightButtons: Array<UIButton>? = nil) { public convenience init?(image: UIImage? = nil, titleLabel: UILabel? = nil, contentView: UIView? = nil, leftButtons: Array<UIButton>? = nil, rightButtons: Array<UIButton>? = nil) {
self.init(frame: CGRectZero) self.init(frame: CGRectZero)
prepareProperties(image, titleLabel: titleLabel, detailView: detailView, leftButtons: leftButtons, rightButtons: rightButtons) prepareProperties(image, titleLabel: titleLabel, contentView: contentView, leftButtons: leftButtons, rightButtons: rightButtons)
} }
/** /**
...@@ -379,9 +379,9 @@ public class ImageCardView : MaterialPulseView { ...@@ -379,9 +379,9 @@ public class ImageCardView : MaterialPulseView {
} else if nil != titleLabel { } else if nil != titleLabel {
verticalFormat += "-(insetTop)" verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInset.top + titleLabelInset.top metrics["insetTop"] = contentInset.top + titleLabelInset.top
} else if nil != detailView { } else if nil != contentView {
verticalFormat += "-(insetTop)" verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInset.top + detailViewInset.top metrics["insetTop"] = contentInset.top + contentViewInset.top
} }
// title // title
...@@ -398,20 +398,20 @@ public class ImageCardView : MaterialPulseView { ...@@ -398,20 +398,20 @@ public class ImageCardView : MaterialPulseView {
} }
// detail // detail
if let v: UIView = detailView { if let v: UIView = contentView {
addSubview(v) addSubview(v)
if nil == imageLayer?.contents && nil != titleLabel { if nil == imageLayer?.contents && nil != titleLabel {
verticalFormat += "-(insetB)" verticalFormat += "-(insetB)"
metrics["insetB"] = titleLabelInset.bottom + detailViewInset.top metrics["insetB"] = titleLabelInset.bottom + contentViewInset.top
} else { } else {
metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + detailViewInset.top metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + contentViewInset.top
} }
verticalFormat += "-[detailView]" verticalFormat += "-[contentView]"
views["detailView"] = v views["contentView"] = v
MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInset.left + detailViewInset.left, right: contentInset.right + detailViewInset.right) MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInset.left + contentViewInset.left, right: contentInset.right + contentViewInset.right)
} }
// leftButtons // leftButtons
...@@ -486,11 +486,11 @@ public class ImageCardView : MaterialPulseView { ...@@ -486,11 +486,11 @@ public class ImageCardView : MaterialPulseView {
metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom
} }
if nil != detailView { if nil != contentView {
if nil == metrics["insetC"] { if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInset.bottom + detailViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0) metrics["insetBottom"] = contentInset.bottom + contentViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} else { } else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0) metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} }
} else if nil != titleLabel { } else if nil != titleLabel {
if nil == metrics["insetC"] { if nil == metrics["insetC"] {
...@@ -501,7 +501,7 @@ public class ImageCardView : MaterialPulseView { ...@@ -501,7 +501,7 @@ public class ImageCardView : MaterialPulseView {
} else if nil != metrics["insetC"] { } else if nil != metrics["insetC"] {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentInset.top + (divider ? dividerInset.top + dividerInset.bottom : 0) metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentInset.top + (divider ? dividerInset.top + dividerInset.bottom : 0)
} }
} else if nil != detailView { } else if nil != contentView {
if 0 < leftButtons?.count { if 0 < leftButtons?.count {
verticalFormat += "-(insetC)-[button]" verticalFormat += "-(insetC)-[button]"
views["button"] = leftButtons![0] views["button"] = leftButtons![0]
...@@ -515,9 +515,9 @@ public class ImageCardView : MaterialPulseView { ...@@ -515,9 +515,9 @@ public class ImageCardView : MaterialPulseView {
} }
if nil == metrics["insetC"] { if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInset.bottom + detailViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0) metrics["insetBottom"] = contentInset.bottom + contentViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} else { } else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0) metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} }
} else { } else {
if 0 < leftButtons?.count { if 0 < leftButtons?.count {
...@@ -583,10 +583,10 @@ public class ImageCardView : MaterialPulseView { ...@@ -583,10 +583,10 @@ public class ImageCardView : MaterialPulseView {
/** /**
:name: prepareProperties :name: prepareProperties
*/ */
internal func prepareProperties(image: UIImage?, titleLabel: UILabel?, detailView: UIView?, leftButtons: Array<UIButton>?, rightButtons: Array<UIButton>?) { internal func prepareProperties(image: UIImage?, titleLabel: UILabel?, contentView: UIView?, leftButtons: Array<UIButton>?, rightButtons: Array<UIButton>?) {
self.image = image self.image = image
self.titleLabel = titleLabel self.titleLabel = titleLabel
self.detailView = detailView self.contentView = contentView
self.leftButtons = leftButtons self.leftButtons = leftButtons
self.rightButtons = rightButtons self.rightButtons = rightButtons
} }
......
...@@ -349,6 +349,10 @@ public class MaterialButton : UIButton { ...@@ -349,6 +349,10 @@ public class MaterialButton : UIButton {
} }
} }
public override func alignmentRectInsets() -> UIEdgeInsets {
return UIEdgeInsetsZero
}
/** /**
A method that accepts CAAnimation objects and executes them on the A method that accepts CAAnimation objects and executes them on the
view's backing layer. view's backing layer.
......
...@@ -114,7 +114,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD ...@@ -114,7 +114,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
*/ */
public func navigationBar(navigationBar: UINavigationBar, shouldPushItem item: UINavigationItem) -> Bool { public func navigationBar(navigationBar: UINavigationBar, shouldPushItem item: UINavigationItem) -> Bool {
if let v: NavigationBar = navigationBar as? NavigationBar { if let v: NavigationBar = navigationBar as? NavigationBar {
item.setHidesBackButton(true, animated: false) item.hidesBackButton = true
if var c: Array<UIControl> = item.leftControls { if var c: Array<UIControl> = item.leftControls {
c.append(v.backButton) c.append(v.backButton)
item.leftControls = c item.leftControls = c
......
...@@ -35,19 +35,27 @@ private var MaterialAssociatedObjectNavigationItemKey: UInt8 = 0 ...@@ -35,19 +35,27 @@ private var MaterialAssociatedObjectNavigationItemKey: UInt8 = 0
public class MaterialAssociatedObjectNavigationItem { public class MaterialAssociatedObjectNavigationItem {
/// Detail View. /// Detail View.
public var detailView: UIView? public var contentView: UIView?
/// Title label. /// Title label.
public var titleLabel: UILabel? public var titleLabel: UILabel
/// Detail text.
public var detail: String?
/// Detail label. /// Detail label.
public var detailLabel: UILabel? public var detailLabel: UILabel
/// Left controls. /// Left controls.
public var leftControls: Array<UIControl>? public var leftControls: Array<UIControl>?
/// Right controls. /// Right controls.
public var rightControls: Array<UIControl>? public var rightControls: Array<UIControl>?
public init() {
titleLabel = UILabel()
detailLabel = UILabel()
}
} }
public extension UINavigationItem { public extension UINavigationItem {
...@@ -64,17 +72,17 @@ public extension UINavigationItem { ...@@ -64,17 +72,17 @@ public extension UINavigationItem {
} }
/// Detail View. /// Detail View.
public var detailView: UIView? { public internal(set) var contentView: UIView? {
get { get {
return item.detailView return item.contentView
} }
set(value) { set(value) {
item.detailView = value item.contentView = value
} }
} }
/// Title Label. /// Title Label.
public var titleLabel: UILabel? { public internal(set) var titleLabel: UILabel {
get { get {
return item.titleLabel return item.titleLabel
} }
...@@ -83,8 +91,18 @@ public extension UINavigationItem { ...@@ -83,8 +91,18 @@ public extension UINavigationItem {
} }
} }
/// Detail text.
public var detail: String? {
get {
return item.detail
}
set(value) {
item.detail = value
}
}
/// Detail Label. /// Detail Label.
public var detailLabel: UILabel? { public internal(set) var detailLabel: UILabel {
get { get {
return item.detailLabel return item.detailLabel
} }
......
...@@ -99,9 +99,15 @@ public class SearchBar : StatusBarView { ...@@ -99,9 +99,15 @@ public class SearchBar : StatusBarView {
} }
} }
/// Prepares the contentView. /**
public override func prepareContentView() { Prepares the view instance when intialized. When subclassing,
super.prepareContentView() it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public override func prepareView() {
super.prepareView()
prepareTextField() prepareTextField()
prepareClearButton() prepareClearButton()
} }
......
...@@ -74,7 +74,7 @@ public class StatusBarView : ControlView { ...@@ -74,7 +74,7 @@ public class StatusBarView : ControlView {
width = MaterialDevice.width width = MaterialDevice.width
} }
grid.axis.columns = Int(width / 56) grid.axis.columns = Int(width / 48)
// General alignment. // General alignment.
if .iPhone == MaterialDevice.type && MaterialDevice.isLandscape { if .iPhone == MaterialDevice.type && MaterialDevice.isLandscape {
......
...@@ -101,9 +101,15 @@ public class Toolbar : StatusBarView { ...@@ -101,9 +101,15 @@ public class Toolbar : StatusBarView {
} }
} }
/// Prepares the contentView. /**
public override func prepareContentView() { Prepares the view instance when intialized. When subclassing,
super.prepareContentView() it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public override func prepareView() {
super.prepareView()
contentView.grid.axis.direction = .Vertical contentView.grid.axis.direction = .Vertical
} }
......
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