-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## 📜 Description Expose `type` property in `EventEmitter` events. ## 💡 Motivation and Context Added a new property to `KeyboardEventData` - `type`. This property reflects `keyboardType` set on `TextInput`. I decided to include more information about the keyboard (we already have a full control over animation properties, but I thought it could be useful to extend the library functionality and include some other properties, such as `type`/`appearance`/`capitalized` and other). As of now there is no much sense in these properties, but I'm thinking about new API `KeyboardController.retain()`/`KeyboardController.hold()` - and in this case it's super useful to know these properties, to re-create the same `TextInput` and set focus to this newly created input. However it's only plans, but having this information in the API can be useful, so I decided to add it now. ## 📢 Changelog ### Docs - added a reference to a new property; - added description to all events; ### JS - expose `type` from `KeyboardEvents` events; - updated example app; ### iOS - added `UIKeyboardType` extension; - move events creation function to its separate `KeyboardEventEmitterPayload.swift` file to cleanup `KeyboardMovementObserver`; ### Android - added `EditText.keyboardType` extension; ## 🤔 How Has This Been Tested? Tested manually on: - Pixel 3a API 33 (emulator); - iPhone 15 Pro (iOS 17.5). ## 📸 Screenshots (if appropriate): ![image](https://github.com/user-attachments/assets/0e1ba9c0-41ea-4835-8954-12b64b3853ca) ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
- Loading branch information
1 parent
a3bec0d
commit 76942c5
Showing
10 changed files
with
112 additions
and
28 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
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,22 @@ | ||
// | ||
// KeyboardEventEmitterPayload.swift | ||
// Pods | ||
// | ||
// Created by Kiryl Ziusko on 07/12/2024. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
public func buildEventParams(_ height: Double, _ duration: Int, _ tag: NSNumber) -> [AnyHashable: Any] { | ||
var data = [AnyHashable: Any]() | ||
let input = FocusedInputHolder.shared.get() | ||
|
||
data["height"] = height | ||
data["duration"] = duration | ||
data["timestamp"] = Date.currentTimeStamp | ||
data["target"] = tag | ||
data["type"] = input?.keyboardType.name ?? "default" | ||
|
||
return data | ||
} |
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,30 @@ | ||
// | ||
// UIKeyboardType.swift | ||
// Pods | ||
// | ||
// Created by Kiryl Ziusko on 08/12/2024. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
extension UIKeyboardType { | ||
private static let keyboardTypeToStringMapping: [UIKeyboardType: String] = [ | ||
.default: "default", | ||
.asciiCapable: "ascii-capable", | ||
.numbersAndPunctuation: "numbers-and-punctuation", | ||
.URL: "url", | ||
.numberPad: "number-pad", | ||
.phonePad: "phone-pad", | ||
.namePhonePad: "name-phone-pad", | ||
.emailAddress: "email-address", | ||
.decimalPad: "decimal-pad", | ||
.twitter: "twitter", | ||
.webSearch: "web-search", | ||
.asciiCapableNumberPad: "ascii-capable-number-pad", | ||
] | ||
|
||
var name: String { | ||
return UIKeyboardType.keyboardTypeToStringMapping[self] ?? "default" | ||
} | ||
} |
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