Fix widgets on iOS 17
This commit is contained in:
parent
f93f778cb2
commit
32feb827f1
|
@ -48,14 +48,24 @@ struct RecentsEntryView: View {
|
||||||
let entry: RecentsEntry
|
let entry: RecentsEntry
|
||||||
|
|
||||||
@Environment(\.widgetFamily) var family
|
@Environment(\.widgetFamily) var family
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
if #available(iOS 17.0, *) {
|
||||||
|
content
|
||||||
|
.containerBackground(.background, for: .widget)
|
||||||
|
} else {
|
||||||
|
content
|
||||||
|
.padding()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
private var content: some View {
|
||||||
if entry.items.isEmpty {
|
if entry.items.isEmpty {
|
||||||
} else {
|
} else {
|
||||||
switch family {
|
switch family {
|
||||||
case .systemSmall:
|
case .systemSmall:
|
||||||
SquareItemView(item: entry.items[0])
|
SquareItemView(item: entry.items[0])
|
||||||
.padding()
|
|
||||||
|
|
||||||
case .systemMedium, .systemLarge:
|
case .systemMedium, .systemLarge:
|
||||||
VStack {
|
VStack {
|
||||||
|
@ -67,7 +77,6 @@ struct RecentsEntryView: View {
|
||||||
Spacer(minLength: 4)
|
Spacer(minLength: 4)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding()
|
|
||||||
|
|
||||||
case .systemExtraLarge:
|
case .systemExtraLarge:
|
||||||
if #available(iOS 16.0, *) {
|
if #available(iOS 16.0, *) {
|
||||||
|
@ -86,7 +95,6 @@ struct RecentsEntryView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding()
|
|
||||||
} else {
|
} else {
|
||||||
Text("Requires iOS 16")
|
Text("Requires iOS 16")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue