@@ -5,35 +5,37 @@ struct ModularGridView: View {
55 @State var selection : Int = 0
66 @State var items : [ Item ] = ( 0 ... 100 ) . map { Item ( number: $0) }
77 @State var showSettings : Bool = false
8- @State var style = ModularGridStyle ( columns: . min( 200 ) , rows: . min ( 200 ) )
8+ @State var style = ModularGridStyle ( columns: . min( 100 ) , rows: . fixed ( 100 ) )
99
1010 var body : some View {
1111 VStack ( alignment: . trailing) {
1212 Button ( action: { self . showSettings = true } ) {
1313 Text ( " Settings " )
1414 }
15- . padding ( . trailing, self . style. padding. trailing)
16-
17- Grid ( items) { item in
18- Card ( title: " \( item. number) " , color: item. color)
19- . onTapGesture {
20- self . selection = item. number
21- }
22- }
23- . overlayPreferenceValue ( GridItemBoundsPreferencesKey . self) { preferences in
24- RoundedRectangle ( cornerRadius: 16 )
25- . strokeBorder ( lineWidth: 4 )
26- . foregroundColor ( . white)
27- . frame (
28- width: preferences [ self . selection] . width,
29- height: preferences [ self . selection] . height
30- )
31- . position (
32- x: preferences [ self . selection] . midX,
33- y: preferences [ self . selection] . midY
34- )
35- . animation ( . linear)
15+ ScrollView ( style. axes) {
16+ Grid ( items) { item in
17+ Card ( title: " \( item. number) " , color: item. color)
18+ . onTapGesture {
19+ self . selection = item. number
20+ }
21+ }
22+ . overlayPreferenceValue ( GridItemBoundsPreferencesKey . self) { preferences in
23+ RoundedRectangle ( cornerRadius: 16 )
24+ . strokeBorder ( lineWidth: 4 )
25+ . foregroundColor ( . white)
26+ . frame (
27+ width: preferences [ self . selection] . width,
28+ height: preferences [ self . selection] . height
29+ )
30+ . position (
31+ x: preferences [ self . selection] . midX,
32+ y: preferences [ self . selection] . midY
33+ )
34+ . animation ( . linear)
35+ }
36+ . padding ( 16 )
3637 }
38+
3739 }
3840 . sheet ( isPresented: self . $showSettings) {
3941 ModularGridSettingsView ( style: self . $style)
0 commit comments