Commit f65afdde by Daniel Dahan

updated MaterialLayer documentation and MaterialButton internals

parent 710ad186
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
location = "container:" location = "container:"
name = "MaterialButton"> name = "MaterialButton">
<FileRef <FileRef
location = "group:/Users/danieldahan/Dropbox/GraphKit/Technology/Repositories/MaterialKit/Examples/Storyboards/MaterialButton/MaterialButton.xcodeproj"> location = "group:Storyboards/MaterialButton/MaterialButton.xcodeproj">
</FileRef> </FileRef>
</Group> </Group>
<Group <Group
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
960B23541C3870A500E96216 /* MaterialKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 960B23531C3870A500E96216 /* MaterialKit.framework */; };
960B23551C3870A500E96216 /* MaterialKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 960B23531C3870A500E96216 /* MaterialKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
967513CA1C136BB7009F455A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967513C91C136BB7009F455A /* AppDelegate.swift */; }; 967513CA1C136BB7009F455A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967513C91C136BB7009F455A /* AppDelegate.swift */; };
967513CC1C136BB7009F455A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967513CB1C136BB7009F455A /* ViewController.swift */; }; 967513CC1C136BB7009F455A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967513CB1C136BB7009F455A /* ViewController.swift */; };
967513D11C136BB7009F455A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 967513D01C136BB7009F455A /* Assets.xcassets */; }; 967513D11C136BB7009F455A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 967513D01C136BB7009F455A /* Assets.xcassets */; };
...@@ -22,7 +20,6 @@ ...@@ -22,7 +20,6 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
960B23551C3870A500E96216 /* MaterialKit.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -30,7 +27,6 @@ ...@@ -30,7 +27,6 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
960B23531C3870A500E96216 /* MaterialKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = MaterialKit.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/MaterialKit-gdulktuccbcfwbdfadtpxkworhyc/Build/Products/Debug-iphoneos/MaterialKit.framework"; sourceTree = "<absolute>"; };
967513C61C136BB7009F455A /* CardView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CardView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 967513C61C136BB7009F455A /* CardView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CardView.app; sourceTree = BUILT_PRODUCTS_DIR; };
967513C91C136BB7009F455A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 967513C91C136BB7009F455A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
967513CB1C136BB7009F455A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; }; 967513CB1C136BB7009F455A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
...@@ -44,7 +40,6 @@ ...@@ -44,7 +40,6 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
960B23541C3870A500E96216 /* MaterialKit.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -54,7 +49,6 @@ ...@@ -54,7 +49,6 @@
967513BD1C136BB7009F455A = { 967513BD1C136BB7009F455A = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
960B23531C3870A500E96216 /* MaterialKit.framework */,
967513C81C136BB7009F455A /* CardView */, 967513C81C136BB7009F455A /* CardView */,
967513C71C136BB7009F455A /* Products */, 967513C71C136BB7009F455A /* Products */,
); );
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
9637EB0E1C387F08006D9677 /* MaterialKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9637EB0D1C387F08006D9677 /* MaterialKit.framework */; };
9637EB0F1C387F08006D9677 /* MaterialKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9637EB0D1C387F08006D9677 /* MaterialKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
965E8E261C149B530035A270 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965E8E251C149B530035A270 /* AppDelegate.swift */; }; 965E8E261C149B530035A270 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965E8E251C149B530035A270 /* AppDelegate.swift */; };
965E8E281C149B530035A270 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965E8E271C149B530035A270 /* ViewController.swift */; }; 965E8E281C149B530035A270 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965E8E271C149B530035A270 /* ViewController.swift */; };
965E8E2D1C149B530035A270 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 965E8E2C1C149B530035A270 /* Assets.xcassets */; }; 965E8E2D1C149B530035A270 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 965E8E2C1C149B530035A270 /* Assets.xcassets */; };
...@@ -20,6 +22,7 @@ ...@@ -20,6 +22,7 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
9637EB0F1C387F08006D9677 /* MaterialKit.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -27,6 +30,7 @@ ...@@ -27,6 +30,7 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
9637EB0D1C387F08006D9677 /* MaterialKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = MaterialKit.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/MaterialKit-gdulktuccbcfwbdfadtpxkworhyc/Build/Products/Debug-iphoneos/MaterialKit.framework"; sourceTree = "<absolute>"; };
965E8E221C149B530035A270 /* MaterialLayer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MaterialLayer.app; sourceTree = BUILT_PRODUCTS_DIR; }; 965E8E221C149B530035A270 /* MaterialLayer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MaterialLayer.app; sourceTree = BUILT_PRODUCTS_DIR; };
965E8E251C149B530035A270 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 965E8E251C149B530035A270 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
965E8E271C149B530035A270 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; }; 965E8E271C149B530035A270 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
...@@ -40,6 +44,7 @@ ...@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
9637EB0E1C387F08006D9677 /* MaterialKit.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -49,6 +54,7 @@ ...@@ -49,6 +54,7 @@
965E8E191C149B530035A270 = { 965E8E191C149B530035A270 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9637EB0D1C387F08006D9677 /* MaterialKit.framework */,
965E8E241C149B530035A270 /* MaterialLayer */, 965E8E241C149B530035A270 /* MaterialLayer */,
965E8E231C149B530035A270 /* Products */, 965E8E231C149B530035A270 /* Products */,
); );
......
...@@ -49,7 +49,7 @@ class ViewController: UIViewController { ...@@ -49,7 +49,7 @@ class ViewController: UIViewController {
*/ */
func prepareRaisedButtonExample() { func prepareRaisedButtonExample() {
raisedButton.setTitle("Raised", forState: .Normal) raisedButton.setTitle("Raised", forState: .Normal)
raisedButton.titleLabel!.font = RobotoFont.mediumWithSize(28) raisedButton.titleLabel!.font = RobotoFont.mediumWithSize(28)
} }
/** /**
......
...@@ -20,24 +20,16 @@ import UIKit ...@@ -20,24 +20,16 @@ import UIKit
public class FabButton : MaterialButton { public class FabButton : MaterialButton {
/** /**
:name: prepareView Prepares the view instance when intialized. When subclassing,
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() { public override func prepareView() {
super.prepareView() super.prepareView()
setTitleColor(MaterialTheme.fabButton.titleLabelColorForNormalState, forState: .Normal) backgroundColor = MaterialColor.red.darken1
titleLabel?.font = MaterialTheme.fabButton.titleLabelFont depth = .Depth2
shape = .Circle
userInteractionEnabled = MaterialTheme.fabButton.userInteractionEnabled
backgroundColor = MaterialTheme.fabButton.backgroundColor
pulseColorOpacity = MaterialTheme.fabButton.pulseColorOpacity
pulseColor = MaterialTheme.fabButton.pulseColor
depth = MaterialTheme.fabButton.depth
shadowColor = MaterialTheme.fabButton.shadowColor
zPosition = MaterialTheme.fabButton.zPosition
borderWidth = MaterialTheme.fabButton.borderWidth
borderColor = MaterialTheme.fabButton.bordercolor
contentInsets = MaterialTheme.fabButton.contentInsets
shape = MaterialTheme.fabButton.shape
} }
} }
\ No newline at end of file
...@@ -20,25 +20,17 @@ import UIKit ...@@ -20,25 +20,17 @@ import UIKit
public class FlatButton : MaterialButton { public class FlatButton : MaterialButton {
/** /**
:name: prepareView Prepares the view instance when intialized. When subclassing,
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() { public override func prepareView() {
super.prepareView() super.prepareView()
setTitleColor(MaterialTheme.flatButton.titleLabelColorForNormalState, forState: .Normal) setTitleColor(MaterialColor.blue.accent3, forState: .Normal)
titleLabel?.font = MaterialTheme.flatButton.titleLabelFont pulseColor = MaterialColor.blue.accent3
cornerRadius = .Radius1
userInteractionEnabled = MaterialTheme.flatButton.userInteractionEnabled contentInsets = .WideRectangle3
backgroundColor = MaterialTheme.flatButton.backgroundColor
pulseColorOpacity = MaterialTheme.flatButton.pulseColorOpacity
pulseColor = MaterialTheme.flatButton.pulseColor
depth = MaterialTheme.flatButton.depth
shadowColor = MaterialTheme.flatButton.shadowColor
zPosition = MaterialTheme.flatButton.zPosition
cornerRadius = MaterialTheme.flatButton.cornerRadius
borderWidth = MaterialTheme.flatButton.borderWidth
borderColor = MaterialTheme.flatButton.bordercolor
contentInsets = MaterialTheme.flatButton.contentInsets
shape = MaterialTheme.flatButton.shape
} }
} }
\ No newline at end of file
...@@ -24,13 +24,14 @@ public protocol MaterialDelegate {} ...@@ -24,13 +24,14 @@ public protocol MaterialDelegate {}
@objc(MaterialLayer) @objc(MaterialLayer)
public class MaterialLayer : CAShapeLayer { public class MaterialLayer : CAShapeLayer {
/** /**
:name: visualLayer A CAShapeLayer used to manage elements that would be affected by
the clipToBounds property of the backing layer. For example, this
allows the dropshadow effect on the backing layer, while clipping
the image to a desired shape within the visualLayer.
*/ */
public private(set) lazy var visualLayer: CAShapeLayer = CAShapeLayer() public private(set) lazy var visualLayer: CAShapeLayer = CAShapeLayer()
/** /// A property that accesses the layer.frame.origin.x property.
:name: x
*/
public var x: CGFloat { public var x: CGFloat {
get { get {
return frame.origin.x return frame.origin.x
...@@ -40,9 +41,7 @@ public class MaterialLayer : CAShapeLayer { ...@@ -40,9 +41,7 @@ public class MaterialLayer : CAShapeLayer {
} }
} }
/** /// A property that accesses the layer.frame.origin.y property.
:name: y
*/
public var y: CGFloat { public var y: CGFloat {
get { get {
return frame.origin.y return frame.origin.y
...@@ -53,7 +52,10 @@ public class MaterialLayer : CAShapeLayer { ...@@ -53,7 +52,10 @@ public class MaterialLayer : CAShapeLayer {
} }
/** /**
:name: width A property that accesses the layer.frame.origin.width property.
When setting this property in conjunction with the shape property having a
value that is not .None, the height will be adjusted to maintain the correct
shape.
*/ */
public var width: CGFloat { public var width: CGFloat {
get { get {
...@@ -68,7 +70,10 @@ public class MaterialLayer : CAShapeLayer { ...@@ -68,7 +70,10 @@ public class MaterialLayer : CAShapeLayer {
} }
/** /**
:name: height A property that accesses the layer.frame.origin.height property.
When setting this property in conjunction with the shape property having a
value that is not .None, the width will be adjusted to maintain the correct
shape.
*/ */
public var height: CGFloat { public var height: CGFloat {
get { get {
...@@ -83,56 +88,51 @@ public class MaterialLayer : CAShapeLayer { ...@@ -83,56 +88,51 @@ public class MaterialLayer : CAShapeLayer {
} }
/** /**
:name: image A property that manages an image for the visualLayer's contents
property. Images should not be set to the backing layer's contents
property to avoid conflicts when using clipsToBounds.
*/ */
public var image: UIImage? { public var image: UIImage? {
get { didSet {
return nil == visualLayer.contents ? nil : UIImage(CGImage: visualLayer.contents as! CGImageRef) visualLayer.contents = image?.CGImage
}
set(value) {
visualLayer.contents = value?.CGImage
} }
} }
/** /**
:name: contentsRect Allows a relative subrectangle within the range of 0 to 1 to be
specified for the visualLayer's contents property. This allows
much greater flexibility than the contentsGravity property in
terms of how the image is cropped and stretched.
*/ */
public override var contentsRect: CGRect { public override var contentsRect: CGRect {
get { didSet {
return visualLayer.contentsRect
}
set(value) {
visualLayer.contentsRect = contentsRect visualLayer.contentsRect = contentsRect
} }
} }
/** /**
:name: contentsCenter A CGRect that defines a stretchable region inside the visualLayer
with a fixed border around the edge.
*/ */
public override var contentsCenter: CGRect { public override var contentsCenter: CGRect {
get { didSet {
return visualLayer.contentsCenter
}
set(value) {
visualLayer.contentsCenter = contentsCenter visualLayer.contentsCenter = contentsCenter
} }
} }
/** /**
:name: contentsScale A floating point value that defines a ratio between the pixel
dimensions of the visualLayer's contents property and the size
of the layer. By default, this value is set to the UIScreen's
scale value, UIScreen.mainScreen().scale.
*/ */
public override var contentsScale: CGFloat { public override var contentsScale: CGFloat {
get { didSet {
return visualLayer.contentsScale
}
set(value) {
visualLayer.contentsScale = contentsScale visualLayer.contentsScale = contentsScale
} }
} }
/** /// Determines how content should be aligned within the visualLayer's bounds.
:name: contentsGravity
*/
public override var contentsGravity: String { public override var contentsGravity: String {
get { get {
return visualLayer.contentsGravity return visualLayer.contentsGravity
...@@ -143,7 +143,9 @@ public class MaterialLayer : CAShapeLayer { ...@@ -143,7 +143,9 @@ public class MaterialLayer : CAShapeLayer {
} }
/** /**
:name: depth A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
*/ */
public var depth: MaterialDepth { public var depth: MaterialDepth {
didSet { didSet {
...@@ -155,7 +157,9 @@ public class MaterialLayer : CAShapeLayer { ...@@ -155,7 +157,9 @@ public class MaterialLayer : CAShapeLayer {
} }
/** /**
:name: cornerRadius A property that sets the cornerRadius of the backing layer. If the shape
property has a value of .Circle when the cornerRadius is set, it will
become .None, as it no longer maintains its circle shape.
*/ */
public override var cornerRadius: CGFloat { public override var cornerRadius: CGFloat {
didSet { didSet {
...@@ -166,22 +170,25 @@ public class MaterialLayer : CAShapeLayer { ...@@ -166,22 +170,25 @@ public class MaterialLayer : CAShapeLayer {
} }
/** /**
:name: shape A property that manages the overall shape for the object. If either the
width or height property is set, the other will be automatically adjusted
to maintain the shape of the object.
*/ */
public var shape: MaterialShape { public var shape: MaterialShape {
didSet { didSet {
if .None != shape { if .None != shape {
if width < height { if width < height {
width = height frame.size.width = height
} else { } else {
height = width frame.size.height = width
} }
} }
} }
} }
/** /**
:name: init An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/ */
public required init?(coder aDecoder: NSCoder) { public required init?(coder aDecoder: NSCoder) {
shape = .None shape = .None
...@@ -191,7 +198,9 @@ public class MaterialLayer : CAShapeLayer { ...@@ -191,7 +198,9 @@ public class MaterialLayer : CAShapeLayer {
} }
/** /**
:name: init An initializer the same as init(). The layer parameter is ignored
to avoid crashes on certain architectures.
- Parameter layer: AnyObject.
*/ */
public override init(layer: AnyObject) { public override init(layer: AnyObject) {
shape = .None shape = .None
...@@ -200,9 +209,7 @@ public class MaterialLayer : CAShapeLayer { ...@@ -200,9 +209,7 @@ public class MaterialLayer : CAShapeLayer {
prepareVisualLayer() prepareVisualLayer()
} }
/** /// A convenience initializer.
:name: init
*/
public override init() { public override init() {
shape = .None shape = .None
depth = .None depth = .None
...@@ -211,7 +218,8 @@ public class MaterialLayer : CAShapeLayer { ...@@ -211,7 +218,8 @@ public class MaterialLayer : CAShapeLayer {
} }
/** /**
:name: init An initializer that initializes the object with a CGRect object.
- Parameter frame: A CGRect instance.
*/ */
public convenience init(frame: CGRect) { public convenience init(frame: CGRect) {
self.init() self.init()
...@@ -225,7 +233,8 @@ public class MaterialLayer : CAShapeLayer { ...@@ -225,7 +233,8 @@ public class MaterialLayer : CAShapeLayer {
} }
/** /**
:name: animate A method that accepts CAAnimation objects and executes.
- Parameter animation: A CAAnimation instance.
*/ */
public func animate(animation: CAAnimation) { public func animate(animation: CAAnimation) {
animation.delegate = self animation.delegate = self
...@@ -242,14 +251,21 @@ public class MaterialLayer : CAShapeLayer { ...@@ -242,14 +251,21 @@ public class MaterialLayer : CAShapeLayer {
} }
/** /**
:name: animationDidStart A delegation method that is executed when the layer starts
running an animation.
- Parameter anim: The currently running CAAnimation instance.
*/ */
public override func animationDidStart(anim: CAAnimation) { public override func animationDidStart(anim: CAAnimation) {
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStart?(anim) (delegate as? MaterialAnimationDelegate)?.materialAnimationDidStart?(anim)
} }
/** /**
:name: animationDidStop A delegation method that is executed when the layer stops
running an animation.
- Parameter anim: The CAAnimation instance that stopped running.
- Parameter flag: A boolean that indicates if the animation stopped
because it was completed or interrupted. True if completed, false
if interrupted.
*/ */
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) { public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation { if let a: CAPropertyAnimation = anim as? CAPropertyAnimation {
...@@ -268,9 +284,7 @@ public class MaterialLayer : CAShapeLayer { ...@@ -268,9 +284,7 @@ public class MaterialLayer : CAShapeLayer {
layoutVisualLayer() layoutVisualLayer()
} }
/** /// Prepares the visualLayer property.
:name: prepareVisualLayer
*/
public func prepareVisualLayer() { public func prepareVisualLayer() {
// visualLayer // visualLayer
visualLayer.zPosition = 0 visualLayer.zPosition = 0
...@@ -278,21 +292,17 @@ public class MaterialLayer : CAShapeLayer { ...@@ -278,21 +292,17 @@ public class MaterialLayer : CAShapeLayer {
addSublayer(visualLayer) addSublayer(visualLayer)
} }
/** /// Manages the layout for the visualLayer property.
:name: layoutShape
*/
internal func layoutShape() {
if .Circle == shape {
cornerRadius = width / 2
}
}
/**
:name: layoutVisualLayer
*/
internal func layoutVisualLayer() { internal func layoutVisualLayer() {
visualLayer.frame = bounds visualLayer.frame = bounds
visualLayer.position = CGPointMake(width / 2, height / 2) visualLayer.position = CGPointMake(width / 2, height / 2)
visualLayer.cornerRadius = cornerRadius visualLayer.cornerRadius = cornerRadius
} }
/// Manages the layout for the shape of the layer instance.
internal func layoutShape() {
if .Circle == shape {
cornerRadius = width / 2
}
}
} }
...@@ -49,14 +49,14 @@ public class MaterialPulseView : MaterialView { ...@@ -49,14 +49,14 @@ public class MaterialPulseView : MaterialView {
/// The opcaity value for the pulse animation. /// The opcaity value for the pulse animation.
public var pulseColorOpacity: CGFloat = 0.25 { public var pulseColorOpacity: CGFloat = 0.25 {
didSet { didSet {
updatedPulseLayer() updatePulseLayer()
} }
} }
/// The color of the pulse effect. /// The color of the pulse effect.
public var pulseColor: UIColor? { public var pulseColor: UIColor? {
didSet { didSet {
updatedPulseLayer() updatePulseLayer()
} }
} }
...@@ -154,7 +154,7 @@ public class MaterialPulseView : MaterialView { ...@@ -154,7 +154,7 @@ public class MaterialPulseView : MaterialView {
} }
/// Updates the pulseLayer when settings have changed. /// Updates the pulseLayer when settings have changed.
internal func updatedPulseLayer() { internal func updatePulseLayer() {
pulseLayer.backgroundColor = pulseColor?.colorWithAlphaComponent(pulseColorOpacity).CGColor pulseLayer.backgroundColor = pulseColor?.colorWithAlphaComponent(pulseColorOpacity).CGColor
} }
......
...@@ -25,9 +25,6 @@ public struct MaterialTheme { ...@@ -25,9 +25,6 @@ public struct MaterialTheme {
public struct captureView {} public struct captureView {}
public struct textLayer {} public struct textLayer {}
public struct label {} public struct label {}
public struct flatButton {}
public struct raisedButton {}
public struct fabButton {}
} }
// basicCardView // basicCardView
...@@ -208,95 +205,3 @@ public extension MaterialTheme.label { ...@@ -208,95 +205,3 @@ public extension MaterialTheme.label {
public static var font: UIFont = RobotoFont.regular public static var font: UIFont = RobotoFont.regular
} }
// flatButton
public extension MaterialTheme.flatButton {
// shadow
public static var depth: MaterialDepth = .None
public static var shadowColor: UIColor = MaterialColor.black
// shape
public static var cornerRadius: MaterialRadius = .Radius1
public static var contentInsets: MaterialEdgeInsets = .WideRectangle3
public static var shape: MaterialShape = .None
// border
public static var borderWidth: MaterialBorder = .None
public static var bordercolor: UIColor = MaterialColor.black
// color
public static var backgroundColor: UIColor = MaterialColor.clear
public static var pulseColor: UIColor = MaterialColor.blue.accent3
public static var pulseColorOpacity: CGFloat = 0.25
public static var titleLabelColorForNormalState: UIColor = MaterialColor.blue.accent3
// interaction
public static var userInteractionEnabled: Bool = true
// position
public static var zPosition: CGFloat = 200
// font
public static var titleLabelFont: UIFont = RobotoFont.regular
}
// raisedButton
public extension MaterialTheme.raisedButton {
// shadow
public static var depth: MaterialDepth = .Depth2
public static var shadowColor: UIColor = MaterialColor.black
// shape
public static var cornerRadius: MaterialRadius = .Radius1
public static var contentInsets: MaterialEdgeInsets = .WideRectangle2
public static var shape: MaterialShape = .None
// border
public static var borderWidth: MaterialBorder = .None
public static var bordercolor: UIColor = MaterialColor.black
// color
public static var backgroundColor: UIColor = MaterialColor.blue.accent3
public static var pulseColor: UIColor = MaterialColor.white
public static var pulseColorOpacity: CGFloat = 0.25
public static var titleLabelColorForNormalState: UIColor = MaterialColor.white
// interaction
public static var userInteractionEnabled: Bool = true
// position
public static var zPosition: CGFloat = 200
// font
public static var titleLabelFont: UIFont = RobotoFont.regular
}
// fabButton
public extension MaterialTheme.fabButton {
// shadow
public static var depth: MaterialDepth = .Depth2
public static var shadowColor: UIColor = MaterialColor.black
// shape
public static var contentInsets: MaterialEdgeInsets = .None
public static var shape: MaterialShape = .Circle
// border
public static var borderWidth: MaterialBorder = .None
public static var bordercolor: UIColor = MaterialColor.black
// color
public static var backgroundColor: UIColor = MaterialColor.red.darken1
public static var pulseColor: UIColor = MaterialColor.white
public static var pulseColorOpacity: CGFloat = 0.25
public static var titleLabelColorForNormalState: UIColor = MaterialColor.white
// interaction
public static var userInteractionEnabled: Bool = true
// position
public static var zPosition: CGFloat = 200
// font
public static var titleLabelFont: UIFont = RobotoFont.regular
}
...@@ -20,25 +20,18 @@ import UIKit ...@@ -20,25 +20,18 @@ import UIKit
public class RaisedButton : MaterialButton { public class RaisedButton : MaterialButton {
/** /**
:name: prepareView Prepares the view instance when intialized. When subclassing,
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() { public override func prepareView() {
super.prepareView() super.prepareView()
setTitleColor(MaterialTheme.raisedButton.titleLabelColorForNormalState, forState: .Normal) setTitleColor(MaterialColor.white, forState: .Normal)
titleLabel!.font = MaterialTheme.raisedButton.titleLabelFont backgroundColor = MaterialColor.blue.accent3
depth = .Depth2
userInteractionEnabled = MaterialTheme.raisedButton.userInteractionEnabled cornerRadius = .Radius1
backgroundColor = MaterialTheme.raisedButton.backgroundColor contentInsets = .WideRectangle3
pulseColorOpacity = MaterialTheme.raisedButton.pulseColorOpacity
pulseColor = MaterialTheme.raisedButton.pulseColor
depth = MaterialTheme.raisedButton.depth
shadowColor = MaterialTheme.raisedButton.shadowColor
zPosition = MaterialTheme.raisedButton.zPosition
cornerRadius = MaterialTheme.raisedButton.cornerRadius
borderWidth = MaterialTheme.raisedButton.borderWidth
borderColor = MaterialTheme.raisedButton.bordercolor
contentInsets = MaterialTheme.raisedButton.contentInsets
shape = MaterialTheme.raisedButton.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