Commit 7407d97f by Daniel Dahan

Swift 2.3 progression commit

parent f778d3dc
......@@ -56,9 +56,9 @@ public class Button: UIButton {
@IBInspectable public var pulseColor: UIColor = Color.grey.base
/// The type of PulseAnimation.
public var pulseAnimation: PulseAnimation = .AtPointWithBacking {
public var pulseAnimation: PulseAnimation = .pointWithBacking {
didSet {
visualLayer.masksToBounds = .CenterRadialBeyondBounds != pulseAnimation
visualLayer.masksToBounds = .centerRadialBeyondBounds != pulseAnimation
}
}
......
......@@ -141,7 +141,7 @@ public extension UIImage {
// Add in color tint.
if let v: UIColor = tintColor {
CGContextSaveGState(outputContext)
CGContextSetFillColorWithColor(outputContext, v.CGColor)
CGContextSetFillColorWithColor(outputContext, v.cgColor)
CGContextFillRect(outputContext, imageRect)
CGContextRestoreGState(outputContext)
}
......
......@@ -36,9 +36,9 @@ public extension MaterialAnimation {
*/
public static func backgroundColor(color: UIColor, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation: CABasicAnimation = CABasicAnimation(keyPath: "backgroundColor")
animation.toValue = color.CGColor
animation.fillMode = MaterialAnimationFillModeToValue(.Forwards)
animation.removedOnCompletion = false
animation.toValue = color.cgColor
animation.fillMode = MaterialAnimationFillModeToValue(mode: .Forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
if let v: CFTimeInterval = duration {
animation.duration = v
......@@ -53,7 +53,7 @@ public extension MaterialAnimation {
let animation: CABasicAnimation = CABasicAnimation(keyPath: "cornerRadius")
animation.toValue = radius
animation.fillMode = MaterialAnimationFillModeToValue(.Forwards)
animation.removedOnCompletion = false
animation.isRemovedOnCompletion = false
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
if let v: CFTimeInterval = duration {
animation.duration = v
......@@ -68,7 +68,7 @@ public extension MaterialAnimation {
let animation: CABasicAnimation = CABasicAnimation(keyPath: "transform")
animation.toValue = NSValue(CATransform3D: transform)
animation.fillMode = MaterialAnimationFillModeToValue(.Forwards)
animation.removedOnCompletion = false
animation.isRemovedOnCompletion = false
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
if let v: CFTimeInterval = duration {
animation.duration = v
......@@ -298,4 +298,4 @@ public extension MaterialAnimation {
}
return animation
}
}
\ No newline at end of file
}
......@@ -56,9 +56,9 @@ public class MaterialCollectionReusableView : UICollectionReusableView {
@IBInspectable public var pulseColor: UIColor = Color.grey.base
/// The type of PulseAnimation.
public var pulseAnimation: PulseAnimation = .AtPointWithBacking {
public var pulseAnimation: PulseAnimation = .pointWithBacking {
didSet {
visualLayer.masksToBounds = .CenterRadialBeyondBounds != pulseAnimation
visualLayer.masksToBounds = .centerRadialBeyondBounds != pulseAnimation
}
}
......@@ -187,7 +187,7 @@ public class MaterialCollectionReusableView : UICollectionReusableView {
/// A property that accesses the backing layer's backgroundColor.
@IBInspectable public override var backgroundColor: UIColor? {
didSet {
layer.backgroundColor = backgroundColor?.CGColor
layer.backgroundColor = backgroundColor?.cgColor
}
}
......@@ -250,7 +250,7 @@ public class MaterialCollectionReusableView : UICollectionReusableView {
/// A property that accesses the backing layer's shadowColor.
@IBInspectable public var shadowColor: UIColor? {
didSet {
layer.shadowColor = shadowColor?.CGColor
layer.shadowColor = shadowColor?.cgColor
}
}
......@@ -366,7 +366,7 @@ public class MaterialCollectionReusableView : UICollectionReusableView {
/// A preset property to set the borderWidth.
public var borderWidthPreset: MaterialBorder = .None {
didSet {
borderWidth = MaterialBorderToValue(borderWidthPreset)
borderWidth = MaterialBorderToValue(border: borderWidthPreset)
}
}
......@@ -383,10 +383,10 @@ public class MaterialCollectionReusableView : UICollectionReusableView {
/// A property that accesses the layer.borderColor property.
@IBInspectable public var borderColor: UIColor? {
get {
return nil == layer.borderColor ? nil : UIColor(CGColor: layer.borderColor!)
return nil == layer.borderColor ? nil : UIColor(cgColor: layer.borderColor!)
}
set(value) {
layer.borderColor = value?.CGColor
layer.borderColor = value?.cgColor
}
}
......@@ -415,7 +415,7 @@ public class MaterialCollectionReusableView : UICollectionReusableView {
- Parameter aDecoder: A NSCoder instance.
*/
public required init?(coder aDecoder: NSCoder) {
depth = .None
depthPreset = .none
cornerRadiusPreset = .None
shape = .None
contentsGravityPreset = .ResizeAspectFill
......@@ -430,7 +430,7 @@ public class MaterialCollectionReusableView : UICollectionReusableView {
- Parameter frame: A CGRect instance.
*/
public override init(frame: CGRect) {
depth = .None
depthPreset = .none
cornerRadiusPreset = .None
shape = .None
contentsGravityPreset = .ResizeAspectFill
......@@ -443,8 +443,8 @@ public class MaterialCollectionReusableView : UICollectionReusableView {
self.init(frame: CGRect.zero)
}
public override func layoutSublayersOfLayer(layer: CALayer) {
super.layoutSublayersOfLayer(layer)
public override func layoutSublayers(of layer: CALayer) {
super.layoutSublayers(of: layer)
if self.layer == layer {
layoutShape()
layoutVisualLayer()
......@@ -498,7 +498,7 @@ public class MaterialCollectionReusableView : UICollectionReusableView {
if let v: AnyObject = b.toValue {
if let k: String = b.keyPath {
layer.setValue(v, forKeyPath: k)
layer.removeAnimationForKey(k)
layer.removeAnimation(forKey: k)
}
}
}
......@@ -531,9 +531,9 @@ public class MaterialCollectionReusableView : UICollectionReusableView {
- Parameter touches: A set of UITouch objects.
- Parameter event: A UIEvent object.
*/
public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event)
MaterialAnimation.pulseExpandAnimation(layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseOpacity: pulseOpacity, point: layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer), width: width, height: height, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation)
public override func touchesBegan(touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
MaterialAnimation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseOpacity: pulseOpacity, point: layer.convert(touches.first!.location(in: self), from: layer), width: width, height: height, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation)
}
/**
......@@ -542,9 +542,9 @@ public class MaterialCollectionReusableView : UICollectionReusableView {
- Parameter touches: A set of UITouch objects.
- Parameter event: A UIEvent object.
*/
public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event)
MaterialAnimation.pulseContractAnimation(layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation)
public override func touchesEnded(touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event)
MaterialAnimation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation)
}
/**
......@@ -553,9 +553,9 @@ public class MaterialCollectionReusableView : UICollectionReusableView {
- Parameter touches: A set of UITouch objects.
- Parameter event: A UIEvent object.
*/
public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
super.touchesCancelled(touches, withEvent: event)
MaterialAnimation.pulseContractAnimation(layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation)
public override func touchesCancelled(touches: Set<UITouch>, with event: UIEvent?) {
super.touchesCancelled(touches, with: event)
MaterialAnimation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation)
}
/**
......@@ -567,7 +567,7 @@ public class MaterialCollectionReusableView : UICollectionReusableView {
*/
public func prepareView() {
contentScaleFactor = Device.scale
pulseAnimation = .None
pulseAnimation = .none
prepareVisualLayer()
}
......@@ -597,12 +597,12 @@ public class MaterialCollectionReusableView : UICollectionReusableView {
/// Sets the shadow path.
internal func layoutShadowPath() {
if shadowPathAutoSizeEnabled {
if .None == depth {
if .none == depthPreset {
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))
}
}
}
......
......@@ -56,9 +56,9 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
@IBInspectable public var pulseColor: UIColor = Color.grey.base
/// The type of PulseAnimation.
public var pulseAnimation: PulseAnimation = .AtPointWithBacking {
public var pulseAnimation: PulseAnimation = .pointWithBacking {
didSet {
visualLayer.masksToBounds = .CenterRadialBeyondBounds != pulseAnimation
visualLayer.masksToBounds = .centerRadialBeyondBounds != pulseAnimation
}
}
......@@ -187,7 +187,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
/// A property that accesses the backing layer's backgroundColor.
@IBInspectable public override var backgroundColor: UIColor? {
didSet {
layer.backgroundColor = backgroundColor?.CGColor
layer.backgroundColor = backgroundColor?.cgColor
}
}
......@@ -250,7 +250,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
/// A property that accesses the backing layer's shadowColor.
@IBInspectable public var shadowColor: UIColor? {
didSet {
layer.shadowColor = shadowColor?.CGColor
layer.shadowColor = shadowColor?.cgColor
}
}
......@@ -383,10 +383,10 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
/// A property that accesses the layer.borderColor property.
@IBInspectable public var borderColor: UIColor? {
get {
return nil == layer.borderColor ? nil : UIColor(CGColor: layer.borderColor!)
return nil == layer.borderColor ? nil : UIColor(cgColor: layer.borderColor!)
}
set(value) {
layer.borderColor = value?.CGColor
layer.borderColor = value?.cgColor
}
}
......
......@@ -55,9 +55,9 @@ public class MaterialTableViewCell : UITableViewCell {
@IBInspectable public var pulseColor: UIColor = Color.grey.base
/// The type of PulseAnimation.
public var pulseAnimation: PulseAnimation = .AtPointWithBacking {
public var pulseAnimation: PulseAnimation = .pointWithBacking {
didSet {
visualLayer.masksToBounds = .CenterRadialBeyondBounds != pulseAnimation
visualLayer.masksToBounds = .centerRadialBeyondBounds != pulseAnimation
}
}
......@@ -79,7 +79,7 @@ public class MaterialTableViewCell : UITableViewCell {
/// A property that accesses the backing layer's backgroundColor.
@IBInspectable public override var backgroundColor: UIColor? {
didSet {
layer.backgroundColor = backgroundColor?.CGColor
layer.backgroundColor = backgroundColor?.cgColor
}
}
......@@ -136,7 +136,7 @@ public class MaterialTableViewCell : UITableViewCell {
/// A property that accesses the backing layer's shadowColor.
@IBInspectable public var shadowColor: UIColor? {
didSet {
layer.shadowColor = shadowColor?.CGColor
layer.shadowColor = shadowColor?.cgColor
}
}
......@@ -189,20 +189,25 @@ public class MaterialTableViewCell : UITableViewCell {
}
}
/**
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 depthPreset = .none {
didSet {
let value: Depth = DepthPresetToValue(preset)
shadowOffset = value.offset
shadowOpacity = value.opacity
shadowRadius = value.radius
layoutShadowPath()
}
}
/// A preset value for Depth.
public var depthPreset: DepthPreset = .none {
didSet {
depth = DepthPresetToValue(preset: depthPreset)
}
}
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer.
*/
public var depth = Depth.zero {
didSet {
shadowOffset = depth.offset.asSize
shadowOpacity = depth.opacity
shadowRadius = depth.radius
layoutShadowPath()
}
}
/**
A property that sets the cornerRadius of the backing layer. If the shape
......@@ -212,7 +217,7 @@ public class MaterialTableViewCell : UITableViewCell {
public var cornerRadiusPreset: MaterialRadius = .None {
didSet {
if let v: MaterialRadius = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(v)
cornerRadius = MaterialRadiusToValue(radius: v)
}
}
}
......@@ -231,7 +236,7 @@ public class MaterialTableViewCell : UITableViewCell {
/// A preset property to set the borderWidth.
public var borderWidthPreset: MaterialBorder = .None {
didSet {
borderWidth = MaterialBorderToValue(borderWidthPreset)
borderWidth = MaterialBorderToValue(border: borderWidthPreset)
}
}
......@@ -248,10 +253,10 @@ public class MaterialTableViewCell : UITableViewCell {
/// A property that accesses the layer.borderColor property.
@IBInspectable public var borderColor: UIColor? {
get {
return nil == layer.borderColor ? nil : UIColor(CGColor: layer.borderColor!)
return nil == layer.borderColor ? nil : UIColor(cgColor: layer.borderColor!)
}
set(value) {
layer.borderColor = value?.CGColor
layer.borderColor = value?.cgColor
}
}
......
......@@ -66,7 +66,7 @@ public class MaterialTextLayer : CATextLayer {
*/
@IBInspectable public var textColor: UIColor? {
didSet {
foregroundColor = textColor?.CGColor
foregroundColor = textColor?.cgColor
}
}
......
......@@ -187,7 +187,7 @@ public class NavigationBar : UINavigationBar {
/// A property that accesses the backing layer's shadowColor.
@IBInspectable public var shadowColor: UIColor? {
didSet {
layer.shadowColor = shadowColor?.CGColor
layer.shadowColor = shadowColor?.cgColor
}
}
......@@ -255,10 +255,10 @@ public class NavigationBar : UINavigationBar {
/// A property that accesses the layer.borderColor property.
@IBInspectable public var borderColor: UIColor? {
get {
return nil == layer.borderColor ? nil : UIColor(CGColor: layer.borderColor!)
return nil == layer.borderColor ? nil : UIColor(cgColor: layer.borderColor!)
}
set(value) {
layer.borderColor = value?.CGColor
layer.borderColor = value?.cgColor
}
}
......
......@@ -41,9 +41,9 @@ public class PulseView: View {
@IBInspectable public var pulseColor: UIColor = Color.grey.base
/// The type of PulseAnimation.
public var pulseAnimation: PulseAnimation = .AtPointWithBacking {
public var pulseAnimation: PulseAnimation = .pointWithBacking {
didSet {
visualLayer.masksToBounds = .CenterRadialBeyondBounds != pulseAnimation
visualLayer.masksToBounds = .centerRadialBeyondBounds != pulseAnimation
}
}
......
......@@ -53,7 +53,7 @@ public class TextField : UITextField {
/// A property that accesses the backing layer's backgroundColor.
@IBInspectable public override var backgroundColor: UIColor? {
didSet {
layer.backgroundColor = backgroundColor?.CGColor
layer.backgroundColor = backgroundColor?.cgColor
}
}
......@@ -130,7 +130,7 @@ public class TextField : UITextField {
@IBInspectable public var dividerColor: UIColor = Color.darkText.dividers {
didSet {
if !editing {
divider.backgroundColor = dividerColor.CGColor
divider.backgroundColor = dividerColor.cgColor
}
}
}
......@@ -140,7 +140,7 @@ public class TextField : UITextField {
didSet {
if let v: UIColor = dividerActiveColor {
if editing {
divider.backgroundColor = v.CGColor
divider.backgroundColor = v.cgColor
}
}
}
......@@ -552,13 +552,13 @@ public class TextField : UITextField {
/// The animation for the divider when editing begins.
public func dividerEditingDidBeginAnimation() {
divider.frame.size.height = dividerActiveHeight
divider.backgroundColor = nil == dividerActiveColor ? placeholderActiveColor.CGColor : dividerActiveColor!.CGColor
divider.backgroundColor = nil == dividerActiveColor ? placeholderActiveColor.cgColor : dividerActiveColor!.cgColor
}
/// The animation for the divider when editing ends.
public func dividerEditingDidEndAnimation() {
divider.frame.size.height = dividerHeight
divider.backgroundColor = dividerColor.CGColor
divider.backgroundColor = dividerColor.cgColor
}
/// The animation for the placeholder when editing begins.
......
......@@ -52,7 +52,7 @@ public class TextView: UITextView {
/// A property that accesses the backing layer's backgroundColor.
@IBInspectable public override var backgroundColor: UIColor? {
didSet {
layer.backgroundColor = backgroundColor?.CGColor
layer.backgroundColor = backgroundColor?.cgColor
}
}
......@@ -99,7 +99,7 @@ public class TextView: UITextView {
/// A property that accesses the backing layer's shadowColor.
@IBInspectable public var shadowColor: UIColor? {
didSet {
layer.shadowColor = shadowColor?.CGColor
layer.shadowColor = shadowColor?.cgColor
}
}
......@@ -207,10 +207,10 @@ public class TextView: UITextView {
/// A property that accesses the layer.borderColor property.
@IBInspectable public var borderColor: UIColor? {
get {
return nil == layer.borderColor ? nil : UIColor(CGColor: layer.borderColor!)
return nil == layer.borderColor ? nil : UIColor(cgColor: layer.borderColor!)
}
set(value) {
layer.borderColor = value?.CGColor
layer.borderColor = value?.cgColor
}
}
......
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