diff --git a/ios/WonderousWidget/WonderWidgetViewComponents.swift b/ios/WonderousWidget/WonderWidgetViewComponents.swift index 5b558a95..88d0cbc9 100644 --- a/ios/WonderousWidget/WonderWidgetViewComponents.swift +++ b/ios/WonderousWidget/WonderWidgetViewComponents.swift @@ -47,3 +47,17 @@ struct GaugeProgressStyle: ProgressViewStyle { } } } + +// Create an extension to support new containerBackground API on +// iOS 17 while still supporting iOS 16 and less (https://nemecek.be/blog/192/hotfixing-widgets-for-ios-17-containerbackground-padding) +extension View { + func widgetBackground(_ backgroundView: some View) -> some View { + if #available(iOSApplicationExtension 17.0, *) { + return containerBackground(for: .widget) { + backgroundView + } + } else { + return background(backgroundView) + } + } +} diff --git a/ios/WonderousWidget/WonderousWidgetView.swift b/ios/WonderousWidget/WonderousWidgetView.swift index 1d23ee3d..775953cf 100644 --- a/ios/WonderousWidget/WonderousWidgetView.swift +++ b/ios/WonderousWidget/WonderousWidgetView.swift @@ -55,14 +55,15 @@ struct WonderousWidgetView : View { } return ZStack{ - Color.darkGrey BgImage(entry: entry).opacity(0.8) LinearGradient( gradient: Gradient(colors: [.black.opacity(0), .black]), startPoint: .center, endPoint: .bottom) content.padding(16) - }.widgetURL(URL(string: "wonderous:///collection")) + } + .widgetBackground(Color.darkGrey) + .widgetURL(URL(string: "wonderous:///collection")) } }