Procházet zdrojové kódy

Merge 'dev' into Crowdin

Jon B.M před 3 roky
rodič
revize
37af48b30d

+ 0 - 4
BGaverages+CoreDataClass.swift

@@ -1,4 +0,0 @@
-import CoreData
-import Foundation
-
-@objc(BGaverages) public class BGaverages: NSManagedObject {}

+ 0 - 15
BGaverages+CoreDataProperties.swift

@@ -1,15 +0,0 @@
-import CoreData
-import Foundation
-
-public extension BGaverages {
-    @nonobjc class func fetchRequest() -> NSFetchRequest<BGaverages> {
-        NSFetchRequest<BGaverages>(entityName: "BGaverages")
-    }
-
-    @NSManaged var average: NSDecimalNumber?
-    @NSManaged var average_1: NSDecimalNumber?
-    @NSManaged var average_7: NSDecimalNumber?
-    @NSManaged var average_30: NSDecimalNumber?
-    @NSManaged var average_90: NSDecimalNumber?
-    @NSManaged var date: Date?
-}

+ 0 - 4
BGmedian+CoreDataClass.swift

@@ -1,4 +0,0 @@
-import CoreData
-import Foundation
-
-@objc(BGmedian) public class BGmedian: NSManagedObject {}

+ 0 - 15
BGmedian+CoreDataProperties.swift

@@ -1,15 +0,0 @@
-import CoreData
-import Foundation
-
-public extension BGmedian {
-    @nonobjc class func fetchRequest() -> NSFetchRequest<BGmedian> {
-        NSFetchRequest<BGmedian>(entityName: "BGmedian")
-    }
-
-    @NSManaged var date: Date?
-    @NSManaged var median: NSDecimalNumber?
-    @NSManaged var median_1: NSDecimalNumber?
-    @NSManaged var median_7: NSDecimalNumber?
-    @NSManaged var median_30: NSDecimalNumber?
-    @NSManaged var median_90: NSDecimalNumber?
-}

+ 0 - 4
Carbohydrates+CoreDataClass.swift

@@ -1,4 +0,0 @@
-import CoreData
-import Foundation
-
-@objc(Carbohydrates) public class Carbohydrates: NSManagedObject {}

+ 0 - 12
Carbohydrates+CoreDataProperties.swift

@@ -1,12 +0,0 @@
-import CoreData
-import Foundation
-
-public extension Carbohydrates {
-    @nonobjc class func fetchRequest() -> NSFetchRequest<Carbohydrates> {
-        NSFetchRequest<Carbohydrates>(entityName: "Carbohydrates")
-    }
-
-    @NSManaged var carbs: NSDecimalNumber?
-    @NSManaged var date: Date?
-    @NSManaged var enteredBy: String?
-}

+ 0 - 67
FreeAPS.xcworkspace/contents.xcworkspacedata

@@ -1,73 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Workspace
    version = "1.0">
-   <Group
-      location = "container:"
-      name = "CoreDataClassesAndProperties">
-      <FileRef
-         location = "group:Presets+CoreDataClass.swift">
-      </FileRef>
-      <FileRef
-         location = "group:Presets+CoreDataProperties.swift">
-      </FileRef>
-      <FileRef
-         location = "group:InsulinDistribution+CoreDataClass.swift">
-      </FileRef>
-      <FileRef
-         location = "group:InsulinDistribution+CoreDataProperties.swift">
-      </FileRef>
-      <FileRef
-         location = "group:Oref0Suggestion+CoreDataClass.swift">
-      </FileRef>
-      <FileRef
-         location = "group:Oref0Suggestion+CoreDataProperties.swift">
-      </FileRef>
-      <FileRef
-         location = "group:HbA1c+CoreDataClass.swift">
-      </FileRef>
-      <FileRef
-         location = "group:HbA1c+CoreDataProperties.swift">
-      </FileRef>
-      <FileRef
-         location = "group:BGmedian+CoreDataClass.swift">
-      </FileRef>
-      <FileRef
-         location = "group:BGmedian+CoreDataProperties.swift">
-      </FileRef>
-      <FileRef
-         location = "group:BGaverages+CoreDataClass.swift">
-      </FileRef>
-      <FileRef
-         location = "group:BGaverages+CoreDataProperties.swift">
-      </FileRef>
-      <FileRef
-         location = "group:Carbohydrates+CoreDataClass.swift">
-      </FileRef>
-      <FileRef
-         location = "group:Carbohydrates+CoreDataProperties.swift">
-      </FileRef>
-      <FileRef
-         location = "group:LoopStatRecord+CoreDataClass.swift">
-      </FileRef>
-      <FileRef
-         location = "group:LoopStatRecord+CoreDataProperties.swift">
-      </FileRef>
-      <FileRef
-         location = "group:Readings+CoreDataClass.swift">
-      </FileRef>
-      <FileRef
-         location = "group:Readings+CoreDataProperties.swift">
-      </FileRef>
-      <FileRef
-         location = "group:TDD+CoreDataClass.swift">
-      </FileRef>
-      <FileRef
-         location = "group:TDD+CoreDataProperties.swift">
-      </FileRef>
-      <FileRef
-         location = "group:FreeAPS/Sources/Helpers/CoreDataStack.swift">
-      </FileRef>
-   </Group>
    <FileRef
       location = "group:FreeAPS.xcodeproj">
    </FileRef>

