@@ -9,6 +9,8 @@ public struct StepperView {
9
9
let title : any View
10
10
let decrementAction : any View
11
11
@Binding var text : String
12
+ let prompt : String
13
+ let onCommit : ( ( ) -> Void ) ?
12
14
let incrementAction : any View
13
15
/// The step value
14
16
let step : Double
@@ -25,7 +27,9 @@ public struct StepperView {
25
27
26
28
public init ( @ViewBuilder title: ( ) -> any View ,
27
29
@ViewBuilder decrementAction: ( ) -> any View = { FioriButton { _ in FioriIcon . actions. less } } ,
28
- text: Binding < String > ,
30
+ text: Binding < String > = . constant( " " ) ,
31
+ prompt: String = " " ,
32
+ onCommit: ( ( ) -> Void ) ? = nil ,
29
33
@ViewBuilder incrementAction: ( ) -> any View = { FioriButton { _ in FioriIcon . actions. add } } ,
30
34
step: Double = 1 ,
31
35
stepRange: ClosedRange < Double > ,
@@ -36,6 +40,8 @@ public struct StepperView {
36
40
self . title = Title ( title: title)
37
41
self . decrementAction = DecrementAction ( decrementAction: decrementAction)
38
42
self . _text = text
43
+ self . prompt = prompt
44
+ self . onCommit = onCommit
39
45
self . incrementAction = IncrementAction ( incrementAction: incrementAction)
40
46
self . step = step
41
47
self . stepRange = stepRange
@@ -49,14 +55,16 @@ public extension StepperView {
49
55
init ( title: AttributedString ,
50
56
decrementAction: FioriButton ? = FioriButton { _ in FioriIcon . actions. less } ,
51
57
text: Binding < String > ,
58
+ prompt: String = " " ,
59
+ onCommit: ( ( ) -> Void ) ? = nil ,
52
60
incrementAction: FioriButton ? = FioriButton { _ in FioriIcon . actions. add } ,
53
61
step: Double = 1 ,
54
62
stepRange: ClosedRange < Double > ,
55
63
isDecimalSupported: Bool = false ,
56
64
icon: Image ? = nil ,
57
65
description: AttributedString ? = nil )
58
66
{
59
- self . init ( title: { Text ( title) } , decrementAction: { decrementAction } , text: text, incrementAction: { incrementAction } , step: step, stepRange: stepRange, isDecimalSupported: isDecimalSupported, icon: { icon } , description: { OptionalText ( description) } )
67
+ self . init ( title: { Text ( title) } , decrementAction: { decrementAction } , text: text, prompt : prompt , onCommit : onCommit , incrementAction: { incrementAction } , step: step, stepRange: stepRange, isDecimalSupported: isDecimalSupported, icon: { icon } , description: { OptionalText ( description) } )
60
68
}
61
69
}
62
70
@@ -69,6 +77,8 @@ public extension StepperView {
69
77
self . title = configuration. title
70
78
self . decrementAction = configuration. decrementAction
71
79
self . _text = configuration. $text
80
+ self . prompt = configuration. prompt
81
+ self . onCommit = configuration. onCommit
72
82
self . incrementAction = configuration. incrementAction
73
83
self . step = configuration. step
74
84
self . stepRange = configuration. stepRange
@@ -84,7 +94,7 @@ extension StepperView: View {
84
94
if self . _shouldApplyDefaultStyle {
85
95
self . defaultStyle ( )
86
96
} else {
87
- self . style. resolve ( configuration: . init( title: . init( self . title) , decrementAction: . init( self . decrementAction) , text: self . $text, incrementAction: . init( self . incrementAction) , step: self . step, stepRange: self . stepRange, isDecimalSupported: self . isDecimalSupported, icon: . init( self . icon) , description: . init( self . description) ) ) . typeErased
97
+ self . style. resolve ( configuration: . init( title: . init( self . title) , decrementAction: . init( self . decrementAction) , text: self . $text, prompt : self . prompt , onCommit : self . onCommit , incrementAction: . init( self . incrementAction) , step: self . step, stepRange: self . stepRange, isDecimalSupported: self . isDecimalSupported, icon: . init( self . icon) , description: . init( self . description) ) ) . typeErased
88
98
. transformEnvironment ( \. stepperViewStyleStack) { stack in
89
99
if !stack. isEmpty {
90
100
stack. removeLast ( )
@@ -102,7 +112,7 @@ private extension StepperView {
102
112
}
103
113
104
114
func defaultStyle( ) -> some View {
105
- StepperView ( . init( title: . init( self . title) , decrementAction: . init( self . decrementAction) , text: self . $text, incrementAction: . init( self . incrementAction) , step: self . step, stepRange: self . stepRange, isDecimalSupported: self . isDecimalSupported, icon: . init( self . icon) , description: . init( self . description) ) )
115
+ StepperView ( . init( title: . init( self . title) , decrementAction: . init( self . decrementAction) , text: self . $text, prompt : self . prompt , onCommit : self . onCommit , incrementAction: . init( self . incrementAction) , step: self . step, stepRange: self . stepRange, isDecimalSupported: self . isDecimalSupported, icon: . init( self . icon) , description: . init( self . description) ) )
106
116
. shouldApplyDefaultStyle ( false )
107
117
. stepperViewStyle ( StepperViewFioriStyle . ContentFioriStyle ( ) )
108
118
. typeErased
0 commit comments