blob: a7130c2f44ee8ce4c95b3a4ed5062504d77ae4ac (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import SwiftUI
import WaterfallGrid
struct ThumbnailGridView<Item: Hashable & Identifiable, Content: View>: View {
let items: [Item]
let columnCount: Int
let useAlternativeGrid: Bool
let columnsData: [[Item]]
let content: (Item) -> Content
var body: some View {
if useAlternativeGrid {
HStack(alignment: .top) {
ForEach(0..<columnCount, id: \.self) { columnIndex in
LazyVStack {
ForEach(columnsData[columnIndex], id: \.id) { item in
content(item)
.id(item.id)
}
}
.transaction { $0.animation = nil }
}
}
#if os(macOS)
.padding(8)
#else
.padding(.horizontal)
#endif
.transition(.opacity)
} else {
WaterfallGrid(items, id: \.id) { item in
content(item)
.id(item.id)
}
.gridStyle(columns: columnCount)
.transaction { $0.animation = nil }
#if os(macOS)
.padding(8)
#else
.padding(.horizontal)
#endif
.transition(.opacity)
}
}
}
|