Commit 4e65942
authored
feat: focused input (#257)
## 📜 Description
Added new `useReanimatedFocusedInput` hook that returns an information
about `TextInput` that currently is in focus.
## 💡 Motivation and Context
Before we could use a `target` property to measure `TextInput`. However
such approach had several disadvantages:
- on Fabric you need to have an access to `ShadowNode` and it adds more
complexity to the code (and you need to use `findNodeHandle` which is
deprecated in StrictMode);
- if view layout was changed - you are still not aware about it, because
`useKeyboardHandler` is not reporting such cases (and obviously it
shouldn't);
- it seems like measure on Fabric works differently and you need to take
into consideration other UI elements (header height, etc.)
With the introduction of this hook all these disadvantages are gone 😎
In this hook can be enhanced to cover more cases (for example add method
`update` which can synchronously update layout before reading it, or
update layout when certain lifecycle events occurs (for example screen
rotation)).
Closes
#249
#222
## 📢 Changelog
### Docs
- added a new group `Input` in API section;
- added a new page for new `useReanimatedFocusedInput` hook;
- added new key feature in README;
- added new keywords to `package.json`.
### JS
- update KeyboardAwareScrollView UI (don't generate colors randomly
anymore);
- detect growth of `TextInputs`;
- unified codebase across RN architectures (fabric, paper);
- added new unit tests for new hook;
### iOS
- added `KVO` to focused input;
### Android
- all listeners (callbacks, observers) now live in `listeners` package;
- removed zombie-view (on Fabric)
- listener clean up after setEnabled call
## 🤔 How Has This Been Tested?
Tested manually on (both paper and fabric):
- iPhone 6s (iOS 15.6);
- iPhone 11 (iOS 17.0);
- Pixel 7 Pro (Android 14);
- Xiaomi Redmi Note 5 Pro (Android 9);
- iPhone 15 (iOS 17.0, simulator);
- Pixel 3a (Android 13, emulator).
## 📸 Screenshots (if appropriate):
https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/a82f8dcc-41d3-475f-925e-c4bf574f7967
## 📝 Checklist
- [x] CI successfully passed1 parent 2cd92a2 commit 4e65942
File tree
39 files changed
+1016
-293
lines changed- FabricExample
- __tests__
- src/screens/Examples/AwareScrollView
- android/src/main/java/com/reactnativekeyboardcontroller
- events
- extensions
- listeners
- managers
- views
- docs/docs/api/hooks
- input
- module
- example
- __tests__
- src/screens/Examples/AwareScrollView
- ios
- KeyboardController.xcodeproj
- events
- observers
- views
- jest
- src
- specs
39 files changed
+1016
-293
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
Lines changed: 41 additions & 40 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | | - | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | | - | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
| |||
55 | 53 | | |
56 | 54 | | |
57 | 55 | | |
58 | | - | |
| 56 | + | |
59 | 57 | | |
60 | 58 | | |
61 | 59 | | |
62 | 60 | | |
63 | 61 | | |
64 | 62 | | |
65 | | - | |
66 | | - | |
67 | 63 | | |
68 | 64 | | |
69 | 65 | | |
70 | 66 | | |
| 67 | + | |
| 68 | + | |
71 | 69 | | |
72 | 70 | | |
73 | | - | |
74 | 71 | | |
75 | 72 | | |
76 | 73 | | |
| |||
84 | 81 | | |
85 | 82 | | |
86 | 83 | | |
87 | | - | |
88 | | - | |
| 84 | + | |
89 | 85 | | |
90 | | - | |
| 86 | + | |
91 | 87 | | |
92 | 88 | | |
93 | 89 | | |
| |||
98 | 94 | | |
99 | 95 | | |
100 | 96 | | |
| 97 | + | |
| 98 | + | |
101 | 99 | | |
| 100 | + | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
113 | 115 | | |
114 | 116 | | |
115 | 117 | | |
| |||
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
123 | | - | |
| 125 | + | |
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
131 | | - | |
| 133 | + | |
132 | 134 | | |
133 | 135 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
141 | 147 | | |
142 | 148 | | |
143 | 149 | | |
| |||
150 | 156 | | |
151 | 157 | | |
152 | 158 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | 159 | | |
164 | 160 | | |
165 | 161 | | |
166 | 162 | | |
167 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
168 | 174 | | |
169 | 175 | | |
170 | | - | |
| 176 | + | |
171 | 177 | | |
172 | 178 | | |
173 | 179 | | |
| |||
179 | 185 | | |
180 | 186 | | |
181 | 187 | | |
182 | | - | |
183 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
184 | 191 | | |
185 | 192 | | |
186 | 193 | | |
187 | 194 | | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
| 195 | + | |
Lines changed: 22 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 2 | + | |
8 | 3 | | |
| 4 | + | |
9 | 5 | | |
10 | 6 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
24 | 11 | | |
| 12 | + | |
25 | 13 | | |
26 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
Lines changed: 0 additions & 102 deletions
This file was deleted.
0 commit comments