Add support for new containerBackground API in iOS 17
This commit is contained in:
parent
24d08a69e9
commit
e974ce8ca0
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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"))
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user