@@ -11,38 +11,38 @@ import SwiftUI
11
11
/// Example:
12
12
///
13
13
/// struct InteractiveStepper_Previews: PreviewProvider {
14
- /// static var previews: some View {
15
- /// WithState(5) { counterBinding in
16
- /// Stepper(value: counterBinding, in: 0...10) {
17
- /// Text("Counter: \(counterBinding.wrappedValue)")
18
- /// }
14
+ /// static var previews: some View {
15
+ /// WithState(5) { counterBinding in
16
+ /// Stepper(value: counterBinding, in: 0...10) {
17
+ /// Text("Counter: \(counterBinding.wrappedValue)")
18
+ /// }
19
+ /// }
19
20
/// }
20
- /// }
21
21
/// }
22
22
///
23
- public struct WithState < Value, Content: View > : View {
24
- @State private var value : Value
25
- let content : ( Binding < Value > ) -> Content
26
-
27
- public init ( _ value: Value , @ViewBuilder content: @escaping ( Binding < Value > ) -> Content ) {
28
- self . _value = State ( wrappedValue: value)
29
- self . content = content
30
- }
23
+ struct WithState < Value, Content: View > : View {
24
+ @State private var value : Value
25
+ let content : ( Binding < Value > ) -> Content
31
26
32
- public var body : some View {
33
- content ( $value)
34
- }
27
+ init ( _ value: Value , @ViewBuilder content: @escaping ( Binding < Value > ) -> Content ) {
28
+ self . _value = State ( wrappedValue: value)
29
+ self . content = content
30
+ }
31
+
32
+ var body : some View {
33
+ content ( $value)
34
+ }
35
35
}
36
36
37
- struct StatefulWrapper_Previews : PreviewProvider {
38
- static var previews : some View {
39
- WithState ( 5 ) { counterBinding in
40
- Stepper ( value: counterBinding, in: 0 ... 10 ) {
41
- Text ( " Counter: \( counterBinding. wrappedValue) " )
42
- }
43
- . padding ( )
37
+ struct WithState_Previews : PreviewProvider {
38
+ static var previews : some View {
39
+ WithState ( 5 ) { counterBinding in
40
+ Stepper ( value: counterBinding, in: 0 ... 10 ) {
41
+ Text ( " Counter: \( counterBinding. wrappedValue) " )
42
+ }
43
+ . padding ( )
44
+ }
44
45
}
45
- }
46
46
}
47
47
48
48
#endif
0 commit comments