|
@@ -53,6 +53,7 @@ struct Triangle: Shape {
|
|
|
|
|
|
|
|
/// A view that displays a circular trend indicator with a directional triangle
|
|
/// A view that displays a circular trend indicator with a directional triangle
|
|
|
struct TrendShape: View {
|
|
struct TrendShape: View {
|
|
|
|
|
+ let isWatchStateDated: Bool
|
|
|
/// Rotation angle in degrees for the trend direction
|
|
/// Rotation angle in degrees for the trend direction
|
|
|
let rotationDegrees: Double
|
|
let rotationDegrees: Double
|
|
|
/// Flag to be able to adjust size based on Apple Watch size
|
|
/// Flag to be able to adjust size based on Apple Watch size
|
|
@@ -73,6 +74,17 @@ struct TrendShape: View {
|
|
|
endAngle: .degrees(-90)
|
|
endAngle: .degrees(-90)
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ private let staleWatchStateGradient = AngularGradient(
|
|
|
|
|
+ colors: [
|
|
|
|
|
+ Color.secondary,
|
|
|
|
|
+ Color.secondary.opacity(0.8),
|
|
|
|
|
+ Color.secondary.opacity(0.6),
|
|
|
|
|
+ Color.secondary.opacity(0.4),
|
|
|
|
|
+ Color.secondary
|
|
|
|
|
+ ],
|
|
|
|
|
+ center: .center
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
// Color for the direction indicator triangle
|
|
// Color for the direction indicator triangle
|
|
|
private let triangleColor = Color(red: 0.262745098, green: 0.7333333333, blue: 0.9137254902) // #43BBE9
|
|
private let triangleColor = Color(red: 0.262745098, green: 0.7333333333, blue: 0.9137254902) // #43BBE9
|
|
|
|
|
|
|
@@ -146,7 +158,7 @@ struct TrendShape: View {
|
|
|
ZStack {
|
|
ZStack {
|
|
|
// Outer circle with gradient
|
|
// Outer circle with gradient
|
|
|
Circle()
|
|
Circle()
|
|
|
- .stroke(angularGradient, lineWidth: strokeWidth)
|
|
|
|
|
|
|
+ .stroke(isWatchStateDated ? staleWatchStateGradient : angularGradient, lineWidth: strokeWidth)
|
|
|
.frame(width: circleSize, height: circleSize)
|
|
.frame(width: circleSize, height: circleSize)
|
|
|
.background(Circle().fill(Color.black))
|
|
.background(Circle().fill(Color.black))
|
|
|
|
|
|
|
@@ -155,6 +167,7 @@ struct TrendShape: View {
|
|
|
.fill(triangleColor)
|
|
.fill(triangleColor)
|
|
|
.frame(width: triangleSize, height: triangleSize)
|
|
.frame(width: triangleSize, height: triangleSize)
|
|
|
.offset(x: triangleOffset)
|
|
.offset(x: triangleOffset)
|
|
|
|
|
+ .opacity(isWatchStateDated ? 0 : 1)
|
|
|
}
|
|
}
|
|
|
.rotationEffect(.degrees(rotationDegrees))
|
|
.rotationEffect(.degrees(rotationDegrees))
|
|
|
.shadow(color: Color.black.opacity(0.33), radius: 3)
|
|
.shadow(color: Color.black.opacity(0.33), radius: 3)
|