Prechádzať zdrojové kódy

Use standard trend arrow for detailed lock screen widget

Mike Plante 2 rokov pred
rodič
commit
1aa37e6d16

+ 0 - 6
FreeAPS.xcodeproj/project.pbxproj

@@ -310,8 +310,6 @@
 		B9CAAEFC2AE70836000F68BC /* branch.txt in Resources */ = {isa = PBXBuildFile; fileRef = B9CAAEFB2AE70836000F68BC /* branch.txt */; };
 		BA00D96F7B2FF169A06FB530 /* CGMStateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C018D1680307A31C9ED7120 /* CGMStateModel.swift */; };
 		BA90041DC8991147E5C8C3AA /* CalibrationsRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 500371C09F54F89A97D65FDB /* CalibrationsRootView.swift */; };
-		BD188BEC2B1B805B00B183BF /* WidgetBobble.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD188BEB2B1B805A00B183BF /* WidgetBobble.swift */; };
-		BD188BED2B1B805B00B183BF /* WidgetBobble.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD188BEB2B1B805A00B183BF /* WidgetBobble.swift */; };
 		BD2B464E0745FBE7B79913F4 /* NightscoutConfigProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3BF768BD6264FF7D71D66767 /* NightscoutConfigProvider.swift */; };
 		BDF530D82B40F8AC002CAF43 /* LockScreenView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDF530D72B40F8AC002CAF43 /* LockScreenView.swift */; };
 		BF1667ADE69E4B5B111CECAE /* ManualTempBasalProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 680C4420C9A345D46D90D06C /* ManualTempBasalProvider.swift */; };
@@ -863,7 +861,6 @@
 		B9CAAEFB2AE70836000F68BC /* branch.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = branch.txt; sourceTree = SOURCE_ROOT; };
 		BA49538D56989D8DA6FCF538 /* TargetsEditorDataFlow.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TargetsEditorDataFlow.swift; sourceTree = "<group>"; };
 		BC210C0F3CB6D3C86E5DED4E /* LibreConfigRootView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = LibreConfigRootView.swift; sourceTree = "<group>"; };
-		BD188BEB2B1B805A00B183BF /* WidgetBobble.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetBobble.swift; sourceTree = "<group>"; };
 		BDF530D72B40F8AC002CAF43 /* LockScreenView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LockScreenView.swift; sourceTree = "<group>"; };
 		BF8BCB0C37DEB5EC377B9612 /* BasalProfileEditorRootView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = BasalProfileEditorRootView.swift; sourceTree = "<group>"; };
 		C19984D62EFC0035A9E9644D /* BolusProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = BolusProvider.swift; sourceTree = "<group>"; };
@@ -2022,7 +2019,6 @@
 			children = (
 				6B1A8D1D2B14D91600E76752 /* LiveActivityBundle.swift */,
 				6B1A8D1F2B14D91600E76752 /* LiveActivity.swift */,
-				BD188BEB2B1B805A00B183BF /* WidgetBobble.swift */,
 				6B1A8D232B14D91700E76752 /* Assets.xcassets */,
 				6B1A8D252B14D91700E76752 /* Info.plist */,
 			);
@@ -2819,7 +2815,6 @@
 				38FEF3FA2737E42000574A46 /* BaseStateModel.swift in Sources */,
 				CC6C406E2ACDD69E009B8058 /* RawFetchedProfile.swift in Sources */,
 				385CEA8225F23DFD002D6D5B /* NightscoutStatus.swift in Sources */,
-				BD188BEC2B1B805B00B183BF /* WidgetBobble.swift in Sources */,
 				F90692AA274B7AAE0037068D /* HealthKitManager.swift in Sources */,
 				38887CCE25F5725200944304 /* IOBEntry.swift in Sources */,
 				38E98A2425F52C9300C0CED0 /* Logger.swift in Sources */,
@@ -2970,7 +2965,6 @@
 				6BCF84DE2B16843A003AD46E /* LiveActitiyShared.swift in Sources */,
 				6B1A8D1E2B14D91600E76752 /* LiveActivityBundle.swift in Sources */,
 				6B1A8D202B14D91600E76752 /* LiveActivity.swift in Sources */,
