From b0f0a2825a21457d13a52da00adeb0d0ea7e96ca Mon Sep 17 00:00:00 2001 From: Nico Swiatecki Date: Tue, 26 Sep 2023 15:28:26 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=F0=9F=94=A7=20Refactor=20widget=20bac?= =?UTF-8?q?kground=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code changes refactor the widget background handling in the Loop Widget Extension. Instead of using `self.background`, it now checks for availability and uses `self.containerBackground` for newer versions, falling back to `self.background` for older versions. This improves compatibility across different platforms and ensures consistent widget backgrounds. --- Loop Widget Extension/Helpers/WidgetBackground.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Loop Widget Extension/Helpers/WidgetBackground.swift b/Loop Widget Extension/Helpers/WidgetBackground.swift index 9883f4917a..21723ec693 100644 --- a/Loop Widget Extension/Helpers/WidgetBackground.swift +++ b/Loop Widget Extension/Helpers/WidgetBackground.swift @@ -11,6 +11,10 @@ import SwiftUI extension View { @ViewBuilder func widgetBackground() -> some View { - self.background { Color("WidgetBackground") } + if #available(watchOS 10.0, iOSApplicationExtension 17.0, iOS 17.0, macOSApplicationExtension 14.0, *) { + self.containerBackground(for: .widget) { Color("WidgetBackground") } + } else { + self.background { Color("WidgetBackground") } + } } }