|
|
@@ -0,0 +1,88 @@
|
|
|
+import SwiftUI
|
|
|
+
|
|
|
+struct SettingsGearIcon: View {
|
|
|
+ var size: CGFloat = 25
|
|
|
+
|
|
|
+ private var strokeWidth: CGFloat { size / 12 }
|
|
|
+
|
|
|
+ var body: some View {
|
|
|
+ ZStack {
|
|
|
+ SettingsGearOutline()
|
|
|
+ .stroke(
|
|
|
+ style: StrokeStyle(
|
|
|
+ lineWidth: strokeWidth,
|
|
|
+ lineCap: .round,
|
|
|
+ lineJoin: .round
|
|
|
+ )
|
|
|
+ )
|
|
|
+
|
|
|
+ SettingsGearCenterHole()
|
|
|
+ .stroke(
|
|
|
+ style: StrokeStyle(
|
|
|
+ lineWidth: strokeWidth,
|
|
|
+ lineCap: .round,
|
|
|
+ lineJoin: .round
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ .frame(width: size, height: size)
|
|
|
+ .accessibilityHidden(true)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+private struct SettingsGearOutline: Shape {
|
|
|
+ private let teeth = 8
|
|
|
+ private let outerRadius: CGFloat = 8.75
|
|
|
+ private let innerRadius: CGFloat = 6.15
|
|
|
+ private let center = CGPoint(x: 12, y: 12)
|
|
|
+
|
|
|
+ func path(in rect: CGRect) -> Path {
|
|
|
+ let scale = min(rect.width, rect.height) / 24
|
|
|
+ let origin = CGPoint(
|
|
|
+ x: rect.midX - 12 * scale,
|
|
|
+ y: rect.midY - 12 * scale
|
|
|
+ )
|
|
|
+
|
|
|
+ var path = Path()
|
|
|
+
|
|
|
+ for index in 0..<(teeth * 2) {
|
|
|
+ let angle = (CGFloat(index) / CGFloat(teeth * 2)) * (.pi * 2) - (.pi / 2)
|
|
|
+ let radius = index.isMultiple(of: 2) ? outerRadius : innerRadius
|
|
|
+ let point = CGPoint(
|
|
|
+ x: origin.x + (center.x + cos(angle) * radius) * scale,
|
|
|
+ y: origin.y + (center.y + sin(angle) * radius) * scale
|
|
|
+ )
|
|
|
+
|
|
|
+ if index == 0 {
|
|
|
+ path.move(to: point)
|
|
|
+ } else {
|
|
|
+ path.addLine(to: point)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ path.closeSubpath()
|
|
|
+ return path
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+private struct SettingsGearCenterHole: Shape {
|
|
|
+ private let holeRadius: CGFloat = 2.65
|
|
|
+
|
|
|
+ func path(in rect: CGRect) -> Path {
|
|
|
+ let scale = min(rect.width, rect.height) / 24
|
|
|
+ let scaledRadius = holeRadius * scale
|
|
|
+ let centerPoint = CGPoint(
|
|
|
+ x: rect.midX,
|
|
|
+ y: rect.midY
|
|
|
+ )
|
|
|
+
|
|
|
+ return Path(
|
|
|
+ ellipseIn: CGRect(
|
|
|
+ x: centerPoint.x - scaledRadius,
|
|
|
+ y: centerPoint.y - scaledRadius,
|
|
|
+ width: scaledRadius * 2,
|
|
|
+ height: scaledRadius * 2
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|