Commit 7717b774 by Daniel Dahan

Merge branch 'development'

parents 7e33b382 b061cb71
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'MK' s.name = 'MK'
s.version = '1.8.0' s.version = '1.9.0'
s.license = { :type => "AGPLv3+", :file => "LICENSE" } s.license = { :type => "AGPLv3+", :file => "LICENSE" }
s.summary = 'A Material Design Framework In Swift' s.summary = 'A Material Design Framework In Swift'
s.homepage = 'http://materialkit.io' s.homepage = 'http://materialkit.io'
......
...@@ -8,11 +8,13 @@ ...@@ -8,11 +8,13 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
657CD02A1B8EE0D3008C0029 /* MaterialCardView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9A94D1081B8A3F5100F586A5 /* MaterialCardView.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 657CD02A1B8EE0D3008C0029 /* MaterialCardView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9A94D1081B8A3F5100F586A5 /* MaterialCardView.swift */; settings = {ATTRIBUTES = (Public, ); }; };
657CD02C1B8EE0D3008C0029 /* SideNavController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65B965861B8BEEC60055B139 /* SideNavController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 657CD02C1B8EE0D3008C0029 /* SideNavigationViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65B965861B8BEEC60055B139 /* SideNavigationViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
657CD02D1B8EE0D3008C0029 /* MaterialButton.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65B9657D1B8A7C330055B139 /* MaterialButton.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 657CD02D1B8EE0D3008C0029 /* MaterialButton.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65B9657D1B8A7C330055B139 /* MaterialButton.swift */; settings = {ATTRIBUTES = (Public, ); }; };
657CD02F1B8EE0D3008C0029 /* ImageCardView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9A94D10A1B8A485C00F586A5 /* ImageCardView.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 657CD02F1B8EE0D3008C0029 /* ImageCardView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9A94D10A1B8A485C00F586A5 /* ImageCardView.swift */; settings = {ATTRIBUTES = (Public, ); }; };
65B9657E1B8A7C330055B139 /* MaterialButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B9657D1B8A7C330055B139 /* MaterialButton.swift */; }; 65B9657E1B8A7C330055B139 /* MaterialButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B9657D1B8A7C330055B139 /* MaterialButton.swift */; };
65B965871B8BEEC60055B139 /* SideNavController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B965861B8BEEC60055B139 /* SideNavController.swift */; }; 65B965871B8BEEC60055B139 /* SideNavigationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B965861B8BEEC60055B139 /* SideNavigationViewController.swift */; };
65DBE4201B9A9244000C804F /* Roboto-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 65DBE41E1B9A9244000C804F /* Roboto-Bold.ttf */; };
65DBE4211B9A9244000C804F /* Roboto-Thin.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */; };
963832421B88DFD80015F710 /* MaterialKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* MaterialKit.framework */; }; 963832421B88DFD80015F710 /* MaterialKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* MaterialKit.framework */; };
9638325A1B88E31A0015F710 /* MaterialKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963832581B88E31A0015F710 /* MaterialKitTests.swift */; }; 9638325A1B88E31A0015F710 /* MaterialKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963832581B88E31A0015F710 /* MaterialKitTests.swift */; };
963832691B88E5BF0015F710 /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9638325E1B88E5BF0015F710 /* Capture.swift */; }; 963832691B88E5BF0015F710 /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9638325E1B88E5BF0015F710 /* Capture.swift */; };
...@@ -59,7 +61,9 @@ ...@@ -59,7 +61,9 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
65B9657D1B8A7C330055B139 /* MaterialButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialButton.swift; sourceTree = "<group>"; }; 65B9657D1B8A7C330055B139 /* MaterialButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialButton.swift; sourceTree = "<group>"; };
65B965861B8BEEC60055B139 /* SideNavController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideNavController.swift; sourceTree = "<group>"; }; 65B965861B8BEEC60055B139 /* SideNavigationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideNavigationViewController.swift; sourceTree = "<group>"; };
65DBE41E1B9A9244000C804F /* Roboto-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Bold.ttf"; sourceTree = "<group>"; };
65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Thin.ttf"; sourceTree = "<group>"; };
963832361B88DFD80015F710 /* MaterialKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MaterialKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 963832361B88DFD80015F710 /* MaterialKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MaterialKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
963832411B88DFD80015F710 /* MaterialKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MaterialKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 963832411B88DFD80015F710 /* MaterialKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MaterialKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
963832541B88E30F0015F710 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 963832541B88E30F0015F710 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
...@@ -111,12 +115,12 @@ ...@@ -111,12 +115,12 @@
name = View; name = View;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
65B965851B8BEEB00055B139 /* Nav */ = { 65B965851B8BEEB00055B139 /* Navigation */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
65B965861B8BEEC60055B139 /* SideNavController.swift */, 65B965861B8BEEC60055B139 /* SideNavigationViewController.swift */,
); );
name = Nav; name = Navigation;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
9638322C1B88DFD80015F710 = { 9638322C1B88DFD80015F710 = {
...@@ -146,7 +150,7 @@ ...@@ -146,7 +150,7 @@
9AAC38521B89553800FE6B2D /* Font */, 9AAC38521B89553800FE6B2D /* Font */,
963832861B8907FE0015F710 /* Layout */, 963832861B8907FE0015F710 /* Layout */,
65B965731B8A58E60055B139 /* View */, 65B965731B8A58E60055B139 /* View */,
65B965851B8BEEB00055B139 /* Nav */, 65B965851B8BEEB00055B139 /* Navigation */,
963832761B88E8990015F710 /* Text */, 963832761B88E8990015F710 /* Text */,
963832751B88E87B0015F710 /* Button */, 963832751B88E87B0015F710 /* Button */,
9AAC384B1B89524E00FE6B2D /* Card */, 9AAC384B1B89524E00FE6B2D /* Card */,
...@@ -239,6 +243,8 @@ ...@@ -239,6 +243,8 @@
9AAC38521B89553800FE6B2D /* Font */ = { 9AAC38521B89553800FE6B2D /* Font */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
65DBE41E1B9A9244000C804F /* Roboto-Bold.ttf */,
65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */,
9AAC38591B8956E300FE6B2D /* Roboto-Regular.ttf */, 9AAC38591B8956E300FE6B2D /* Roboto-Regular.ttf */,
9AAC38571B8956CF00FE6B2D /* Roboto-Medium.ttf */, 9AAC38571B8956CF00FE6B2D /* Roboto-Medium.ttf */,
9AAC38551B8956C500FE6B2D /* Roboto-Light.ttf */, 9AAC38551B8956C500FE6B2D /* Roboto-Light.ttf */,
...@@ -266,7 +272,7 @@ ...@@ -266,7 +272,7 @@
963832851B89070E0015F710 /* CapturePreview.swift in Headers */, 963832851B89070E0015F710 /* CapturePreview.swift in Headers */,
963832891B89097D0015F710 /* Layout.swift in Headers */, 963832891B89097D0015F710 /* Layout.swift in Headers */,
657CD02A1B8EE0D3008C0029 /* MaterialCardView.swift in Headers */, 657CD02A1B8EE0D3008C0029 /* MaterialCardView.swift in Headers */,
657CD02C1B8EE0D3008C0029 /* SideNavController.swift in Headers */, 657CD02C1B8EE0D3008C0029 /* SideNavigationViewController.swift in Headers */,
657CD02D1B8EE0D3008C0029 /* MaterialButton.swift in Headers */, 657CD02D1B8EE0D3008C0029 /* MaterialButton.swift in Headers */,
96C910ED1B95804B00E7CE5C /* MaterialTheme.swift in Headers */, 96C910ED1B95804B00E7CE5C /* MaterialTheme.swift in Headers */,
657CD02F1B8EE0D3008C0029 /* ImageCardView.swift in Headers */, 657CD02F1B8EE0D3008C0029 /* ImageCardView.swift in Headers */,
...@@ -354,6 +360,8 @@ ...@@ -354,6 +360,8 @@
files = ( files = (
9A94D0FA1B895EA500F586A5 /* LICENSE in Resources */, 9A94D0FA1B895EA500F586A5 /* LICENSE in Resources */,
9A94D0FB1B895EA500F586A5 /* Roboto-Regular.ttf in Resources */, 9A94D0FB1B895EA500F586A5 /* Roboto-Regular.ttf in Resources */,
65DBE4211B9A9244000C804F /* Roboto-Thin.ttf in Resources */,
65DBE4201B9A9244000C804F /* Roboto-Bold.ttf in Resources */,
9A94D0FC1B895EA500F586A5 /* Roboto-Medium.ttf in Resources */, 9A94D0FC1B895EA500F586A5 /* Roboto-Medium.ttf in Resources */,
9A94D0FD1B895EA500F586A5 /* Roboto-Light.ttf in Resources */, 9A94D0FD1B895EA500F586A5 /* Roboto-Light.ttf in Resources */,
); );
...@@ -378,7 +386,7 @@ ...@@ -378,7 +386,7 @@
96B57D4E1B90AF7D00DE7BBB /* MaterialTheme.swift in Sources */, 96B57D4E1B90AF7D00DE7BBB /* MaterialTheme.swift in Sources */,
9638326B1B88E5BF0015F710 /* FabButton.swift in Sources */, 9638326B1B88E5BF0015F710 /* FabButton.swift in Sources */,
9A94D1091B8A3F5100F586A5 /* MaterialCardView.swift in Sources */, 9A94D1091B8A3F5100F586A5 /* MaterialCardView.swift in Sources */,
65B965871B8BEEC60055B139 /* SideNavController.swift in Sources */, 65B965871B8BEEC60055B139 /* SideNavigationViewController.swift in Sources */,
9638326C1B88E5BF0015F710 /* FlatButton.swift in Sources */, 9638326C1B88E5BF0015F710 /* FlatButton.swift in Sources */,
963832711B88E5BF0015F710 /* MaterialText.swift in Sources */, 963832711B88E5BF0015F710 /* MaterialText.swift in Sources */,
9638326A1B88E5BF0015F710 /* CapturePreview.swift in Sources */, 9638326A1B88E5BF0015F710 /* CapturePreview.swift in Sources */,
......
...@@ -170,7 +170,7 @@ Add a sleek Side Navigation to give your users a wonderful experience. ...@@ -170,7 +170,7 @@ Add a sleek Side Navigation to give your users a wonderful experience.
```swift ```swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
sideNav = SideNavController(mainViewController: MainViewController(), leftViewController: LeftViewController(), rightViewController: RightViewController()) sideNav = SideNavigationViewController(mainViewController: MainViewController(), leftViewController: LeftViewController(), rightViewController: RightViewController())
sideNav!.delegate = self sideNav!.delegate = self
window = UIWindow(frame: UIScreen.mainScreen().bounds) window = UIWindow(frame: UIScreen.mainScreen().bounds)
window!.rootViewController = sideNav window!.rootViewController = sideNav
......
...@@ -32,12 +32,12 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -32,12 +32,12 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
/** /**
:name: verticalSpace :name: verticalSpace
*/ */
public var verticalSpace: CGFloat = 8 public var verticalSpace: CGFloat = MaterialTheme.verticalSpace
/** /**
:name: horizontalSpace :name: horizontalSpace
*/ */
public var horizontalSpace: CGFloat = 8 public var horizontalSpace: CGFloat = MaterialTheme.horizontalSpace
/** /**
:name: titleLabelContainer :name: titleLabelContainer
...@@ -72,8 +72,9 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -72,8 +72,9 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
t.setTranslatesAutoresizingMaskIntoConstraints(false) t.setTranslatesAutoresizingMaskIntoConstraints(false)
t.textColor = MaterialTheme.white.color t.textColor = MaterialTheme.white.color
t.backgroundColor = MaterialTheme.clear.color t.backgroundColor = MaterialTheme.clear.color
t.font = Roboto.mediumWithSize(18) t.font = Roboto.medium
t.numberOfLines = 1 t.numberOfLines = 1
t.lineBreakMode = .ByTruncatingTail
prepareCard() prepareCard()
} else { } else {
titleLabelContainer?.removeFromSuperview() titleLabelContainer?.removeFromSuperview()
...@@ -110,9 +111,9 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -110,9 +111,9 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
l.setTranslatesAutoresizingMaskIntoConstraints(false) l.setTranslatesAutoresizingMaskIntoConstraints(false)
l.textColor = MaterialTheme.white.color l.textColor = MaterialTheme.white.color
l.backgroundColor = MaterialTheme.clear.color l.backgroundColor = MaterialTheme.clear.color
l.font = Roboto.lightWithSize(16) l.font = Roboto.light
l.numberOfLines = 0 l.numberOfLines = 0
l.lineBreakMode = .ByWordWrapping l.lineBreakMode = .ByTruncatingTail
prepareCard() prepareCard()
} else { } else {
detailLabelContainer?.removeFromSuperview() detailLabelContainer?.removeFromSuperview()
...@@ -179,6 +180,39 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -179,6 +180,39 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
} }
} }
/**
:name: init
*/
public required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
/**
:name: init
*/
public convenience init?(titleLabel: UILabel? = nil, detailLabel: UILabel? = nil, divider: UIView? = nil, leftButtons: Array<MaterialButton>? = nil, rightButtons: Array<MaterialButton>? = nil) {
self.init(frame: CGRectZero)
prepareProperties(titleLabel, detailLabel: detailLabel, divider: divider, leftButtons: leftButtons, rightButtons: rightButtons)
}
/**
:name: init
*/
public required init(frame: CGRect) {
super.init(frame: CGRectZero)
}
//
// :name: prepareProperties
//
internal func prepareProperties(titleLabel: UILabel?, detailLabel: UILabel?, divider: UIView?, leftButtons: Array<MaterialButton>?, rightButtons: Array<MaterialButton>?) {
self.titleLabel = titleLabel
self.detailLabel = detailLabel
self.divider = divider
self.leftButtons = leftButtons
self.rightButtons = rightButtons
}
// //
// :name: prepareView // :name: prepareView
// //
...@@ -208,9 +242,10 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -208,9 +242,10 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
verticalFormat += "[titleLabelContainer]" verticalFormat += "[titleLabelContainer]"
views["titleLabelContainer"] = titleLabelContainer! views["titleLabelContainer"] = titleLabelContainer!
// text // common text
titleLabelContainer!.addConstraints(Layout.constraint("H:|-(horizontalSpace)-[titleLabel]-(horizontalSpace)-|", options: nil, metrics: ["horizontalSpace": horizontalSpace], views: ["titleLabel": titleLabel!])) Layout.height(titleLabelContainer!, child: titleLabel!, height: 1.5 * titleLabel!.font.pointSize)
titleLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[titleLabel(height)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "height": titleLabel!.font.pointSize + verticalSpace], views: ["titleLabel": titleLabel!])) Layout.expandToParentVerticallyWithPad(titleLabelContainer!, child: titleLabel!, top: verticalSpace, bottom: verticalSpace)
Layout.expandToParentHorizontallyWithPad(titleLabelContainer!, child: titleLabel!, left: horizontalSpace, right: horizontalSpace)
} }
// detail // detail
...@@ -221,10 +256,11 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -221,10 +256,11 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
views["detailLabelContainer"] = detailLabelContainer! views["detailLabelContainer"] = detailLabelContainer!
// text // text
detailLabelContainer!.addConstraints(Layout.constraint("H:|-(horizontalSpace)-[detailLabel]-(horizontalSpace)-|", options: nil, metrics: ["horizontalSpace": horizontalSpace], views: ["detailLabel": detailLabel!])) Layout.expandToParentHorizontallyWithPad(detailLabelContainer!, child: detailLabel!, left: horizontalSpace, right: horizontalSpace)
detailLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[detailLabel(<=maximumDetailLabelHeight)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "maximumDetailLabelHeight": maximumDetailLabelHeight], views: ["detailLabel": detailLabel!])) detailLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[detailLabel(<=maximumDetailLabelHeight)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "maximumDetailLabelHeight": maximumDetailLabelHeight], views: ["detailLabel": detailLabel!]))
} }
// buttons
if nil != buttonsContainer && (nil != leftButtons || nil != rightButtons) { if nil != buttonsContainer && (nil != leftButtons || nil != rightButtons) {
// divider // divider
if nil != divider { if nil != divider {
...@@ -247,7 +283,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -247,7 +283,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
buttonsContainer!.addSubview(button) buttonsContainer!.addSubview(button)
buttonViews["button\(i)"] = button buttonViews["button\(i)"] = button
horizontalFormat += "-(horizontalSpace)-[button\(i)]" horizontalFormat += "-(horizontalSpace)-[button\(i)]"
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: horizontalSpace, bottom: verticalSpace) Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalSpace, bottom: verticalSpace)
} }
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat, options: nil, metrics: ["horizontalSpace": horizontalSpace], views: buttonViews)) buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat, options: nil, metrics: ["horizontalSpace": horizontalSpace], views: buttonViews))
} }
...@@ -261,7 +297,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -261,7 +297,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
buttonsContainer!.addSubview(button) buttonsContainer!.addSubview(button)
buttonViews["button\(i)"] = button buttonViews["button\(i)"] = button
horizontalFormat += "[button\(i)]-(horizontalSpace)-" horizontalFormat += "[button\(i)]-(horizontalSpace)-"
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: horizontalSpace, bottom: verticalSpace) Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalSpace, bottom: verticalSpace)
} }
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat + "|", options: nil, metrics: ["horizontalSpace": horizontalSpace], views: buttonViews)) buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat + "|", options: nil, metrics: ["horizontalSpace": horizontalSpace], views: buttonViews))
} }
......
...@@ -32,12 +32,12 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable { ...@@ -32,12 +32,12 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
/** /**
:name: verticalSpace :name: verticalSpace
*/ */
public var verticalSpace: CGFloat = 8 public var verticalSpace: CGFloat = MaterialTheme.verticalSpace
/** /**
:name: horizontalSpace :name: horizontalSpace
*/ */
public var horizontalSpace: CGFloat = 8 public var horizontalSpace: CGFloat = MaterialTheme.horizontalSpace
/** /**
:name: shadow :name: shadow
...@@ -113,8 +113,9 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable { ...@@ -113,8 +113,9 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
titleLabelContainer!.addSubview(t) titleLabelContainer!.addSubview(t)
t.setTranslatesAutoresizingMaskIntoConstraints(false) t.setTranslatesAutoresizingMaskIntoConstraints(false)
t.backgroundColor = MaterialTheme.clear.color t.backgroundColor = MaterialTheme.clear.color
t.font = Roboto.mediumWithSize(18) t.font = Roboto.medium
t.numberOfLines = 1 t.numberOfLines = 1
t.lineBreakMode = .ByTruncatingTail
if nil == imageView { if nil == imageView {
titleLabelContainer!.backgroundColor = MaterialTheme.white.color titleLabelContainer!.backgroundColor = MaterialTheme.white.color
t.textColor = MaterialTheme.black.color t.textColor = MaterialTheme.black.color
...@@ -160,9 +161,9 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable { ...@@ -160,9 +161,9 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
l.setTranslatesAutoresizingMaskIntoConstraints(false) l.setTranslatesAutoresizingMaskIntoConstraints(false)
l.textColor = MaterialTheme.black.color l.textColor = MaterialTheme.black.color
l.backgroundColor = MaterialTheme.clear.color l.backgroundColor = MaterialTheme.clear.color
l.font = Roboto.lightWithSize(16) l.font = Roboto.light
l.numberOfLines = 0 l.numberOfLines = 0
l.lineBreakMode = .ByWordWrapping l.lineBreakMode = .ByTruncatingTail
prepareCard() prepareCard()
} else { } else {
detailLabelContainer?.removeFromSuperview() detailLabelContainer?.removeFromSuperview()
...@@ -229,6 +230,40 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable { ...@@ -229,6 +230,40 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
} }
} }
/**
:name: init
*/
public required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
/**
:name: init
*/
public convenience init?(imageView: UIImageView? = nil, titleLabel: UILabel? = nil, detailLabel: UILabel? = nil, divider: UIView? = nil, leftButtons: Array<MaterialButton>? = nil, rightButtons: Array<MaterialButton>? = nil) {
self.init(frame: CGRectZero)
prepareProperties(imageView, titleLabel: titleLabel, detailLabel: detailLabel, divider: divider, leftButtons: leftButtons, rightButtons: rightButtons)
}
/**
:name: init
*/
public required init(frame: CGRect) {
super.init(frame: CGRectZero)
}
//
// :name: prepareProperties
//
internal func prepareProperties(imageView: UIImageView?, titleLabel: UILabel?, detailLabel: UILabel?, divider: UIView?, leftButtons: Array<MaterialButton>?, rightButtons: Array<MaterialButton>?) {
self.imageView = imageView
self.titleLabel = titleLabel
self.detailLabel = detailLabel
self.divider = divider
self.leftButtons = leftButtons
self.rightButtons = rightButtons
}
// //
// :name: prepareView // :name: prepareView
// //
...@@ -270,21 +305,16 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable { ...@@ -270,21 +305,16 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
layoutConstraints += Layout.constraint("H:|[titleLabelContainer]|", options: nil, metrics: nil, views: ["titleLabelContainer": titleLabelContainer!]) layoutConstraints += Layout.constraint("H:|[titleLabelContainer]|", options: nil, metrics: nil, views: ["titleLabelContainer": titleLabelContainer!])
verticalFormat += "[titleLabelContainer]" verticalFormat += "[titleLabelContainer]"
views["titleLabelContainer"] = titleLabelContainer! views["titleLabelContainer"] = titleLabelContainer!
// text
titleLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[titleLabel(height)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "height": titleLabel!.font.pointSize + verticalSpace], views: ["titleLabel": titleLabel!]))
} else { } else {
//container //container
Layout.alignFromBottomLeft(imageViewContainer!, child: titleLabelContainer!) Layout.alignFromBottomLeft(imageViewContainer!, child: titleLabelContainer!)
Layout.expandToParentHorizontally(imageViewContainer!, child: titleLabelContainer!) Layout.expandToParentHorizontally(imageViewContainer!, child: titleLabelContainer!)
Layout.height(titleLabelContainer!, child: titleLabel!, height: titleLabel!.font.pointSize + verticalSpace)
// text
titleLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[titleLabel(height)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "height": titleLabel!.font.pointSize + verticalSpace], views: ["titleLabel": titleLabel!]))
} }
// common text // common text
titleLabelContainer!.addConstraints(Layout.constraint("H:|-(horizontalSpace)-[titleLabel]-(horizontalSpace)-|", options: nil, metrics: ["horizontalSpace": horizontalSpace], views: ["titleLabel": titleLabel!])) Layout.height(titleLabelContainer!, child: titleLabel!, height: 1.5 * titleLabel!.font.pointSize)
Layout.expandToParentVerticallyWithPad(titleLabelContainer!, child: titleLabel!, top: verticalSpace, bottom: verticalSpace)
Layout.expandToParentHorizontallyWithPad(titleLabelContainer!, child: titleLabel!, left: horizontalSpace, right: horizontalSpace)
} }
// detail // detail
...@@ -295,10 +325,11 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable { ...@@ -295,10 +325,11 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
views["detailLabelContainer"] = detailLabelContainer! views["detailLabelContainer"] = detailLabelContainer!
// text // text
detailLabelContainer!.addConstraints(Layout.constraint("H:|-(horizontalSpace)-[detailLabel]-(horizontalSpace)-|", options: nil, metrics: ["horizontalSpace": horizontalSpace], views: ["detailLabel": detailLabel!])) Layout.expandToParentHorizontallyWithPad(detailLabelContainer!, child: detailLabel!, left: horizontalSpace, right: horizontalSpace)
detailLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[detailLabel(<=maximumDetailLabelHeight)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "maximumDetailLabelHeight": maximumDetailLabelHeight], views: ["detailLabel": detailLabel!])) detailLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[detailLabel(<=maximumDetailLabelHeight)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "maximumDetailLabelHeight": maximumDetailLabelHeight], views: ["detailLabel": detailLabel!]))
} }
// buttons
if nil != buttonsContainer && (nil != leftButtons || nil != rightButtons) { if nil != buttonsContainer && (nil != leftButtons || nil != rightButtons) {
// divider // divider
if nil != divider { if nil != divider {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.8.0</string> <string>1.9.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
...@@ -24,9 +24,11 @@ ...@@ -24,9 +24,11 @@
<string></string> <string></string>
<key>UIAppFonts</key> <key>UIAppFonts</key>
<array> <array>
<string>Roboto-Medium.ttf</string> <string>Roboto-Thin</string>
<string>Roboto-Regular.ttf</string>
<string>Roboto-Light.ttf</string> <string>Roboto-Light.ttf</string>
<string>Roboto-Regular.ttf</string>
<string>Roboto-Medium.ttf</string>
<string>Roboto-Bold</string>
</array> </array>
</dict> </dict>
</plist> </plist>
...@@ -135,9 +135,7 @@ public struct Layout { ...@@ -135,9 +135,7 @@ public struct Layout {
:name: alignAllSides :name: alignAllSides
*/ */
public static func alignAllSides(parent: UIView, child: UIView) { public static func alignAllSides(parent: UIView, child: UIView) {
let views: Dictionary<String, AnyObject> = ["child" : child] expandToParent(parent, child: child)
parent.addConstraints(constraint("H:|[child]|", options: nil, metrics: nil, views: views))
parent.addConstraints(constraint("V:|[child]|", options: nil, metrics: nil, views: views))
} }
/** /**
......
...@@ -121,9 +121,9 @@ public class MaterialButton : UIButton { ...@@ -121,9 +121,9 @@ public class MaterialButton : UIButton {
// //
internal func prepareShadow() { internal func prepareShadow() {
layer.shadowColor = MaterialTheme.black.color.CGColor layer.shadowColor = MaterialTheme.black.color.CGColor
layer.shadowOffset = CGSizeMake(0.5, 0.5) layer.shadowOffset = CGSizeMake(0.1, 0.1)
layer.shadowOpacity = 0.5 layer.shadowOpacity = 0.4
layer.shadowRadius = 5 layer.shadowRadius = 2
} }
// //
......
...@@ -120,9 +120,9 @@ public class MaterialCardView : UIView { ...@@ -120,9 +120,9 @@ public class MaterialCardView : UIView {
// //
internal func prepareShadow() { internal func prepareShadow() {
layer.shadowColor = MaterialTheme.black.color.CGColor layer.shadowColor = MaterialTheme.black.color.CGColor
layer.shadowOffset = CGSizeMake(0.05, 0.05) layer.shadowOffset = CGSizeMake(0.1, 0.1)
layer.shadowOpacity = 0.1 layer.shadowOpacity = 0.4
layer.shadowRadius = 3 layer.shadowRadius = 2
} }
// //
......
...@@ -18,7 +18,10 @@ ...@@ -18,7 +18,10 @@
import UIKit import UIKit
public struct MaterialTheme { public struct MaterialTheme {}
// colors
extension MaterialTheme {
// clear // clear
public struct clear { public struct clear {
public static let color: UIColor = UIColor.clearColor() public static let color: UIColor = UIColor.clearColor()
...@@ -366,3 +369,14 @@ public struct MaterialTheme { ...@@ -366,3 +369,14 @@ public struct MaterialTheme {
public static let darken4: UIColor = UIColor(red: 38/255, green: 50/255, blue: 56/255, alpha: 1) public static let darken4: UIColor = UIColor(red: 38/255, green: 50/255, blue: 56/255, alpha: 1)
} }
} }
// spacing
extension MaterialTheme {
public static var verticalSpace: CGFloat = 8
public static var horizontalSpace: CGFloat = 2 * verticalSpace
}
// fonts
extension MaterialTheme {
public static var textFontSize: CGFloat = 16
}
\ No newline at end of file
...@@ -19,6 +19,33 @@ ...@@ -19,6 +19,33 @@
import UIKit import UIKit
public struct Roboto { public struct Roboto {
/**
:name: thin
*/
public static var thin: UIFont {
return thinWithSize(MaterialTheme.textFontSize)
}
/**
:name: thinWithSize
*/
public static func thinWithSize(size: CGFloat) -> UIFont {
if let f = UIFont(name: "Roboto-Thin", size: size) {
return f
}
return UIFont.systemFontOfSize(size)
}
/**
:name: light
*/
public static var light: UIFont {
return lightWithSize(MaterialTheme.textFontSize)
}
/**
:name: lightWithSize
*/
public static func lightWithSize(size: CGFloat) -> UIFont { public static func lightWithSize(size: CGFloat) -> UIFont {
if let f = UIFont(name: "Roboto-Light", size: size) { if let f = UIFont(name: "Roboto-Light", size: size) {
return f return f
...@@ -26,6 +53,16 @@ public struct Roboto { ...@@ -26,6 +53,16 @@ public struct Roboto {
return UIFont.systemFontOfSize(size) return UIFont.systemFontOfSize(size)
} }
/**
:name: regular
*/
public static var regular: UIFont {
return regularWithSize(MaterialTheme.textFontSize)
}
/**
:name: mediumWithSize
*/
public static func mediumWithSize(size: CGFloat) -> UIFont { public static func mediumWithSize(size: CGFloat) -> UIFont {
if let f = UIFont(name: "Roboto-Medium", size: size) { if let f = UIFont(name: "Roboto-Medium", size: size) {
return f return f
...@@ -33,10 +70,37 @@ public struct Roboto { ...@@ -33,10 +70,37 @@ public struct Roboto {
return UIFont.systemFontOfSize(size) return UIFont.systemFontOfSize(size)
} }
/**
:name: medium
*/
public static var medium: UIFont {
return mediumWithSize(MaterialTheme.textFontSize)
}
/**
:name: regularWithSize
*/
public static func regularWithSize(size: CGFloat) -> UIFont { public static func regularWithSize(size: CGFloat) -> UIFont {
if let f = UIFont(name: "Roboto-Regular", size: size) { if let f = UIFont(name: "Roboto-Regular", size: size) {
return f return f
} }
return UIFont.systemFontOfSize(size) return UIFont.systemFontOfSize(size)
} }
/**
:name: bold
*/
public static var bold: UIFont {
return boldWithSize(MaterialTheme.textFontSize)
}
/**
:name: boldWithSize
*/
public static func boldWithSize(size: CGFloat) -> UIFont {
if let f = UIFont(name: "Roboto-Regular", size: size) {
return f
}
return UIFont.systemFontOfSize(size)
}
} }
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