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

use my LA for now, fix this later...

polscm32 1 год назад
Родитель
Сommit
357424d761

+ 8 - 8
FreeAPS.xcodeproj/project.pbxproj

@@ -288,8 +288,8 @@
 		6B1A8D2E2B156EEF00E76752 /* LiveActivityBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B1A8D2D2B156EEF00E76752 /* LiveActivityBridge.swift */; };
 		6B1F539F9FF75646D1606066 /* SnoozeDataFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36A708CDB546692C2230B385 /* SnoozeDataFlow.swift */; };
 		6B9625766B697D1C98E455A2 /* PumpSettingsEditorStateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72778B68C3004F71F6E79BDC /* PumpSettingsEditorStateModel.swift */; };
-		6BCF84DD2B16843A003AD46E /* LiveActitiyShared.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BCF84DC2B16843A003AD46E /* LiveActitiyShared.swift */; };
-		6BCF84DE2B16843A003AD46E /* LiveActitiyShared.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BCF84DC2B16843A003AD46E /* LiveActitiyShared.swift */; };
+		6BCF84DD2B16843A003AD46E /* LiveActitiyAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BCF84DC2B16843A003AD46E /* LiveActitiyAttributes.swift */; };
+		6BCF84DE2B16843A003AD46E /* LiveActitiyAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BCF84DC2B16843A003AD46E /* LiveActitiyAttributes.swift */; };
 		6EADD581738D64431902AC0A /* (null) in Sources */ = {isa = PBXBuildFile; };
 		6FFAE524D1D9C262F2407CAE /* SnoozeProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAE81192B118804DCD23034 /* SnoozeProvider.swift */; };
 		711C0CB42CAABE788916BC9D /* ManualTempBasalDataFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96653287EDB276A111288305 /* ManualTempBasalDataFlow.swift */; };
@@ -884,7 +884,7 @@
 		6B1A8D232B14D91700E76752 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
 		6B1A8D252B14D91700E76752 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		6B1A8D2D2B156EEF00E76752 /* LiveActivityBridge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LiveActivityBridge.swift; sourceTree = "<group>"; };
-		6BCF84DC2B16843A003AD46E /* LiveActitiyShared.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LiveActitiyShared.swift; sourceTree = "<group>"; };
+		6BCF84DC2B16843A003AD46E /* LiveActitiyAttributes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LiveActitiyAttributes.swift; sourceTree = "<group>"; };
 		6F8BA8533F56BC55748CA877 /* PreferencesEditorProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = PreferencesEditorProvider.swift; sourceTree = "<group>"; };
 		72778B68C3004F71F6E79BDC /* PumpSettingsEditorStateModel.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = PumpSettingsEditorStateModel.swift; sourceTree = "<group>"; };
 		79BDA519C9B890FD9A5DFCF3 /* ISFEditorDataFlow.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ISFEditorDataFlow.swift; sourceTree = "<group>"; };
@@ -2208,7 +2208,7 @@
 			isa = PBXGroup;
 			children = (
 				6B1A8D2D2B156EEF00E76752 /* LiveActivityBridge.swift */,
-				6BCF84DC2B16843A003AD46E /* LiveActitiyShared.swift */,
+				6BCF84DC2B16843A003AD46E /* LiveActitiyAttributes.swift */,
 				BDF34F922C10D0E100D51995 /* LiveActivityAttributes+Helper.swift */,
 				BDF34F882C10C65E00D51995 /* Data */,
 			);
@@ -3203,9 +3203,9 @@
 				1D845DF2E3324130E1D95E67 /* DataTableProvider.swift in Sources */,
 				19F95FFA29F1102A00314DDC /* StatRootView.swift in Sources */,
 				0D9A5E34A899219C5C4CDFAF /* DataTableStateModel.swift in Sources */,
-				6BCF84DD2B16843A003AD46E /* LiveActitiyShared.swift in Sources */,
+				6BCF84DD2B16843A003AD46E /* LiveActitiyAttributes.swift in Sources */,
 				195D80B92AF697F700D25097 /* DynamicProvider.swift in Sources */,
-				6BCF84DD2B16843A003AD46E /* LiveActitiyShared.swift in Sources */,
+				6BCF84DD2B16843A003AD46E /* LiveActitiyAttributes.swift in Sources */,
 				D6D02515BBFBE64FEBE89856 /* DataTableRootView.swift in Sources */,
 				38569349270B5DFB0002C50D /* AppGroupSource.swift in Sources */,
 				F5CA3DB1F9DC8B05792BBFAA /* CGMDataFlow.swift in Sources */,
