@@ -153,13 +153,14 @@ public struct ResponsiveTextField {
153
153
154
154
// MARK: - Managing the first responder state
155
155
156
- public struct FirstResponderStateChangeHandler {
156
+ @MainActor
157
+ public struct FirstResponderStateChangeHandler : Sendable {
157
158
/// A closure that will be called when the first responder state changes.
158
159
///
159
160
/// - Parameters:
160
161
/// - Bool: A boolean indicating if the text field is now the first responder or not.
161
162
///
162
- public var handleStateChange : ( Bool ) -> Void
163
+ public var handleStateChange : @ Sendable @ MainActor ( Bool ) -> Void
163
164
164
165
/// Allows fine-grained control over if the text field should become the first responder.
165
166
///
@@ -169,7 +170,7 @@ public struct FirstResponderStateChangeHandler {
169
170
/// If the responder change was triggered programatically by a `FirstResponderDemand`
170
171
/// and this returns `false` the demand will still be marked as fulfilled and reset to `nil`.
171
172
///
172
- public var canBecomeFirstResponder : ( ( ) -> Bool ) ?
173
+ public var canBecomeFirstResponder : ( @ Sendable @ MainActor ( ) -> Bool ) ?
173
174
174
175
/// Allows fine-grained control over if the text field should resign the first responder.
175
176
///
@@ -179,21 +180,21 @@ public struct FirstResponderStateChangeHandler {
179
180
/// If the responder change was triggered programatically by a `FirstResponderDemand`
180
181
/// and this returns `false` the demand will still be marked as fulfilled and reset to `nil`.
181
182
///
182
- public var canResignFirstResponder : ( ( ) -> Bool ) ?
183
+ public var canResignFirstResponder : ( @ Sendable @ MainActor ( ) -> Bool ) ?
183
184
184
185
/// Initialises a state change handler with a `handleStateChange` callback.
185
186
///
186
187
/// Most of the time this is the only callback that you will need to provide so this initialiser
187
188
/// can be called with trailing closure syntax.
188
189
///
189
- public init ( handleStateChange: @escaping ( Bool ) -> Void ) {
190
+ public init ( handleStateChange: @escaping @ Sendable @ MainActor ( Bool ) -> Void ) {
190
191
self . handleStateChange = handleStateChange
191
192
}
192
193
193
194
public init (
194
- handleStateChange: @escaping ( Bool ) -> Void ,
195
- canBecomeFirstResponder: ( ( ) -> Bool ) ? = nil ,
196
- canResignFirstResponder: ( ( ) -> Bool ) ? = nil
195
+ handleStateChange: @escaping @ Sendable @ MainActor ( Bool ) -> Void ,
196
+ canBecomeFirstResponder: ( @ Sendable @ MainActor ( ) -> Bool ) ? = nil ,
197
+ canResignFirstResponder: ( @ Sendable @ MainActor ( ) -> Bool ) ? = nil
197
198
) {
198
199
self . handleStateChange = handleStateChange
199
200
self . canBecomeFirstResponder = canBecomeFirstResponder
@@ -253,7 +254,8 @@ public struct FirstResponderStateChangeHandler {
253
254
/// cycle completes using this method. You can pass in any suitable scheduler, such as `RunLoop.main` or
254
255
/// `DispatchQueue.main`.
255
256
///
256
- public func receive< S: Scheduler > ( on scheduler: S , options: S . SchedulerOptions ? = nil ) -> Self {
257
+ public func receive< S: Scheduler > ( on scheduler: S , options: S . SchedulerOptions ? = nil ) -> Self
258
+ where S: Sendable , S. SchedulerOptions: Sendable {
257
259
return . init(
258
260
handleStateChange: { isFirstResponder in
259
261
scheduler. schedule ( options: options) {
@@ -288,7 +290,7 @@ extension FirstResponderStateChangeHandler {
288
290
289
291
/// Represents a request to change the text field's first responder state.
290
292
///
291
- public enum FirstResponderDemand : Equatable {
293
+ public enum FirstResponderDemand : Equatable , Sendable {
292
294
/// The text field should become first responder on the next view update.
293
295
case shouldBecomeFirstResponder
294
296
@@ -466,10 +468,10 @@ extension ResponsiveTextField {
466
468
/// that you use in your app. Configurations are composable and can be combined to create more
467
469
/// detailed configurations.
468
470
///
469
- public struct Configuration {
470
- var configure : ( UITextField ) -> Void
471
+ public struct Configuration : Sendable {
472
+ var configure : @ MainActor @ Sendable ( UITextField ) -> Void
471
473
472
- public init ( configure: @escaping ( UITextField ) -> Void ) {
474
+ public init ( configure: @escaping @ MainActor @ Sendable ( UITextField ) -> Void ) {
473
475
self . configure = configure
474
476
}
475
477
0 commit comments