Skip to content

Commit 1ad602a

Browse files
committed
feat(Stepper): allow dynamic children
1 parent b2b15e5 commit 1ad602a

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

ios/SwiftUIRootView.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ public class SwiftUIRootView: SwiftUIContainerView {
107107
}
108108
}
109109
}))
110+
case let stepper as GenericNode<StepperProps>:
111+
AnyView(StepperView(props: stepper.props, content: {
112+
if let children = stepper.children {
113+
ForEach(children, id: \.id) { child in
114+
self.buildSwiftUIView(from: child)
115+
}
116+
}
117+
}))
110118
case let text as GenericNode<TextProps>:
111119
AnyView(TextView(props: text.props))
112120
case let textField as GenericNode<TextFieldProps>:
@@ -115,8 +123,6 @@ public class SwiftUIRootView: SwiftUIContainerView {
115123
AnyView(PickerView(props: picker.props))
116124
case let datePicker as GenericNode<DatePickerProps>:
117125
AnyView(DatePickerView(props: datePicker.props))
118-
case let stepper as GenericNode<StepperProps>:
119-
AnyView(StepperView(props: stepper.props))
120126
case let toggle as GenericNode<ToggleProps>:
121127
AnyView(ToggleView(props: toggle.props))
122128
case let slider as GenericNode<SliderProps>:

ios/components/Stepper/StepperView.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import SwiftUI
22

33
// MARK: - View
44

5-
public struct StepperView: View {
5+
public struct StepperView<Content: View>: View {
66
@ObservedObject public var props: StepperProps
77
@FocusState private var isFocused: Bool
8+
let content: () -> Content
89

9-
public init(props: StepperProps) {
10+
public init(props: StepperProps, @ViewBuilder content: @escaping () -> Content) {
1011
self.props = props
12+
self.content = content
1113
}
1214

1315
public var body: some View {
@@ -34,7 +36,7 @@ public struct StepperView: View {
3436
in: props.minimum ... props.maximum,
3537
step: props.step
3638
) {
37-
Text("\(props.value)")
39+
content()
3840
}
3941
.applyStyles(props.style)
4042
.focused($isFocused)

0 commit comments

Comments
 (0)