-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement adding an action to a
UITextField
(#3)
* Implement adding an action to a `UITextField` * Update `CHANGELOG.md`
- Loading branch information
1 parent
e3e3372
commit 1fb8391
Showing
4 changed files
with
101 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// flex-ui | ||
// Copyright © 2025 Space Code. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
/// A private class that wraps a closure to be executed as an action for a `UIControl`. | ||
/// This class allows associating arbitrary closure actions with buttons, and is used internally | ||
/// to manage custom button actions in the `FlexUI` extension. | ||
final class Command { | ||
// MARK: Properties | ||
|
||
/// The closure that will be executed when the button action is triggered. | ||
let block: () -> Void | ||
|
||
// MARK: Initialization | ||
|
||
/// Initializes a new instance of `Command` with the provided closure. | ||
/// | ||
/// - Parameter block: The closure to be executed when the button is tapped. | ||
init(block: @escaping () -> Void) { | ||
self.block = block | ||
} | ||
|
||
// MARK: Actions | ||
|
||
/// The action method that is triggered when the associated button's event occurs. | ||
/// It executes the stored closure. | ||
@objc | ||
func action() { | ||
block() | ||
} | ||
} |