فهرست منبع

change loop icon to systemImage circle.fill

polscm32 2 سال پیش
والد
کامیت
4b39f98836

+ 1 - 0
FreeAPS/Sources/Modules/Home/HomeStateModel.swift

@@ -62,6 +62,7 @@ extension Home {
         @Published var timeZone: TimeZone?
         @Published var hours: Int16 = 6
         @Published var totalBolus: Decimal = 0
+        @Published var isStatusPopupPresented: Bool = false
 
         let coredataContext = CoreDataStack.shared.persistentContainer.viewContext
 

+ 11 - 9
FreeAPS/Sources/Modules/Home/View/Header/LoopView.swift

@@ -21,27 +21,29 @@ struct LoopView: View {
         return formatter
     }
 
-    private let rect = CGRect(x: 0, y: 0, width: 24, height: 24)
+    private let rect = CGRect(x: 0, y: 0, width: 14, height: 14)
     var body: some View {
-        VStack(alignment: .center) {
+        HStack(alignment: .center) {
             ZStack {
-                Circle()
-                    .strokeBorder(color, lineWidth: 4)
+                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 {
-                Text("looping").font(.caption2)
+                Text("looping").font(.caption).fontWeight(.bold)
             } else if manualTempBasal {
-                Text("Manual").font(.caption2)
+                Text("Manual").font(.caption).fontWeight(.bold)
             } else if actualSuggestion?.timestamp != nil {
-                Text(timeString).font(.caption2)
-                    .foregroundColor(.secondary)
+                Text(timeString).font(.caption).fontWeight(.bold)
             } else {
-                Text("--").font(.caption2).foregroundColor(.secondary)
+                Text("--").font(.caption).fontWeight(.bold)
             }
         }
     }

+ 32 - 6
FreeAPS/Sources/Modules/Home/View/Header/PumpView.swift

@@ -9,6 +9,8 @@ struct PumpView: View {
 
     @State var state: Home.StateModel
 
+    @Environment(\.colorScheme) var colorScheme
+
     private var reservoirFormatter: NumberFormatter {
         let formatter = NumberFormatter()
         formatter.numberStyle = .decimal
@@ -29,23 +31,47 @@ struct PumpView: View {
         return formatter
     }
 
+    private var dateFormatter: DateFormatter {
+        let dateFormatter = DateFormatter()
+        dateFormatter.timeStyle = .short
+        return dateFormatter
+    }
+
     var body: some View {
         HStack {
-            Text("IOB").font(.callout).foregroundColor(.secondary)
+            Text("IOB").font(.caption).foregroundColor(.secondary)
             Text(
                 (numberFormatter.string(from: (state.suggestion?.iob ?? 0) as NSNumber) ?? "0") +
                     NSLocalizedString(" U", comment: "Insulin unit")
             )
-            .font(.callout).fontWeight(.bold)
+            .font(.caption).fontWeight(.bold)
 
             Spacer()
 
-            Text("COB").font(.callout).foregroundColor(.secondary)
+            Text("COB").font(.caption).foregroundColor(.secondary)
             Text(
                 (numberFormatter.string(from: (state.suggestion?.cob ?? 0) as NSNumber) ?? "0") +
                     NSLocalizedString(" g", comment: "gram of carbs")
             )
-            .font(.callout).fontWeight(.bold)
+            .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()
+            }
 
             Spacer()
 
@@ -64,7 +90,7 @@ struct PumpView: View {
                             reservoirFormatter
                                 .string(from: reservoir as NSNumber)! + NSLocalizedString(" U", comment: "Insulin unit")
                         )
-                        .font(.callout).fontWeight(.bold)
+                        .font(.caption).fontWeight(.bold)
                     }
                 }
             }
@@ -78,7 +104,7 @@ struct PumpView: View {
                         .aspectRatio(contentMode: .fit)
                         .frame(maxHeight: 15)
                         .foregroundColor(batteryColor)
-                    Text("\(Int(battery.percent ?? 100)) %").font(.callout)
+                    Text("\(Int(battery.percent ?? 100)) %").font(.caption)
                         .fontWeight(.bold)
                 }
             }

+ 27 - 25
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -193,23 +193,23 @@ extension Home {
             }
         }
 
-        var loopView: some View {
-            LoopView(
-                suggestion: $state.suggestion,
-                enactedSuggestion: $state.enactedSuggestion,
-                closedLoop: $state.closedLoop,
-                timerDate: $state.timerDate,
-                isLooping: $state.isLooping,
-                lastLoopDate: $state.lastLoopDate,
-                manualTempBasal: $state.manualTempBasal
-            ).onTapGesture {
-                isStatusPopupPresented = true
-            }.onLongPressGesture {
-                let impactHeavy = UIImpactFeedbackGenerator(style: .heavy)
-                impactHeavy.impactOccurred()
-                state.runLoop()
-            }
-        }
+//        var loopView: some View {
+//            LoopView(
+//                suggestion: $state.suggestion,
+//                enactedSuggestion: $state.enactedSuggestion,
+//                closedLoop: $state.closedLoop,
+//                timerDate: $state.timerDate,
+//                isLooping: $state.isLooping,
+//                lastLoopDate: $state.lastLoopDate,
+//                manualTempBasal: $state.manualTempBasal
+//            ).onTapGesture {
+//                isStatusPopupPresented = true
+//            }.onLongPressGesture {
+//                let impactHeavy = UIImpactFeedbackGenerator(style: .heavy)
+//                impactHeavy.impactOccurred()
+//                state.runLoop()
+//            }
+//        }
 
         var tempBasalString: String? {
             guard let tempRate = state.tempRate else {
@@ -387,11 +387,11 @@ extension Home {
                             .font(.system(size: 12, weight: .bold)).foregroundColor(.zt)
                     }
 
-                    Spacer()
-
-                    loopView.padding(.top, 16)
-
-                    Spacer()
+//                    Spacer()
+//
+                    ////                    loopView.padding(.top, 16)
+//
+//                    Spacer()
 
                     Group {
                         Circle().fill(Color.loopYellow).frame(width: 8, height: 8)
@@ -703,6 +703,8 @@ extension Home {
 
                     timeInterval
 
+                    Spacer()
+
                     legendPanel
 
                     Spacer()
@@ -716,7 +718,7 @@ extension Home {
             .navigationTitle("Home")
             .navigationBarHidden(true)
             .ignoresSafeArea(.keyboard)
-            .popup(isPresented: isStatusPopupPresented, alignment: .top, direction: .top) {
+            .popup(isPresented: state.isStatusPopupPresented, alignment: .top, direction: .top) {
                 popup
                     .padding()
                     .background(
@@ -728,13 +730,13 @@ extension Home {
                             ) : Color(UIColor.darkGray))
                     )
                     .onTapGesture {
-                        isStatusPopupPresented = false
+                        state.isStatusPopupPresented = false
                     }
                     .gesture(
                         DragGesture(minimumDistance: 10, coordinateSpace: .local)
                             .onEnded { value in
                                 if value.translation.height < 0 {
-                                    isStatusPopupPresented = false
+                                    state.isStatusPopupPresented = false
                                 }
                             }
                     )