@@ -62,7 +62,7 @@ public struct FioriButton: View {
62
62
let image : ( UIControl . State ) -> any View
63
63
let imagePosition : FioriButtonImagePosition
64
64
let imageTitleSpacing : CGFloat
65
- private let touchAreaInset : CGFloat = 50
65
+ private let touchAreaInset : CGFloat = 3
66
66
67
67
@Environment ( \. isEnabled) private var isEnabled
68
68
@Environment ( \. fioriButtonStyle) private var fioriButtonStyle
@@ -164,17 +164,20 @@ public struct FioriButton: View {
164
164
} )
165
165
} else {
166
166
Button {
167
- self . action ? ( . normal )
167
+ //
168
168
} label: {
169
169
EmptyView ( )
170
170
}
171
- . buttonStyle ( _ButtonStyleImpl ( fioriButtonStyle: self . fioriButtonStyle, label: self . label, image: self . image, imagePosition: self . imagePosition, imageTitleSpacing: self . imageTitleSpacing, isEnabled: self . isEnabled) )
171
+ . buttonStyle ( _ButtonStyleImpl ( fioriButtonStyle: self . fioriButtonStyle, label: self . label, image: self . image, imagePosition: self . imagePosition, imageTitleSpacing: self . imageTitleSpacing, isEnabled: self . isEnabled, state: self . state) )
172
+ . overlay ( GeometryReader { proxy in
173
+ Color . clear. contentShape ( Rectangle ( ) ) . gesture ( self . createGesture ( proxy. size) )
174
+ } )
172
175
}
173
176
}
174
177
}
175
178
176
179
func createGesture( _ size: CGSize ) -> some Gesture {
177
- let touchArea = CGRect ( origin: . zero, size: size) . insetBy ( dx: - self . touchAreaInset , dy: - self . touchAreaInset)
180
+ let touchArea = CGRect ( origin: . zero, size: size) . insetBy ( dx: 0 , dy: - self . touchAreaInset)
178
181
var isCancelled = false
179
182
180
183
return DragGesture ( minimumDistance: 0 )
@@ -185,6 +188,9 @@ public struct FioriButton: View {
185
188
186
189
if !touchArea. contains ( value. location) {
187
190
isCancelled = true
191
+ } else if !self . isSelectionPersistent {
192
+ self . _state = self . state == . normal ? . selected : . normal
193
+ self . action ? ( self . state)
188
194
}
189
195
}
190
196
. onEnded { _ in
@@ -233,10 +239,9 @@ private struct _ButtonStyleImpl: ButtonStyle {
233
239
let imagePosition : FioriButtonImagePosition
234
240
let imageTitleSpacing : CGFloat
235
241
let isEnabled : Bool
242
+ let state : UIControl . State
236
243
237
244
func makeBody( configuration: Configuration ) -> some View {
238
- let state : UIControl . State = self . isEnabled ? ( configuration. isPressed ? . highlighted : . normal) : . disabled
239
-
240
245
let config = FioriButtonStyleConfiguration ( state: state, _label: { state in
241
246
let v = self . label ( state)
242
247
return FioriButtonStyleConfiguration . Label ( v)
0 commit comments