Skip to content

Commit f45cfbc

Browse files
committed
Update CurrentVersionSheet.swift
1 parent 8a3731d commit f45cfbc

1 file changed

Lines changed: 52 additions & 33 deletions

File tree

Sources/SwiftNEW/Views/Sheets/CurrentVersionSheet.swift

Lines changed: 52 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -59,45 +59,23 @@ extension SwiftNEW {
5959
if showSearch {
6060
searchField
6161
}
62+
#if os(macOS)
63+
currentVersionScrollView(bottomInset: 0, maxScrollHeight: maxScrollHeight)
64+
65+
Spacer()
66+
67+
currentVersionControls
68+
#else
6269
ZStack(alignment: .bottom) {
63-
ScrollView(showsIndicators: false) {
64-
ForEach(items) { item in
65-
if item.version == Bundle.version || item.subVersion == Bundle.version {
66-
ForEach(item.new.filter { matchesSearch($0) }) { new in
67-
releaseRow(new, bodyFont: .footnote, spacing: 2)
68-
}
69-
}
70-
}
71-
// Bottom inset so last item can scroll past the frosted button area.
72-
Color.clear.frame(height: 196)
73-
}
74-
#if !os(tvOS)
75-
.frame(maxWidth: 380)
76-
.padding(.horizontal)
77-
#elseif os(tvOS)
78-
.frame(maxHeight: maxScrollHeight)
79-
#endif
80-
81-
VStack(spacing: 0) {
82-
if history {
83-
HStack {
84-
showHistoryButton
85-
searchButton
86-
}
87-
.padding(.bottom)
88-
} else {
89-
searchButton
90-
.padding(.bottom)
91-
}
92-
93-
closeCurrentButton
94-
.padding(.bottom, 6)
95-
}
70+
currentVersionScrollView(bottomInset: 196, maxScrollHeight: maxScrollHeight)
71+
72+
currentVersionControls
9673
.frame(maxWidth: .infinity)
9774
.padding(.top, 108)
9875
.background { bottomControlBackdrop }
9976
}
10077
.frame(maxWidth: .infinity, maxHeight: .infinity)
78+
#endif
10179
}
10280
}
10381
.task(id: data) {
@@ -111,6 +89,47 @@ extension SwiftNEW {
11189
#endif
11290
}
11391

92+
private func currentVersionScrollView(bottomInset: CGFloat, maxScrollHeight: CGFloat?) -> some View {
93+
ScrollView(showsIndicators: false) {
94+
ForEach(items) { item in
95+
if item.version == Bundle.version || item.subVersion == Bundle.version {
96+
ForEach(item.new.filter { matchesSearch($0) }) { new in
97+
releaseRow(new, bodyFont: .footnote, spacing: 2)
98+
}
99+
}
100+
}
101+
102+
if bottomInset > 0 {
103+
// Let the final row scroll above the overlaid controls.
104+
Color.clear.frame(height: bottomInset)
105+
}
106+
}
107+
#if !os(tvOS)
108+
.frame(maxWidth: 380)
109+
.padding(.horizontal)
110+
#elseif os(tvOS)
111+
.frame(maxHeight: maxScrollHeight)
112+
#endif
113+
}
114+
115+
private var currentVersionControls: some View {
116+
VStack(spacing: 0) {
117+
if history {
118+
HStack {
119+
showHistoryButton
120+
searchButton
121+
}
122+
.padding(.bottom)
123+
} else {
124+
searchButton
125+
.padding(.bottom)
126+
}
127+
128+
closeCurrentButton
129+
.padding(.bottom, 6)
130+
}
131+
}
132+
114133
@ViewBuilder
115134
private var headerTopSpacer: some View {
116135
if presentation == .embed {

0 commit comments

Comments
 (0)