Skip to content

Commit 5c6a859

Browse files
committed
Improved layout so it doesn't need a scroll view when enough space is available.
1 parent 25e9647 commit 5c6a859

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

Cookbook/CookbookCommon/Sources/CookbookCommon/Recipes/MiniApps/InstrumentSFZ.swift

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,23 @@ struct InstrumentSFZView: View {
4545

4646
GeometryReader { geoProxy in
4747
VStack {
48-
ScrollView {
49-
ForEach(0..<instrumentParamsChunked.count, id:\.self) { chunkIndex in
50-
HStack {
51-
ForEach(instrumentParamsChunked[chunkIndex], id: \.self) { param in
52-
ParameterRow(param: param)
53-
}
54-
}.padding(5)
48+
let paramRows = ForEach(0..<instrumentParamsChunked.count, id:\.self) { chunkIndex in
49+
HStack {
50+
ForEach(instrumentParamsChunked[chunkIndex], id: \.self) { param in
51+
ParameterRow(param: param)
52+
}
53+
}.padding(5)
54+
}
55+
// i wanted to do it with verticalSizeClass, but couldn't work it out
56+
if horizontalSizeClass == .compact {
57+
ScrollView {
58+
paramRows
5559
}
60+
} else {
61+
paramRows
5662
}
5763
CookbookKeyboard(noteOn: conductor.noteOn,
58-
noteOff: conductor.noteOff).frame(height: geoProxy.size.height / 4)
64+
noteOff: conductor.noteOff).frame(height: geoProxy.size.height / 5)
5965
}
6066
}
6167
.cookbookNavBarTitle("Instrument SFZ")

0 commit comments

Comments
 (0)