Impressia/VernissageWidget/Extensions/View+ContainerBackground.swift

30 lines
834 B
Swift
Raw Normal View History

2023-09-16 10:39:21 +02:00
//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
// Licensed under the Apache License 2.0.
//
import SwiftUI
extension View {
// func widgetBackground(backgroundView: some View) -> some View {
// if #available(iOSApplicationExtension 17.0, *) {
// return containerBackground(for: .widget) {
// backgroundView
// }
// } else {
// return background(backgroundView)
// }
// }
func widgetBackground<V>(@ViewBuilder content: @escaping () -> V) -> some View where V: View {
if #available(iOSApplicationExtension 17.0, *) {
return containerBackground(for: .widget) {
content()
}
} else {
return background(content())
}
}
}