mirror of
https://github.com/exyte/Macaw.git
synced 2024-09-11 13:15:35 +03:00
Swift 4.1 adaptation
This commit is contained in:
parent
5003c54654
commit
45dbffc1b7
@ -1,2 +1,2 @@
|
||||
4.0
|
||||
4.1
|
||||
|
||||
|
@ -29,7 +29,7 @@ Pod::Spec.new do |s|
|
||||
s.ios.deployment_target = "9.0"
|
||||
s.osx.deployment_target = "10.12"
|
||||
s.requires_arc = true
|
||||
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' }
|
||||
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.1' }
|
||||
|
||||
s.source_files = [
|
||||
'Source/**/*.swift'
|
||||
|
@ -40,7 +40,7 @@ func boundsWithDerivative(p0: Point, p1: Point, p2: Point, p3: Point) -> Rect? {
|
||||
let cy = 3 * p1.y - 3 * p0.y
|
||||
let sy = solveEquation(a: ay, b: by, c: cy)
|
||||
|
||||
let solutions = [0, 1, sx.s1, sx.s2, sy.s1, sy.s2].flatMap { $0 }
|
||||
let solutions = [0, 1, sx.s1, sx.s2, sy.s1, sy.s2].compactMap { $0 }
|
||||
var minX: Double? = .none
|
||||
var minY: Double? = .none
|
||||
var maxX: Double? = .none
|
||||
|
@ -84,8 +84,8 @@ public extension AnimatableVariable where T: ContentsInterpolation {
|
||||
}
|
||||
|
||||
// Shapes on same hierarhy level
|
||||
let fromShapes = fromNode.contents.flatMap { $0 as? Shape }
|
||||
let toShapes = to.flatMap { $0 as? Shape }
|
||||
let fromShapes = fromNode.contents.compactMap { $0 as? Shape }
|
||||
let toShapes = to.compactMap { $0 as? Shape }
|
||||
let minPathsNumber = min(fromShapes.count, toShapes.count)
|
||||
|
||||
var animations = [Animation]()
|
||||
@ -117,8 +117,8 @@ public extension AnimatableVariable where T: ContentsInterpolation {
|
||||
}
|
||||
|
||||
// Groups on same hierahy level
|
||||
let fromGroups = fromNode.contents.flatMap { $0 as? Group }
|
||||
let toGroups = to.flatMap { $0 as? Group }
|
||||
let fromGroups = fromNode.contents.compactMap { $0 as? Group }
|
||||
let toGroups = to.compactMap { $0 as? Group }
|
||||
let minGroupsNumber = min(fromGroups.count, toGroups.count)
|
||||
for i in 0..<minGroupsNumber {
|
||||
let fromGroup = fromGroups[i]
|
||||
|
@ -56,7 +56,7 @@ open class Node: Drawable {
|
||||
}
|
||||
|
||||
public func nodesBy(tag: String) -> [Node] {
|
||||
return [nodeBy(tag: tag)].flatMap { $0 }
|
||||
return [nodeBy(tag: tag)].compactMap { $0 }
|
||||
}
|
||||
|
||||
// MARK: - Events
|
||||
|
@ -60,7 +60,7 @@ class GroupRenderer: NodeRenderer {
|
||||
renderers.forEach { $0.dispose() }
|
||||
renderers.removeAll()
|
||||
|
||||
if let updatedRenderers = group?.contents.flatMap ({ child -> NodeRenderer? in
|
||||
if let updatedRenderers = group?.contents.compactMap ({ child -> NodeRenderer? in
|
||||
guard let interval = renderingInterval else {
|
||||
return RenderUtils.createNodeRenderer(child, context: ctx, animationCache: animationCache)
|
||||
}
|
||||
|
@ -103,19 +103,19 @@ open class SVGSerializer {
|
||||
}
|
||||
|
||||
fileprivate func polygonToSVG(_ polygon: Polygon) -> String {
|
||||
let points = polygon.points.flatMap { String($0) }.joined(separator: ",")
|
||||
let points = polygon.points.compactMap { String($0) }.joined(separator: ",")
|
||||
return tag(SVGPolygonOpenTag, ["points": points])
|
||||
}
|
||||
|
||||
fileprivate func polylineToSVG(_ polyline: Polyline) -> String {
|
||||
let points = polyline.points.flatMap { String($0) }.joined(separator: ",")
|
||||
let points = polyline.points.compactMap { String($0) }.joined(separator: ",")
|
||||
return tag(SVGPolylineOpenTag, ["points": points])
|
||||
}
|
||||
|
||||
fileprivate func pathToSVG(_ path: Path) -> String {
|
||||
var d = ""
|
||||
for segment in path.segments {
|
||||
d += "\(segment.type) \(segment.data.flatMap { String(Int($0)) }.joined(separator: " "))"
|
||||
d += "\(segment.type) \(segment.data.compactMap { String(Int($0)) }.joined(separator: " "))"
|
||||
}
|
||||
return tag(SVGPathOpenTag, ["d": d])
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user