Skip to content

Commit b68d347

Browse files
committed
Improved placeholder state in Explore tab
1 parent 53079b1 commit b68d347

File tree

3 files changed

+53
-10
lines changed

3 files changed

+53
-10
lines changed

WWDC/ExploreTabContent.swift

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,47 @@ extension ExploreTabContent.Item {
7272
imageURL: URL(string: "https://wwdc.io/images/placeholder.jpg")!
7373
)
7474
]
75+
static let placeholderItems2: [ExploreTabContent.Item] = [
76+
.init(
77+
id: "4",
78+
title: "Placeholder Item Regular",
79+
subtitle: "Placeholder Description 4",
80+
overlayText: "24m",
81+
overlaySymbol: "play",
82+
imageURL: URL(string: "https://wwdc.io/images/placeholder.jpg")!
83+
),
84+
.init(
85+
id: "5",
86+
title: "Placeholder",
87+
subtitle: "Placeholder Item Description 5",
88+
overlayText: "37m",
89+
overlaySymbol: "play",
90+
imageURL: URL(string: "https://wwdc.io/images/placeholder.jpg")!
91+
),
92+
.init(
93+
id: "6",
94+
title: "Placeholder Item Longer Title",
95+
subtitle: "Placeholder Item Description 6",
96+
overlayText: "37m",
97+
overlaySymbol: "play",
98+
imageURL: URL(string: "https://wwdc.io/images/placeholder.jpg")!
99+
),
100+
.init(
101+
id: "7",
102+
title: "Placeholder",
103+
subtitle: "Item Description 7",
104+
overlayText: "35m",
105+
overlaySymbol: "play",
106+
imageURL: URL(string: "https://wwdc.io/images/placeholder.jpg")!
107+
)
108+
]
75109
}
76110

77111
extension ExploreTabContent {
78112
static let placeholder: ExploreTabContent = {
79113
ExploreTabContent(id: "1", sections: [
80114
Section(id: "placeholder-1", title: "Placeholder Section First", icon: .symbol("app.badge.checkmark"), items: ExploreTabContent.Item.placeholderItems),
81-
Section(id: "placeholder-2", title: "Placeholder Section Second Longer Title", icon: .symbol("app.badge.checkmark"), items: ExploreTabContent.Item.placeholderItems),
115+
Section(id: "placeholder-2", title: "Placeholder Section Second Longer Title", icon: .symbol("app.badge.checkmark"), items: ExploreTabContent.Item.placeholderItems2),
82116
Section(id: "placeholder-3", title: "Placeholder Short", icon: .symbol("app.badge.checkmark"), items: ExploreTabContent.Item.placeholderItems)
83117
])
84118
}()

WWDC/ExploreTabItemView.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ struct ExploreTabItemView: View {
2727
item.progress != nil ? .topTrailing : .bottomTrailing
2828
}
2929

30-
private var hasOverlay: Bool { item.overlayText != nil || item.overlaySymbol != nil }
30+
@Environment(\.redactionReasons)
31+
private var redactionReasons
32+
33+
private var hasOverlay: Bool {
34+
guard redactionReasons.isEmpty else { return false }
35+
return item.overlayText != nil || item.overlaySymbol != nil
36+
}
3137

3238
var body: some View {
3339
VStack(alignment: .leading, spacing: 8) {

WWDC/ExploreTabRootView.swift

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ struct ExploreTabRootView: View {
44
@EnvironmentObject private var provider: ExploreTabProvider
55

66
var body: some View {
7-
if let content = provider.content {
8-
ExploreTabContentView(content: content, scrollOffset: $provider.scrollOffset)
9-
#if DEBUG
10-
.contextMenu { Button("Export JSON…", action: content.exportJSON) }
11-
#endif
12-
} else {
13-
ExploreTabContentView(content: .placeholder, scrollOffset: .constant(.zero))
14-
.redacted(reason: .placeholder)
7+
ZStack {
8+
if let content = provider.content {
9+
ExploreTabContentView(content: content, scrollOffset: $provider.scrollOffset)
10+
#if DEBUG
11+
.contextMenu { Button("Export JSON…", action: content.exportJSON) }
12+
#endif
13+
} else {
14+
ExploreTabContentView(content: .placeholder, scrollOffset: .constant(.zero))
15+
.redacted(reason: .placeholder)
16+
}
1517
}
18+
.animation(.spring(), value: provider.content?.sections.flatMap(\.items).count)
1619
}
1720

1821
}

0 commit comments

Comments
 (0)