@@ -3270,8 +3270,8 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				6BCF84DE2B16843A003AD46E /* LiveActitiyShared.swift in Sources */,
-				6BCF84DE2B16843A003AD46E /* LiveActitiyShared.swift in Sources */,
+				6BCF84DE2B16843A003AD46E /* LiveActitiyAttributes.swift in Sources */,
+				6BCF84DE2B16843A003AD46E /* LiveActitiyAttributes.swift in Sources */,
 				6B1A8D1E2B14D91600E76752 /* LiveActivityBundle.swift in Sources */,
 				6B1A8D202B14D91600E76752 /* LiveActivity.swift in Sources */,
 			);

+ 0 - 10
FreeAPS/Sources/Models/FreeAPSSettings.swift

@@ -50,7 +50,6 @@ struct FreeAPSSettings: JSON, Equatable {
     var displayFatAndProteinOnWatch: Bool = false
     var confirmBolusFaster: Bool = false
     var onlyAutotuneBasals: Bool = false
-<<<<<<< HEAD
     var overrideFactor: Decimal = 0.8
     var useCalc: Bool = true
     var fattyMeals: Bool = false
@@ -60,9 +59,6 @@ struct FreeAPSSettings: JSON, Equatable {
     var displayPresets: Bool = true
     var useLiveActivity: Bool = false
     var historyLayout: HistoryLayout = .twoTabs
-=======
-    var useLiveActivity: Bool = false
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
     var lockScreenView: LockScreenView = .simple
 }
 
@@ -297,7 +293,6 @@ extension FreeAPSSettings: Decodable {
             settings.onlyAutotuneBasals = onlyAutotuneBasals
         }
 
-<<<<<<< HEAD
         if let displayPresets = try? container.decode(Bool.self, forKey: .displayPresets) {
             settings.displayPresets = displayPresets
         }
@@ -310,11 +305,6 @@ extension FreeAPSSettings: Decodable {
             settings.historyLayout = historyLayout
         }
 
-=======
-        if let useLiveActivity = try? container.decode(Bool.self, forKey: .useLiveActivity) {
-            settings.useLiveActivity = useLiveActivity
-        }
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
         if let lockScreenView = try? container.decode(LockScreenView.self, forKey: .lockScreenView) {
             settings.lockScreenView = lockScreenView
         }

+ 3 - 8
FreeAPS/Sources/Services/LiveActivity/LiveActitiyShared.swift

@@ -7,14 +7,6 @@ struct LiveActivityAttributes: ActivityAttributes {
         let direction: String?
         let change: String
         let date: Date
-
-        let detailedViewState: ContentAdditionalState?
-
-        /// true for the first state that is set on the activity
-        let isInitialState: Bool
-    }
-
-    public struct ContentAdditionalState: Codable, Hashable {
         let chart: [Double]
         let chartDate: [Date?]
         let rotationDegrees: Double
@@ -22,6 +14,9 @@ struct LiveActivityAttributes: ActivityAttributes {
         let lowGlucose: Double
         let cob: Decimal
         let iob: Decimal
+        let lockScreenView: String
+        let unit: String
+        let isOverrideActive: Bool
     }
 
     let startDate: Date

+ 0 - 221
FreeAPS/Sources/Services/LiveActivity/LiveActivityBridge.swift

@@ -1,119 +1,9 @@
 import ActivityKit
-<<<<<<< HEAD
 import CoreData
-=======
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
 import Foundation
 import Swinject
 import UIKit
 
-<<<<<<< HEAD
-=======
-extension LiveActivityAttributes.ContentState {
-    static func formatGlucose(_ value: Int, mmol: Bool, forceSign: Bool) -> String {
-        let formatter = NumberFormatter()
-        formatter.numberStyle = .decimal
-        formatter.maximumFractionDigits = 0
-        if mmol {
-            formatter.minimumFractionDigits = 1
-            formatter.maximumFractionDigits = 1
-        }
-        if forceSign {
-            formatter.positivePrefix = formatter.plusSign
-        }
-        formatter.roundingMode = .halfUp
-
-        return formatter
-            .string(from: mmol ? value.asMmolL as NSNumber : NSNumber(value: value))!
-    }
-
-    init?(
-        new bg: BloodGlucose,
-        prev: BloodGlucose?,
-        mmol: Bool,
-        chart: [Readings],
-        settings: FreeAPSSettings,
-        suggestion: Suggestion
-    ) {
-        guard let glucose = bg.glucose else {
-            return nil
-        }
-
-        let formattedBG = Self.formatGlucose(glucose, mmol: mmol, forceSign: false)
-
-        var rotationDegrees: Double = 0.0
-
-        switch bg.direction {
-        case .doubleUp,
-             .singleUp,
-             .tripleUp:
-            rotationDegrees = -90
-        case .fortyFiveUp:
-            rotationDegrees = -45
-        case .flat:
-            rotationDegrees = 0
-        case .fortyFiveDown:
-            rotationDegrees = 45
-        case .doubleDown,
-             .singleDown,
-             .tripleDown:
-            rotationDegrees = 90
-        case .notComputable,
-             Optional.none,
-             .rateOutOfRange,
-             .some(.none):
-            rotationDegrees = 0
-        }
-
-        let trendString = bg.direction?.symbol
-
-        let change = prev?.glucose.map({
-            Self.formatGlucose(glucose - $0, mmol: mmol, forceSign: true)
-        }) ?? ""
-
-        let detailedState: LiveActivityAttributes.ContentAdditionalState?
-
-        switch settings.lockScreenView {
-        case .detailed:
-            let chartBG = chart.map(\.glucose)
-
-            let conversionFactor: Double = settings.units == .mmolL ? 18.0 : 1.0
-            let convertedChartBG = chartBG.map { Double($0) / conversionFactor }
-
-            let chartDate = chart.map(\.date)
-
-            /// glucose limits from UI settings
-            let highGlucose = settings.high / Decimal(conversionFactor)
-            let lowGlucose = settings.low / Decimal(conversionFactor)
-
-            let cob = suggestion.cob ?? 0
-            let iob = suggestion.iob ?? 0
-
-            detailedState = LiveActivityAttributes.ContentAdditionalState(
-                chart: convertedChartBG,
-                chartDate: chartDate,
-                rotationDegrees: rotationDegrees,
-                highGlucose: Double(highGlucose),
-                lowGlucose: Double(lowGlucose),
-                cob: cob,
-                iob: iob
-            )
-        case .simple:
-            detailedState = nil
-        }
-
-        self.init(
-            bg: formattedBG,
-            direction: trendString,
-            change: change,
-            date: bg.dateString,
-            detailedViewState: detailedState,
-            isInitialState: false
-        )
-    }
-}
-
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
 @available(iOS 16.2, *) private struct ActiveActivity {
     let activity: Activity<LiveActivityAttributes>
     let startDate: Date
@@ -134,15 +24,9 @@ extension LiveActivityAttributes.ContentState {
     }
 }
 
-<<<<<<< HEAD
 @available(iOS 16.2, *) final class LiveActivityBridge: Injectable, ObservableObject
 {
     @Injected() private var settingsManager: SettingsManager!
-=======
-@available(iOS 16.2, *) final class LiveActivityBridge: Injectable, ObservableObject {
-    @Injected() private var settingsManager: SettingsManager!
-    @Injected() private var glucoseStorage: GlucoseStorage!
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
     @Injected() private var broadcaster: Broadcaster!
     @Injected() private var storage: FileStorage!
 
@@ -153,7 +37,6 @@ extension LiveActivityAttributes.ContentState {
         settingsManager.settings
     }
 
-<<<<<<< HEAD
     var determination: DeterminationData?
     private var currentActivity: ActiveActivity?
     private var latestGlucose: GlucoseData?
@@ -161,19 +44,10 @@ extension LiveActivityAttributes.ContentState {
     var isOverridesActive: OverrideData?
 
     let context = CoreDataStack.shared.newTaskContext()
-=======
-    var suggestion: Suggestion? {
-        storage.retrieve(OpenAPS.Enact.suggested, as: Suggestion.self)
-    }
-
-    private var currentActivity: ActiveActivity?
-    private var latestGlucose: BloodGlucose?
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
 
     init(resolver: Resolver) {
         systemEnabled = activityAuthorizationInfo.areActivitiesEnabled
         injectServices(resolver)
-<<<<<<< HEAD
         setupNotifications()
         monitorForLiveActivityAuthorizationChanges()
         setupGlucoseArray()
@@ -211,27 +85,6 @@ extension LiveActivityAttributes.ContentState {
             // Push the update to the Live Activity
             glucoseDidUpdate(glucoseFromPersistence ?? [])
         }
-=======
-        broadcaster.register(GlucoseObserver.self, observer: self)
-
-        Foundation.NotificationCenter.default.addObserver(
-            forName: UIApplication.didEnterBackgroundNotification,
-            object: nil,
-            queue: nil
-        ) { _ in
-            self.forceActivityUpdate()
-        }
-
-        Foundation.NotificationCenter.default.addObserver(
-            forName: UIApplication.didBecomeActiveNotification,
-            object: nil,
-            queue: nil
-        ) { _ in
-            self.forceActivityUpdate()
-        }
-
-        monitorForLiveActivityAuthorizationChanges()
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
     }
 
     private func monitorForLiveActivityAuthorizationChanges() {
@@ -254,11 +107,7 @@ extension LiveActivityAttributes.ContentState {
         if settings.useLiveActivity {
             if currentActivity?.needsRecreation() ?? true
             {
-<<<<<<< HEAD
                 glucoseDidUpdate(glucoseFromPersistence ?? [])
-=======
-                glucoseDidUpdate(glucoseStorage.recent())
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
             }
         } else {
             Task {
@@ -269,55 +118,33 @@ extension LiveActivityAttributes.ContentState {
 
     /// attempts to present this live activity state, creating a new activity if none exists yet
     @MainActor private func pushUpdate(_ state: LiveActivityAttributes.ContentState) async {
-<<<<<<< HEAD
 //        // End all activities that are not the current one
-=======
-        // hide duplicate/unknown activities
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
         for unknownActivity in Activity<LiveActivityAttributes>.activities
             .filter({ self.currentActivity?.activity.id != $0.id })
         {
             await unknownActivity.end(nil, dismissalPolicy: .immediate)
         }
 
-<<<<<<< HEAD
         if let currentActivity = currentActivity {
             if currentActivity.needsRecreation(), UIApplication.shared.applicationState == .active {
-=======
-        if let currentActivity {
-            if currentActivity.needsRecreation(), UIApplication.shared.applicationState == .active {
-                // activity is no longer visible or old. End it and try to push the update again
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
                 await endActivity()
                 await pushUpdate(state)
             } else {
                 let content = ActivityContent(
                     state: state,
-<<<<<<< HEAD
                     staleDate: min(state.date, Date.now).addingTimeInterval(360) // 6 minutes in seconds
-=======
-                    staleDate: min(state.date, Date.now).addingTimeInterval(TimeInterval(6 * 60))
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
                 )
                 await currentActivity.activity.update(content)
             }
         } else {
             do {
-<<<<<<< HEAD
                 // Create initial non-stale content
                 let nonStaleContent = ActivityContent(
-=======
-                // always push a non-stale content as the first update
-                // pushing a stale content as the frst content results in the activity not being shown at all
-                // apparently this initial state is also what is shown after the live activity expires (after 8h)
-                let expired = ActivityContent(
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
                     state: LiveActivityAttributes.ContentState(
                         bg: "--",
                         direction: nil,
                         change: "--",
                         date: Date.now,
-<<<<<<< HEAD
                         chart: [],
                         chartDate: [],
                         rotationDegrees: 0,
@@ -328,39 +155,22 @@ extension LiveActivityAttributes.ContentState {
                         lockScreenView: "Simple",
                         unit: "--",
                         isOverrideActive: false
-=======
-                        detailedViewState: nil,
-                        isInitialState: true
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
                     ),
                     staleDate: Date.now.addingTimeInterval(60)
                 )
 
-<<<<<<< HEAD
                 // Request a new activity
                 let activity = try Activity.request(
                     attributes: LiveActivityAttributes(startDate: Date.now),
                     content: nonStaleContent,
-=======
-                let activity = try Activity.request(
-                    attributes: LiveActivityAttributes(startDate: Date.now),
-                    content: expired,
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
                     pushType: nil
                 )
                 currentActivity = ActiveActivity(activity: activity, startDate: Date.now)
 
-<<<<<<< HEAD
                 // Push the actual content
                 await pushUpdate(state)
             } catch {
                 print("Activity creation error: \(error)")
-=======
-                // then show the actual content
-                await pushUpdate(state)
-            } catch {
-                print("activity creation error: \(error)")
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
             }
         }
     }
@@ -380,13 +190,8 @@ extension LiveActivityAttributes.ContentState {
 }
 
 @available(iOS 16.2, *)
-<<<<<<< HEAD
 extension LiveActivityBridge {
     func glucoseDidUpdate(_ glucose: [GlucoseData]) {
-=======
-extension LiveActivityBridge: GlucoseObserver {
-    func glucoseDidUpdate(_ glucose: [BloodGlucose]) {
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
         guard settings.useLiveActivity else {
             if currentActivity != nil {
                 Task {
@@ -398,7 +203,6 @@ extension LiveActivityBridge: GlucoseObserver {
 
         // backfill latest glucose if contained in this update
         if glucose.count > 1 {
-<<<<<<< HEAD
             latestGlucose = glucose.dropFirst().first
         }
         defer {
@@ -418,31 +222,6 @@ extension LiveActivityBridge: GlucoseObserver {
                 settings: settings,
                 determination: determination,
                 override: isOverridesActive
-=======
-            latestGlucose = glucose[glucose.count - 2]
-        }
-        defer {
-            self.latestGlucose = glucose.last
-        }
-
-        // fetch glucose for chart from Core Data
-        let coreDataStorage = CoreDataStorage()
-        let sixHoursAgo = Calendar.current.date(byAdding: .hour, value: -6, to: Date()) ?? Date()
-        let fetchGlucose = coreDataStorage.fetchGlucose(interval: sixHoursAgo as NSDate)
-
-        guard let bg = glucose.last else {
-            return
-        }
-
-        if let suggestion = suggestion {
-            let content = LiveActivityAttributes.ContentState(
-                new: bg,
-                prev: latestGlucose,
-                mmol: settings.units == .mmolL,
-                chart: fetchGlucose,
-                settings: settings,
-                suggestion: suggestion
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
             )
 
             if let content = content {

+ 0 - 319
LiveActivity/LiveActivity.swift

@@ -35,26 +35,18 @@ struct LiveActivity: Widget {
     @ViewBuilder private func changeLabel(context: ActivityViewContext<LiveActivityAttributes>) -> some View {
         if !context.state.change.isEmpty {
             if context.isStale {
-<<<<<<< HEAD
                 Text(context.state.change).foregroundStyle(.primary.opacity(0.5)).font(.headline)
                     .strikethrough(pattern: .solid, color: .red.opacity(0.6)).font(.callout)
             } else {
                 HStack {
                     Text(context.state.change).font(.headline)
                 }
-=======
-                Text(context.state.change).foregroundStyle(.primary.opacity(0.5))
-                    .strikethrough(pattern: .solid, color: .red.opacity(0.6))
-            } else {
-                Text(context.state.change)
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
             }
         } else {
             Text("--")
         }
     }
 
-<<<<<<< HEAD
     @ViewBuilder func mealLabel(context: ActivityViewContext<LiveActivityAttributes>) -> some View {
         HStack {
             VStack(alignment: .leading, spacing: 1, content: {
@@ -114,28 +106,6 @@ struct LiveActivity: Widget {
                 }
             })
         }
-=======
-    @ViewBuilder func mealLabel(
-        context _: ActivityViewContext<LiveActivityAttributes>,
-        additionalState: LiveActivityAttributes.ContentAdditionalState
-    ) -> some View {
-        VStack(alignment: .leading, spacing: 1, content: {
-            HStack {
-                Text("COB: ").font(.caption)
-                Text(
-                    (carbsFormatter.string(from: additionalState.cob as NSNumber) ?? "--") +
-                        NSLocalizedString(" g", comment: "grams of carbs")
-                ).font(.caption).fontWeight(.bold)
-            }
-            HStack {
-                Text("IOB: ").font(.caption)
-                Text(
-                    (bolusFormatter.string(from: additionalState.iob as NSNumber) ?? "--") +
-                        NSLocalizedString(" U", comment: "Unit in number of units delivered (keep the space character!)")
-                ).font(.caption).fontWeight(.bold)
-            }
-        })
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
     }
 
     @ViewBuilder func trend(context: ActivityViewContext<LiveActivityAttributes>) -> some View {
@@ -148,29 +118,17 @@ struct LiveActivity: Widget {
         }
     }
 
-<<<<<<< HEAD
     private func updatedLabel(context: ActivityViewContext<LiveActivityAttributes>) -> Text {
         let text = Text("Updated: \(dateFormatter.string(from: context.state.date))")
             .font(.caption2)
         if context.isStale {
             // foregroundStyle is not available in <iOS 17 hence the check here
-=======
-    private func expiredLabel() -> some View {
-        Text("Live Activity Expired. Open Trio to Refresh")
-            .minimumScaleFactor(0.01)
-    }
-
-    private func updatedLabel(context: ActivityViewContext<LiveActivityAttributes>) -> Text {
-        let text = Text("Updated: \(dateFormatter.string(from: context.state.date))")
-        if context.isStale {
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
             if #available(iOSApplicationExtension 17.0, *) {
                 return text.bold().foregroundStyle(.red)
             } else {
                 return text.bold().foregroundColor(.red)
             }
         } else {
-<<<<<<< HEAD
             if #available(iOSApplicationExtension 17.0, *) {
                 return text.bold().foregroundStyle(.secondary)
             } else {
@@ -187,16 +145,6 @@ struct LiveActivity: Widget {
                 .strikethrough(context.isStale, pattern: .solid, color: .red.opacity(0.6))
             Text(context.state.unit).foregroundStyle(.secondary).font(.subheadline).offset(x: -5, y: 5)
         }
-=======
-            return text
-        }
-    }
-
-    private func bgLabel(context: ActivityViewContext<LiveActivityAttributes>) -> Text {
-        Text(context.state.bg)
-            .fontWeight(.bold)
-            .strikethrough(context.isStale, pattern: .solid, color: .red.opacity(0.6))
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
     }
 
     private func bgAndTrend(context: ActivityViewContext<LiveActivityAttributes>, size: Size) -> (some View, Int) {
@@ -212,11 +160,7 @@ struct LiveActivity: Widget {
         var directionText: String?
         var warnColor: Color?
         if let direction = context.state.direction {
-<<<<<<< HEAD
             if size == .compact {
-=======
-            if size == .compact || size == .minimal {
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
                 directionText = String(direction[direction.startIndex ... direction.startIndex])
 
                 if direction.count > 1 {
@@ -257,19 +201,11 @@ struct LiveActivity: Widget {
                 }
             }
         }
-<<<<<<< HEAD
         .foregroundStyle(context.isStale ? Color.primary.opacity(0.5) : Color.primary)
-=======
-        .foregroundStyle(
-            context.state.detailedViewState == nil ? (context.isStale ? Color.primary.opacity(0.5) : Color.primary) :
-                (context.isStale ? Color.white.opacity(0.5) : Color.white)
-        )
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
 
         return (stack, characters)
     }
 
-<<<<<<< HEAD
     @ViewBuilder func bobble(context: ActivityViewContext<LiveActivityAttributes>) -> some View {
         let gradient = LinearGradient(colors: [
             Color(red: 0.6235294118, green: 0.4235294118, blue: 0.9803921569),
@@ -331,55 +267,11 @@ struct LiveActivity: Widget {
             .chartXAxis {
                 AxisMarks(position: .automatic) { _ in
                     AxisGridLine(stroke: .init(lineWidth: 0.2, dash: [2, 3])).foregroundStyle(Color.white)
-=======
-    @ViewBuilder func chart(
-        context: ActivityViewContext<LiveActivityAttributes>,
-        additionalState: LiveActivityAttributes.ContentAdditionalState
-    ) -> some View {
-        if context.isStale {
-            Text("No data available")
-        } else {
-            Chart {
-                ForEach(additionalState.chart.indices, id: \.self) { index in
-                    let currentValue = additionalState.chart[index]
-                    if currentValue > additionalState.highGlucose {
-                        PointMark(
-                            x: .value("Time", additionalState.chartDate[index] ?? Date()),
-                            y: .value("Value", currentValue)
-                        ).foregroundStyle(Color.orange.gradient).symbolSize(12)
-                    } else if currentValue < additionalState.lowGlucose {
-                        PointMark(
-                            x: .value("Time", additionalState.chartDate[index] ?? Date()),
-                            y: .value("Value", currentValue)
-                        ).foregroundStyle(Color.red.gradient).symbolSize(12)
-                    } else {
-                        PointMark(
-                            x: .value("Time", additionalState.chartDate[index] ?? Date()),
-                            y: .value("Value", currentValue)
-                        ).foregroundStyle(Color.green.gradient).symbolSize(12)
-                    }
-                }
-            }.chartPlotStyle { plotContent in
-                plotContent.background(.cyan.opacity(0.1))
-            }
-            .chartYAxis {
-                AxisMarks(position: .leading) { _ in
-                    AxisValueLabel().foregroundStyle(Color.white)
-                    AxisGridLine(stroke: .init(lineWidth: 0.1, dash: [2, 3])).foregroundStyle(Color.white)
-                }
-            }
-            .chartXAxis {
-                AxisMarks(position: .automatic) { _ in
-                    AxisValueLabel(format: .dateTime.hour(.defaultDigits(amPM: .narrow)), anchor: .top)
-                        .foregroundStyle(Color.white)
-                    AxisGridLine(stroke: .init(lineWidth: 0.1, dash: [2, 3])).foregroundStyle(Color.white)
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133
                 }
             }
         }
     }
 
-<<<<<<< HEAD
     var body: some WidgetConfiguration {
         ActivityConfiguration(for: LiveActivityAttributes.self) { context in
             // Lock screen/banner UI goes here
@@ -473,214 +365,3 @@ struct LiveActivity: Widget {
         }
     }
 }
-=======
-    @ViewBuilder func content(context: ActivityViewContext<LiveActivityAttributes>) -> some View {
-        // Lock screen/banner UI goes here
-        if let detailedViewState = context.state.detailedViewState {
-            HStack(spacing: 2) {
-                VStack {
-                    chart(context: context, additionalState: detailedViewState).frame(width: UIScreen.main.bounds.width / 1.8)
-                }.padding(.all, 15)
-                Divider().foregroundStyle(Color.white)
-                VStack(alignment: .center) {
-                    Spacer()
-                    ZStack {
-                        VStack {
-                            bgAndTrend(context: context, size: .expanded).0.font(.largeTitle)
-                            changeLabel(context: context).font(.callout)
-                        }.frame(width: 130, height: 130)
-                    }.scaleEffect(0.85).offset(y: 30)
-                    mealLabel(context: context, additionalState: detailedViewState).padding(.bottom, 8)
-                    updatedLabel(context: context).font(.caption).padding(.bottom, 70)
-                }
-            }
-            .privacySensitive()
-            .imageScale(.small)
-            .background(Color.white.opacity(0.2))
-            .foregroundColor(Color.white)
-            .activityBackgroundTint(Color.black.opacity(0.7))
-            .activitySystemActionForegroundColor(Color.white)
-        } else {
-            Group {
-                if context.state.isInitialState {
-                    // add vertical and horizontal spacers around the label to ensure that the live activity view gets filled completely
-                    HStack {
-                        Spacer()
-                        VStack {
-                            Spacer()
-                            expiredLabel()
-                            Spacer()
-                        }
-                        Spacer()
-                    }
-                } else {
-                    HStack(spacing: 3) {
-                        bgAndTrend(context: context, size: .expanded).0.font(.title)
-                        Spacer()
-                        VStack(alignment: .trailing, spacing: 5) {
-                            changeLabel(context: context).font(.title3)
-                            updatedLabel(context: context).font(.caption).foregroundStyle(.primary.opacity(0.7))
-                        }
-                    }
-                }
-            }
-            .privacySensitive()
-            .padding(.all, 15)
-            // Semantic BackgroundStyle and Color values work here. They adapt to the given interface style (light mode, dark mode)
-            // Semantic UIColors do NOT (as of iOS 17.1.1). Like UIColor.systemBackgroundColor (it does not adapt to changes of the interface style)
-            // The colorScheme environment varaible that is usually used to detect dark mode does NOT work here (it reports false values)
-            .foregroundStyle(Color.primary)
-            .background(BackgroundStyle.background.opacity(0.4))
-            .activityBackgroundTint(Color.clear)
-        }
-    }
-
-    func dynamicIsland(context: ActivityViewContext<LiveActivityAttributes>) -> DynamicIsland {
-        DynamicIsland {
-            // Expanded UI goes here.  Compose the expanded UI through
-            // various regions, like leading/trailing/center/bottom
-            DynamicIslandExpandedRegion(.leading) {
-                bgAndTrend(context: context, size: .expanded).0.font(.title2).padding(.leading, 5)
-            }
-            DynamicIslandExpandedRegion(.trailing) {
-                changeLabel(context: context).font(.title2).padding(.trailing, 5)
-            }
-            DynamicIslandExpandedRegion(.bottom) {
-                if context.state.isInitialState {
-                    expiredLabel()
-                } else if let detailedViewState = context.state.detailedViewState {
-                    chart(context: context, additionalState: detailedViewState)
-                } else {
-                    Group {
-                        updatedLabel(context: context).font(.caption).foregroundStyle(Color.secondary)
-                    }
-                    .frame(
-                        maxHeight: .infinity,
-                        alignment: .bottom
-                    )
-                }
-            }
-            DynamicIslandExpandedRegion(.center) {
-                if context.state.detailedViewState != nil {
-                    updatedLabel(context: context).font(.caption).foregroundStyle(Color.secondary)
-                }
-            }
-        } compactLeading: {
-            bgAndTrend(context: context, size: .compact).0.padding(.leading, 4)
-        } compactTrailing: {
-            changeLabel(context: context).padding(.trailing, 4)
-        } minimal: {
-            let (_label, characterCount) = bgAndTrend(context: context, size: .minimal)
-
-            let label = _label.padding(.leading, 7).padding(.trailing, 3)
-
-            if characterCount < 4 {
-                label
-            } else if characterCount < 5 {
-                label.fontWidth(.condensed)
-            } else {
-                label.fontWidth(.compressed)
-            }
-        }
-        .widgetURL(URL(string: "Trio://"))
-        .keylineTint(Color.purple)
-        .contentMargins(.horizontal, 0, for: .minimal)
-        .contentMargins(.trailing, 0, for: .compactLeading)
-        .contentMargins(.leading, 0, for: .compactTrailing)
-    }
-
-    var body: some WidgetConfiguration {
-        ActivityConfiguration(for: LiveActivityAttributes.self, content: self.content, dynamicIsland: self.dynamicIsland)
-    }
-}
-
-private extension LiveActivityAttributes {
-    static var preview: LiveActivityAttributes {
-        LiveActivityAttributes(startDate: Date())
-    }
-}
-
-private extension LiveActivityAttributes.ContentState {
-    // 0 is the widest digit. Use this to get an upper bound on text width.
-
-    // Use mmol/l notation with decimal point as well for the same reason, it uses up to 4 characters, while mg/dl uses up to 3
-    static var testWide: LiveActivityAttributes.ContentState {
-        LiveActivityAttributes.ContentState(
-            bg: "00.0",
-            direction: "→",
-            change: "+0.0",
-            date: Date(),
-            detailedViewState: nil,
-            isInitialState: false
-        )
-    }
-
-    static var testVeryWide: LiveActivityAttributes.ContentState {
-        LiveActivityAttributes.ContentState(
-            bg: "00.0",
-            direction: "↑↑",
-            change: "+0.0",
-            date: Date(),
-            detailedViewState: nil,
-            isInitialState: false
-        )
-    }
-
-    static var testSuperWide: LiveActivityAttributes.ContentState {
-        LiveActivityAttributes.ContentState(
-            bg: "00.0",
-            direction: "↑↑↑",
-            change: "+0.0",
-            date: Date(),
-            detailedViewState: nil,
-            isInitialState: false
-        )
-    }
-
-    // 2 characters for BG, 1 character for change is the minimum that will be shown
-    static var testNarrow: LiveActivityAttributes.ContentState {
-        LiveActivityAttributes.ContentState(
-            bg: "00",
-            direction: "↑",
-            change: "+0",
-            date: Date(),
-            detailedViewState: nil,
-            isInitialState: false
-        )
-    }
-
-    static var testMedium: LiveActivityAttributes.ContentState {
-        LiveActivityAttributes.ContentState(
-            bg: "000",
-            direction: "↗︎",
-            change: "+00",
-            date: Date(),
-            detailedViewState: nil,
-            isInitialState: false
-        )
-    }
-
-    static var testExpired: LiveActivityAttributes.ContentState {
-        LiveActivityAttributes.ContentState(
-            bg: "--",
-            direction: nil,
-            change: "--",
-            date: Date().addingTimeInterval(-60 * 60),
-            detailedViewState: nil,
-            isInitialState: true
-        )
-    }
-}
-
-@available(iOS 17.0, iOSApplicationExtension 17.0, *)
-#Preview("Notification", as: .content, using: LiveActivityAttributes.preview) {
-    LiveActivity()
-} contentStates: {
-    LiveActivityAttributes.ContentState.testSuperWide
-    LiveActivityAttributes.ContentState.testVeryWide
-    LiveActivityAttributes.ContentState.testWide
-    LiveActivityAttributes.ContentState.testMedium
-    LiveActivityAttributes.ContentState.testNarrow
-    LiveActivityAttributes.ContentState.testExpired
-}
->>>>>>> 9672da256c317a314acc76d6e4f6e82cc174d133