diff --git a/Loop Widget Extension/Components/SystemActionLink.swift b/Loop Widget Extension/Components/SystemActionLink.swift index eb62bbfa40..7962ec1a9f 100644 --- a/Loop Widget Extension/Components/SystemActionLink.swift +++ b/Loop Widget Extension/Components/SystemActionLink.swift @@ -9,7 +9,11 @@ import Foundation import SwiftUI +@available(iOS 16.1, *) struct SystemActionLink: View { + + @Environment(\.widgetRenderingMode) private var widgetRenderingMode + enum Destination: String, CaseIterable { case carbEntry = "carb-entry" case bolus = "manual-bolus" @@ -36,22 +40,26 @@ struct SystemActionLink: View { case .bolus: return Color("insulin") case .preMeal: - return active ? .white : Color("fresh") + return active ? Color("WidgetBackground") : Color("fresh") case .customPreset: - return active ? .white : Color("glucose") + return active ? Color("WidgetBackground") : Color("glucose") } } private func backgroundColor(active: Bool) -> Color { - switch destination { - case .carbEntry: - return active ? Color("fresh") : Color("WidgetSecondaryBackground") - case .bolus: - return active ? Color("insulin") : Color("WidgetSecondaryBackground") - case .preMeal: - return active ? Color("fresh") : Color("WidgetSecondaryBackground") - case .customPreset: - return active ? Color("glucose") : Color("WidgetSecondaryBackground") + if widgetRenderingMode == .accented { + Color(UIColor.systemBackground).opacity(active ? 0.45 : 0.15) + } else { + switch destination { + case .carbEntry: + active ? Color("fresh") : Color("WidgetSecondaryBackground") + case .bolus: + active ? Color("insulin") : Color("WidgetSecondaryBackground") + case .preMeal: + active ? Color("fresh") : Color("WidgetSecondaryBackground") + case .customPreset: + active ? Color("glucose") : Color("WidgetSecondaryBackground") + } } } @@ -73,10 +81,8 @@ struct SystemActionLink: View { icon .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center) .foregroundColor(foregroundColor(active: active)) - .background( - ContainerRelativeShape() - .fill(backgroundColor(active: active)) - ) + .background(backgroundColor(active: active)) + .clipShape(ContainerRelativeShape()) } } } diff --git a/Loop Widget Extension/LoopWidgets.swift b/Loop Widget Extension/LoopWidgets.swift index 26f92edb45..a7065deb4a 100644 --- a/Loop Widget Extension/LoopWidgets.swift +++ b/Loop Widget Extension/LoopWidgets.swift @@ -13,6 +13,8 @@ struct LoopWidgets: WidgetBundle { @WidgetBundleBuilder var body: some Widget { - SystemStatusWidget() + if #available(iOS 16.1, *) { + SystemStatusWidget() + } } } diff --git a/Loop Widget Extension/Widgets/SystemStatusWidget.swift b/Loop Widget Extension/Widgets/SystemStatusWidget.swift index a64096d2ad..015f6c5d50 100644 --- a/Loop Widget Extension/Widgets/SystemStatusWidget.swift +++ b/Loop Widget Extension/Widgets/SystemStatusWidget.swift @@ -10,9 +10,11 @@ import LoopUI import SwiftUI import WidgetKit +@available(iOS 16.1, *) struct SystemStatusWidgetEntryView : View { @Environment(\.widgetFamily) private var widgetFamily + @Environment(\.widgetRenderingMode) private var widgetRenderingMode var entry: StatusWidgetTimelineProvider.Entry @@ -27,17 +29,21 @@ struct SystemStatusWidgetEntryView : View { .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center) .padding(5) .background( - ContainerRelativeShape() - .fill(Color("WidgetSecondaryBackground")) + widgetRenderingMode == .accented + ? Color(UIColor.systemBackground).opacity(0.15) + : Color("WidgetSecondaryBackground") ) + .clipShape(ContainerRelativeShape()) PumpView(entry: entry) .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center) .padding(5) .background( - ContainerRelativeShape() - .fill(Color("WidgetSecondaryBackground")) + widgetRenderingMode == .accented + ? Color(UIColor.systemBackground).opacity(0.15) + : Color("WidgetSecondaryBackground") ) + .clipShape(ContainerRelativeShape()) } if widgetFamily != .systemSmall { @@ -66,6 +72,7 @@ struct SystemStatusWidgetEntryView : View { } } +@available(iOS 16.1, *) struct SystemStatusWidget: Widget { let kind: String = "SystemStatusWidget"