Commit 71fcc474 by Daniel Dahan

added Flat, Fab, and Raised buttons with pulse

parent dc553e4a
//
// 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 class FabButton : MaterialButton {
//
// :name: prepareView
//
internal override func prepareView() {
super.prepareView()
setTitleColor(MaterialTheme.button.fab.titleLabelColorForNormalState, forState: .Normal)
titleLabel!.font = MaterialTheme.button.fab.titleLabelFont
userInteractionEnabled = MaterialTheme.button.fab.userInteractionEnabled
backgroundColor = MaterialTheme.button.fab.backgroudColor
pulseColor = MaterialTheme.button.fab.pulseColor
shadowDepth = MaterialTheme.button.fab.shadowDepth
shadowColor = MaterialTheme.button.fab.shadowColor
zPosition = MaterialTheme.button.fab.zPosition
masksToBounds = MaterialTheme.button.fab.masksToBounds
cornerRadius = MaterialTheme.button.fab.cornerRadius
borderWidth = MaterialTheme.button.fab.borderWidth
borderColor = MaterialTheme.button.fab.bordercolor
contentInsets = MaterialTheme.button.fab.contentInsets
shape = MaterialTheme.button.fab.shape
}
}
\ No newline at end of file
......@@ -26,13 +26,11 @@ public class FlatButton : MaterialButton {
super.prepareView()
setTitleColor(MaterialTheme.button.flat.titleLabelColorForNormalState, forState: .Normal)
titleLabel!.font = MaterialTheme.button.flat.titleLabelFont
}
//
// :name: prepareLayer
//
internal override func prepareLayer() {
super.prepareLayer()
userInteractionEnabled = MaterialTheme.button.flat.userInteractionEnabled
backgroundColor = MaterialTheme.button.flat.backgroudColor
pulseColor = MaterialTheme.button.flat.pulseColor
shadowDepth = MaterialTheme.button.flat.shadowDepth
shadowColor = MaterialTheme.button.flat.shadowColor
zPosition = MaterialTheme.button.flat.zPosition
......@@ -41,6 +39,6 @@ public class FlatButton : MaterialButton {
borderWidth = MaterialTheme.button.flat.borderWidth
borderColor = MaterialTheme.button.flat.bordercolor
contentInsets = MaterialTheme.button.flat.contentInsets
backgroundColor = MaterialTheme.button.flat.backgroudColor
shape = MaterialTheme.button.flat.shape
}
}
\ No newline at end of file
......@@ -20,31 +20,28 @@ import UIKit
public typealias MaterialBorderType = CGFloat
public enum MaterialBorder : MaterialBorderType {
case None
case Thin
case Light
case Regular
case Medium
case Thick
public enum MaterialBorder {
case Border0
case Border1
case Border2
case Border3
case Border4
}
/**
:name: MaterialBorderToValue
*/
public func MaterialBorderToValue(width: MaterialBorder) -> MaterialBorderType {
switch width {
case .None:
public func MaterialBorderToValue(border: MaterialBorder) -> MaterialBorderType {
switch border {
case .Border0:
return 0
case .Thin:
case .Border1:
return 0.5
case .Light:
case .Border2:
return 1
case .Regular:
case .Border3:
return 2
case .Medium:
case .Border4:
return 3
case .Thick:
return 4
}
}
......@@ -19,15 +19,34 @@
import UIKit
public class MaterialButton : UIButton {
//
// :name: visualLayer
//
public private(set) lazy var visualLayer: CAShapeLayer = CAShapeLayer()
//
// :name: pulseLayer
//
internal lazy var pulseLayer: CAShapeLayer = CAShapeLayer()
/**
:name: pulseColor
*/
public var pulseColor: UIColor? {
didSet {
pulseLayer.backgroundColor = pulseColor?.colorWithAlphaComponent(0.5).CGColor
}
}
/**
:name: backgroundColor
*/
public override var backgroundColor: UIColor? {
get {
return nil == layer.backgroundColor ? nil : UIColor(CGColor: layer.backgroundColor!)
return nil == visualLayer.backgroundColor ? nil : UIColor(CGColor: visualLayer.backgroundColor!)
}
set(value) {
layer.backgroundColor = value?.CGColor
visualLayer.backgroundColor = value?.CGColor
}
}
......@@ -36,10 +55,10 @@ public class MaterialButton : UIButton {
*/
public var x: CGFloat {
get {
return layer.frame.origin.x
return frame.origin.x
}
set(value) {
layer.frame.origin.x = value
frame.origin.x = value
}
}
......@@ -48,10 +67,10 @@ public class MaterialButton : UIButton {
*/
public var y: CGFloat {
get {
return layer.frame.origin.y
return frame.origin.y
}
set(value) {
layer.frame.origin.y = value
frame.origin.y = value
}
}
......@@ -60,10 +79,14 @@ public class MaterialButton : UIButton {
*/
public var width: CGFloat {
get {
return layer.frame.size.width
return frame.size.width
}
set(value) {
layer.frame.size.width = value
frame.size.width = value
if nil != shape {
frame.size.height = value
prepareShape()
}
}
}
......@@ -72,10 +95,14 @@ public class MaterialButton : UIButton {
*/
public var height: CGFloat {
get {
return layer.frame.size.height
return frame.size.height
}
set(value) {
layer.frame.size.height = value
frame.size.height = value
if nil != shape {
frame.size.width = value
prepareShape()
}
}
}
......@@ -84,7 +111,7 @@ public class MaterialButton : UIButton {
*/
public var shadowColor: UIColor! {
didSet {
layer.shadowColor = shadowColor.CGColor
layer.shadowColor = nil == shadowColor ? MaterialColor.clear.CGColor : shadowColor!.CGColor
}
}
......@@ -93,7 +120,7 @@ public class MaterialButton : UIButton {
*/
public var shadowOffset: CGSize! {
didSet {
layer.shadowOffset = shadowOffset
layer.shadowOffset = nil == shadowOffset ? CGSizeMake(0, 0) : shadowOffset!
}
}
......@@ -102,7 +129,7 @@ public class MaterialButton : UIButton {
*/
public var shadowOpacity: Float! {
didSet {
layer.shadowOpacity = shadowOpacity
layer.shadowOpacity = nil == shadowOpacity ? 0 : shadowOpacity!
}
}
......@@ -111,7 +138,7 @@ public class MaterialButton : UIButton {
*/
public var shadowRadius: CGFloat! {
didSet {
layer.shadowRadius = shadowRadius
layer.shadowRadius = nil == shadowRadius ? 0 : shadowRadius!
}
}
......@@ -120,7 +147,7 @@ public class MaterialButton : UIButton {
*/
public var masksToBounds: Bool! {
didSet {
layer.masksToBounds = masksToBounds
visualLayer.masksToBounds = nil == masksToBounds ? false : masksToBounds!
}
}
......@@ -129,7 +156,8 @@ public class MaterialButton : UIButton {
*/
public var cornerRadius: MaterialRadius! {
didSet {
layer.cornerRadius = MaterialRadiusToValue(cornerRadius!)
visualLayer.cornerRadius = MaterialRadiusToValue(nil == cornerRadius ? .Radius0 : cornerRadius!)
shape = nil
}
}
......@@ -138,16 +166,13 @@ public class MaterialButton : UIButton {
*/
public var shape: MaterialShape? {
didSet {
if width < height {
width = height
} else {
height = width
}
switch shape! {
case .Square:
layer.cornerRadius = 0
case .Circle:
layer.cornerRadius = width / 2
if nil != shape {
if width < height {
frame.size.width = height
} else {
frame.size.height = width
}
prepareShape()
}
}
}
......@@ -157,7 +182,7 @@ public class MaterialButton : UIButton {
*/
public var borderWidth: MaterialBorder! {
didSet {
layer.borderWidth = MaterialBorderToValue(borderWidth)
visualLayer.borderWidth = MaterialBorderToValue(nil == borderWidth ? .Border0 : borderWidth!)
}
}
......@@ -166,16 +191,16 @@ public class MaterialButton : UIButton {
*/
public var borderColor: UIColor! {
didSet {
layer.borderColor = borderColor.CGColor
visualLayer.borderColor = nil == borderColor ? MaterialColor.clear.CGColor : borderColor!.CGColor
}
}
/**
:name: shadowDepth
*/
public var shadowDepth: MaterialShadow! {
public var shadowDepth: MaterialDepth! {
didSet {
let value: MaterialShadowType = MaterialShadowToValue(shadowDepth)
let value: MaterialDepthType = MaterialDepthToValue(shadowDepth!)
shadowOffset = value.offset
shadowOpacity = value.opacity
shadowRadius = value.radius
......@@ -196,17 +221,12 @@ public class MaterialButton : UIButton {
*/
public var contentInsets: MaterialInsets! {
didSet {
let value: MaterialInsetsType = MaterialInsetsToValue(contentInsets)
let value: MaterialInsetsType = MaterialInsetsToValue(nil == contentInsets ? .Inset0 : contentInsets)
contentEdgeInsets = UIEdgeInsetsMake(value.top, value.left, value.bottom, value.right)
}
}
/**
:name: pulseColor
*/
public var pulseColor: UIColor? = MaterialColor.white
/**
:name: init
*/
public required init?(coder aDecoder: NSCoder) {
......@@ -219,11 +239,27 @@ public class MaterialButton : UIButton {
public override init(frame: CGRect) {
super.init(frame: frame)
prepareView()
prepareLayer()
}
/**
:name: init
*/
public convenience init() {
self.init(frame: CGRectZero)
self.init(frame: CGRectMake(MaterialTheme.view.x, MaterialTheme.view.y, MaterialTheme.view.width, MaterialTheme.view.height))
}
/**
:name: layerClass
*/
public override class func layerClass() -> AnyClass {
return CAShapeLayer.self
}
/**
:name: layoutSubviews
*/
public override func layoutSubviews() {
super.layoutSubviews()
visualLayer.frame = bounds
}
/**
......@@ -231,6 +267,25 @@ public class MaterialButton : UIButton {
*/
public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event)
let point: CGPoint = touches.first!.locationInView(self)
if nil != visualLayer.presentationLayer()?.hitTest(point) {
// set start position
CATransaction.begin()
CATransaction.setAnimationDuration(0)
let w: CGFloat = width / 2
pulseLayer.hidden = false
pulseLayer.position = point
pulseLayer.bounds = CGRectMake(0, 0, w, w)
pulseLayer.cornerRadius = CGFloat(w / 2)
CATransaction.commit()
// expand
CATransaction.begin()
CATransaction.setAnimationDuration(0.3)
pulseLayer.transform = CATransform3DMakeScale(2.5, 2.5, 2.5)
visualLayer.transform = CATransform3DMakeScale(1.05, 1.05, 1.05)
CATransaction.commit()
}
}
/**
......@@ -238,6 +293,7 @@ public class MaterialButton : UIButton {
*/
public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event)
shrink()
}
/**
......@@ -245,19 +301,38 @@ public class MaterialButton : UIButton {
*/
public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
super.touchesCancelled(touches, withEvent: event)
shrink()
}
//
// :name: prepareView
//
internal func prepareView() {
userInteractionEnabled = MaterialTheme.button.userInteractionEnabled
// visualLayer
layer.addSublayer(visualLayer)
// pulseLayer
pulseLayer.hidden = true
visualLayer.insertSublayer(pulseLayer, atIndex: 1000)
}
//
// :name: prepareLayer
// :name: prepareShape
//
internal func prepareLayer() {
internal func prepareShape() {
visualLayer.cornerRadius = .Square == shape ? 0 : width / 2
}
//
// :name: shrink
//
internal func shrink() {
// contract
CATransaction.begin()
CATransaction.setAnimationDuration(0.3)
pulseLayer.hidden = true
pulseLayer.transform = CATransform3DIdentity
visualLayer.transform = CATransform3DIdentity
CATransaction.commit()
}
}
\ No newline at end of file
......@@ -18,7 +18,6 @@
import UIKit
// color
public struct MaterialColor {
// clear
public static let clear: UIColor = UIColor.clearColor()
......
......@@ -18,9 +18,9 @@
import UIKit
public typealias MaterialShadowType = (offset: CGSize, opacity: Float, radius: CGFloat)
public typealias MaterialDepthType = (offset: CGSize, opacity: Float, radius: CGFloat)
public enum MaterialShadow {
public enum MaterialDepth {
case Depth0
case Depth1
case Depth2
......@@ -30,10 +30,10 @@ public enum MaterialShadow {
}
/**
:name: MaterialShadowToValue
:name: MaterialDepthToValue
*/
public func MaterialShadowToValue(shadow: MaterialShadow) -> MaterialShadowType {
switch shadow {
public func MaterialDepthToValue(depth: MaterialDepth) -> MaterialDepthType {
switch depth {
case .Depth0:
return (offset: CGSizeZero, opacity: 0, radius: 0)
case .Depth1:
......
......@@ -18,9 +18,8 @@
import UIKit
/**
:name: MaterialGravity
*/
public typealias MaterialGravityType = String
public enum MaterialGravity {
case Center
case Top
......
......@@ -26,7 +26,6 @@ public enum MaterialInsets {
case Inset2
case Inset3
case Inset4
case Inset5
}
/**
......@@ -41,10 +40,8 @@ public func MaterialInsetsToValue(inset: MaterialInsets) -> MaterialInsetsType {
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)
case .Inset4:
return (top: 32, left: 32, bottom: 32, right: 32)
}
}
......@@ -60,7 +60,7 @@ public class MaterialPulseView: MaterialView {
// expand
CATransaction.begin()
CATransaction.setAnimationDuration(0.3)
pulseLayer.transform = CATransform3DMakeScale(2, 2, 2)
pulseLayer.transform = CATransform3DMakeScale(2.5, 2.5, 2.5)
visualLayer.transform = CATransform3DMakeScale(1.05, 1.05, 1.05)
CATransaction.commit()
}
......@@ -71,13 +71,7 @@ public class MaterialPulseView: MaterialView {
*/
public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event)
// contract
CATransaction.begin()
CATransaction.setAnimationDuration(0.3)
pulseLayer.hidden = true
pulseLayer.transform = CATransform3DIdentity
visualLayer.transform = CATransform3DIdentity
CATransaction.commit()
shrink()
}
/**
......@@ -85,6 +79,7 @@ public class MaterialPulseView: MaterialView {
*/
public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
super.touchesCancelled(touches, withEvent: event)
shrink()
}
//
......@@ -95,13 +90,7 @@ public class MaterialPulseView: MaterialView {
userInteractionEnabled = MaterialTheme.pulseView.userInteractionEnabled
backgroundColor = MaterialTheme.pulseView.backgroudColor
pulseColor = MaterialTheme.pulseView.pulseColor
}
//
// :name: prepareLayer
//
internal override func prepareLayer() {
super.prepareLayer()
contentsRect = MaterialTheme.pulseView.contentsRect
contentsCenter = MaterialTheme.pulseView.contentsCenter
contentsScale = MaterialTheme.pulseView.contentsScale
......@@ -118,4 +107,17 @@ public class MaterialPulseView: MaterialView {
pulseLayer.hidden = true
visualLayer.insertSublayer(pulseLayer, atIndex: 1000)
}
//
// :name: shrink
//
internal func shrink() {
// contract
CATransaction.begin()
CATransaction.setAnimationDuration(0.3)
pulseLayer.hidden = true
pulseLayer.transform = CATransform3DIdentity
visualLayer.transform = CATransform3DIdentity
CATransaction.commit()
}
}
......@@ -21,11 +21,11 @@ import UIKit
public typealias MaterialRadiusType = CGFloat
public enum MaterialRadius {
case None
case Light
case Regular
case Medium
case Heavy
case Radius0
case Radius1
case Radius2
case Radius3
case Radius4
}
/**
......@@ -33,15 +33,15 @@ public enum MaterialRadius {
*/
public func MaterialRadiusToValue(radius: MaterialRadius) -> MaterialRadiusType {
switch radius {
case .None:
case .Radius0:
return 0
case .Light:
case .Radius1:
return 4
case .Regular:
case .Radius2:
return 8
case .Medium:
case .Radius3:
return 16
case .Heavy:
return 20
case .Radius4:
return 32
}
}
//
// 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 typealias MaterialSizeType = CGFloat
public enum MaterialSize {
case Size0
case Size1
case Size2
case Size3
case Size4
}
/**
:name: MaterialSizeToValue
*/
public func MaterialSizeToValue(size: MaterialSize) -> MaterialSizeType {
switch size {
case .Size0:
return 0
case .Size1:
return 0.5
case .Size2:
return 1
case .Size3:
return 2
case .Size4:
return 3
}
}
......@@ -23,9 +23,9 @@ public struct MaterialTheme {
public struct pulseView {}
public struct navigation {}
public struct button {
public struct fab {}
public struct flat {}
public struct raised {}
public struct fab {}
}
}
......@@ -38,15 +38,15 @@ public extension MaterialTheme.view {
public static let height: CGFloat = UIScreen.mainScreen().bounds.height
// shadow
public static let shadowDepth: MaterialShadow = .Depth0
public static let shadowDepth: MaterialDepth = .Depth0
public static let shadowColor: UIColor = MaterialColor.black
// shape
public static let masksToBounds: Bool = false
public static let cornerRadius: MaterialRadius = .None
public static let cornerRadius: MaterialRadius = .Radius0
// border
public static let borderWidth: MaterialBorder = .None
public static let borderWidth: MaterialBorder = .Border0
public static let bordercolor: UIColor = MaterialColor.black
// color
......@@ -74,7 +74,7 @@ public extension MaterialTheme.pulseView {
public static let height: CGFloat = MaterialTheme.view.height
// shadow
public static let shadowDepth: MaterialShadow = MaterialTheme.view.shadowDepth
public static let shadowDepth: MaterialDepth = MaterialTheme.view.shadowDepth
public static let shadowColor: UIColor = MaterialTheme.view.shadowColor
// shape
......@@ -111,7 +111,7 @@ public extension MaterialTheme.navigation {
public static let height: CGFloat = 70
// shadow
public static let shadowDepth: MaterialShadow = .Depth1
public static let shadowDepth: MaterialDepth = .Depth1
public static let shadowColor: UIColor = MaterialTheme.view.shadowColor
// shape
......@@ -139,16 +139,17 @@ public extension MaterialTheme.navigation {
public static let zPosition: CGFloat = 100
}
// button
public extension MaterialTheme.button {
// button.flat
public extension MaterialTheme.button.flat {
// shadow
public static let shadowDepth: MaterialShadow = .Depth0
public static let shadowDepth: MaterialDepth = .Depth0
public static let shadowColor: UIColor = MaterialTheme.view.shadowColor
// shape
public static let masksToBounds: Bool = MaterialTheme.view.masksToBounds
public static let cornerRadius: MaterialRadius = .Light
public static let masksToBounds: Bool = true
public static let cornerRadius: MaterialRadius = .Radius1
public static let contentInsets: MaterialInsets = .Inset2
public static let shape: MaterialShape? = nil
// border
public static let borderWidth: MaterialBorder = MaterialTheme.view.borderWidth
......@@ -156,7 +157,8 @@ public extension MaterialTheme.button {
// color
public static let backgroudColor: UIColor = MaterialColor.clear
public static let titleLabelColorForNormalState: UIColor = MaterialColor.blueGrey.darken4
public static let pulseColor: UIColor = MaterialColor.blue.accent3
public static let titleLabelColorForNormalState: UIColor = MaterialColor.blue.accent3
// interaction
public static let userInteractionEnabled: Bool = true
......@@ -168,41 +170,65 @@ public extension MaterialTheme.button {
public static let titleLabelFont: UIFont = RobotoFont.regular
}
// button.flat
public extension MaterialTheme.button.flat {
// button.raised
public extension MaterialTheme.button.raised {
// shadow
public static let shadowDepth: MaterialShadow = MaterialTheme.button.shadowDepth
public static let shadowColor: UIColor = MaterialTheme.button.shadowColor
public static let shadowDepth: MaterialDepth = .Depth2
public static let shadowColor: UIColor = MaterialTheme.view.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
public static let masksToBounds: Bool = true
public static let cornerRadius: MaterialRadius = .Radius1
public static let contentInsets: MaterialInsets = .Inset2
public static let shape: MaterialShape? = nil
// border
public static let borderWidth: MaterialBorder = MaterialTheme.button.borderWidth
public static let bordercolor: UIColor = MaterialTheme.button.bordercolor
public static let borderWidth: MaterialBorder = MaterialTheme.view.borderWidth
public static let bordercolor: UIColor = MaterialTheme.view.bordercolor
// color
public static let backgroudColor: UIColor = MaterialTheme.button.backgroudColor
public static let titleLabelColorForNormalState: UIColor = MaterialTheme.button.titleLabelColorForNormalState
public static let backgroudColor: UIColor = MaterialColor.blue.accent3
public static let pulseColor: UIColor = MaterialColor.white
public static let titleLabelColorForNormalState: UIColor = MaterialColor.white
// interaction
public static let userInteractionEnabled: Bool = MaterialTheme.button.userInteractionEnabled
public static let userInteractionEnabled: Bool = true
// position
public static let zPosition: CGFloat = MaterialTheme.button.zPosition
public static let zPosition: CGFloat = 200
// font
public static let titleLabelFont: UIFont = RobotoFont.regular
}
// button.fab
public extension MaterialTheme.button.fab {
// shadow
public static let shadowDepth: MaterialDepth = .Depth2
public static let shadowColor: UIColor = MaterialTheme.view.shadowColor
}
// button.raised
public extension MaterialTheme.button.raised {
// shape
public static let masksToBounds: Bool = true
public static let cornerRadius: MaterialRadius = .Radius0
public static let contentInsets: MaterialInsets = .Inset0
public static let shape: MaterialShape? = .Circle
// border
public static let borderWidth: MaterialBorder = MaterialTheme.view.borderWidth
public static let bordercolor: UIColor = MaterialTheme.view.bordercolor
// color
public static let backgroudColor: UIColor = MaterialColor.red.darken1
public static let pulseColor: UIColor = MaterialColor.white
public static let titleLabelColorForNormalState: UIColor = MaterialColor.white
// interaction
public static let userInteractionEnabled: Bool = true
// position
public static let zPosition: CGFloat = 200
// font
public static let titleLabelFont: UIFont = RobotoFont.regular
}
......@@ -187,7 +187,7 @@ public class MaterialView: UIView {
*/
public var cornerRadius: MaterialRadius! {
didSet {
visualLayer.cornerRadius = MaterialRadiusToValue(nil == cornerRadius ? .None : cornerRadius!)
visualLayer.cornerRadius = MaterialRadiusToValue(nil == cornerRadius ? .Radius0 : cornerRadius!)
shape = nil
}
}
......@@ -213,7 +213,7 @@ public class MaterialView: UIView {
*/
public var borderWidth: MaterialBorder! {
didSet {
visualLayer.borderWidth = MaterialBorderToValue(nil == borderWidth ? .None : borderWidth!)
visualLayer.borderWidth = MaterialBorderToValue(nil == borderWidth ? .Border0 : borderWidth!)
}
}
......@@ -229,9 +229,9 @@ public class MaterialView: UIView {
/**
:name: shadowDepth
*/
public var shadowDepth: MaterialShadow! {
public var shadowDepth: MaterialDepth! {
didSet {
let value: MaterialShadowType = MaterialShadowToValue(shadowDepth!)
let value: MaterialDepthType = MaterialDepthToValue(shadowDepth!)
shadowOffset = value.offset
shadowOpacity = value.opacity
shadowRadius = value.radius
......@@ -260,7 +260,6 @@ public class MaterialView: UIView {
public override init(frame: CGRect) {
super.init(frame: frame)
prepareView()
prepareLayer()
}
/**
......@@ -291,12 +290,7 @@ public class MaterialView: UIView {
internal func prepareView() {
userInteractionEnabled = MaterialTheme.view.userInteractionEnabled
backgroundColor = MaterialTheme.view.backgroudColor
}
//
// :name: prepareLayer
//
internal func prepareLayer() {
contentsRect = MaterialTheme.view.contentsRect
contentsCenter = MaterialTheme.view.contentsCenter
contentsScale = MaterialTheme.view.contentsScale
......
......@@ -43,13 +43,7 @@ public class NavigationBarView: MaterialView {
userInteractionEnabled = MaterialTheme.navigation.userInteractionEnabled
backgroundColor = MaterialTheme.navigation.backgroudColor
lightContentStatusBar = MaterialTheme.navigation.lightContentStatusBar
}
//
// :name: prepareLayer
//
internal override func prepareLayer() {
super.prepareLayer()
contentsRect = MaterialTheme.navigation.contentsRect
contentsCenter = MaterialTheme.navigation.contentsCenter
contentsScale = MaterialTheme.navigation.contentsScale
......
//
// 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 class RaisedButton : MaterialButton {
//
// :name: prepareView
//
internal override func prepareView() {
super.prepareView()
setTitleColor(MaterialTheme.button.raised.titleLabelColorForNormalState, forState: .Normal)
titleLabel!.font = MaterialTheme.button.raised.titleLabelFont
userInteractionEnabled = MaterialTheme.button.raised.userInteractionEnabled
backgroundColor = MaterialTheme.button.raised.backgroudColor
pulseColor = MaterialTheme.button.raised.pulseColor
shadowDepth = MaterialTheme.button.raised.shadowDepth
shadowColor = MaterialTheme.button.raised.shadowColor
zPosition = MaterialTheme.button.raised.zPosition
masksToBounds = MaterialTheme.button.raised.masksToBounds
cornerRadius = MaterialTheme.button.raised.cornerRadius
borderWidth = MaterialTheme.button.raised.borderWidth
borderColor = MaterialTheme.button.raised.bordercolor
contentInsets = MaterialTheme.button.raised.contentInsets
shape = MaterialTheme.button.raised.shape
}
}
\ No newline at end of file
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