Просмотр исходного кода

Merge branch 'devWatch' into Crowdin

Jon B Mårtensson 4 лет назад
Родитель
Сommit
7fd5ba77a9

+ 2 - 0
FreeAPS.xcodeproj/project.pbxproj

@@ -2600,6 +2600,7 @@
 				INFOPLIST_FILE = "FreeAPSWatch WatchKit Extension/Info.plist";
 				INFOPLIST_FILE = "FreeAPSWatch WatchKit Extension/Info.plist";
 				INFOPLIST_KEY_CFBundleDisplayName = "$(APP_DISPLAY_NAME) WatchKit Extension";
 				INFOPLIST_KEY_CFBundleDisplayName = "$(APP_DISPLAY_NAME) WatchKit Extension";
 				INFOPLIST_KEY_CLKComplicationPrincipalClass = ComplicationController;
 				INFOPLIST_KEY_CLKComplicationPrincipalClass = ComplicationController;
+				INFOPLIST_KEY_CLKComplicationPrincipalClass = "$(PRODUCT_MODULE_NAME).ComplicationController"
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
 				LD_RUNPATH_SEARCH_PATHS = (
 				LD_RUNPATH_SEARCH_PATHS = (
 					"$(inherited)",
 					"$(inherited)",
@@ -2635,6 +2636,7 @@
 				INFOPLIST_FILE = "FreeAPSWatch WatchKit Extension/Info.plist";
 				INFOPLIST_FILE = "FreeAPSWatch WatchKit Extension/Info.plist";
 				INFOPLIST_KEY_CFBundleDisplayName = "$(APP_DISPLAY_NAME) WatchKit Extension";
 				INFOPLIST_KEY_CFBundleDisplayName = "$(APP_DISPLAY_NAME) WatchKit Extension";
 				INFOPLIST_KEY_CLKComplicationPrincipalClass = ComplicationController;
 				INFOPLIST_KEY_CLKComplicationPrincipalClass = ComplicationController;
+				INFOPLIST_KEY_CLKComplicationPrincipalClass = "$(PRODUCT_MODULE_NAME).ComplicationController";
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
 				LD_RUNPATH_SEARCH_PATHS = (
 				LD_RUNPATH_SEARCH_PATHS = (
 					"$(inherited)",
 					"$(inherited)",

+ 1 - 2
FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings

@@ -330,8 +330,7 @@ Enact a temp Basal or a temp target */
 " g" = " g";
 " g" = " g";
 
 
 /* The short unit display string for grams */
 /* The short unit display string for grams */
-"g" = "g
-Einheitenzeichen g, für Gramm";
+"g" = "g";
 
 
 /* when 0 U/hr */
 /* when 0 U/hr */
 "0 U/hr" = "0 IE/h";
 "0 U/hr" = "0 IE/h";

+ 1 - 0
FreeAPS/Sources/Localizations/Main/it.lproj/Localizable.strings

@@ -842,6 +842,7 @@ Enact a temp Basal or a temp target */
 "Carbs required: %d g" = "Carbs required: %d g";
 "Carbs required: %d g" = "Carbs required: %d g";
 
 
 /* */
 /* */
+
 "To prevent LOW required %d g of carbs" = "To prevent LOW required %d g of carbs";
 "To prevent LOW required %d g of carbs" = "To prevent LOW required %d g of carbs";
 
 
 /* */
 /* */

+ 54 - 8
FreeAPSWatch WatchKit Extension/ComplicationController.swift

@@ -1,4 +1,5 @@
 import ClockKit
 import ClockKit
+import SwiftUI
 
 
 class ComplicationController: NSObject, CLKComplicationDataSource {
 class ComplicationController: NSObject, CLKComplicationDataSource {
     // MARK: - Complication Configuration
     // MARK: - Complication Configuration
@@ -8,9 +9,13 @@ class ComplicationController: NSObject, CLKComplicationDataSource {
             CLKComplicationDescriptor(
             CLKComplicationDescriptor(
                 identifier: "complication",
                 identifier: "complication",
                 displayName: "FreeAPS X",
                 displayName: "FreeAPS X",
-                supportedFamilies: CLKComplicationFamily.allCases
+                supportedFamilies: [
+                    .graphicCorner,
+                    .modularSmall,
+                    .utilitarianSmall,
+                    .circularSmall
+                ]
             )
             )
-            // Multiple complication support can be added here with more descriptors
         ]
         ]
 
 
         // Call the handler with the currently supported complication descriptors
         // Call the handler with the currently supported complication descriptors
@@ -35,9 +40,49 @@ class ComplicationController: NSObject, CLKComplicationDataSource {
 
 
     // MARK: - Timeline Population
     // MARK: - Timeline Population
 
 
-    func getCurrentTimelineEntry(for _: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
-        // Call the handler with the current timeline entry
-        handler(nil)
+    func getCurrentTimelineEntry(
+        for complication: CLKComplication,
+        withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void
+    ) {
+        switch complication.family {
+        case .graphicCorner:
+            guard let image = UIImage(named: "Complication/Graphic Corner") else {
+                handler(nil)
+                return
+            }
+            let template = CLKComplicationTemplateGraphicCornerTextImage(
+                textProvider: CLKTextProvider(format: "%@", "FreeAPS X"),
+                imageProvider: CLKFullColorImageProvider(fullColorImage: image)
+            )
+            let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
+            handler(timelineEntry)
+        case .modularSmall:
+            let template = CLKComplicationTemplateModularSmallRingText(
+                textProvider: CLKTextProvider(format: "%@", "FAX"),
+                fillFraction: 1,
+                ringStyle: .closed
+            )
+
+            let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
+            handler(timelineEntry)
+        case .utilitarianSmall:
+            guard let image = UIImage(named: "Complication/Utilitarian") else {
+                handler(nil)
+                return
+            }
+            let template = CLKComplicationTemplateUtilitarianSmallSquare(
+                imageProvider: CLKImageProvider(onePieceImage: image)
+            )
+            let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
+            handler(timelineEntry)
+        case .circularSmall:
+            let template =
+                CLKComplicationTemplateCircularSmallSimpleText(textProvider: CLKTextProvider(format: "%@", "FAX"))
+            let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
+            handler(timelineEntry)
+        default:
+            handler(nil)
+        }
     }
     }
 
 
     func getTimelineEntries(
     func getTimelineEntries(
@@ -46,14 +91,15 @@ class ComplicationController: NSObject, CLKComplicationDataSource {
         limit _: Int,
         limit _: Int,
         withHandler handler: @escaping ([CLKComplicationTimelineEntry]?) -> Void
         withHandler handler: @escaping ([CLKComplicationTimelineEntry]?) -> Void
     ) {
     ) {
-        // Call the handler with the timeline entries after the given date
         handler(nil)
         handler(nil)
     }
     }
 
 
     // MARK: - Sample Templates
     // MARK: - Sample Templates
 
 
-    func getLocalizableSampleTemplate(for _: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) {
-        // This method will be called once per supported complication, and the results will be cached
+    func getLocalizableSampleTemplate(
+        for _: CLKComplication,
+        withHandler handler: @escaping (CLKComplicationTemplate?) -> Void
+    ) {
         handler(nil)
         handler(nil)
     }
     }
 }
 }

+ 9 - 9
FreeAPSWatch WatchKit Extension/Views/BolusView.swift

@@ -25,18 +25,18 @@ struct BolusView: View {
                 } label: { Image(systemName: "minus") }
                 } label: { Image(systemName: "minus") }
                     .frame(width: 50)
                     .frame(width: 50)
                 Spacer()
                 Spacer()
-                Text(numberFormatter.string(from: (steps * Double(state.bolusIncrement ?? 0.1)) as NSNumber)! + NSLocalizedString(" U", comment: "Abbreviation for insulin unit"))
+                Text(numberFormatter.string(from: (steps * Double(state.bolusIncrement ?? 0.1)) as NSNumber)! + " U")
                     .font(.headline)
                     .font(.headline)
                     .focusable(true)
                     .focusable(true)
                     .digitalCrownRotation(
                     .digitalCrownRotation(
-                    $steps,
-                    from: 0,
-                    through: Double((state.maxBolus ?? 5) / (state.bolusIncrement ?? 0.1)),
-                    by: 1,
-                    sensitivity: .medium,
-                    isContinuous: false,
-                    isHapticFeedbackEnabled: true
-                )
+                        $steps,
+                        from: 0,
+                        through: Double((state.maxBolus ?? 5) / (state.bolusIncrement ?? 0.1)),
+                        by: 1,
+                        sensitivity: .medium,
+                        isContinuous: false,
+                        isHapticFeedbackEnabled: true
+                    )
                 Spacer()
                 Spacer()
                 Button {
                 Button {
                     let newValue = steps + 1
                     let newValue = steps + 1

+ 2 - 0
FreeAPSWatch WatchKit Extension/Views/CarbsView.swift

@@ -54,11 +54,13 @@ struct CarbsView: View {
                         .frame(width: 24, height: 24)
                         .frame(width: 24, height: 24)
                         .foregroundColor(.loopGreen)
                         .foregroundColor(.loopGreen)
                     Text("Add Carbs ")
                     Text("Add Carbs ")
+
                 }
                 }
             }
             }
             .disabled(amount <= 0)
             .disabled(amount <= 0)
         }
         }
         .navigationTitle("Add Carbs ")
         .navigationTitle("Add Carbs ")
+
         .onAppear {
         .onAppear {
             amount = Double(state.carbsRequired ?? 0)
             amount = Double(state.carbsRequired ?? 0)
         }
         }