Commit dd004d08 by Daniel Dahan

MaterialLayer is now Layer and updated for Switch 2.3

parent 6efe0a94
......@@ -58,7 +58,7 @@
96BCB7C61CB40DC500C806FE /* Icon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB77D1CB40DC500C806FE /* Icon.swift */; };
96BCB7C71CB40DC500C806FE /* MaterialKeyframeAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB77E1CB40DC500C806FE /* MaterialKeyframeAnimation.swift */; };
96BCB7C81CB40DC500C806FE /* MaterialLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB77F1CB40DC500C806FE /* MaterialLabel.swift */; };
96BCB7C91CB40DC500C806FE /* MaterialLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7801CB40DC500C806FE /* MaterialLayer.swift */; };
96BCB7C91CB40DC500C806FE /* Layer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7801CB40DC500C806FE /* Layer.swift */; };
96BCB7CA1CB40DC500C806FE /* Layout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7811CB40DC500C806FE /* Layout.swift */; };
96BCB7CB1CB40DC500C806FE /* MaterialPulseAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7821CB40DC500C806FE /* MaterialPulseAnimation.swift */; };
96BCB7CD1CB40DC500C806FE /* PulseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7841CB40DC500C806FE /* PulseView.swift */; };
......@@ -137,7 +137,7 @@
96BCB8311CB4115200C806FE /* MaterialFont.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB77B1CB40DC500C806FE /* MaterialFont.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8321CB4115200C806FE /* RobotoFont.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7941CB40DC500C806FE /* RobotoFont.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8331CB4115200C806FE /* Icon.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB77D1CB40DC500C806FE /* Icon.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8341CB4115200C806FE /* MaterialLayer.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7801CB40DC500C806FE /* MaterialLayer.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8341CB4115200C806FE /* Layer.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7801CB40DC500C806FE /* Layer.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8351CB4115200C806FE /* MaterialTextLayer.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB78A1CB40DC500C806FE /* MaterialTextLayer.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8361CB4115200C806FE /* Grid.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7611CB40DC500C806FE /* Grid.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8371CB4115200C806FE /* Layout.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7811CB40DC500C806FE /* Layout.swift */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -249,7 +249,7 @@
96BCB77D1CB40DC500C806FE /* Icon.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Icon.swift; sourceTree = "<group>"; };
96BCB77E1CB40DC500C806FE /* MaterialKeyframeAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialKeyframeAnimation.swift; sourceTree = "<group>"; };
96BCB77F1CB40DC500C806FE /* MaterialLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialLabel.swift; sourceTree = "<group>"; };
96BCB7801CB40DC500C806FE /* MaterialLayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialLayer.swift; sourceTree = "<group>"; };
96BCB7801CB40DC500C806FE /* Layer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Layer.swift; sourceTree = "<group>"; };
96BCB7811CB40DC500C806FE /* Layout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Layout.swift; sourceTree = "<group>"; };
96BCB7821CB40DC500C806FE /* MaterialPulseAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialPulseAnimation.swift; sourceTree = "<group>"; };
96BCB7841CB40DC500C806FE /* PulseView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PulseView.swift; sourceTree = "<group>"; };
......@@ -610,7 +610,7 @@
96BCB80D1CB410FD00C806FE /* Layer */ = {
isa = PBXGroup;
children = (
96BCB7801CB40DC500C806FE /* MaterialLayer.swift */,
96BCB7801CB40DC500C806FE /* Layer.swift */,
96BCB78A1CB40DC500C806FE /* MaterialTextLayer.swift */,
);
name = Layer;
......@@ -694,7 +694,7 @@
96BCB8311CB4115200C806FE /* MaterialFont.swift in Headers */,
96BCB8321CB4115200C806FE /* RobotoFont.swift in Headers */,
96BCB8331CB4115200C806FE /* Icon.swift in Headers */,
96BCB8341CB4115200C806FE /* MaterialLayer.swift in Headers */,
96BCB8341CB4115200C806FE /* Layer.swift in Headers */,
96BCB8351CB4115200C806FE /* MaterialTextLayer.swift in Headers */,
96BCB8361CB4115200C806FE /* Grid.swift in Headers */,
96BCB8371CB4115200C806FE /* Layout.swift in Headers */,
......@@ -960,7 +960,7 @@
96BCB7B11CB40DC500C806FE /* Material+UIImage+Crop.swift in Sources */,
96BCB7B81CB40DC500C806FE /* MaterialBorder.swift in Sources */,
96BCB7A61CB40DC500C806FE /* CardView.swift in Sources */,
96BCB7C91CB40DC500C806FE /* MaterialLayer.swift in Sources */,
96BCB7C91CB40DC500C806FE /* Layer.swift in Sources */,
96BCB7E21CB40DC500C806FE /* RootController.swift in Sources */,
96BCB7DC1CB40DC500C806FE /* RaisedButton.swift in Sources */,
96BCB7DD1CB40DC500C806FE /* RobotoFont.swift in Sources */,
......
......@@ -326,7 +326,6 @@ public struct Color {
public static let accent4: NSColor = NSColor(red: 255/255, green: 109/255, blue: 0/255, alpha: 1)
}
// deep orange
public struct deepOrange {
public static let lighten5: NSColor = NSColor(red: 251/255, green: 233/255, blue: 231/255, alpha: 1)
......@@ -345,7 +344,6 @@ public struct Color {
public static let accent4: NSColor = NSColor(red: 221/255, green: 44/255, blue: 0/255, alpha: 1)
}
// brown
public struct brown {
public static let lighten5: NSColor = NSColor(red: 239/255, green: 235/255, blue: 233/255, alpha: 1)
......
......@@ -223,13 +223,13 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
public private(set) var captureSession: CaptureSession!
/// A reference to the focus layer used in focus animations.
public private(set) var focusLayer: MaterialLayer?
public private(set) var focusLayer: Layer?
/// A reference to the exposure layer used in exposure animations.
public private(set) var exposureLayer: MaterialLayer?
public private(set) var exposureLayer: Layer?
/// A reference to the reset layer used in reset animations.
public private(set) var resetLayer: MaterialLayer?
public private(set) var resetLayer: Layer?
/// A reference to the cameraButton.
public var cameraButton: UIButton? {
......@@ -513,7 +513,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
/// Prepares the focusLayer.
private func prepareFocusLayer() {
if nil == focusLayer {
focusLayer = MaterialLayer(frame: CGRect(x: 0, y: 0, width: 150, height: 150))
focusLayer = Layer(frame: CGRect(x: 0, y: 0, width: 150, height: 150))
focusLayer!.isHidden = true
focusLayer!.borderWidth = 2
focusLayer!.borderColor = Color.white.cgColor
......@@ -524,7 +524,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
/// Prepares the exposureLayer.
private func prepareExposureLayer() {
if nil == exposureLayer {
exposureLayer = MaterialLayer(frame: CGRect(x: 0, y: 0, width: 150, height: 150))
exposureLayer = Layer(frame: CGRect(x: 0, y: 0, width: 150, height: 150))
exposureLayer!.isHidden = true
exposureLayer!.borderWidth = 2
exposureLayer!.borderColor = Color.yellow.darken1.cgColor
......@@ -535,7 +535,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
/// Prepares the resetLayer.
private func prepareResetLayer() {
if nil == resetLayer {
resetLayer = MaterialLayer(frame: CGRect(x: 0, y: 0, width: 150, height: 150))
resetLayer = Layer(frame: CGRect(x: 0, y: 0, width: 150, height: 150))
resetLayer!.isHidden = true
resetLayer!.borderWidth = 2
resetLayer!.borderColor = Color.red.accent1.cgColor
......@@ -544,7 +544,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
}
/// Animates the tap and layer.
private func animateTapLayer(layer v: MaterialLayer, point: CGPoint) {
private func animateTapLayer(layer v: Layer, point: CGPoint) {
MaterialAnimation.animationDisabled {
v.transform = CATransform3DIdentity
v.position = point
......
......@@ -33,8 +33,8 @@ import UIKit
@objc(MaterialDelegate)
public protocol MaterialDelegate {}
@objc(MaterialLayer)
public class MaterialLayer : CAShapeLayer {
@objc(Layer)
public class Layer: CAShapeLayer {
/**
A CAShapeLayer used to manage elements that would be affected by
the clipToBounds property of the backing layer. For example, this
......@@ -106,7 +106,7 @@ public class MaterialLayer : CAShapeLayer {
*/
@IBInspectable public var image: UIImage? {
didSet {
visualLayer.contents = image?.CGImage
visualLayer.contents = image?.cgImage
}
}
......@@ -146,7 +146,7 @@ public class MaterialLayer : CAShapeLayer {
/// A Preset for the contentsGravity property.
public var contentsGravityPreset: MaterialGravity {
didSet {
contentsGravity = MaterialGravityToValue(contentsGravityPreset)
contentsGravity = MaterialGravityToValue(gravity: contentsGravityPreset)
}
}
......@@ -176,7 +176,7 @@ public class MaterialLayer : CAShapeLayer {
*/
public var depth: MaterialDepth = .None {
didSet {
let value: MaterialDepthType = MaterialDepthToValue(depth)
let value: MaterialDepthType = MaterialDepthToValue(depth: depth)
shadowOffset = value.offset
shadowOpacity = value.opacity
shadowRadius = value.radius
......@@ -192,7 +192,7 @@ public class MaterialLayer : CAShapeLayer {
public var cornerRadiusPreset: MaterialRadius = .None {
didSet {
if let v: MaterialRadius = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(v)
cornerRadius = MaterialRadiusToValue(radius: v)
}
}
}
......@@ -232,7 +232,7 @@ public class MaterialLayer : CAShapeLayer {
/// A preset property to set the borderWidth.
public var borderWidthPreset: MaterialBorder = .None {
didSet {
borderWidth = MaterialBorderToValue(borderWidthPreset)
borderWidth = MaterialBorderToValue(border: borderWidthPreset)
}
}
......@@ -287,24 +287,24 @@ public class MaterialLayer : CAShapeLayer {
public func animate(animation: CAAnimation) {
animation.delegate = self
if let a: CABasicAnimation = animation as? CABasicAnimation {
a.fromValue = (nil == presentationLayer() ? self : presentationLayer() as! CALayer).valueForKeyPath(a.keyPath!)
a.fromValue = (nil == presentation() ? self : presentation()!).value(forKeyPath: a.keyPath!)
}
if let a: CAPropertyAnimation = animation as? CAPropertyAnimation {
addAnimation(a, forKey: a.keyPath!)
add(a, forKey: a.keyPath!)
} else if let a: CAAnimationGroup = animation as? CAAnimationGroup {
addAnimation(a, forKey: nil)
add(a, forKey: nil)
} else if let a: CATransition = animation as? CATransition {
addAnimation(a, forKey: kCATransition)
add(a, forKey: kCATransition)
}
}
/**
A delegation method that is executed when the layer starts
running an animation.
- Parameter anim: The currently running CAAnimation instance.
- Parameter animation: The currently running CAAnimation instance.
*/
public override func animationDidStart(anim: CAAnimation) {
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStart?(anim)
public override func animationDidStart(_ animation: CAAnimation) {
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStart?(animation: animation)
}
/**
......@@ -315,18 +315,18 @@ public class MaterialLayer : CAShapeLayer {
because it was completed or interrupted. True if completed, false
if interrupted.
*/
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation {
public override func animationDidStop(_ animation: CAAnimation, finished flag: Bool) {
if let a: CAPropertyAnimation = animation as? CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
if let v: AnyObject = b.toValue {
if let k: String = b.keyPath {
setValue(v, forKeyPath: k)
removeAnimationForKey(k)
removeAnimation(forKey: k)
}
}
}
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(animation: animation, finished: flag)
} else if let a: CAAnimationGroup = animation as? CAAnimationGroup {
for x in a.animations! {
animationDidStop(x, finished: true)
}
......@@ -363,9 +363,9 @@ public class MaterialLayer : CAShapeLayer {
if .None == depth {
shadowPath = nil
} else if nil == shadowPath {
shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath
} else {
animate(MaterialAnimation.shadowPath(UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath, duration: 0))
animate(animation: MaterialAnimation.shadowPath(path: UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath, duration: 0))
}
}
}
......
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