Jelajahi Sumber

More UI fixes
* use SF symbol circle for loop view
* align loop view next to glucose bobble
* small font changes in header
* add evBG string next to glucose bobble
* add history to tap bar
* move temp target to profiles WiP
* indicate in tap bar if TT is active WiP

polscm32 2 tahun lalu
induk
melakukan
66f97f45e2

+ 1 - 1
FreeAPS.xcworkspace/xcshareddata/swiftpm/Package.resolved

@@ -30,7 +30,7 @@
       },
       {
         "package": "SwiftCharts",
-        "repositoryURL": "https://github.com/ivanschuetz/SwiftCharts.git",
+        "repositoryURL": "https://github.com/ivanschuetz/SwiftCharts",
         "state": {
           "branch": "master",
           "revision": "c354c1945bb35a1f01b665b22474f6db28cba4a2",

+ 1 - 4
FreeAPS/Sources/Modules/Home/View/Chart/MainChartView.swift

@@ -461,9 +461,6 @@ extension MainChartView {
                     .foregroundColor(.orange)
                 Text("UAM")
                     .foregroundColor(.secondary)
-                if eventualBG != nil {
-                    Text("⇢ " + String(eventualBG ?? 0))
-                }
             }
             .font(.caption2)
             .padding(.horizontal, 40)
@@ -759,7 +756,7 @@ extension MainChartView {
         startMarker = Date(timeIntervalSince1970: TimeInterval(NSDate().timeIntervalSince1970 - 86400))
         endMarker = Date(timeIntervalSince1970: TimeInterval(NSDate().timeIntervalSince1970 + 10800))
     }
-    
+
     /// get y axis scale
     /// but only call the function every 60min, i.e. every 12th glucose value
     private func counter() {

+ 18 - 17
FreeAPS/Sources/Modules/Home/View/Header/LoopView.swift

@@ -21,32 +21,33 @@ struct LoopView: View {
         return formatter
     }
 
-    private let rect = CGRect(x: 0, y: 0, width: 14, height: 14)
+    @Environment(\.colorScheme) var colorScheme
+
     var body: some View {
         HStack(alignment: .center) {
-            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)))
+//            Rectangle().frame(width: UIScreen.main.bounds.width / 2.5, height: 2, alignment: .leading).foregroundColor(color)
+            ZStack {
+                Image(systemName: "circle")
+                    .font(.system(size: 15))
+                    .fontWeight(.bold)
+                    .foregroundColor(color)
 
-            if isLooping {
-                ProgressView()
-                    .foregroundColor(Color.loopGreen)
+                if isLooping {
+                    ProgressView()
+                        .foregroundColor(Color.loopGreen)
+                }
             }
-//            }
             if isLooping {
-                Text("looping").font(.caption).fontWeight(.bold)
+                Text("looping").font(.caption2).foregroundColor(colorScheme == .dark ? Color.white.opacity(0.9) : Color.secondary)
             } else if manualTempBasal {
-                Text("Manual").font(.caption).fontWeight(.bold)
+                Text("Manual").font(.caption2).foregroundColor(colorScheme == .dark ? Color.white.opacity(0.9) : Color.secondary)
             } else if actualSuggestion?.timestamp != nil {
-                Text(timeString).font(.caption).fontWeight(.bold)
+                Text(timeString).font(.caption2)
+                    .foregroundColor(colorScheme == .dark ? Color.white.opacity(0.9) : Color.secondary)
             } else {
-                Text("--").font(.caption).fontWeight(.bold)
+                Text("--").font(.caption2).foregroundColor(colorScheme == .dark ? Color.white.opacity(0.9) : Color.secondary)
             }
-            Rectangle().frame(width: UIScreen.main.bounds.width / 2.5, height: 2, alignment: .trailing).foregroundColor(color)
+//            Rectangle().frame(width: UIScreen.main.bounds.width / 2.5, height: 2, alignment: .trailing).foregroundColor(color)
         }
     }
 

+ 5 - 15
FreeAPS/Sources/Modules/Home/View/Header/PumpView.swift

@@ -40,9 +40,7 @@ struct PumpView: View {
     var body: some View {
         HStack {
             Image(systemName: "syringe")
-                .resizable()
-                .aspectRatio(contentMode: .fit)
-                .frame(maxHeight: 15)
+                .font(.system(size: 15))
                 .foregroundColor(.blue)
             Text(
                 (numberFormatter.string(from: (state.suggestion?.iob ?? 0) as NSNumber) ?? "0") +
@@ -53,9 +51,7 @@ struct PumpView: View {
             Spacer()
 
             Image(systemName: "fork.knife")
-                .resizable()
-                .aspectRatio(contentMode: .fit)
-                .frame(maxHeight: 15)
+                .font(.system(size: 15))
                 .foregroundColor(.loopYellow)
             Text(
                 (numberFormatter.string(from: (state.suggestion?.cob ?? 0) as NSNumber) ?? "0") +
@@ -68,9 +64,7 @@ struct PumpView: View {
             if let reservoir = reservoir {
                 HStack {
                     Image(systemName: "drop.fill")
-                        .resizable()
-                        .aspectRatio(contentMode: .fit)
-                        .frame(maxHeight: 15)
+                        .font(.system(size: 15))
                         .foregroundColor(reservoirColor)
                     if reservoir == 0xDEAD_BEEF {
                         Text("50+ " + NSLocalizedString("U", comment: "Insulin unit")).font(.callout).fontWeight(.bold)
@@ -89,9 +83,7 @@ struct PumpView: View {
             if let battery = battery, battery.display ?? false, expiresAtDate == nil {
                 HStack {
                     Image(systemName: "battery.100")
-                        .resizable()
-                        .aspectRatio(contentMode: .fit)
-                        .frame(maxHeight: 15)
+                        .font(.system(size: 15))
                         .foregroundColor(batteryColor)
                     Text("\(Int(battery.percent ?? 100)) %").font(.callout)
                         .fontWeight(.bold)
@@ -101,9 +93,7 @@ struct PumpView: View {
             if let date = expiresAtDate {
                 HStack {
                     Image(systemName: "stopwatch.fill")
-                        .resizable()
-                        .aspectRatio(contentMode: .fit)
-                        .frame(maxHeight: 15)
+                        .font(.system(size: 15))
                         .foregroundColor(timerColor)
 
                     Text(remainingTimeString(time: date.timeIntervalSince(timerDate))).font(.callout).fontWeight(.bold)

+ 68 - 30
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -475,7 +475,6 @@ extension Home {
                 )
             }
             .padding(.bottom)
-            .modal(for: .dataTable, from: self)
         }
 
         private func selectedProfile() -> (name: String, isOn: Bool) {
@@ -527,6 +526,25 @@ extension Home {
                     .padding([.leading, .trailing], 10)
 
                 HStack {
+                    Button {
+                        state.showModal(for: .dataTable)
+                    }
+                    label: {
+                        if #available(iOS 17.0, *) {
+                            Image(systemName: "book.pages")
+                                .font(.system(size: 24))
+                                .foregroundColor(colorIcon)
+                                .padding(8)
+                        } else {
+                            Image(systemName: "book")
+                                .font(.system(size: 24))
+                                .foregroundColor(colorIcon)
+                                .padding(8)
+                        }
+                    }
+                    .foregroundColor(colorIcon)
+                    .buttonStyle(.borderless)
+                    Spacer()
                     Button { state.showModal(for: .addCarbs(editMode: false, override: false)) }
                     label: {
                         ZStack(alignment: Alignment(horizontal: .trailing, vertical: .bottom)) {
@@ -544,15 +562,15 @@ extension Home {
                         }
                     }.buttonStyle(.borderless)
                     Spacer()
-                    Button { state.showModal(for: .addTempTarget) }
-                    label: {
-                        Image(systemName: "target")
-                            .font(.system(size: 24))
-                            .padding(8)
-                    }
-                    .foregroundColor(state.isTempTargetActive ? Color.purple : colorIcon)
-                    .buttonStyle(.borderless)
-                    Spacer()
+//                    Button { state.showModal(for: .addTempTarget) }
+//                    label: {
+//                        Image(systemName: "target")
+//                            .font(.system(size: 24))
+//                            .padding(8)
+//                    }
+//                    .foregroundColor(state.isTempTargetActive ? Color.purple : colorIcon)
+//                    .buttonStyle(.borderless)
+//                    Spacer()
                     Button {
                         state.showModal(for: .bolus(
                             waitForSuggestion: true,
@@ -593,13 +611,13 @@ extension Home {
                             .foregroundColor(colorIcon)
                             .padding(8)
                     }
-                    .foregroundColor(colorIcon)
+                    .foregroundColor(state.isTempTargetActive ? Color.purple : colorIcon)
                     .buttonStyle(.borderless)
                     Spacer()
                     Button { state.showModal(for: .statistics)
                     }
                     label: {
-                        Image(systemName: "chart.bar")
+                        Image(systemName: "chart.pie")
                             .font(.system(size: 24))
                             .foregroundColor(colorIcon)
                             .padding(8)
@@ -644,25 +662,45 @@ extension Home {
                 VStack(spacing: 0) {
                     Spacer()
 
-                    glucoseView.padding(.top, 40)
-
-                    Spacer()
+                    ZStack(alignment: .bottom) {
+                        /// glucose bobble
+                        glucoseView
+
+                        /// eventualBG string at bottomTrailing
+                        if let eventualBG = state.eventualBG {
+                            Text(
+                                "⇢ " + numberFormatter.string(
+                                    from: (
+                                        state.units == .mmolL ? eventualBG
+                                            .asMmolL : Decimal(eventualBG)
+                                    ) as NSNumber
+                                )!
+                            )
+                            .font(.system(size: 12))
+                            .foregroundColor(.secondary)
+                            .padding(.leading)
+                            .offset(x: 75, y: 4)
+                        }
 
-                    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()
-                    }
+                        /// Loop view at bottomLeading
+                        LoopView(
+                            suggestion: $state.suggestion,
+                            enactedSuggestion: $state.enactedSuggestion,
+                            closedLoop: $state.closedLoop,
+                            timerDate: $state.timerDate,
+                            isLooping: $state.isLooping,
+                            lastLoopDate: $state.lastLoopDate,
+                            manualTempBasal: $state.manualTempBasal
+                        ).padding(.trailing)
+                            .offset(x: -80, y: 4)
+                            .onTapGesture {
+                                state.isStatusPopupPresented = true
+                            }.onLongPressGesture {
+                                let impactHeavy = UIImpactFeedbackGenerator(style: .heavy)
+                                impactHeavy.impactOccurred()
+                                state.runLoop()
+                            }
+                    }.padding(.top, 40)
 
                     Spacer()
 

+ 18 - 1
FreeAPS/Sources/Modules/OverrideProfilesConfig/View/OverrideProfilesRootView.swift

@@ -251,7 +251,24 @@ extension OverrideProfilesConfig {
                     }
                 }
 
-                header: { Text("Insulin") }
+                header: {
+                    HStack {
+                        Text("Insulin")
+                        Spacer()
+
+                        Button {
+                            state.showModal(for: .addTempTarget)
+                        } label: {
+                            HStack {
+                                Image(systemName: "plus.circle.fill")
+                                    .font(.system(size: 20))
+                                Text("add temp target")
+                                    .font(.caption)
+                                    .foregroundStyle(Color.blue)
+                            }
+                        }
+                    }
+                }
                 footer: {
                     Text(
                         "Your profile basal insulin will be adjusted with the override percentage and your profile ISF and CR will be inversly adjusted with the percentage."