Commit 181d9e7c by Daniel Dahan

added MaterialInsets

parent 1ef54bde
......@@ -16,6 +16,8 @@
65BDD1541BB6F473006F7F2B /* MaterialShadow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65BDD1531BB6F473006F7F2B /* MaterialShadow.swift */; settings = {ASSET_TAGS = (); }; };
65BDD1571BB6FC82006F7F2B /* MaterialButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65BDD1561BB6FC82006F7F2B /* MaterialButton.swift */; settings = {ASSET_TAGS = (); }; };
65BDD1591BB6FE3E006F7F2B /* FlatButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65BDD1581BB6FE3E006F7F2B /* FlatButton.swift */; settings = {ASSET_TAGS = (); }; };
65BDD15B1BB7095E006F7F2B /* MaterialRadius.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65BDD15A1BB7095E006F7F2B /* MaterialRadius.swift */; settings = {ASSET_TAGS = (); }; };
65BDD15D1BB70D60006F7F2B /* MaterialInsets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65BDD15C1BB70D60006F7F2B /* MaterialInsets.swift */; settings = {ASSET_TAGS = (); }; };
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 */; };
962F3E531BACA68C0004B8AD /* NavigationBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962F3E521BACA68C0004B8AD /* NavigationBarView.swift */; };
......@@ -48,6 +50,8 @@
65BDD1531BB6F473006F7F2B /* MaterialShadow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialShadow.swift; sourceTree = "<group>"; };
65BDD1561BB6FC82006F7F2B /* MaterialButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialButton.swift; sourceTree = "<group>"; };
65BDD1581BB6FE3E006F7F2B /* FlatButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FlatButton.swift; sourceTree = "<group>"; };
65BDD15A1BB7095E006F7F2B /* MaterialRadius.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialRadius.swift; sourceTree = "<group>"; };
65BDD15C1BB70D60006F7F2B /* MaterialInsets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialInsets.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>"; };
962F3E521BACA68C0004B8AD /* NavigationBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationBarView.swift; sourceTree = "<group>"; };
......@@ -175,6 +179,8 @@
65BDD1481BB5DC98006F7F2B /* MaterialColor.swift */,
65BDD14E1BB5EE4A006F7F2B /* MaterialGravity.swift */,
65BDD1531BB6F473006F7F2B /* MaterialShadow.swift */,
65BDD15A1BB7095E006F7F2B /* MaterialRadius.swift */,
65BDD15C1BB70D60006F7F2B /* MaterialInsets.swift */,
);
name = Theme;
sourceTree = "<group>";
......@@ -303,6 +309,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
65BDD15D1BB70D60006F7F2B /* MaterialInsets.swift in Sources */,
65BDD1471BB5B916006F7F2B /* MaterialView.swift in Sources */,
65BDD1521BB6EE7C006F7F2B /* RobotoFont.swift in Sources */,
65BDD1591BB6FE3E006F7F2B /* FlatButton.swift in Sources */,
......@@ -311,6 +318,7 @@
65BDD1541BB6F473006F7F2B /* MaterialShadow.swift in Sources */,
65BDD1571BB6FC82006F7F2B /* MaterialButton.swift in Sources */,
65BDD14B1BB5DD02006F7F2B /* MaterialFont.swift in Sources */,
65BDD15B1BB7095E006F7F2B /* MaterialRadius.swift in Sources */,
65BDD1491BB5DC98006F7F2B /* MaterialColor.swift in Sources */,
65BDD14D1BB5ED9F006F7F2B /* MaterialTheme.swift in Sources */,
);
......
......@@ -27,8 +27,8 @@ public class FlatButton : MaterialButton {
setTitleColor(MaterialTheme.button.flat.titleLabelColorForNormalState, forState: .Normal)
titleLabel!.font = MaterialTheme.button.flat.titleLabelFont
backgroundColor = MaterialColor.red.base //MaterialTheme.button.flat.backgroudColor
// contentEdgeInsets = UIEdgeInsetsMake(8, 12, 8, 12)
cornerRadius = MaterialTheme.button.flat.cornerRadius
contentInsets = MaterialTheme.button.flat.contentInsets
}
//
......
......@@ -113,6 +113,22 @@ public class MaterialButton : UIButton {
}
/**
:name: cornerRadius
*/
public var cornerRadius: MaterialRadius! {
didSet {
switch cornerRadius! {
case .Square:
layer.cornerRadius = 0
case .Smooth:
layer.cornerRadius = 4
case .Round:
layer.cornerRadius = bounds.width / 2
}
}
}
/**
:name: shadow
*/
public var shadow: MaterialShadow! {
......@@ -134,6 +150,16 @@ public class MaterialButton : UIButton {
}
/**
:name: contentInsets
*/
public var contentInsets: MaterialInsets! {
didSet {
let inset: (top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat) = MaterialInsetsToValues(contentInsets)
contentEdgeInsets = UIEdgeInsetsMake(inset.top, inset.left, inset.bottom, inset.right)
}
}
/**
:name: pulseColor
*/
public var pulseColor: UIColor? = MaterialColor.white
......
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import UIKit
public enum MaterialInsets {
case Inset0
case Inset1
case Inset2
case Inset3
case Inset4
case Inset5
}
/**
:name: MaterialInsetsToValues
*/
public func MaterialInsetsToValues(inset: MaterialInsets) -> (top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat) {
switch inset {
case .Inset0:
return (top: 0, left: 0, bottom: 0, right: 0)
case .Inset1:
return (top: 4, left: 4, bottom: 4, right: 4)
case .Inset2:
return (top: 8, left: 8, bottom: 8, right: 8)
case .Inset3:
return (top: 12, left: 12, bottom: 12, right: 12)
case .Inset4:
return (top: 16, left: 16, bottom: 16, right: 16)
case .Inset5:
return (top: 20, left: 18, bottom: 20, right: 20)
}
}
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
public enum MaterialRadius {
case Square
case Smooth
case Round
}
......@@ -39,7 +39,10 @@ public extension MaterialTheme.view {
// shadow
public static let shadow: MaterialShadow = .Depth0
public static let shadowColor: UIColor = MaterialColor.blueGrey.darken4
// shape
public static let masksToBounds: Bool = false
public static let cornerRadius: MaterialRadius = .Square
// color
public static let backgroudColor: UIColor = MaterialColor.white
......@@ -68,7 +71,10 @@ public extension MaterialTheme.navigation {
// shadow
public static let shadow: MaterialShadow = .Depth1
public static let shadowColor: UIColor = MaterialTheme.view.shadowColor
// shape
public static let masksToBounds: Bool = MaterialTheme.view.masksToBounds
public static let cornerRadius: MaterialRadius = MaterialTheme.view.cornerRadius
// color
public static let backgroudColor: UIColor = MaterialColor.blue.accent3
......@@ -92,7 +98,11 @@ public extension MaterialTheme.button {
// shadow
public static let shadow: MaterialShadow = .Depth0
public static let shadowColor: UIColor = MaterialTheme.view.shadowColor
// shape
public static let masksToBounds: Bool = MaterialTheme.view.masksToBounds
public static let cornerRadius: MaterialRadius = .Smooth
public static let contentInsets: MaterialInsets = .Inset2
// color
public static let backgroudColor: UIColor = MaterialColor.clear
......@@ -113,7 +123,11 @@ public extension MaterialTheme.button.flat {
// shadow
public static let shadow: MaterialShadow = MaterialTheme.button.shadow
public static let shadowColor: UIColor = MaterialTheme.button.shadowColor
// shape
public static let masksToBounds: Bool = MaterialTheme.button.masksToBounds
public static let cornerRadius: MaterialRadius = MaterialTheme.button.cornerRadius
public static let contentInsets: MaterialInsets = MaterialTheme.button.contentInsets
// color
public static let backgroudColor: UIColor = MaterialTheme.button.backgroudColor
......
......@@ -158,6 +158,22 @@ public class MaterialView: UIView {
}
/**
:name: cornerRadius
*/
public var cornerRadius: MaterialRadius! {
didSet {
switch cornerRadius! {
case .Square:
layer.cornerRadius = 0
case .Smooth:
layer.cornerRadius = 4
case .Round:
layer.cornerRadius = bounds.width / 2
}
}
}
/**
:name: shadow
*/
public var shadow: MaterialShadow! {
......@@ -232,6 +248,7 @@ public class MaterialView: UIView {
shadowColor = MaterialTheme.view.shadowColor
zPosition = MaterialTheme.view.zPosition
masksToBounds = MaterialTheme.view.masksToBounds
cornerRadius = MaterialTheme.view.cornerRadius
}
}
......@@ -58,5 +58,6 @@ public class NavigationBarView: MaterialView {
shadowColor = MaterialTheme.navigation.shadowColor
zPosition = MaterialTheme.navigation.zPosition
masksToBounds = MaterialTheme.navigation.masksToBounds
cornerRadius = MaterialTheme.navigation.cornerRadius
}
}
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