Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions Loop Widget Extension/Components/SystemActionLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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")
}
}
}

Expand All @@ -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())
}
}
}
4 changes: 3 additions & 1 deletion Loop Widget Extension/LoopWidgets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ struct LoopWidgets: WidgetBundle {

@WidgetBundleBuilder
var body: some Widget {
SystemStatusWidget()
if #available(iOS 16.1, *) {
SystemStatusWidget()
}
}
}
15 changes: 11 additions & 4 deletions Loop Widget Extension/Widgets/SystemStatusWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 {
Expand Down Expand Up @@ -66,6 +72,7 @@ struct SystemStatusWidgetEntryView : View {
}
}

@available(iOS 16.1, *)
struct SystemStatusWidget: Widget {
let kind: String = "SystemStatusWidget"

Expand Down