فهرست منبع

Confirmation Bolus updates from dev

Jon Mårtensson 4 سال پیش
والد
کامیت
bcf71becb4

+ 4 - 5
FreeAPS.xcodeproj/project.pbxproj

@@ -205,7 +205,6 @@
 		38E8757927579D9200975559 /* Publisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3811DE5525C9D4D500A708ED /* Publisher.swift */; };
 		38E8757B2757B1C300975559 /* TempTargetsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38E8757A2757B1C300975559 /* TempTargetsView.swift */; };
 		38E8757D2757C45D00975559 /* BolusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38E8757C2757C45D00975559 /* BolusView.swift */; };
-		38E8757E2758C86A00975559 /* ConvenienceExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38192E0C261BAF980094D973 /* ConvenienceExtensions.swift */; };
 		38E8758027595DC600975559 /* BolusConfirmationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38E8757F27595DC500975559 /* BolusConfirmationView.swift */; };
 		38E989DD25F5021400C0CED0 /* PumpStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38E989DC25F5021400C0CED0 /* PumpStatus.swift */; };
 		38E98A2325F52C9300C0CED0 /* Signpost.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38E98A1B25F52C9300C0CED0 /* Signpost.swift */; };
@@ -2535,7 +2534,7 @@
 				CODE_SIGN_ENTITLEMENTS = FreeAPSWatch/FreeAPSWatch.entitlements;
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = "$(BUILD_VERSION)";
-				DEVELOPMENT_TEAM = "${DEVELOPER_TEAM}";
+				DEVELOPMENT_TEAM = T7VZ6LU6H3;
 				GENERATE_INFOPLIST_FILE = YES;
 				IBSC_MODULE = FreeAPSWatch_WatchKit_Extension;
 				INFOPLIST_KEY_CFBundleDisplayName = "$(APP_DISPLAY_NAME)";
@@ -2565,7 +2564,7 @@
 				CODE_SIGN_ENTITLEMENTS = FreeAPSWatch/FreeAPSWatch.entitlements;
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = "$(BUILD_VERSION)";
-				DEVELOPMENT_TEAM = "${DEVELOPER_TEAM}";
+				DEVELOPMENT_TEAM = T7VZ6LU6H3;
 				GENERATE_INFOPLIST_FILE = YES;
 				IBSC_MODULE = FreeAPSWatch_WatchKit_Extension;
 				INFOPLIST_KEY_CFBundleDisplayName = "$(APP_DISPLAY_NAME)";
@@ -2594,7 +2593,7 @@
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = "$(BUILD_VERSION)";
 				DEVELOPMENT_ASSET_PATHS = "\"FreeAPSWatch WatchKit Extension/Preview Content\"";
-				DEVELOPMENT_TEAM = BA7ZHP4963;
+				DEVELOPMENT_TEAM = T7VZ6LU6H3;
 				ENABLE_PREVIEWS = YES;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = "FreeAPSWatch WatchKit Extension/Info.plist";
@@ -2629,7 +2628,7 @@
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = "$(BUILD_VERSION)";
 				DEVELOPMENT_ASSET_PATHS = "\"FreeAPSWatch WatchKit Extension/Preview Content\"";
-				DEVELOPMENT_TEAM = BA7ZHP4963;
+				DEVELOPMENT_TEAM = T7VZ6LU6H3;
 				ENABLE_PREVIEWS = YES;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = "FreeAPSWatch WatchKit Extension/Info.plist";

+ 12 - 20
FreeAPSWatch WatchKit Extension/Views/BolusView.swift

@@ -10,9 +10,10 @@ struct BolusView: View {
         formatter.numberStyle = .decimal
         formatter.minimum = 0
         formatter.maximum = Double((state.maxBolus ?? 5) / (state.bolusIncrement ?? 0.1)) as NSNumber
-        formatter.maximumFractionDigits = 2
-        formatter.minimumFractionDigits = 2
+        formatter.maximumFractionDigits = (state.bolusIncrement ?? 0.1) > 0.05 ? 1 : 2
+        formatter.minimumFractionDigits = (state.bolusIncrement ?? 0.1) > 0.05 ? 1 : 2
         formatter.allowsFloats = true
+        formatter.roundingIncrement = Double(state.bolusIncrement ?? 0.1) as NSNumber
         return formatter
     }
 
@@ -70,23 +71,7 @@ struct BolusView: View {
                     }
                     .disabled(steps <= 0)
                 }
