Skip to content

Commit 9302056

Browse files
committed
Fix demo
1 parent c2540f8 commit 9302056

File tree

1 file changed

+42
-40
lines changed

1 file changed

+42
-40
lines changed

Development/Development/BookCollectionView.swift

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ struct BookCollectionViewSingleSection: View, PreviewProvider {
1919

2020
var body: some View {
2121
CollectionView(
22+
layout: .list.separator(
23+
separator: {
24+
RoundedRectangle(cornerRadius: 8)
25+
.fill(.secondary)
26+
.frame(height: 8)
27+
.padding(.horizontal, 20)
28+
}
29+
),
2230
content: {
2331
SelectableForEach(
2432
data: Item.mock(),
@@ -31,37 +39,32 @@ struct BookCollectionViewSingleSection: View, PreviewProvider {
3139
Cell(index: index, item: item)
3240
}
3341
)
34-
},
35-
layout: .list.separator(separator: {
36-
RoundedRectangle(cornerRadius: 8)
37-
.fill(.secondary)
38-
.frame(height: 8)
39-
.padding(.horizontal, 20)
40-
})
42+
}
4143
)
42-
44+
4345
}
4446
}
45-
47+
4648
}
4749

4850
struct BookCollectionViewSingleSectionNoSeparator: View, PreviewProvider {
49-
51+
5052
var body: some View {
5153
ContentView()
5254
}
53-
55+
5456
static var previews: some View {
5557
Self()
5658
.previewDisplayName(nil)
5759
}
58-
60+
5961
private struct ContentView: View {
60-
62+
6163
@State var selected: Item?
62-
64+
6365
var body: some View {
6466
CollectionView(
67+
layout: .list,
6568
content: {
6669
SelectableForEach(
6770
data: Item.mock(),
@@ -74,13 +77,12 @@ struct BookCollectionViewSingleSectionNoSeparator: View, PreviewProvider {
7477
Cell(index: index, item: item)
7578
}
7679
)
77-
},
78-
layout: .list
80+
}
7981
)
80-
82+
8183
}
8284
}
83-
85+
8486
}
8587

8688
struct BookCollectionViewCombined: View, PreviewProvider {
@@ -101,6 +103,7 @@ struct BookCollectionViewCombined: View, PreviewProvider {
101103

102104
var body: some View {
103105
CollectionView(
106+
layout: .list,
104107
content: {
105108

106109
Text("Static content")
@@ -142,8 +145,7 @@ struct BookCollectionViewCombined: View, PreviewProvider {
142145
Cell(index: item.id, item: item)
143146
}
144147

145-
},
146-
layout: .list
148+
}
147149
)
148150
}
149151
}
@@ -158,6 +160,12 @@ struct BookCollectionViewCombined: View, PreviewProvider {
158160

159161
var body: some View {
160162
CollectionView(
163+
layout: .list.separator {
164+
RoundedRectangle(cornerRadius: 8)
165+
.fill(.secondary)
166+
.frame(height: 8)
167+
.padding(.horizontal, 20)
168+
},
161169
content: {
162170
SelectableForEach(
163171
data: Item.mock(),
@@ -170,13 +178,7 @@ struct BookCollectionViewCombined: View, PreviewProvider {
170178
Cell(index: index, item: item)
171179
}
172180
)
173-
},
174-
layout: .list.separator {
175-
RoundedRectangle(cornerRadius: 8)
176-
.fill(.secondary)
177-
.frame(height: 8)
178-
.padding(.horizontal, 20)
179-
}
181+
}
180182
)
181183
}
182184
}
@@ -193,6 +195,12 @@ struct BookCollectionViewCombined: View, PreviewProvider {
193195
var body: some View {
194196

195197
CollectionView(
198+
layout: .list.separator {
199+
RoundedRectangle(cornerRadius: 8)
200+
.fill(.secondary)
201+
.frame(height: 8)
202+
.padding(.horizontal, 20)
203+
},
196204
content: {
197205
SelectableForEach(
198206
data: Item.mock(),
@@ -211,13 +219,7 @@ struct BookCollectionViewCombined: View, PreviewProvider {
211219
Cell(index: index, item: item)
212220
}
213221
)
214-
},
215-
layout: .list.separator {
216-
RoundedRectangle(cornerRadius: 8)
217-
.fill(.secondary)
218-
.frame(height: 8)
219-
.padding(.horizontal, 20)
220-
}
222+
}
221223
)
222224
}
223225
}
@@ -229,18 +231,19 @@ struct BookPlatformList: View, PreviewProvider {
229231
var body: some View {
230232
ContentView()
231233
}
232-
234+
233235
static var previews: some View {
234236
Self()
235237
.previewDisplayName(nil)
236238
}
237-
239+
238240
private struct ContentView: View {
239-
241+
240242
@State var selected: Item?
241-
243+
242244
var body: some View {
243245
CollectionView(
246+
layout: CollectionViewLayouts.PlatformList(),
244247
content: {
245248
SelectableForEach(
246249
data: Item.mock(),
@@ -254,8 +257,7 @@ struct BookPlatformList: View, PreviewProvider {
254257
Cell(index: index, item: item)
255258
}
256259
)
257-
},
258-
layout: CollectionViewLayouts.PlatformList()
260+
}
259261
)
260262
}
261263
}

0 commit comments

Comments
 (0)