Ver código fonte

fix padding in lockscreenwidget
fix incorrect timelabels in main chart
fix xGridLines that disappeared after last dev merge

polscm32 2 anos atrás
pai
commit
b5ff233d18
2 arquivos alterados com 16 adições e 18 exclusões
  1. 9 11
      LiveActivity/LiveActivity.swift
  2. 7 7
      LiveActivity/WidgetBobble.swift

+ 9 - 11
LiveActivity/LiveActivity.swift

@@ -20,7 +20,7 @@ struct LiveActivity: Widget {
     }
     }
 
 
     func updatedLabel(context: ActivityViewContext<LiveActivityAttributes>) -> Text {
     func updatedLabel(context: ActivityViewContext<LiveActivityAttributes>) -> Text {
-        Text(dateFormatter.string(from: context.state.date))
+        Text("Updated: \(dateFormatter.string(from: context.state.date))")
     }
     }
 
 
     func bgLabel(context: ActivityViewContext<LiveActivityAttributes>) -> Text {
     func bgLabel(context: ActivityViewContext<LiveActivityAttributes>) -> Text {
@@ -77,7 +77,7 @@ struct LiveActivity: Widget {
                 ForEach(context.state.chart.indices, id: \.self) { index in
                 ForEach(context.state.chart.indices, id: \.self) { index in
                     LineMark(
                     LineMark(
                         x: .value("Time", context.state.chartDate[index] ?? Date()),
                         x: .value("Time", context.state.chartDate[index] ?? Date()),
-                        y: .value("Value", context.state.chart[index] ?? 0)
+                        y: .value("Value", context.state.chart[index])
                     ).foregroundStyle(Color.green.gradient).symbolSize(12)
                     ).foregroundStyle(Color.green.gradient).symbolSize(12)
                 }
                 }
             }.chartPlotStyle { plotContent in
             }.chartPlotStyle { plotContent in
@@ -86,9 +86,6 @@ struct LiveActivity: Widget {
             .chartYAxis {
             .chartYAxis {
                 AxisMarks(position: .leading)
                 AxisMarks(position: .leading)
             }
             }
-            .chartXAxis {
-                AxisMarks(position: .automatic)
-            }
         }
         }
     }
     }
 
 
@@ -98,9 +95,9 @@ struct LiveActivity: Widget {
 
 
             HStack(spacing: 2) {
             HStack(spacing: 2) {
                 VStack {
                 VStack {
-                    chart(context: context).frame(width: UIScreen.main.bounds.width / 1.7)
+                    chart(context: context).frame(width: UIScreen.main.bounds.width / 1.8)
                 }.padding(.vertical, 5).padding(.horizontal, 15)
                 }.padding(.vertical, 5).padding(.horizontal, 15)
-                Divider()
+                Divider().foregroundStyle(Color.white)
                 VStack {
                 VStack {
                     ZStack {
                     ZStack {
                         bobble(context: context)
                         bobble(context: context)
@@ -111,8 +108,8 @@ struct LiveActivity: Widget {
                             bgLabel(context: context).font(.title2).imageScale(.small)
                             bgLabel(context: context).font(.title2).imageScale(.small)
                             changeLabel(context: context).font(.callout)
                             changeLabel(context: context).font(.callout)
                         }
                         }
-                    }.padding(.trailing, 5).padding(.top, 5)
-                    updatedLabel(context: context).font(.caption).padding(.bottom)
+                    }.padding(.trailing, 10).padding(.top, 5)
+                    updatedLabel(context: context).font(.caption).padding(.bottom).padding(.trailing, 5)
                 }
                 }
             }
             }
             .privacySensitive()
             .privacySensitive()
@@ -136,9 +133,10 @@ struct LiveActivity: Widget {
                     changeLabel(context: context).font(.title).padding(.trailing, 5)
                     changeLabel(context: context).font(.title).padding(.trailing, 5)
                 }
                 }
                 DynamicIslandExpandedRegion(.bottom) {
                 DynamicIslandExpandedRegion(.bottom) {
+                    chart(context: context)
+                }
+                DynamicIslandExpandedRegion(.center) {
                     updatedLabel(context: context).font(.caption).foregroundStyle(Color.secondary)
                     updatedLabel(context: context).font(.caption).foregroundStyle(Color.secondary)
-                        .padding(.bottom, 5)
-                    chart(context: context).frame(height: 70)
                 }
                 }
             } compactLeading: {
             } compactLeading: {
                 HStack(spacing: 1) {
                 HStack(spacing: 1) {

+ 7 - 7
LiveActivity/WidgetBobble.swift

@@ -10,16 +10,16 @@ struct WidgetBobble: View {
         HStack(alignment: .center) {
         HStack(alignment: .center) {
             ZStack {
             ZStack {
                 Group {
                 Group {
-                    CircleShape(gradient: gradient)
-                    TriangleShape(color: color)
+                    CircleShapeWidget(gradient: gradient)
+                    TriangleShapeWidget(color: color)
                 }
                 }
-                CircleShape(gradient: gradient)
+                CircleShapeWidget(gradient: gradient)
             }
             }
         }
         }
     }
     }
 }
 }
 
 
-struct CircleShape: View {
+struct CircleShapeWidget: View {
     @Environment(\.colorScheme) var colorScheme
     @Environment(\.colorScheme) var colorScheme
 
 
     let gradient: AngularGradient
     let gradient: AngularGradient
@@ -38,11 +38,11 @@ struct CircleShape: View {
     }
     }
 }
 }
 
 
-struct TriangleShape: View {
+struct TriangleShapeWidget: View {
     let color: Color
     let color: Color
 
 
     var body: some View {
     var body: some View {
-        Triangle()
+        TriangleWidget()
             .fill(color)
             .fill(color)
             .frame(width: 35, height: 35)
             .frame(width: 35, height: 35)
             .rotationEffect(.degrees(90))
             .rotationEffect(.degrees(90))
@@ -50,7 +50,7 @@ struct TriangleShape: View {
     }
     }
 }
 }
 
 
-struct Triangle: Shape {
+struct TriangleWidget: Shape {
     func path(in rect: CGRect) -> Path {
     func path(in rect: CGRect) -> Path {
         var path = Path()
         var path = Path()