-                label: {
-                    Image(systemName: "xmark.circle.fill")
-                        .resizable()
-                        .foregroundColor(.loopRed)
-                        .frame(width: 30, height: 30)
-                }
-                Button {
-                    enactBolus()
-                }
-                label: {
-                    Image(systemName: "checkmark.circle.fill")
-                        .resizable()
-                        .foregroundColor(.loopGreen)
-                        .frame(width: 30, height: 30)
-                }
-                .disabled(steps <= 0)
-            }
+            }.frame(maxHeight: .infinity)
         }
         .navigationTitle("Enact Bolus")
         .onAppear {
@@ -102,6 +87,13 @@ struct BolusView: View {
 
 struct BolusView_Previews: PreviewProvider {
     static var previews: some View {
-        BolusView().environmentObject(WatchStateModel())
+        let state = WatchStateModel()
+        state.bolusRecommended = 10.3
+        state.bolusIncrement = 0.05
+        return Group {
+            BolusView()
+            BolusView().previewDevice("Apple Watch Series 5 - 40mm")
+            BolusView().previewDevice("Apple Watch Series 3 - 38mm")
+        }.environmentObject(state)
     }
 }

+ 12 - 46
FreeAPSWatch WatchKit Extension/Views/CarbsView.swift

@@ -16,48 +16,10 @@ struct CarbsView: View {
     }
 
     var body: some View {
-        VStack(spacing: 16) {
-            HStack {
-                Button {
-                    let newValue = amount - 5
-                    amount = max(newValue, 0)
-                } label: { Image(systemName: "minus") }
-                    .frame(width: 50)
-                Spacer()
-                Text(numberFormatter.string(from: amount as NSNumber)! + " g")
-                    .font(.title2)
-                    .focusable(true)
-                    .digitalCrownRotation(
-                        $amount,
-                        from: 0,
-                        through: Double(state.maxCOB ?? 120),
-                        by: 1,
-                        sensitivity: .medium,
-                        isContinuous: false,
-                        isHapticFeedbackEnabled: true
-                    )
-                Spacer()
-                Button {
-                    let newValue = amount + 5
-                    amount = min(newValue, Double(state.maxCOB ?? 120))
-                } label: { Image(systemName: "plus") }
-                    .frame(width: 50)
-            }
-            Button {
-                state.addCarbs(Int(amount))
-            }
-            label: {
+        GeometryReader { geo in
+            VStack(spacing: 16) {
                 HStack {
-                    Image("carbs", bundle: nil)
-                        .renderingMode(.template)
-                        .resizable()
-                        .frame(width: 24, height: 24)
-                        .foregroundColor(.loopGreen)
-                    Text("Add Carbs ")
-
-=======
                     Button {
-                        WKInterfaceDevice.current().play(.click)
                         let newValue = amount - 5
                         amount = max(newValue, 0)
                     } label: {
@@ -79,14 +41,12 @@ struct CarbsView: View {
                         )
                     Spacer()
                     Button {
-                        WKInterfaceDevice.current().play(.click)
                         let newValue = amount + 5
                         amount = min(newValue, Double(state.maxCOB ?? 120))
                     } label: { Image(systemName: "plus") }
                         .frame(width: geo.size.width / 4)
                 }
                 Button {
-                    WKInterfaceDevice.current().play(.click)
                     state.addCarbs(Int(amount))
                 }
                 label: {
@@ -96,14 +56,13 @@ struct CarbsView: View {
                             .resizable()
                             .frame(width: 24, height: 24)
                             .foregroundColor(.loopGreen)
-                        Text("Add Carbs ")
+                        Text("Add Carbs")
                     }
->>>>>>> 1e5c754... 38mm watch support and fixed bolus rounding
                 }
                 .disabled(amount <= 0)
             }.frame(maxHeight: .infinity)
         }
-        .navigationTitle("Add Carbs ")
+        .navigationTitle("Add Carbs")
         .onAppear {
             amount = Double(state.carbsRequired ?? 0)
         }
@@ -112,6 +71,13 @@ struct CarbsView: View {
 
 struct CarbsView_Previews: PreviewProvider {
     static var previews: some View {
-        CarbsView().environmentObject(WatchStateModel())
+        let state = WatchStateModel()
+        state.carbsRequired = 120
+        return Group {
+            CarbsView()
+            CarbsView().previewDevice("Apple Watch Series 5 - 40mm")
+            CarbsView().previewDevice("Apple Watch Series 3 - 38mm")
+        }
+        .environmentObject(state)
     }
 }