-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## 📜 Description Make `dismiss` method async to get rid off boilerplate/utilities functions in main project. ## 💡 Motivation and Context Originally this idea was suggested by @terrysahaidak. Before many projects had its own implementation of this method. But @terrysahaidak suggested and I agreed that it would be better to keep this method directly inside the library. ## 📢 Changelog <!-- High level overview of important changes --> <!-- For example: fixed status bar manipulation; added new types declarations; --> <!-- If your changes don't affect one of platform/language below - then remove this platform/language --> ### Docs - include methods signature in methods description; ### JS - changed mock implementation; - make `dismiss` method async; - create `module` file; - set global listeners for `KeyboardEvents` inside `module` file; ## 🤔 How Has This Been Tested? Tested on CI. ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
- Loading branch information
1 parent
8ba5bb4
commit 80d8972
Showing
11 changed files
with
82 additions
and
40 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
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,37 @@ | ||
import { KeyboardControllerNative, KeyboardEvents } from "./bindings"; | ||
|
||
import type { KeyboardControllerModule } from "./types"; | ||
|
||
let isVisible = false; | ||
|
||
KeyboardEvents.addListener("keyboardDidHide", () => { | ||
isVisible = false; | ||
}); | ||
|
||
KeyboardEvents.addListener("keyboardDidShow", () => { | ||
isVisible = true; | ||
}); | ||
|
||
const dismiss = async (): Promise<void> => { | ||
return new Promise((resolve) => { | ||
if (!isVisible) { | ||
resolve(); | ||
|
||
return; | ||
} | ||
|
||
const subscription = KeyboardEvents.addListener("keyboardDidHide", () => { | ||
resolve(undefined); | ||
subscription.remove(); | ||
}); | ||
|
||
KeyboardControllerNative.dismiss(); | ||
}); | ||
}; | ||
|
||
export const KeyboardController: KeyboardControllerModule = { | ||
setDefaultMode: KeyboardControllerNative.setDefaultMode, | ||
setInputMode: KeyboardControllerNative.setInputMode, | ||
setFocusTo: KeyboardControllerNative.setFocusTo, | ||
dismiss: dismiss, | ||
}; |
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