+ 1 - 1
FreeAPS/Sources/APS/CGM/GlucoseSimulatorSource.swift

@@ -183,7 +183,7 @@ class IntelligentGenerator: BloodGlucoseGenerator {
 
     private func makeStepInTrend() {
         currentGlucose +=
-        Int(Double((trendTargetValue - currentGlucose) / trendStepsLeft) * [0.3, 0.6, 1, 1.3, 1.6, 2.0].randomElement()!)
+            Int(Double((trendTargetValue - currentGlucose) / trendStepsLeft) * [0.3, 0.6, 1, 1.3, 1.6, 2.0].randomElement()!)
         trendStepsLeft -= 1
         if trendStepsLeft == 0 {
             generateNewTrend()

+ 6 - 0
FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings

@@ -1375,6 +1375,12 @@ Enact a temp Basal or a temp target */
 
 "Are you sure you want to delete this CGM?" = "Are you sure you want to delete this CGM?";
 
+/* New Experimental feature */
+"Experimental" = "Experimental";
+    
+/* Smoothing of CGM readings */
+"Smooth Glucose Value" = "Smooth Glucose Value";
+
  /* -----------------------------------------------------------------------------------------------------------
 
   Infotexts from openaps.docs and androidaps.docs

+ 3 - 1
FreeAPS/Sources/Modules/AddCarbs/AddCarbsStateModel.swift

@@ -58,7 +58,9 @@ extension AddCarbs {
                 // Adjust for interval setting other than 60 minutes
                 equivalent /= Decimal(60 / interval)
                 // Round to 1 fraction digit
-                equivalent = Decimal(round(Double(equivalent * 10) / 10))
+                // equivalent = Decimal(round(Double(equivalent * 10) / 10))
+                let roundedEquivalent: Double = round(Double(equivalent * 10)) / 10
+                equivalent = Decimal(roundedEquivalent)
                 // Number of equivalents
                 var numberOfEquivalents = carbEquivalents / equivalent
                 // Only use delay in first loop

+ 49 - 40
FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift

@@ -44,49 +44,10 @@ extension AddCarbs {
                             Text("grams").foregroundColor(.secondary)
                         }.padding(.vertical)
 
-                        if state.useFPU {
-                            HStack {
-                                Text("Protein").foregroundColor(.loopRed).fontWeight(.thin)
-                                Spacer()
-                                DecimalTextField(
-                                    "0",
-                                    value: $state.protein,
-                                    formatter: formatter,
-                                    autofocus: false,
-                                    cleanInput: true
-                                ).foregroundColor(.loopRed)
-
-                                Text("grams").foregroundColor(.secondary)
-                            }
-                            HStack {
-                                Text("Fat").foregroundColor(.loopYellow).fontWeight(.thin)
-                                Spacer()
-                                DecimalTextField(
-                                    "0",
-                                    value: $state.fat,
-                                    formatter: formatter,
-                                    autofocus: false,
-                                    cleanInput: true
-                                )
-                                Text("grams").foregroundColor(.secondary)
-                            }
-
-                            HStack {
-                                Button {
-                                    isPromtPresented = true
-                                }
-                                label: { Text("Save as Preset") }
-                            }
-                            .frame(maxWidth: .infinity, alignment: .trailing)
-                            .disabled(state.carbs <= 0 && state.fat <= 0 && state.protein <= 0)
-                            .popover(isPresented: $isPromtPresented) {
-                                presetPopover
-                            }
-                        }
+                        if state.useFPU { proteinAndFat() }
                         DatePicker("Date", selection: $state.date)
                     }
                 }
-
                 Section {
                     Button { state.add() }
                     label: { Text("Save and continue") }
@@ -150,6 +111,54 @@ extension AddCarbs {
                 }
                 label: { Text("Delete Selected Preset") }
                     .disabled(state.selection == nil)
+                    .accentColor(.orange)
+            }
+        }
+
+        @ViewBuilder private func proteinAndFat() -> some View {
+            HStack {
+                Text("Protein").foregroundColor(.red) // .fontWeight(.thin)
+                Spacer()
+                DecimalTextField(
+                    "0",
+                    value: $state.protein,
+                    formatter: formatter,
+                    autofocus: false,
+                    cleanInput: true
+                ).foregroundColor(.loopRed)
+
+                Text("grams").foregroundColor(.secondary)
+            }
+            HStack {
+                Text("Fat").foregroundColor(.orange) // .fontWeight(.thin)
+                Spacer()
+                DecimalTextField(
+                    "0",
+                    value: $state.fat,
+                    formatter: formatter,
+                    autofocus: false,
+                    cleanInput: true
+                )
+                Text("grams").foregroundColor(.secondary)
+            }
+            HStack {
+                Button {
+                    isPromtPresented = true
+                }
+                label: { Text("Save as Preset") }
+            }
+            .frame(maxWidth: .infinity, alignment: .trailing)
+            .disabled(
+                (state.carbs <= 0 && state.fat <= 0 && state.protein <= 0) ||
+                    (
+                        (((state.selection?.carbs ?? 0) as NSDecimalNumber) as Decimal) == state
+                            .carbs && (((state.selection?.fat ?? 0) as NSDecimalNumber) as Decimal) == state
+                            .fat && (((state.selection?.protein ?? 0) as NSDecimalNumber) as Decimal) == state
+                            .protein
+                    )
+            )
+            .popover(isPresented: $isPromtPresented) {
+                presetPopover
             }
         }
     }

+ 0 - 4
HbA1c+CoreDataClass.swift

@@ -1,4 +0,0 @@
-import CoreData
-import Foundation
-
-@objc(HbA1c) public class HbA1c: NSManagedObject {}

+ 0 - 15
HbA1c+CoreDataProperties.swift

@@ -1,15 +0,0 @@
-import CoreData
-import Foundation
-
-public extension HbA1c {
-    @nonobjc class func fetchRequest() -> NSFetchRequest<HbA1c> {
-        NSFetchRequest<HbA1c>(entityName: "HbA1c")
-    }
-
-    @NSManaged var date: Date?
-    @NSManaged var hba1c: NSDecimalNumber?
-    @NSManaged var hba1c_1: NSDecimalNumber?
-    @NSManaged var hba1c_7: NSDecimalNumber?
-    @NSManaged var hba1c_30: NSDecimalNumber?
-    @NSManaged var hba1c_90: NSDecimalNumber?
-}

+ 0 - 4
InsulinDistribution+CoreDataClass.swift

@@ -1,4 +0,0 @@
-import CoreData
-import Foundation
-
-@objc(InsulinDistribution) public class InsulinDistribution: NSManagedObject {}

+ 0 - 14
InsulinDistribution+CoreDataProperties.swift

@@ -1,14 +0,0 @@
-import CoreData
-import Foundation
-
-public extension InsulinDistribution {
-    @nonobjc class func fetchRequest() -> NSFetchRequest<InsulinDistribution> {
-        NSFetchRequest<InsulinDistribution>(entityName: "InsulinDistribution")
-    }
-
-    @NSManaged var bolus: NSDecimalNumber?
-    @NSManaged var date: Date?
-    @NSManaged var scheduledBasal: NSDecimalNumber?
-    @NSManaged var tempBasal: NSDecimalNumber?
-    @NSManaged var insulin: Oref0Suggestion?
-}

+ 0 - 4
LoopStatRecord+CoreDataClass.swift

@@ -1,4 +0,0 @@
-import CoreData
-import Foundation
-
-@objc(LoopStatRecord) public class LoopStatRecord: NSManagedObject {}

+ 0 - 13
LoopStatRecord+CoreDataProperties.swift

@@ -1,13 +0,0 @@
-import CoreData
-import Foundation
-
-public extension LoopStatRecord {
-    @nonobjc class func fetchRequest() -> NSFetchRequest<LoopStatRecord> {
-        NSFetchRequest<LoopStatRecord>(entityName: "LoopStatRecord")
-    }
-
-    @NSManaged var duration: Double
-    @NSManaged var end: Date?
-    @NSManaged var loopStatus: String?
-    @NSManaged var start: Date?
-}

+ 0 - 4
Oref0Suggestion+CoreDataClass.swift

@@ -1,4 +0,0 @@
-import CoreData
-import Foundation
-
-@objc(Oref0Suggestion) public class Oref0Suggestion: NSManagedObject {}

+ 0 - 43
Oref0Suggestion+CoreDataProperties.swift

@@ -1,43 +0,0 @@
-import CoreData
-import Foundation
-
-public extension Oref0Suggestion {
-    @nonobjc class func fetchRequest() -> NSFetchRequest<Oref0Suggestion> {
-        NSFetchRequest<Oref0Suggestion>(entityName: "Oref0Suggestion")
-    }
-
-    @NSManaged var computedInsulinDistribution: NSSet?
-    @NSManaged var computedTDD: NSSet?
-}
-
-// MARK: Generated accessors for computedInsulinDistribution
-
-public extension Oref0Suggestion {
-    @objc(addComputedInsulinDistributionObject:)
-    @NSManaged func addToComputedInsulinDistribution(_ value: InsulinDistribution)
-
-    @objc(removeComputedInsulinDistributionObject:)
-    @NSManaged func removeFromComputedInsulinDistribution(_ value: InsulinDistribution)
-
-    @objc(addComputedInsulinDistribution:)
-    @NSManaged func addToComputedInsulinDistribution(_ values: NSSet)
-
-    @objc(removeComputedInsulinDistribution:)
-    @NSManaged func removeFromComputedInsulinDistribution(_ values: NSSet)
-}
-
-// MARK: Generated accessors for computedTDD
-
-public extension Oref0Suggestion {
-    @objc(addComputedTDDObject:)
-    @NSManaged func addToComputedTDD(_ value: TDD)
-
-    @objc(removeComputedTDDObject:)
-    @NSManaged func removeFromComputedTDD(_ value: TDD)
-
-    @objc(addComputedTDD:)
-    @NSManaged func addToComputedTDD(_ values: NSSet)
-
-    @objc(removeComputedTDD:)
-    @NSManaged func removeFromComputedTDD(_ values: NSSet)
-}

+ 0 - 4
Presets+CoreDataClass.swift

@@ -1,4 +0,0 @@
-import CoreData
-import Foundation
-
-@objc(Presets) public class Presets: NSManagedObject {}

+ 0 - 13
Presets+CoreDataProperties.swift

@@ -1,13 +0,0 @@
-import CoreData
-import Foundation
-
-public extension Presets {
-    @nonobjc class func fetchRequest() -> NSFetchRequest<Presets> {
-        NSFetchRequest<Presets>(entityName: "Presets")
-    }
-
-    @NSManaged var carbs: NSDecimalNumber?
-    @NSManaged var dish: String?
-    @NSManaged var fat: NSDecimalNumber?
-    @NSManaged var protein: NSDecimalNumber?
-}

+ 0 - 4
Readings+CoreDataClass.swift

@@ -1,4 +0,0 @@
-import CoreData
-import Foundation
-
-@objc(Readings) public class Readings: NSManagedObject {}

+ 0 - 11
Readings+CoreDataProperties.swift

@@ -1,11 +0,0 @@
-import CoreData
-import Foundation
-
-public extension Readings {
-    @nonobjc class func fetchRequest() -> NSFetchRequest<Readings> {
-        NSFetchRequest<Readings>(entityName: "Readings")
-    }
-
-    @NSManaged var date: Date?
-    @NSManaged var glucose: Int16
-}

+ 0 - 4
TDD+CoreDataClass.swift

@@ -1,4 +0,0 @@
-import CoreData
-import Foundation
-
-@objc(TDD) public class TDD: NSManagedObject {}

+ 0 - 12
TDD+CoreDataProperties.swift

@@ -1,12 +0,0 @@
-import CoreData
-import Foundation
-
-public extension TDD {
-    @nonobjc class func fetchRequest() -> NSFetchRequest<TDD> {
-        NSFetchRequest<TDD>(entityName: "TDD")
-    }
-
-    @NSManaged var tdd: NSDecimalNumber?
-    @NSManaged var timestamp: Date?
-    @NSManaged var computed: Oref0Suggestion?
-}