-				BD188BED2B1B805B00B183BF /* WidgetBobble.swift in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

+ 6 - 21
LiveActivity/LiveActivity.swift

@@ -147,26 +147,14 @@ struct LiveActivity: Widget {
                 }
             }
         }
-        .foregroundStyle(context.isStale ? Color.primary.opacity(0.5) : Color.primary)
+        .foregroundStyle(
+            context.state.lockScreenView == "Simple" ? (context.isStale ? Color.primary.opacity(0.5) : Color.primary) :
+                (context.isStale ? Color.white.opacity(0.5) : Color.white)
+        )
 
         return (stack, characters)
     }
 
-    @ViewBuilder func bobble(context: ActivityViewContext<LiveActivityAttributes>) -> some View {
-        @State var angularGradient = AngularGradient(colors: [
-            Color(red: 0.7215686275, green: 0.3411764706, blue: 1),
-            Color(red: 0.6235294118, green: 0.4235294118, blue: 0.9803921569),
-            Color(red: 0.4862745098, green: 0.5450980392, blue: 0.9529411765),
-            Color(red: 0.3411764706, green: 0.6666666667, blue: 0.9254901961),
-            Color(red: 0.262745098, green: 0.7333333333, blue: 0.9137254902),
-            Color(red: 0.7215686275, green: 0.3411764706, blue: 1)
-        ], center: .center, startAngle: .degrees(270), endAngle: .degrees(-90))
-        let triangleColor = Color(red: 0.262745098, green: 0.7333333333, blue: 0.9137254902)
-
-        WidgetBobble(gradient: angularGradient, color: triangleColor)
-            .rotationEffect(.degrees(context.state.rotationDegrees))
-    }
-
     @ViewBuilder func chart(context: ActivityViewContext<LiveActivityAttributes>) -> some View {
         if context.isStale {
             Text("No data available")
@@ -239,13 +227,10 @@ struct LiveActivity: Widget {
                     VStack(alignment: .center) {
                         Spacer()
                         ZStack {
-                            bobble(context: context)
-                                .scaleEffect(0.6)
-                                .clipped()
                             VStack {
-                                bgLabel(context: context).font(.title2).imageScale(.small)
+                                bgAndTrend(context: context, size: .expanded).0.font(.largeTitle)
                                 changeLabel(context: context).font(.callout)
-                            }
+                            }.frame(width: 130, height: 130)
                         }.scaleEffect(0.85).offset(y: 18)
                         mealLabel(context: context).padding(.bottom, 8)
                         updatedLabel(context: context).font(.caption).padding(.bottom, 50)

+ 0 - 58
LiveActivity/WidgetBobble.swift

@@ -1,58 +0,0 @@
-import SwiftUI
-
-struct WidgetBobble: View {
-    @Environment(\.colorScheme) var colorScheme
-
-    let gradient: AngularGradient
-    let color: Color
-
-    var body: some View {
-        HStack(alignment: .center) {
-            ZStack {
-                Group {
-                    CircleShapeWidget(gradient: gradient)
-                    TriangleShapeWidget(color: color)
-                }
-                CircleShapeWidget(gradient: gradient)
-            }
-        }
-    }
-}
-
-struct CircleShapeWidget: View {
-    @Environment(\.colorScheme) var colorScheme
-
-    let gradient: AngularGradient
-
-    var body: some View {
-        Circle()
-            .stroke(gradient, lineWidth: 10)
-            .background(Circle().fill(.clear))
-            .frame(width: 130, height: 130)
-    }
-}
-
-struct TriangleShapeWidget: View {
-    let color: Color
-
-    var body: some View {
-        TriangleWidget()
-            .fill(color)
-            .frame(width: 35, height: 35)
-            .rotationEffect(.degrees(90))
-            .offset(x: 88)
-    }
-}
-
-struct TriangleWidget: Shape {
-    func path(in rect: CGRect) -> Path {
-        var path = Path()
-
-        path.move(to: CGPoint(x: rect.midX, y: rect.minY + 15))
-        path.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY))
-        path.addQuadCurve(to: CGPoint(x: rect.minX, y: rect.maxY), control: CGPoint(x: rect.midX, y: rect.midY + 10))
-        path.closeSubpath()
-
-        return path
-    }
-}