From fd729eb28a05e96e4e529a1a28c0b33ee3254fa6 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 14 Dec 2023 15:01:11 +0900 Subject: [PATCH] fixed recorders widget for iOS 17 --- RecordersWidget/RecordersWidget.swift | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/RecordersWidget/RecordersWidget.swift b/RecordersWidget/RecordersWidget.swift index e896539..a1119fc 100644 --- a/RecordersWidget/RecordersWidget.swift +++ b/RecordersWidget/RecordersWidget.swift @@ -80,8 +80,9 @@ struct RecordersWidgetEntryView: View { .opacity(0.3) } } - .padding([.top, .leading, .trailing], family == .systemSmall ? 16 : 20) + .padding([.top, .leading, .trailing], 16) .padding([.bottom], 4) + .widgetBackground(Color.clear) } func row(leftText: Text, rightText: Text, isActiveRecorder: Bool = false, isAlive: Bool = false) -> some View { @@ -105,6 +106,18 @@ struct RecordersWidget: Widget { } .configurationDisplayName("Arc Recorders") .description("Status of Arc recorders.") - .supportedFamilies([.systemSmall, .systemMedium]) + .supportedFamilies([.systemSmall]) + .contentMarginsDisabled() + } +} + +// workaround for iOS 17's required new background thing while still supporting iOS 16 +extension View { + func widgetBackground(_ backgroundView: some View) -> some View { + if #available(iOSApplicationExtension 17.0, *) { + return containerBackground(for: .widget) { backgroundView } + } else { + return background(backgroundView) + } } }