Skip to content

Commit 6f0d070

Browse files
fix: size down to 3 columns when view is small
Closes #22
1 parent 763d9d2 commit 6f0d070

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

LabelWorkshop/views/LibraryView.swift

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ func loadImage(for entry: Entry) -> UIImage? {
1414

1515
struct LibraryView: View {
1616
let library: Library
17-
let columns: [GridItem]
1817

1918
@State private var showTagManager: Bool = false
2019

@@ -23,22 +22,19 @@ struct LibraryView: View {
2322

2423
init(library: Library) {
2524
self.library = library
26-
if UIDevice.current.userInterfaceIdiom == .phone {
27-
self.columns = LibraryView.columnsPhone
28-
} else {
29-
self.columns = LibraryView.columnsPad
30-
}
3125
}
3226

3327
var body: some View {
34-
ScrollView {
35-
LazyVGrid(columns: columns) {
36-
ForEach (library.safeGetEntries(), id: \.path) { entry in
37-
GridRow {
38-
EntryMiniView(entry: entry)
28+
GeometryReader { geometry in
29+
ScrollView {
30+
LazyVGrid(columns: geometry.size.width < 600 ? LibraryView.columnsPhone : LibraryView.columnsPad) {
31+
ForEach (library.safeGetEntries(), id: \.path) { entry in
32+
GridRow {
33+
EntryMiniView(entry: entry)
34+
}
3935
}
40-
}
41-
}.padding(16)
36+
}.padding(16)
37+
}
4238
}
4339
.toolbar {
4440
ToolbarItem( placement: .navigationBarTrailing){

0 commit comments

Comments
 (0)