@@ -24,76 +24,76 @@ struct SettingsView: View {
24
24
}
25
25
26
26
var body : some View {
27
- GeometryReader { geometry in
28
- NavigationView {
29
- Form ( ) {
30
- Section ( header: Text ( " Columns " ) ) {
31
- #if os(iOS) && !targetEnvironment(macCatalyst)
32
- self . valueSelector ( self . $newSettings. columnsInPortrait, bounds: 1 ... 10 , step: 1 , label: " Portrait " , in: geometry)
33
- self . valueSelector ( self . $newSettings. columnsInLandscape, bounds: 1 ... 10 , step: 1 , label: " Landscape " , in: geometry)
34
- #else
35
- self . valueSelector ( self . $newSettings. columnsInLandscape, bounds: 1 ... 10 , step: 1 , label: " Columns " , in: geometry)
36
- #endif
37
- }
27
+ NavigationView {
28
+ Form ( ) {
29
+ Section ( header: Text ( " Columns " ) ) {
30
+ #if os(iOS) && !targetEnvironment(macCatalyst)
31
+ self . valueSelector ( self . $newSettings. columnsInPortrait, bounds: 1 ... 10 , step: 1 , label: " Portrait " )
32
+ self . valueSelector ( self . $newSettings. columnsInLandscape, bounds: 1 ... 10 , step: 1 , label: " Landscape " )
33
+ #else
34
+ self . valueSelector ( self . $newSettings. columnsInLandscape, bounds: 1 ... 10 , step: 1 , label: " Columns " )
35
+ #endif
36
+ }
38
37
39
- Section ( header: Text ( " Spacing " ) ) {
40
- self . valueSelector ( self . $newSettings. spacing, bounds: 0 ... 40 , step: 1 , label: " Spacing " , in : geometry )
41
- }
38
+ Section ( header: Text ( " Spacing " ) ) {
39
+ self . valueSelector ( self . $newSettings. spacing, bounds: 0 ... 40 , step: 1 , label: " Spacing " )
40
+ }
42
41
43
- Section ( header: Text ( " Padding " ) ) {
44
- self . valueSelector ( self . $newSettings. padding. top, bounds: 0 ... 40 , step: 1 , label: " Top " , in : geometry )
45
- self . valueSelector ( self . $newSettings. padding. leading, bounds: 0 ... 40 , step: 1 , label: " Leading " , in : geometry )
46
- self . valueSelector ( self . $newSettings. padding. bottom, bounds: 0 ... 40 , step: 1 , label: " Bottom " , in : geometry )
47
- self . valueSelector ( self . $newSettings. padding. trailing, bounds: 0 ... 40 , step: 1 , label: " Trailing " , in : geometry )
48
- }
42
+ Section ( header: Text ( " Padding " ) ) {
43
+ self . valueSelector ( self . $newSettings. padding. top, bounds: 0 ... 40 , step: 1 , label: " Top " )
44
+ self . valueSelector ( self . $newSettings. padding. leading, bounds: 0 ... 40 , step: 1 , label: " Leading " )
45
+ self . valueSelector ( self . $newSettings. padding. bottom, bounds: 0 ... 40 , step: 1 , label: " Bottom " )
46
+ self . valueSelector ( self . $newSettings. padding. trailing, bounds: 0 ... 40 , step: 1 , label: " Trailing " )
47
+ }
49
48
50
- Section ( header: Text ( " Scroll Options " ) ) {
51
- Picker ( selection: self . $newSettings. scrollDirection, label: Text ( " Direction " ) ) {
52
- ForEach ( Axis . allCases, id: \. self) { axes in
53
- Text ( axes. description. capitalized)
54
- }
49
+ Section ( header: Text ( " Scroll Options " ) ) {
50
+ Picker ( selection: self . $newSettings. scrollDirection, label: Text ( " Direction " ) ) {
51
+ ForEach ( Axis . allCases, id: \. self) { axes in
52
+ Text ( axes. description. capitalized)
55
53
}
56
- Toggle ( isOn: self . $newSettings. showsIndicators) {
57
- Text ( " Show Indicators " )
58
- }
59
- . pickerStyle ( SegmentedPickerStyle ( ) )
60
54
}
61
-
62
- Section ( header: Text ( " Animation " ) ) {
63
- Toggle ( isOn: self . $animationEnabled) {
64
- Text ( " Enabled " )
65
- }
66
- if self . animationEnabled {
67
- self . valueSelector ( self . $newSettings. animationSpeed, bounds: 0.1 ... 1 , step: 0.05 , label: " Speed " , in: geometry)
68
- }
55
+ Toggle ( isOn: self . $newSettings. showsIndicators) {
56
+ Text ( " Show Indicators " )
69
57
}
58
+ . pickerStyle ( SegmentedPickerStyle ( ) )
70
59
}
71
- . onDisappear {
72
- let animation = Animation . default. speed ( self . newSettings. animationSpeed)
73
- self . newSettings. animation = self . animationEnabled ? animation : nil
74
- self . settings. wrappedValue = self . newSettings
60
+
61
+ Section ( header: Text ( " Animation " ) ) {
62
+ Toggle ( isOn: self . $animationEnabled) {
63
+ Text ( " Enabled " )
64
+ }
65
+ if self . animationEnabled {
66
+ self . valueSelector ( self . $newSettings. animationSpeed, bounds: 0.1 ... 1 , step: 0.05 , label: " Speed " )
67
+ }
75
68
}
76
- . customNavigationBarTitle ( Text ( " Settings " ) , displayMode: . inline)
77
- . customNavigationBarItems ( leading: self . leadingNavigationBarItems ( ) , trailing: self . trailingNavigationBarItems ( ) )
78
69
}
70
+ . onDisappear {
71
+ let animation = Animation . default. speed ( self . newSettings. animationSpeed)
72
+ self . newSettings. animation = self . animationEnabled ? animation : nil
73
+ self . settings. wrappedValue = self . newSettings
74
+ }
75
+ . customNavigationBarTitle ( Text ( " Settings " ) , displayMode: . inline)
76
+ . customNavigationBarItems ( leading: self . leadingNavigationBarItems ( ) , trailing: self . trailingNavigationBarItems ( ) )
79
77
}
80
78
. navigationViewStyle ( StackNavigationViewStyle ( ) )
81
79
}
82
80
83
- private func valueSelector< V> ( _ selection: Binding < V > , bounds: ClosedRange < V > , step: V . Stride , label: String , in geometry : GeometryProxy ) -> some View
81
+ private func valueSelector< V> ( _ selection: Binding < V > , bounds: ClosedRange < V > , step: V . Stride , label: String ) -> some View
84
82
where V : BinaryFloatingPoint , V. Stride : BinaryFloatingPoint {
85
- #if os(tvOS)
86
- return Picker ( selection: selection, label: Text ( label) ) {
83
+ #if os(tvOS) || os(visionOS)
84
+ Picker ( selection: selection, label: Text ( label) ) {
87
85
ForEach ( Array ( stride ( from: bounds. lowerBound, through: bounds. upperBound, by: step) ) , id: \. self) { index in
88
86
Text ( String ( format: " %.2f " , Double ( index) ) )
89
87
}
90
88
}
91
89
#else
92
- return HStack ( ) {
93
- Text ( " \( label) : \( String ( format: " %.2f " , Double ( selection. wrappedValue) ) ) " )
94
- Spacer ( )
95
- Slider ( value: selection, in: bounds, step: step)
96
- . frame ( width: geometry. size. width / 2 )
90
+ GeometryReader { geometry in
91
+ HStack ( ) {
92
+ Text ( " \( label) : \( String ( format: " %.2f " , Double ( selection. wrappedValue) ) ) " )
93
+ Spacer ( )
94
+ Slider ( value: selection, in: bounds, step: step)
95
+ . frame ( width: geometry. size. width / 2 )
96
+ }
97
97
}
98
98
#endif
99
99
}
0 commit comments