Explorar o código

various UI fixes

polscm32 %!s(int64=2) %!d(string=hai) anos
pai
achega
ac07fa37f7

+ 44 - 55
FreeAPS/Sources/Modules/Home/View/Chart/MainChartView2.swift

@@ -50,11 +50,11 @@ private enum PredictionType: Hashable {
 
 struct MainChartView2: View {
     private enum Config {
-        static let bolusSize: CGFloat = 4
+        static let bolusSize: CGFloat = 8
         static let bolusScale: CGFloat = 2.5
         static let carbsSize: CGFloat = 5
         static let carbsScale: CGFloat = 0.3
-        static let fpuSize: CGFloat = 5
+        static let fpuSize: CGFloat = 3
     }
 
     @Binding var glucose: [BloodGlucose]
@@ -86,6 +86,7 @@ struct MainChartView2: View {
     @State private var ChartCarbs: [Carb] = []
     @State private var ChartFpus: [Carb] = []
     @State private var ChartBoluses: [ChartBolus] = []
+    @State private var count: Decimal = 1
     @State private var startMarker = Date(timeIntervalSince1970: TimeInterval(NSDate().timeIntervalSince1970 - 86400))
     @State private var endMarker = Date(timeIntervalSince1970: TimeInterval(NSDate().timeIntervalSince1970 + 10800))
 
@@ -119,10 +120,10 @@ struct MainChartView2: View {
             ScrollViewReader { scroller in
                 ScrollView(.horizontal, showsIndicators: false) {
                     VStack {
+                        BasalChart()
+
                         MainChart()
 
-                        BasalChart()
-                            .padding(.bottom, 8)
                     }.onChange(of: screenHours) { _ in
                         scroller.scrollTo("MainChart", anchor: .trailing)
                     }.onAppear {
@@ -138,7 +139,7 @@ struct MainChartView2: View {
                     }
                 }
             }
-            Legend()
+            Legend().padding(.vertical, 4)
         })
     }
 }
@@ -185,7 +186,7 @@ extension MainChartView2 {
                     .symbolSize((Config.carbsSize + CGFloat(carbAmount) * Config.carbsScale) * 10)
                     .foregroundStyle(Color.orange)
                     .annotation(position: .top) {
-                        Text(bolusFormatter.string(from: carbAmount as NSNumber)!).font(.caption2)
+                        Text(bolusFormatter.string(from: carbAmount as NSNumber)!).font(.caption2).foregroundStyle(Color.orange)
                     }
                 }
                 ForEach(ChartFpus, id: \.self) { fpu in
@@ -196,26 +197,25 @@ extension MainChartView2 {
                     )
                     .symbolSize((Config.fpuSize + CGFloat(fpuAmount) * Config.carbsScale) * 10)
                     .foregroundStyle(Color.brown)
-                    .annotation(position: .top) {
-                        Text(bolusFormatter.string(from: fpuAmount as NSNumber)!).font(.caption2)
-                    }
                 }
 
                 ForEach(ChartBoluses, id: \.self) { bolus in
                     let bolusAmount = bolus.amount
+                    var triangle: BasicChartSymbolShape { .triangle }
+
                     PointMark(
                         x: .value("Time", bolus.timestamp, unit: .second),
-                        y: .value("Value", bolus.nearestGlucose.sgv ?? 120)
+//                        y: .value("Value", bolus.nearestGlucose.sgv ?? 120)
+                        y: .value("Value", 50)
                     )
-                    .symbolSize((Config.bolusSize + CGFloat(bolusAmount) * Config.bolusScale) * 10)
+                    .symbolSize((Config.bolusSize + CGFloat(bolusAmount) * Config.bolusScale) * 5)
+                    .symbol(triangle)
                     .foregroundStyle(Color.insulin)
-                    .annotation(position: .bottom) {
-                        Text(bolusFormatter.string(from: bolusAmount as NSNumber)!).font(.caption2)
-                    }
+//                    .annotation(position: .bottom) {
+//                        Text(bolusFormatter.string(from: bolusAmount as NSNumber)!).font(.caption2).foregroundStyle(Color.insulin)
+//                    }
                 }
 
-                // MARK: this code causes 'compiler is unable to type-check this expression'-error
-
                 ForEach(ChartTempTargets, id: \.self) { tt in
                     let randomString = UUID().uuidString
                     LineMark(
@@ -263,26 +263,16 @@ extension MainChartView2 {
                 }
                 ForEach(glucose) {
                     if let sgv = $0.sgv {
-                        /* let color: Color
-                         if sgv < lowGlucose {
-                             color = Color.red
-                         } else if sgv > highGlucose {
-                             color = Color.loopYellow
-                         } else {
-                             color = Color.green
-                         }*/
                         PointMark(
                             x: .value("Time", $0.dateString, unit: .second),
                             y: .value("Value", sgv)
-                            // series: .value("Value", "unsmooth")
-                        ).foregroundStyle(Color.green.gradient).symbolSize(16)
+                        ).foregroundStyle(Color.green.gradient).symbolSize(25)
 
                         if smooth {
                             LineMark(
                                 x: .value("Time", $0.dateString, unit: .second),
                                 y: .value("Value", sgv)
-                                // series: .value("Value", "smooth")
-                            ).foregroundStyle(Color.green.gradient).symbolSize(16)
+                            ).foregroundStyle(Color.green.gradient).symbolSize(25)
                                 .interpolationMethod(.cardinal)
                         }
                     }
@@ -315,19 +305,20 @@ extension MainChartView2 {
                 }
                 .frame(
                     width: max(0, screenSize.width - 20, fullWidth(viewWidth: screenSize.width)),
-                    height: UIScreen.main.bounds.height / 3.5
+                    height: UIScreen.main.bounds.height / 3.3
                 )
-//                .chartYScale(domain: 0 ... 450)
                 .chartXAxis {
-                    AxisMarks(values: .stride(by: .hour, count: 2)) { _ in
+                    AxisMarks(values: .stride(by: .hour, count: screenHours == 24 ? 4 : 2)) { _ in
                         if displayXgridLines {
                             AxisGridLine(stroke: .init(lineWidth: 0.5, dash: [2, 3]))
                         } else {
                             AxisGridLine(stroke: .init(lineWidth: 0, dash: [2, 3]))
                         }
+                        AxisValueLabel(format: .dateTime.hour(.defaultDigits(amPM: .narrow)), anchor: .top)
                     }
-                }.chartYAxis {
-                    AxisMarks(position: .trailing, values: .stride(by: 100)) { value in
+                }
+                .chartYAxis {
+                    AxisMarks(position: .trailing) { value in
                         if displayYgridLines {
                             AxisGridLine(stroke: .init(lineWidth: 0.5, dash: [2, 3]))
                         } else {
@@ -340,7 +331,6 @@ extension MainChartView2 {
                         }
                     }
                 }
-                .aspectRatio(1, contentMode: .fit)
         }
     }
 
@@ -405,34 +395,33 @@ extension MainChartView2 {
                 calculateBasals()
                 calculateTempBasals()
             }
-            // .frame(height: 80)
             .frame(
                 width: max(0, screenSize.width - 20, fullWidth(viewWidth: screenSize.width)),
-                height: UIScreen.main.bounds.height / 10
+                height: UIScreen.main.bounds.height / 10.5
             )
-//            .chartYScale(domain: 0 ... maxBasal)
-            //            .rotationEffect(.degrees(180))
-            //            .chartXAxis(.hidden)
-            .chartXAxis {
-                AxisMarks(values: .stride(by: .hour, count: screenHours == 24 ? 4 : 2)) { _ in
-                    if displayXgridLines {
-                        AxisGridLine(stroke: .init(lineWidth: 0.5, dash: [2, 3]))
-                    } else {
-                        AxisGridLine(stroke: .init(lineWidth: 0, dash: [2, 3]))
-                    }
-                    // AxisValueLabel(format: .dateTime.hour(.defaultDigits(amPM: .narrow)), anchor: .top)
-                    AxisValueLabel(format: .dateTime.hour())
-                }
-            }.chartYAxis {
-                AxisMarks(position: .trailing, values: .stride(by: 1)) { _ in
+            .rotationEffect(.degrees(180))
+            .scaleEffect(x: -1, y: 1)
+            .chartXAxis(.hidden)
+//            .chartXAxis {
+//                AxisMarks(values: .stride(by: .hour, count: screenHours == 24 ? 4 : 2)) { _ in
+//                    if displayXgridLines {
+//                        AxisGridLine(stroke: .init(lineWidth: 0.5, dash: [2, 3]))
+//                    } else {
+//                        AxisGridLine(stroke: .init(lineWidth: 0, dash: [2, 3]))
+//                    }
+            ////                     AxisValueLabel(format: .dateTime.hour(.defaultDigits(amPM: .narrow)), anchor: .top)
+            ////                    AxisValueLabel(format: .dateTime.hour())
+//                }
+//            }
+            .chartYAxis {
+                AxisMarks(position: .trailing) { _ in
                     if displayYgridLines {
                         AxisGridLine(stroke: .init(lineWidth: 0.5, dash: [2, 3]))
                     } else {
                         AxisGridLine(stroke: .init(lineWidth: 0, dash: [2, 3]))
                     }
-                    AxisTick(length: 4, stroke: .init(lineWidth: 4))
-                        .foregroundStyle(Color.gray)
-                    AxisValueLabel()
+                    AxisTick(length: 30, stroke: .init(lineWidth: 4))
+                        .foregroundStyle(Color.clear)
                 }
             }
         }
@@ -440,7 +429,7 @@ extension MainChartView2 {
 
     private func Legend() -> some View {
         ZStack {
-            Capsule(style: .circular).foregroundStyle(.gray.opacity(0.1)).padding(.horizontal, 30)
+            Capsule(style: .circular).foregroundStyle(.gray.opacity(0.1)).padding(.horizontal, 30).frame(maxHeight: 15)
 
             HStack {
                 Image(systemName: "line.diagonal")

+ 1 - 1
FreeAPS/Sources/Modules/Home/View/Header/CurrentGlucoseView.swift

@@ -158,7 +158,7 @@ struct Triangle: Shape {
     func path(in rect: CGRect) -> Path {
         var path = Path()
 
-        path.move(to: CGPoint(x: rect.midX, y: rect.minY + 10))
+        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))

+ 12 - 10
FreeAPS/Sources/Modules/Home/View/Header/LoopView.swift

@@ -24,18 +24,19 @@ struct LoopView: View {
     private let rect = CGRect(x: 0, y: 0, width: 14, height: 14)
     var body: some View {
         HStack(alignment: .center) {
-            ZStack {
-                Image(systemName: "circle.fill")
-                    .resizable()
-                    .frame(width: rect.width, height: rect.height, alignment: .center)
-                    .foregroundColor(color)
-                    .mask(mask(in: rect).fill(style: FillStyle(eoFill: true)))
+            Rectangle().frame(width: UIScreen.main.bounds.width / 2.5, height: 2, alignment: .leading).foregroundColor(color)
+//            ZStack {
+//                Image(systemName: "circle.fill")
+//                    .resizable()
+//                    .frame(width: rect.width, height: rect.height, alignment: .center)
+//                    .foregroundColor(color)
+//                    .mask(mask(in: rect).fill(style: FillStyle(eoFill: true)))
 
-                if isLooping {
-                    ProgressView()
-                        .foregroundColor(Color.loopGreen)
-                }
+            if isLooping {
+                ProgressView()
+                    .foregroundColor(Color.loopGreen)
             }
+//            }
             if isLooping {
                 Text("looping").font(.caption).fontWeight(.bold)
             } else if manualTempBasal {
@@ -45,6 +46,7 @@ struct LoopView: View {
             } else {
                 Text("--").font(.caption).fontWeight(.bold)
             }
+            Rectangle().frame(width: UIScreen.main.bounds.width / 2.5, height: 2, alignment: .trailing).foregroundColor(color)
         }
     }
 

+ 8 - 26
FreeAPS/Sources/Modules/Home/View/Header/PumpView.swift

@@ -39,39 +39,21 @@ struct PumpView: View {
 
     var body: some View {
         HStack {
-            Text("IOB").font(.caption).foregroundColor(.secondary)
+            Text("IOB").font(.callout).foregroundColor(.secondary)
             Text(
                 (numberFormatter.string(from: (state.suggestion?.iob ?? 0) as NSNumber) ?? "0") +
                     NSLocalizedString(" U", comment: "Insulin unit")
             )
-            .font(.caption).fontWeight(.bold)
+            .font(.callout).fontWeight(.bold)
 
             Spacer()
 
-            Text("COB").font(.caption).foregroundColor(.secondary)
+            Text("COB").font(.callout).foregroundColor(.secondary)
             Text(
                 (numberFormatter.string(from: (state.suggestion?.cob ?? 0) as NSNumber) ?? "0") +
                     NSLocalizedString(" g", comment: "gram of carbs")
             )
-            .font(.caption).fontWeight(.bold)
-
-            Spacer()
-
-            LoopView(
-                suggestion: $state.suggestion,
-                enactedSuggestion: $state.enactedSuggestion,
-                closedLoop: $state.closedLoop,
-                timerDate: $state.timerDate,
-                isLooping: $state.isLooping,
-                lastLoopDate: $state.lastLoopDate,
-                manualTempBasal: $state.manualTempBasal
-            ).onTapGesture {
-                state.isStatusPopupPresented = true
-            }.onLongPressGesture {
-                let impactHeavy = UIImpactFeedbackGenerator(style: .heavy)
-                impactHeavy.impactOccurred()
-                state.runLoop()
-            }
+            .font(.callout).fontWeight(.bold)
 
             Spacer()
 
@@ -83,13 +65,13 @@ struct PumpView: View {
                         .frame(maxHeight: 15)
                         .foregroundColor(reservoirColor)
                     if reservoir == 0xDEAD_BEEF {
-                        Text("50+ " + NSLocalizedString("U", comment: "Insulin unit")).font(.caption).fontWeight(.bold)
+                        Text("50+ " + NSLocalizedString("U", comment: "Insulin unit")).font(.callout).fontWeight(.bold)
                     } else {
                         Text(
                             reservoirFormatter
                                 .string(from: reservoir as NSNumber)! + NSLocalizedString(" U", comment: "Insulin unit")
                         )
-                        .font(.caption).fontWeight(.bold)
+                        .font(.callout).fontWeight(.bold)
                     }
                 }
             }
@@ -103,7 +85,7 @@ struct PumpView: View {
                         .aspectRatio(contentMode: .fit)
                         .frame(maxHeight: 15)
                         .foregroundColor(batteryColor)
-                    Text("\(Int(battery.percent ?? 100)) %").font(.caption)
+                    Text("\(Int(battery.percent ?? 100)) %").font(.callout)
                         .fontWeight(.bold)
                 }
             }
@@ -116,7 +98,7 @@ struct PumpView: View {
                         .frame(maxHeight: 15)
                         .foregroundColor(timerColor)
 
-                    Text(remainingTimeString(time: date.timeIntervalSince(timerDate))).font(.caption).fontWeight(.bold)
+                    Text(remainingTimeString(time: date.timeIntervalSince(timerDate))).font(.callout).fontWeight(.bold)
                 }
             }
         }

+ 20 - 11
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -651,15 +651,7 @@ extension Home {
                 VStack(spacing: 0) {
                     Spacer()
 
-//                    ZStack {
-                    glucoseView.padding(.top, 75)
-
-//                        loopView
-//                            /// circles width is 110, loops width is 35 -> (110/2) - (35/2) = 55 - 17.5 = 37.5
-//                            .offset(x: UIScreen.main.bounds.width * 0.43, y: -37.5)
-//                            .padding(.trailing, 10)
-//                    }
-//                    .padding(.top, 75)
+                    glucoseView.padding(.top, 40)
 
                     Spacer()
 
@@ -685,14 +677,31 @@ extension Home {
                         .frame(maxHeight: UIScreen.main.bounds.height / 2.2)
 
                     Spacer()
+                        .frame(height: UIScreen.main.bounds.height / 40)
 
                     timeInterval
 
                     Spacer()
-
-//                    legendPanel
+                        .frame(height: UIScreen.main.bounds.height / 40)
+
+                    LoopView(
+                        suggestion: $state.suggestion,
+                        enactedSuggestion: $state.enactedSuggestion,
+                        closedLoop: $state.closedLoop,
+                        timerDate: $state.timerDate,
+                        isLooping: $state.isLooping,
+                        lastLoopDate: $state.lastLoopDate,
+                        manualTempBasal: $state.manualTempBasal
+                    ).onTapGesture {
+                        state.isStatusPopupPresented = true
+                    }.onLongPressGesture {
+                        let impactHeavy = UIImpactFeedbackGenerator(style: .heavy)
+                        impactHeavy.impactOccurred()
+                        state.runLoop()
+                    }
 
                     Spacer()
+                        .frame(height: UIScreen.main.bounds.height / 40)
 
                     bottomPanel(geo)
                 }

+ 0 - 6
LiveActivity/WidgetBobble.swift

@@ -25,12 +25,6 @@ struct CircleShapeWidget: View {
     let gradient: AngularGradient
 
     var body: some View {
-//        let colorBackground: Color = colorScheme == .dark ? Color(
-//            red: 0.05490196078,
-//            green: 0.05490196078,
-//            blue: 0.05490196078
-//        ) : .white
-
         Circle()
             .stroke(gradient, lineWidth: 10)
             .background(Circle().fill(.clear))