From f47ec7f7dab839114471890ed1a3f23763dbbf25 Mon Sep 17 00:00:00 2001 From: Anton Marunko Date: Sat, 8 Feb 2020 15:50:52 +0600 Subject: [PATCH] updated to swift 5.2 --- Source/animation/AnimationProducer.swift | 1 - .../CombinationAnimationGenerator.swift | 4 ++-- Source/model/draw/Color.swift | 5 ++++- Source/model/draw/Gradient.swift | 18 ++++++++---------- Source/model/draw/LinearGradient.swift | 5 ++++- Source/model/draw/RadialGradient.swift | 12 ++++++++++-- Source/svg/SVGParser.swift | 6 +++--- Source/views/MacawView.swift | 10 +++++----- 8 files changed, 36 insertions(+), 25 deletions(-) diff --git a/Source/animation/AnimationProducer.swift b/Source/animation/AnimationProducer.swift index b6c8887d..e4fc0a3e 100644 --- a/Source/animation/AnimationProducer.swift +++ b/Source/animation/AnimationProducer.swift @@ -269,7 +269,6 @@ class AnimationProducer { } let currentDate = Date() - var animationsToRemove = [Animation]() let count = contentsAnimations.count for (index, animationDesc) in contentsAnimations.reversed().enumerated() { diff --git a/Source/animation/types/animation_generators/CombinationAnimationGenerator.swift b/Source/animation/types/animation_generators/CombinationAnimationGenerator.swift index ee38fa7d..7012323c 100644 --- a/Source/animation/types/animation_generators/CombinationAnimationGenerator.swift +++ b/Source/animation/types/animation_generators/CombinationAnimationGenerator.swift @@ -116,12 +116,12 @@ extension AnimationProducer { func addCombineAnimation(_ combineAnimation: Animation, _ context: AnimationContext) { guard let combine = combineAnimation as? CombineAnimation, let renderer = combine.nodeRenderer, - let view = renderer.view else { + let _ = renderer.view else { return } var animations = combine.animations - if let fromBounds = combine.node?.bounds, let toBounds = combine.toNodes.group().bounds { + if let _ = combine.node?.bounds, let _ = combine.toNodes.group().bounds { let childAnimations = createChildAnimations(combine) as! [BasicAnimation] animations.append(contentsOf: childAnimations) } diff --git a/Source/model/draw/Color.swift b/Source/model/draw/Color.swift index 3229fc88..e726e7a4 100644 --- a/Source/model/draw/Color.swift +++ b/Source/model/draw/Color.swift @@ -190,7 +190,10 @@ open class Color: Fill { return rgbt( r: r, g: g, b: b, t: 0 ) } - override func equals(other: T) -> Bool where T: Color { + override func equals(other: T) -> Bool where T: Fill { + guard let other = other as? Color else { + return false + } return val == other.val } } diff --git a/Source/model/draw/Gradient.swift b/Source/model/draw/Gradient.swift index c82a065b..75cbe937 100644 --- a/Source/model/draw/Gradient.swift +++ b/Source/model/draw/Gradient.swift @@ -8,17 +8,15 @@ open class Gradient: Fill { self.stops = stops } - override func equals(other: T) -> Bool where T: Gradient { - if userSpace == other.userSpace { - - if stops.isEmpty && other.stops.isEmpty { - return true - } - - return stops.elementsEqual(other.stops) - - } else { + override func equals(other: T) -> Bool where T: Fill { + guard let other = other as? Gradient, userSpace == other.userSpace else { return false } + + if stops.isEmpty && other.stops.isEmpty { + return true + } + + return stops.elementsEqual(other.stops) } } diff --git a/Source/model/draw/LinearGradient.swift b/Source/model/draw/LinearGradient.swift index c7924030..b0a92f41 100644 --- a/Source/model/draw/LinearGradient.swift +++ b/Source/model/draw/LinearGradient.swift @@ -52,7 +52,10 @@ open class LinearGradient: Gradient { ) } - override func equals(other: T) -> Bool where T: LinearGradient { + override func equals(other: T) -> Bool where T: Fill { + guard let other = other as? LinearGradient else { + return false + } return super.equals(other: other) && x1 == other.x1 && x2 == other.x2 && y1 == other.y1 && y2 == other.y2 } } diff --git a/Source/model/draw/RadialGradient.swift b/Source/model/draw/RadialGradient.swift index 4e98df86..90bad736 100644 --- a/Source/model/draw/RadialGradient.swift +++ b/Source/model/draw/RadialGradient.swift @@ -18,7 +18,15 @@ open class RadialGradient: Gradient { ) } - override func equals(other: T) -> Bool where T: RadialGradient { - return super.equals(other: other) && cx == other.cx && cy == other.cy && fx == other.fx && fy == other.fy && r == other.r + override func equals(other: T) -> Bool where T: Fill { + guard let other = other as? RadialGradient else { + return false + } + let cxEquals = cx == other.cx + let cyEquals = cy == other.cy + let fxEquals = fx == other.fx + let fyEquals = fy == other.fy + let rEquals = r == other.r + return super.equals(other: other) && cxEquals && cyEquals && fxEquals && fyEquals && rEquals } } diff --git a/Source/svg/SVGParser.swift b/Source/svg/SVGParser.swift index e4bf1630..f3e0a7c6 100644 --- a/Source/svg/SVGParser.swift +++ b/Source/svg/SVGParser.swift @@ -465,7 +465,7 @@ open class SVGParser { if let units = element.allAttributes["patternContentUnits"]?.text, units == "objectBoundingBox" { contentUserSpace = false } - + var contentNode: Node? if pattern.children.isEmpty { if let parentPattern = parentPattern { @@ -483,7 +483,7 @@ open class SVGParser { } contentNode = Group(contents: shapes) } - + return UserSpacePattern(content: contentNode!, bounds: bounds, userSpace: userSpace, @@ -1599,7 +1599,7 @@ open class SVGParser { guard let element = stop.element else { return .none } - + var offset: Double = 0 // This is default value, value can be omitted if let parsedOffset = getDoubleValueFromPercentage(element, attribute: "offset") { offset = parsedOffset diff --git a/Source/views/MacawView.swift b/Source/views/MacawView.swift index 0b918eb9..2b208498 100644 --- a/Source/views/MacawView.swift +++ b/Source/views/MacawView.swift @@ -101,12 +101,12 @@ open class MacawView: MView, MGestureRecognizerDelegate { #if os(OSX) open override var layer: CALayer? { didSet { - guard self.layer != nil else { - return - } - initializeView() + guard self.layer != nil else { + return + } + initializeView() - self.renderer = RenderUtils.createNodeRenderer(node, view: self) + self.renderer = RenderUtils.createNodeRenderer(node, view: self) } } #endif