| 1 |
// |
|
| 2 |
// LoadResistanceIconView.swift |
|
| 3 |
// USB Meter |
|
| 4 |
// |
|
| 5 | ||
| 6 |
import SwiftUI |
|
| 7 | ||
| 8 |
struct LoadResistanceIconView: View {
|
|
| 9 |
let color: Color |
|
| 10 | ||
| 11 |
var body: some View {
|
|
| 12 |
GeometryReader { proxy in
|
|
| 13 |
let width = proxy.size.width |
|
| 14 |
let height = proxy.size.height |
|
| 15 |
let midY = height / 2 |
|
| 16 |
let startX = width * 0.10 |
|
| 17 |
let endX = width * 0.90 |
|
| 18 |
let boxMinX = width * 0.28 |
|
| 19 |
let boxMaxX = width * 0.72 |
|
| 20 |
let boxHeight = height * 0.34 |
|
| 21 |
let boxRect = CGRect( |
|
| 22 |
x: boxMinX, |
|
| 23 |
y: midY - (boxHeight / 2), |
|
| 24 |
width: boxMaxX - boxMinX, |
|
| 25 |
height: boxHeight |
|
| 26 |
) |
|
| 27 |
let strokeWidth = max(1.2, height * 0.055) |
|
| 28 | ||
| 29 |
ZStack {
|
|
| 30 |
Path { path in
|
|
| 31 |
path.move(to: CGPoint(x: startX, y: midY)) |
|
| 32 |
path.addLine(to: CGPoint(x: boxRect.minX, y: midY)) |
|
| 33 |
path.move(to: CGPoint(x: boxRect.maxX, y: midY)) |
|
| 34 |
path.addLine(to: CGPoint(x: endX, y: midY)) |
|
| 35 |
} |
|
| 36 |
.stroke( |
|
| 37 |
color, |
|
| 38 |
style: StrokeStyle( |
|
| 39 |
lineWidth: strokeWidth, |
|
| 40 |
lineCap: .round, |
|
| 41 |
lineJoin: .round |
|
| 42 |
) |
|
| 43 |
) |
|
| 44 | ||
| 45 |
Path { path in
|
|
| 46 |
path.addRect(boxRect) |
|
| 47 |
} |
|
| 48 |
.stroke( |
|
| 49 |
color, |
|
| 50 |
style: StrokeStyle( |
|
| 51 |
lineWidth: strokeWidth, |
|
| 52 |
lineCap: .round, |
|
| 53 |
lineJoin: .round |
|
| 54 |
) |
|
| 55 |
) |
|
| 56 |
} |
|
| 57 |
} |
|
| 58 |
.padding(4) |
|
| 59 |
} |
|
| 60 |
} |