Skip to content

Commit 62032eb

Browse files
committed
Address some PR comments
1 parent b8b3d05 commit 62032eb

File tree

5 files changed

+44
-38
lines changed

5 files changed

+44
-38
lines changed

Sources/SwiftCrossUI/Path.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ public struct Path {
299299
/// - endAngle: The angle of the end of the arc, measured in radians clockwise from right.
300300
/// Must be between 0 and 2pi (inclusive).
301301
/// - clockwise: `true` if the arc is to be drawn clockwise, `false` if the arc is to
302-
/// be drawn counter-clockwise. Used to determine whether to draw the larger arc or
303-
/// the smaller arc identified by the given start and end angles.
302+
/// be drawn counter-clockwise. Used to determine which of the two possible arcs to
303+
/// draw between the given start and end angles.
304304
public consuming func addArc(
305305
center: SIMD2<Double>,
306306
radius: Double,

Sources/SwiftCrossUI/Views/Shapes/Shape.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
///
33
/// If no stroke color or fill color is specified, the default is no stroke and a fill of the
44
/// current foreground color.
5-
public protocol Shape: View
6-
where Content == EmptyView {
5+
public protocol Shape: View where Content == EmptyView {
76
/// Draw the path for this shape.
87
///
98
/// The bounds passed to a shape that is immediately drawn as a view will always have an
@@ -44,8 +43,7 @@ where Content == EmptyView {
4443
/// a dry run, while the other properties are used to inform the layout engine how big
4544
/// or small the shape can be. The ``ViewSize/idealSize`` property should not vary with
4645
/// the `proposal`, and should only depend on the shape's contents. Pass `nil` for the
47-
/// maximum width/height if the shape has no maximum size (and therefore may occupy
48-
/// the entire screen).
46+
/// maximum width/height if the shape has no maximum size.
4947
func size(fitting proposal: SIMD2<Int>) -> ViewSize
5048
}
5149

Sources/UIKitBackend/UIColor+Color.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ extension Color {
3030

3131
var cgColor: CGColor {
3232
CGColor(
33-
red: CGFloat(red), green: CGFloat(green), blue: CGFloat(blue), alpha: CGFloat(alpha))
33+
red: CGFloat(red),
34+
green: CGFloat(green),
35+
blue: CGFloat(blue),
36+
alpha: CGFloat(alpha)
37+
)
3438
}
3539
}

Sources/UIKitBackend/UIKitBackend+Path.swift

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -129,25 +129,29 @@ extension UIKitBackend {
129129
shapeLayer.miterLimit = path.miterLimit
130130
shapeLayer.fillRule = path.usesEvenOddFillRule ? .evenOdd : .nonZero
131131

132-
shapeLayer.lineJoin =
133-
switch path.lineJoinStyle {
134-
case .miter:
135-
.miter
136-
case .round:
137-
.round
138-
case .bevel:
139-
.bevel
140-
}
132+
switch path.lineJoinStyle {
133+
case .miter:
134+
shapeLayer.lineJoin = .miter
135+
case .round:
136+
shapeLayer.lineJoin = .round
137+
case .bevel:
138+
shapeLayer.lineJoin = .bevel
139+
@unknown default:
140+
print("Warning: unrecognized lineJoinStyle \(path.lineJoinStyle)")
141+
shapeLayer.lineJoin = .miter
142+
}
141143

142-
shapeLayer.lineCap =
143-
switch path.lineCapStyle {
144-
case .butt:
145-
.butt
146-
case .round:
147-
.round
148-
case .square:
149-
.square
150-
}
144+
switch path.lineCapStyle {
145+
case .butt:
146+
shapeLayer.lineCap = .butt
147+
case .round:
148+
shapeLayer.lineCap = .round
149+
case .square:
150+
shapeLayer.lineCap = .square
151+
@unknown default:
152+
print("Warning: unrecognized lineCapStyle \(path.lineCapStyle)")
153+
shapeLayer.lineCap = .butt
154+
}
151155

152156
shapeLayer.strokeColor = strokeColor.cgColor
153157
shapeLayer.fillColor = fillColor.cgColor

Sources/WinUIBackend/WinUIBackend.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,26 +1191,26 @@ public final class WinUIBackend: AppBackend {
11911191
_ collection: WinUI.GeometryCollection,
11921192
lastPoint: Point
11931193
) -> PathFigure {
1194-
var pathGeo: PathGeometry
1194+
var pathGeometry: PathGeometry
11951195
if collection.size > 0,
11961196
let castedLast = collection.getAt(collection.size - 1) as? PathGeometry
11971197
{
1198-
pathGeo = castedLast
1198+
pathGeometry = castedLast
11991199
} else {
1200-
pathGeo = PathGeometry()
1201-
collection.append(pathGeo)
1200+
pathGeometry = PathGeometry()
1201+
collection.append(pathGeometry)
12021202
}
12031203

12041204
var figure: PathFigure
1205-
if pathGeo.figures.size > 0 {
1205+
if pathGeometry.figures.size > 0 {
12061206
// Note: the if check and force-unwrap is necessary. You can't do an `if let`
12071207
// here because PathFigureCollection uses unsigned integers for its indices so
12081208
// `size - 1` would underflow (causing a fatalError) if it's empty.
1209-
figure = pathGeo.figures.getAt(pathGeo.figures.size - 1)!
1209+
figure = pathGeometry.figures.getAt(pathGeometry.figures.size - 1)!
12101210
} else {
12111211
figure = PathFigure()
12121212
figure.startPoint = lastPoint
1213-
pathGeo.figures.append(figure)
1213+
pathGeometry.figures.append(figure)
12141214
}
12151215

12161216
return figure
@@ -1226,14 +1226,14 @@ public final class WinUIBackend: AppBackend {
12261226
lastPoint = Point(x: Float(point.x), y: Float(point.y))
12271227

12281228
if geometry.size > 0,
1229-
let pathGeo = geometry.getAt(geometry.size - 1) as? PathGeometry,
1230-
pathGeo.figures.size > 0
1229+
let pathGeometry = geometry.getAt(geometry.size - 1) as? PathGeometry,
1230+
pathGeometry.figures.size > 0
12311231
{
1232-
let figure = pathGeo.figures.getAt(pathGeo.figures.size - 1)!
1232+
let figure = pathGeometry.figures.getAt(pathGeometry.figures.size - 1)!
12331233
if figure.segments.size > 0 {
12341234
let newFigure = PathFigure()
12351235
newFigure.startPoint = lastPoint
1236-
pathGeo.figures.append(newFigure)
1236+
pathGeometry.figures.append(newFigure)
12371237
} else {
12381238
figure.startPoint = lastPoint
12391239
}
@@ -1362,8 +1362,8 @@ public final class WinUIBackend: AppBackend {
13621362
}
13631363

13641364
if geometry.size > 0,
1365-
let pathGeo = geometry.getAt(geometry.size - 1) as? PathGeometry,
1366-
pathGeo.figures.contains(where: { ($0?.segments.size ?? 0) > 0 })
1365+
let pathGeometry = geometry.getAt(geometry.size - 1) as? PathGeometry,
1366+
pathGeometry.figures.contains(where: { ($0?.segments.size ?? 0) > 0 })
13671367
{
13681368
// Start a new PathGeometry so that transforms don't apply going forward
13691369
geometry.append(PathGeometry())

0 commit comments

Comments
 (0)