Commit 54acad4
authored
fix(Android): fix formSheet not adjusting for keyboard when it contains input with autofocus (#2911)
## Description
Sometimes, formSheet that contains input with autoFocus would not
account for the keyboard and would remain behind it. This is because
`SheetDelegate` is set as a `OnApplyWindowInsetsListener` when fragment
is resumed - this happens after finishing formSheet entering animations
(animators impact fragment lifecycle). Sometimes, IME insets were
applied before this handler was set. Now, we can use
`WindowInsetsAnimationCallback` added in [this
PR](#2909).
Its `onPrepare` method is called before `onApplyWindowInsets` therefore
making it possible to set `OnApplyWindowInsetsListener` in time.
## Changes
- change `insetsObserverProxy`'s `listeners` to `HashSet` (we might try
to add the same listener multiple times)
- override `onPrepare` method in `WindowInsetsAnimationCallback`
- change visibility of `SheetDelegate` to `internal`
## Test code and steps to reproduce
Open `Test2895` screen in the example app, open & close the formSheet
(multiple times).
## Checklist
- [x] Included code example that can be used to test this change
- [x] Ensured that CI passes1 parent 3c3db41 commit 54acad4
File tree
5 files changed
+25
-11
lines changed- android/src/main/java/com/swmansion/rnscreens
- bottomsheet
- ext
5 files changed
+25
-11
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
541 | 542 | | |
542 | 543 | | |
543 | 544 | | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
544 | 561 | | |
545 | 562 | | |
546 | 563 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
Lines changed: 0 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | 178 | | |
185 | 179 | | |
186 | 180 | | |
187 | | - | |
188 | 181 | | |
189 | 182 | | |
190 | 183 | | |
191 | 184 | | |
192 | 185 | | |
193 | 186 | | |
194 | 187 | | |
195 | | - | |
196 | 188 | | |
197 | 189 | | |
198 | 190 | | |
| |||
202 | 194 | | |
203 | 195 | | |
204 | 196 | | |
205 | | - | |
206 | 197 | | |
207 | 198 | | |
208 | 199 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
0 commit comments