Skip to content

Commit c892115

Browse files
committed
Fix indentation in WithState
1 parent ab82502 commit c892115

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

Sources/LayoutInspector/WithState.swift

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,38 @@ import SwiftUI
1111
/// Example:
1212
///
1313
/// 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+
/// }
1920
/// }
20-
/// }
2121
/// }
2222
///
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
3126

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+
}
3535
}
3636

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+
}
4445
}
45-
}
4646
}
4747

4848
#endif

0 commit comments

Comments
 (0)