Commit 83e34b7
authored
feat:
## 📜 Description
Added `extraContentPadding` prop for `KeyboardChatScrollView` component.
## 💡 Motivation and Context
This prop is very useful when you want to extend scrollable range and
re-arrange the content so that it takes the same position as before
(relatively). Theoretically "re-arrange" functionality must be
configurable, but I tested many apps and what I can tell is that it
looks like almost always this "re-arrange" respects
`keyboardLiftBehavior` prop. Later we can introduce additional prop to
have a better control, but for now we keep it simple.
I was thinking on whether to make this prop a `SharedValue` or a plain
value and I decided to make it `SharedValue` because:
- theoretically we may do all work on UI thread, i. e. synchronously
detect "input growth" and synchronously adjust position;
- we may want to change position with animation (with plain number we
would have to add `animated` prop or smth like that);
- we may want to have a customizable animation (duration, easing, so
SharedValue can be a perfect driver).
We also heavily use reanimated hooks internally, so integration with
`SharedValue` looks very natural.
I intentionally didn't want to modify original hooks and I extended
functionality using new hook: `useExtraContentPadding`. This new hook
extends `contentInsets` + adjust scroll position. Maybe we'll et
conflicts between hook in future, but at the moment it's extendable 😎
Closes
#1324
## 📢 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
- added new prop description;
- added new prop usage in guide page;
### JS
- added `extraContentPadding` prop for `KeyboardChatScrollView`
component
- cover new functionality by unit tests;
## 🤔 How Has This Been Tested?
Tested manually on:
- iPhone 17 Pro (iOS 26.2);
- Pixel 7 Pro (Android 16)
## 📸 Screenshots (if appropriate):
|Android|iOS|
|-------|-----|
|<video
src="https://github.com/user-attachments/assets/00b90e82-a410-41d2-9f5d-6a7d71330ff5">|<video
src="https://github.com/user-attachments/assets/a919b334-83fe-48a5-afdf-76406ce00f66">|
## 📝 Checklist
- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changedextraContentPadding prop (#1332)1 parent a096e39 commit 83e34b7
24 files changed
Lines changed: 1067 additions & 40 deletions
File tree
- FabricExample/src/screens/Examples/KeyboardChatScrollView
- docs/docs
- api/components
- guides
- example/src/screens/Examples/KeyboardChatScrollView
- src/components
- KeyboardChatScrollView
- useChatKeyboard
- __fixtures__
- __tests__
- useExtraContentPadding
- __fixtures__
- __tests__
- ScrollViewWithBottomPadding
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
18 | 24 | | |
19 | 25 | | |
20 | 26 | | |
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
24 | | - | |
25 | | - | |
| 30 | + | |
| 31 | + | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| |||
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
| 59 | + | |
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
| |||
Lines changed: 24 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
61 | | - | |
62 | | - | |
63 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
64 | 73 | | |
65 | 74 | | |
66 | 75 | | |
| |||
90 | 99 | | |
91 | 100 | | |
92 | 101 | | |
93 | | - | |
94 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
95 | 109 | | |
96 | 110 | | |
97 | 111 | | |
| |||
124 | 138 | | |
125 | 139 | | |
126 | 140 | | |
127 | | - | |
| 141 | + | |
128 | 142 | | |
129 | 143 | | |
130 | 144 | | |
| |||
138 | 152 | | |
139 | 153 | | |
140 | 154 | | |
141 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
142 | 159 | | |
143 | 160 | | |
144 | 161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
87 | 104 | | |
88 | 105 | | |
89 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
200 | 263 | | |
201 | 264 | | |
202 | 265 | | |
| |||
312 | 375 | | |
313 | 376 | | |
314 | 377 | | |
| 378 | + | |
315 | 379 | | |
316 | 380 | | |
317 | 381 | | |
318 | 382 | | |
319 | 383 | | |
320 | 384 | | |
321 | 385 | | |
| 386 | + | |
322 | 387 | | |
323 | 388 | | |
324 | 389 | | |
| |||
355 | 420 | | |
356 | 421 | | |
357 | 422 | | |
| 423 | + | |
358 | 424 | | |
359 | 425 | | |
360 | | - | |
361 | | - | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
362 | 430 | | |
363 | 431 | | |
364 | 432 | | |
| |||
370 | 438 | | |
371 | 439 | | |
372 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
373 | 451 | | |
374 | 452 | | |
375 | 453 | | |
| |||
397 | 475 | | |
398 | 476 | | |
399 | 477 | | |
| 478 | + | |
400 | 479 | | |
401 | 480 | | |
402 | 481 | | |
| |||
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
18 | 24 | | |
19 | 25 | | |
20 | 26 | | |
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
24 | | - | |
25 | | - | |
| 30 | + | |
| 31 | + | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| |||
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
| 58 | + | |
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
| |||
Lines changed: 27 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| |||
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
62 | | - | |
63 | | - | |
64 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
65 | 77 | | |
66 | 78 | | |
67 | 79 | | |
| |||
91 | 103 | | |
92 | 104 | | |
93 | 105 | | |
94 | | - | |
95 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
96 | 113 | | |
97 | 114 | | |
98 | 115 | | |
| |||
124 | 141 | | |
125 | 142 | | |
126 | 143 | | |
127 | | - | |
| 144 | + | |
128 | 145 | | |
129 | 146 | | |
130 | 147 | | |
| |||
138 | 155 | | |
139 | 156 | | |
140 | 157 | | |
141 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
142 | 162 | | |
143 | 163 | | |
144 | 164 | | |
| |||
0 commit comments