Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

react-native-keyboard-controller@1.22.4.patch

933 lines43.1 KB

1diff --git a/lib/commonjs/components/KeyboardChatScrollView/index.js b/lib/commonjs/components/KeyboardChatScrollView/index.js
2index 5617394..4f2222a 100644
3--- a/lib/commonjs/components/KeyboardChatScrollView/index.js
4+++ b/lib/commonjs/components/KeyboardChatScrollView/index.js
5@@ -27,9 +27,12 @@ const KeyboardChatScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
6 offset = 0,
7 extraContentPadding = ZERO_CONTENT_PADDING,
8 blankSpace = ZERO_BLANK_SPACE,
9+ adjustedInsetCompensation = 0,
10+ adjustedStartInsetCompensation = 0,
11 applyWorkaroundForContentInsetHitTestBug = false,
12 onLayout: onLayoutProp,
13 onContentSizeChange: onContentSizeChangeProp,
14+ onContentInsetChange,
15 onEndVisible,
16 ...rest
17 }, ref) => {
18@@ -51,13 +54,17 @@ const KeyboardChatScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
19 freeze: freezeSV,
20 offset,
21 blankSpace,
22- extraContentPadding
23+ extraContentPadding,
24+ adjustedInsetCompensation,
25+ adjustedStartInsetCompensation
26 });
27 (0, _useExtraContentPadding.useExtraContentPadding)({
28 scrollViewRef,
29 extraContentPadding,
30 keyboardPadding: padding,
31 blankSpace,
32+ adjustedInsetCompensation,
33+ adjustedStartInsetCompensation,
34 scroll,
35 layout,
36 size,
37@@ -88,10 +95,26 @@ const KeyboardChatScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
38 // a bug for you, please open an issue.
39 const totalPadding = (0, _reactNativeReanimated.useDerivedValue)(() => Math.min(layout.value.height, Math.max(blankSpace.value, padding.value + extraContentPadding.value)));
41+ // iOS applies the destination contentInset and contentOffset together at
42+ // keyboard-animation start. Keep that native target behavior, but report
43+ // the presentation height so virtualized-list layout follows the keyboard.
44+ const reportedPadding = (0, _reactNativeReanimated.useDerivedValue)(() => _reactNative.Platform.OS === "ios" ? Math.min(layout.value.height, Math.max(blankSpace.value, currentHeight.value + extraContentPadding.value)) : totalPadding.value);
46+ // Mirror the effective bottom padding (keyboard + composer + blank floor)
47+ // to the consumer - a virtualized list needs it in its own scroll math or
48+ // its end/maintain targets point at the under-the-keyboard resting offset.
49+ (0, _reactNativeReanimated.useAnimatedReaction)(() => reportedPadding.value, (current, previous) => {
50+ if (onContentInsetChange && current !== previous) {
51+ (0, _reactNativeReanimated.runOnJS)(onContentInsetChange)({
52+ bottom: current
53+ });
54+ }
55+ }, [onContentInsetChange]);
57 // Scroll indicator inset = keyboard + extraContentPadding (excludes blankSpace).
58 // Apps that render into the unsafe area can supply a negative
59 // scrollIndicatorInsets adjustment at the application layer.
60- const indicatorPadding = (0, _reactNativeReanimated.useDerivedValue)(() => padding.value + extraContentPadding.value);
61+ const indicatorPadding = (0, _reactNativeReanimated.useDerivedValue)(() => padding.value);
62 const onLayout = (0, _react.useCallback)(e => {
63 onLayoutInternal(e);
64 onLayoutProp === null || onLayoutProp === void 0 || onLayoutProp(e);
65diff --git a/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js b/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js
66index 4d33b3f..6a787d3 100644
67--- a/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js
68+++ b/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js
69@@ -206,7 +206,7 @@ const clampedScrollTarget = (offsetBeforeScroll, keyboardHeight, contentHeight,
70 * ```
71 */
72 exports.clampedScrollTarget = clampedScrollTarget;
73-const computeIOSContentOffset = (relativeScroll, keyboardHeight, contentHeight, layoutHeight, inverted, totalPaddingForMaxScroll) => {
74+const computeIOSContentOffset = (relativeScroll, keyboardHeight, contentHeight, layoutHeight, inverted, totalPaddingForMaxScroll, startInsetCompensation = 0) => {
75 "worklet";
77 const paddingForMax = totalPaddingForMaxScroll !== undefined ? totalPaddingForMaxScroll : keyboardHeight;
78@@ -214,8 +214,9 @@ const computeIOSContentOffset = (relativeScroll, keyboardHeight, contentHeight,
79 const maxScroll = Math.max(contentHeight - layoutHeight, 0);
80 return Math.max(Math.min(relativeScroll - keyboardHeight, maxScroll), -paddingForMax);
81 }
82- const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, 0);
83- return Math.min(Math.max(keyboardHeight + relativeScroll, 0), maxScroll);
84+ const minScroll = -startInsetCompensation;
85+ const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, minScroll);
86+ return Math.min(Math.max(keyboardHeight + relativeScroll, minScroll), maxScroll);
87 };
88 exports.computeIOSContentOffset = computeIOSContentOffset;
89 //# sourceMappingURL=helpers.js.map
90\ No newline at end of file
91diff --git a/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js b/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js
92index cecee07..533a9e9 100644
93--- a/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js
94+++ b/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js
95@@ -32,7 +32,9 @@ function useChatKeyboard(scrollViewRef, options) {
96 freeze,
97 offset,
98 blankSpace,
99- extraContentPadding
100+ extraContentPadding,
101+ adjustedInsetCompensation,
102+ adjustedStartInsetCompensation
103 } = options;
104 const padding = (0, _reactNativeReanimated.useSharedValue)(0);
105 const currentHeight = (0, _reactNativeReanimated.useSharedValue)(0);
106@@ -59,6 +61,9 @@ function useChatKeyboard(scrollViewRef, options) {
107 targetKeyboardHeight.value = e.height;
108 }
109 const effective = (0, _helpers.getEffectiveHeight)(e.height, targetKeyboardHeight.value, offset);
110+ if (e.duration === 0) {
111+ currentHeight.value = effective;
112+ }
113 const atEnd = (0, _helpers.isScrollAtEnd)(scroll.value, layout.value.height, size.value.height, inverted);
115 // Scale minimum padding absorption by how much of it is visible.
116@@ -67,7 +72,7 @@ function useChatKeyboard(scrollViewRef, options) {
117 const visiblePadding = visibleFraction * blankSpace.value;
118 const minimumPaddingAbsorbed = Math.max(0, visiblePadding - extraContentPadding.value);
119 const scrollEffective = (0, _helpers.getScrollEffective)(effective, minimumPaddingAbsorbed);
120- const actualTotalPadding = Math.max(blankSpace.value, effective + extraContentPadding.value);
121+ const actualTotalPadding = Math.max(blankSpace.value, effective + extraContentPadding.value) + adjustedInsetCompensation;
123 // `onInteractive` owns the native scroll offset. When its final
124 // keyboardWillHide event arrives, consume the marker so this
125@@ -87,8 +92,8 @@ function useChatKeyboard(scrollViewRef, options) {
126 const maxScroll = Math.max(size.value.height - layout.value.height, 0);
127 contentOffsetY.value = Math.max(-actualTotalPadding, Math.min(scroll.value, maxScroll));
128 } else {
129- const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, 0);
130- contentOffsetY.value = Math.max(0, Math.min(scroll.value, maxScroll));
131+ const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, -adjustedStartInsetCompensation);
132+ contentOffsetY.value = Math.max(-adjustedStartInsetCompensation, Math.min(scroll.value, maxScroll));
133 }
134 return;
135 }
136@@ -102,8 +107,8 @@ function useChatKeyboard(scrollViewRef, options) {
137 const maxScroll = Math.max(size.value.height - layout.value.height, 0);
138 contentOffsetY.value = Math.max(-actualTotalPadding, Math.min(scroll.value, maxScroll));
139 } else {
140- const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, 0);
141- contentOffsetY.value = Math.max(0, Math.min(scroll.value, maxScroll));
142+ const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, -adjustedStartInsetCompensation);
143+ contentOffsetY.value = Math.max(-adjustedStartInsetCompensation, Math.min(scroll.value, maxScroll));
144 }
145 return;
146 }
147@@ -129,17 +134,25 @@ function useChatKeyboard(scrollViewRef, options) {
148 contentOffsetY.value = scroll.value;
149 return;
150 }
151- contentOffsetY.value = (0, _helpers.computeIOSContentOffset)(relativeScroll, scrollEffective, size.value.height, layout.value.height, inverted, actualTotalPadding);
152+ contentOffsetY.value = (0, _helpers.computeIOSContentOffset)(relativeScroll, scrollEffective, size.value.height, layout.value.height, inverted, actualTotalPadding, adjustedStartInsetCompensation);
153 },
154- onInteractive: () => {
155+ onMove: e => {
156 "worklet";
158- isInteractiveDismissal.value = true;
159+ if (freeze.value) {
160+ return;
161+ }
162+ currentHeight.value = (0, _helpers.getEffectiveHeight)(e.height, targetKeyboardHeight.value, offset);
163 },
164- onMove: () => {
165+ onInteractive: e => {
166 "worklet";
168- // iOS doesn't need per-frame updates (contentOffset handles it)
169+ isInteractiveDismissal.value = true;
171+ if (freeze.value) {
172+ return;
173+ }
174+ currentHeight.value = (0, _helpers.getEffectiveHeight)(e.height, targetKeyboardHeight.value, offset);
175 },
176 onEnd: e => {
177 "worklet";
178@@ -148,9 +161,10 @@ function useChatKeyboard(scrollViewRef, options) {
179 return;
180 }
181 const effective = (0, _helpers.getEffectiveHeight)(e.height, targetKeyboardHeight.value, offset);
182+ currentHeight.value = effective;
183 padding.value = effective;
184 }
185- }, [inverted, keyboardLiftBehavior, offset, extraContentPadding]);
186+ }, [inverted, keyboardLiftBehavior, offset, extraContentPadding, adjustedInsetCompensation, adjustedStartInsetCompensation]);
187 return {
188 padding,
189 currentHeight,
190diff --git a/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js b/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js
191index 54a1c57..00c2941 100644
192--- a/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js
193+++ b/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js
194@@ -31,6 +31,8 @@ function useExtraContentPadding(options) {
195 extraContentPadding,
196 keyboardPadding,
197 blankSpace,
198+ adjustedInsetCompensation,
199+ adjustedStartInsetCompensation,
200 scroll,
201 layout,
202 size,
203@@ -50,8 +52,13 @@ function useExtraContentPadding(options) {
204 // otherwise the native ScrollView clamps to the old range.
205 requestAnimationFrame(() => {
206 // check that view is still mounted and ref is actual
207- // otherwise it may lead to a crash
208- if (!scrollViewRef()) {
209+ // otherwise it may lead to a crash. Reanimated 4.7+ passes the
210+ // ref to the UI runtime as a shareable holding the node in `.value`.
211+ const node =
212+ typeof scrollViewRef === "function"
213+ ? scrollViewRef()
214+ : scrollViewRef.value;
215+ if (!node) {
216 return;
217 }
218 (0, _reactNativeReanimated.scrollTo)(scrollViewRef, 0, target, false);
219@@ -70,8 +77,8 @@ function useExtraContentPadding(options) {
220 }
222 // Compute effective delta considering blankSpace floor
223- const previousTotal = Math.max(blankSpace.value, keyboardPadding.value + previous);
224- const currentTotal = Math.max(blankSpace.value, keyboardPadding.value + current);
225+ const previousTotal = Math.max(blankSpace.value, keyboardPadding.value + previous) + adjustedInsetCompensation;
226+ const currentTotal = Math.max(blankSpace.value, keyboardPadding.value + current) + adjustedInsetCompensation;
227 const effectiveDelta = currentTotal - previousTotal;
228 if (effectiveDelta === 0) {
229 // blankSpace absorbed the change
230@@ -90,10 +97,11 @@ function useExtraContentPadding(options) {
231 const target = Math.max(scroll.value - effectiveDelta, -currentTotal);
232 scrollToTarget(target);
233 } else {
234- const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, 0);
235- const target = Math.min(scroll.value + effectiveDelta, maxScroll);
236+ const minScroll = -adjustedStartInsetCompensation;
237+ const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, minScroll);
238+ const target = Math.max(minScroll, Math.min(scroll.value + effectiveDelta, maxScroll));
239 scrollToTarget(target);
240 }
241- }, [inverted, keyboardLiftBehavior]);
242+ }, [inverted, keyboardLiftBehavior, adjustedInsetCompensation, adjustedStartInsetCompensation]);
243 }
244 //# sourceMappingURL=index.js.map
245\ No newline at end of file
246diff --git a/lib/module/components/KeyboardChatScrollView/index.js b/lib/module/components/KeyboardChatScrollView/index.js
247index d085394..a57c2f9 100644
248--- a/lib/module/components/KeyboardChatScrollView/index.js
249+++ b/lib/module/components/KeyboardChatScrollView/index.js
250@@ -1,7 +1,7 @@
251 function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
252 import React, { forwardRef, useCallback, useMemo } from "react";
253-import { StyleSheet } from "react-native";
254-import { makeMutable, useAnimatedRef, useAnimatedStyle, useDerivedValue } from "react-native-reanimated";
255+import { Platform, StyleSheet } from "react-native";
256+import { makeMutable, runOnJS, useAnimatedReaction, useAnimatedRef, useAnimatedStyle, useDerivedValue } from "react-native-reanimated";
257 import Reanimated from "react-native-reanimated";
258 import useCombinedRef from "../hooks/useCombinedRef";
259 import ScrollViewWithBottomPadding from "../ScrollViewWithBottomPadding";
260@@ -20,9 +20,12 @@ const KeyboardChatScrollView = /*#__PURE__*/forwardRef(({
261 offset = 0,
262 extraContentPadding = ZERO_CONTENT_PADDING,
263 blankSpace = ZERO_BLANK_SPACE,
264+ adjustedInsetCompensation = 0,
265+ adjustedStartInsetCompensation = 0,
266 applyWorkaroundForContentInsetHitTestBug = false,
267 onLayout: onLayoutProp,
268 onContentSizeChange: onContentSizeChangeProp,
269+ onContentInsetChange,
270 onEndVisible,
271 ...rest
272 }, ref) => {
273@@ -44,13 +47,17 @@ const KeyboardChatScrollView = /*#__PURE__*/forwardRef(({
274 freeze: freezeSV,
275 offset,
276 blankSpace,
277- extraContentPadding
278+ extraContentPadding,
279+ adjustedInsetCompensation,
280+ adjustedStartInsetCompensation
281 });
282 useExtraContentPadding({
283 scrollViewRef,
284 extraContentPadding,
285 keyboardPadding: padding,
286 blankSpace,
287+ adjustedInsetCompensation,
288+ adjustedStartInsetCompensation,
289 scroll,
290 layout,
291 size,
292@@ -81,10 +88,26 @@ const KeyboardChatScrollView = /*#__PURE__*/forwardRef(({
293 // a bug for you, please open an issue.
294 const totalPadding = useDerivedValue(() => Math.min(layout.value.height, Math.max(blankSpace.value, padding.value + extraContentPadding.value)));
296+ // iOS applies the destination contentInset and contentOffset together at
297+ // keyboard-animation start. Keep that native target behavior, but report
298+ // the presentation height so virtualized-list layout follows the keyboard.
299+ const reportedPadding = useDerivedValue(() => Platform.OS === "ios" ? Math.min(layout.value.height, Math.max(blankSpace.value, currentHeight.value + extraContentPadding.value)) : totalPadding.value);
301+ // Mirror the effective bottom padding (keyboard + composer + blank floor)
302+ // to the consumer - a virtualized list needs it in its own scroll math or
303+ // its end/maintain targets point at the under-the-keyboard resting offset.
304+ useAnimatedReaction(() => reportedPadding.value, (current, previous) => {
305+ if (onContentInsetChange && current !== previous) {
306+ runOnJS(onContentInsetChange)({
307+ bottom: current
308+ });
309+ }
310+ }, [onContentInsetChange]);
312 // Scroll indicator inset = keyboard + extraContentPadding (excludes blankSpace).
313 // Apps that render into the unsafe area can supply a negative
314 // scrollIndicatorInsets adjustment at the application layer.
315- const indicatorPadding = useDerivedValue(() => padding.value + extraContentPadding.value);
316+ const indicatorPadding = useDerivedValue(() => padding.value);
317 const onLayout = useCallback(e => {
318 onLayoutInternal(e);
319 onLayoutProp === null || onLayoutProp === void 0 || onLayoutProp(e);
320diff --git a/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js b/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js
321index 295e221..2f7b87e 100644
322--- a/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js
323+++ b/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js
324@@ -193,7 +193,7 @@ export const clampedScrollTarget = (offsetBeforeScroll, keyboardHeight, contentH
325 * computeIOSContentOffset(100, 300, 1000, 800, false); // 400
326 * ```
327 */
328-export const computeIOSContentOffset = (relativeScroll, keyboardHeight, contentHeight, layoutHeight, inverted, totalPaddingForMaxScroll) => {
329+export const computeIOSContentOffset = (relativeScroll, keyboardHeight, contentHeight, layoutHeight, inverted, totalPaddingForMaxScroll, startInsetCompensation = 0) => {
330 "worklet";
332 const paddingForMax = totalPaddingForMaxScroll !== undefined ? totalPaddingForMaxScroll : keyboardHeight;
333@@ -201,7 +201,8 @@ export const computeIOSContentOffset = (relativeScroll, keyboardHeight, contentH
334 const maxScroll = Math.max(contentHeight - layoutHeight, 0);
335 return Math.max(Math.min(relativeScroll - keyboardHeight, maxScroll), -paddingForMax);
336 }
337- const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, 0);
338- return Math.min(Math.max(keyboardHeight + relativeScroll, 0), maxScroll);
339+ const minScroll = -startInsetCompensation;
340+ const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, minScroll);
341+ return Math.min(Math.max(keyboardHeight + relativeScroll, minScroll), maxScroll);
342 };
343 //# sourceMappingURL=helpers.js.map
344\ No newline at end of file
345diff --git a/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js b/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js
346index 407275d..19427d7 100644
347--- a/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js
348+++ b/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js
349@@ -25,7 +25,9 @@ function useChatKeyboard(scrollViewRef, options) {
350 freeze,
351 offset,
352 blankSpace,
353- extraContentPadding
354+ extraContentPadding,
355+ adjustedInsetCompensation,
356+ adjustedStartInsetCompensation
357 } = options;
358 const padding = useSharedValue(0);
359 const currentHeight = useSharedValue(0);
360@@ -52,6 +54,9 @@ function useChatKeyboard(scrollViewRef, options) {
361 targetKeyboardHeight.value = e.height;
362 }
363 const effective = getEffectiveHeight(e.height, targetKeyboardHeight.value, offset);
364+ if (e.duration === 0) {
365+ currentHeight.value = effective;
366+ }
367 const atEnd = isScrollAtEnd(scroll.value, layout.value.height, size.value.height, inverted);
369 // Scale minimum padding absorption by how much of it is visible.
370@@ -60,7 +65,7 @@ function useChatKeyboard(scrollViewRef, options) {
371 const visiblePadding = visibleFraction * blankSpace.value;
372 const minimumPaddingAbsorbed = Math.max(0, visiblePadding - extraContentPadding.value);
373 const scrollEffective = getScrollEffective(effective, minimumPaddingAbsorbed);
374- const actualTotalPadding = Math.max(blankSpace.value, effective + extraContentPadding.value);
375+ const actualTotalPadding = Math.max(blankSpace.value, effective + extraContentPadding.value) + adjustedInsetCompensation;
377 // `onInteractive` owns the native scroll offset. When its final
378 // keyboardWillHide event arrives, consume the marker so this
379@@ -80,8 +85,8 @@ function useChatKeyboard(scrollViewRef, options) {
380 const maxScroll = Math.max(size.value.height - layout.value.height, 0);
381 contentOffsetY.value = Math.max(-actualTotalPadding, Math.min(scroll.value, maxScroll));
382 } else {
383- const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, 0);
384- contentOffsetY.value = Math.max(0, Math.min(scroll.value, maxScroll));
385+ const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, -adjustedStartInsetCompensation);
386+ contentOffsetY.value = Math.max(-adjustedStartInsetCompensation, Math.min(scroll.value, maxScroll));
387 }
388 return;
389 }
390@@ -95,8 +100,8 @@ function useChatKeyboard(scrollViewRef, options) {
391 const maxScroll = Math.max(size.value.height - layout.value.height, 0);
392 contentOffsetY.value = Math.max(-actualTotalPadding, Math.min(scroll.value, maxScroll));
393 } else {
394- const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, 0);
395- contentOffsetY.value = Math.max(0, Math.min(scroll.value, maxScroll));
396+ const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, -adjustedStartInsetCompensation);
397+ contentOffsetY.value = Math.max(-adjustedStartInsetCompensation, Math.min(scroll.value, maxScroll));
398 }
399 return;
400 }
401@@ -122,17 +127,25 @@ function useChatKeyboard(scrollViewRef, options) {
402 contentOffsetY.value = scroll.value;
403 return;
404 }
405- contentOffsetY.value = computeIOSContentOffset(relativeScroll, scrollEffective, size.value.height, layout.value.height, inverted, actualTotalPadding);
406+ contentOffsetY.value = computeIOSContentOffset(relativeScroll, scrollEffective, size.value.height, layout.value.height, inverted, actualTotalPadding, adjustedStartInsetCompensation);
407 },
408- onInteractive: () => {
409+ onMove: e => {
410 "worklet";
412- isInteractiveDismissal.value = true;
413+ if (freeze.value) {
414+ return;
415+ }
416+ currentHeight.value = getEffectiveHeight(e.height, targetKeyboardHeight.value, offset);
417 },
418- onMove: () => {
419+ onInteractive: e => {
420 "worklet";
422- // iOS doesn't need per-frame updates (contentOffset handles it)
423+ isInteractiveDismissal.value = true;
425+ if (freeze.value) {
426+ return;
427+ }
428+ currentHeight.value = getEffectiveHeight(e.height, targetKeyboardHeight.value, offset);
429 },
430 onEnd: e => {
431 "worklet";
432@@ -141,9 +154,10 @@ function useChatKeyboard(scrollViewRef, options) {
433 return;
434 }
435 const effective = getEffectiveHeight(e.height, targetKeyboardHeight.value, offset);
436+ currentHeight.value = effective;
437 padding.value = effective;
438 }
439- }, [inverted, keyboardLiftBehavior, offset, extraContentPadding]);
440+ }, [inverted, keyboardLiftBehavior, offset, extraContentPadding, adjustedInsetCompensation, adjustedStartInsetCompensation]);
441 return {
442 padding,
443 currentHeight,
444diff --git a/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js b/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js
445index 5885415..8b3c4f0 100644
446--- a/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js
447+++ b/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js
448@@ -25,6 +25,8 @@ function useExtraContentPadding(options) {
449 extraContentPadding,
450 keyboardPadding,
451 blankSpace,
452+ adjustedInsetCompensation,
453+ adjustedStartInsetCompensation,
454 scroll,
455 layout,
456 size,
457@@ -44,8 +46,13 @@ function useExtraContentPadding(options) {
458 // otherwise the native ScrollView clamps to the old range.
459 requestAnimationFrame(() => {
460 // check that view is still mounted and ref is actual
461- // otherwise it may lead to a crash
462- if (!scrollViewRef()) {
463+ // otherwise it may lead to a crash. Reanimated 4.7+ passes the
464+ // ref to the UI runtime as a shareable holding the node in `.value`.
465+ const node =
466+ typeof scrollViewRef === "function"
467+ ? scrollViewRef()
468+ : scrollViewRef.value;
469+ if (!node) {
470 return;
471 }
472 scrollTo(scrollViewRef, 0, target, false);
473@@ -64,8 +71,8 @@ function useExtraContentPadding(options) {
474 }
476 // Compute effective delta considering blankSpace floor
477- const previousTotal = Math.max(blankSpace.value, keyboardPadding.value + previous);
478- const currentTotal = Math.max(blankSpace.value, keyboardPadding.value + current);
479+ const previousTotal = Math.max(blankSpace.value, keyboardPadding.value + previous) + adjustedInsetCompensation;
480+ const currentTotal = Math.max(blankSpace.value, keyboardPadding.value + current) + adjustedInsetCompensation;
481 const effectiveDelta = currentTotal - previousTotal;
482 if (effectiveDelta === 0) {
483 // blankSpace absorbed the change
484@@ -84,11 +91,12 @@ function useExtraContentPadding(options) {
485 const target = Math.max(scroll.value - effectiveDelta, -currentTotal);
486 scrollToTarget(target);
487 } else {
488- const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, 0);
489- const target = Math.min(scroll.value + effectiveDelta, maxScroll);
490+ const minScroll = -adjustedStartInsetCompensation;
491+ const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, minScroll);
492+ const target = Math.max(minScroll, Math.min(scroll.value + effectiveDelta, maxScroll));
493 scrollToTarget(target);
494 }
495- }, [inverted, keyboardLiftBehavior]);
496+ }, [inverted, keyboardLiftBehavior, adjustedInsetCompensation, adjustedStartInsetCompensation]);
497 }
498 export { useExtraContentPadding };
499 //# sourceMappingURL=index.js.map
500\ No newline at end of file
501diff --git a/lib/typescript/components/KeyboardChatScrollView/types.d.ts b/lib/typescript/components/KeyboardChatScrollView/types.d.ts
502index eba1514..6597d80 100644
503--- a/lib/typescript/components/KeyboardChatScrollView/types.d.ts
504+++ b/lib/typescript/components/KeyboardChatScrollView/types.d.ts
505@@ -88,6 +88,10 @@ export type KeyboardChatScrollViewProps = {
506 * Default is `undefined` (equivalent to `0` — no minimum floor).
507 */
508 blankSpace?: SharedValue<number>;
509+ /** Extra bottom inset UIKit adds beyond the raw contentInset (safe area). Offset math only. */
510+ adjustedInsetCompensation?: number;
511+ /** Leading inset UIKit adds outside raw contentInset. Offset math only. */
512+ adjustedStartInsetCompensation?: number;
513 /**
514 * Fires whenever the effective content inset changes — the static `contentInset`
515 * prop combined with the dynamic keyboard-driven padding.
516diff --git a/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts b/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts
517index 2b51cc4..3acec1f 100644
518--- a/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts
519+++ b/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts
520@@ -129,4 +129,4 @@ export declare const clampedScrollTarget: (offsetBeforeScroll: number, keyboardH
521 * computeIOSContentOffset(100, 300, 1000, 800, false); // 400
522 * ```
523 */
524-export declare const computeIOSContentOffset: (relativeScroll: number, keyboardHeight: number, contentHeight: number, layoutHeight: number, inverted: boolean, totalPaddingForMaxScroll?: number) => number;
525+export declare const computeIOSContentOffset: (relativeScroll: number, keyboardHeight: number, contentHeight: number, layoutHeight: number, inverted: boolean, totalPaddingForMaxScroll?: number, startInsetCompensation?: number) => number;
526diff --git a/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts b/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts
527index aff9b5a..fdd8395 100644
528--- a/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts
529+++ b/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts
530@@ -9,6 +9,10 @@ type UseChatKeyboardOptions = {
531 blankSpace: SharedValue<number>;
532 /** Extra content padding shared value — needed on iOS to correctly clamp contentOffset. */
533 extraContentPadding: SharedValue<number>;
534+ /** Safe-area extra beyond raw contentInset. Offset math only. */
535+ adjustedInsetCompensation: number;
536+ /** Leading inset UIKit adds beyond the raw contentInset. Offset math only. */
537+ adjustedStartInsetCompensation: number;
538 };
539 type UseChatKeyboardReturn = {
540 /** Extra scrollable space (= keyboard height). Used as contentInset on iOS, contentInsetBottom/contentInsetTop on Android. */
541diff --git a/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts b/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts
542index ec73f70..45b3874 100644
543--- a/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts
544+++ b/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts
545@@ -8,6 +8,10 @@ type UseExtraContentPaddingOptions = {
546 keyboardPadding: SharedValue<number>;
547 /** Minimum inset floor — used to absorb keyboard and extraContentPadding changes. */
548 blankSpace: SharedValue<number>;
549+ /** Safe-area extra beyond raw contentInset. Offset math only. */
550+ adjustedInsetCompensation: number;
551+ /** Leading inset UIKit adds beyond raw contentInset. Offset math only. */
552+ adjustedStartInsetCompensation: number;
553 /** Current vertical scroll offset. */
554 scroll: SharedValue<number>;
555 /** Visible viewport dimensions. */
556diff --git a/src/components/KeyboardChatScrollView/index.tsx b/src/components/KeyboardChatScrollView/index.tsx
557index 554b38c..725d546 100644
558--- a/src/components/KeyboardChatScrollView/index.tsx
559+++ b/src/components/KeyboardChatScrollView/index.tsx
560@@ -1,7 +1,9 @@
561 import React, { forwardRef, useCallback, useMemo } from "react";
562-import { StyleSheet } from "react-native";
563+import { Platform, StyleSheet } from "react-native";
564 import {
565 makeMutable,
566+ runOnJS,
567+ useAnimatedReaction,
568 useAnimatedRef,
569 useAnimatedStyle,
570 useDerivedValue,
571@@ -39,9 +41,12 @@ const KeyboardChatScrollView: React.ForwardRefExoticComponent<
572 offset = 0,
573 extraContentPadding = ZERO_CONTENT_PADDING,
574 blankSpace = ZERO_BLANK_SPACE,
575+ adjustedInsetCompensation = 0,
576+ adjustedStartInsetCompensation = 0,
577 applyWorkaroundForContentInsetHitTestBug = false,
578 onLayout: onLayoutProp,
579 onContentSizeChange: onContentSizeChangeProp,
580+ onContentInsetChange,
581 onEndVisible,
582 ...rest
583 },
584@@ -68,6 +73,8 @@ const KeyboardChatScrollView: React.ForwardRefExoticComponent<
585 offset,
586 blankSpace,
587 extraContentPadding,
588+ adjustedInsetCompensation,
589+ adjustedStartInsetCompensation,
590 });
592 useExtraContentPadding({
593@@ -75,6 +82,8 @@ const KeyboardChatScrollView: React.ForwardRefExoticComponent<
594 extraContentPadding,
595 keyboardPadding: padding,
596 blankSpace,
597+ adjustedInsetCompensation,
598+ adjustedStartInsetCompensation,
599 scroll,
600 layout,
601 size,
602@@ -112,13 +121,40 @@ const KeyboardChatScrollView: React.ForwardRefExoticComponent<
603 ),
604 );
606- // Scroll indicator inset = keyboard + extraContentPadding (excludes blankSpace).
607- // Apps that render into the unsafe area can supply a negative
608- // scrollIndicatorInsets adjustment at the application layer.
609- const indicatorPadding = useDerivedValue(
610- () => padding.value + extraContentPadding.value,
611+ // iOS applies the destination contentInset and contentOffset together at
612+ // keyboard-animation start. Keep that native target behavior, but report
613+ // the presentation height so virtualized-list layout follows the keyboard.
614+ const reportedPadding = useDerivedValue(() =>
615+ Platform.OS === "ios"
616+ ? Math.min(
617+ layout.value.height,
618+ Math.max(
619+ blankSpace.value,
620+ currentHeight.value + extraContentPadding.value,
621+ ),
622+ )
623+ : totalPadding.value,
624 );
626+ // Mirror the effective bottom padding (keyboard + composer + blank floor)
627+ // to the consumer — a virtualized list needs it in its own scroll math or
628+ // its end/maintain targets point at the under-the-keyboard resting offset.
629+ useAnimatedReaction(
630+ () => reportedPadding.value,
631+ (current, previous) => {
632+ if (onContentInsetChange && current !== previous) {
633+ runOnJS(onContentInsetChange)({ bottom: current });
634+ }
635+ },
636+ [onContentInsetChange],
637+ );
639+ // Scroll indicator inset = keyboard only (excludes extraContentPadding and
640+ // blankSpace): with a floating composer the indicator track should run the
641+ // full height of the scroll view, behind the composer, like iOS Messages.
642+ // The keyboard still lifts it so it never disappears under the keyboard.
643+ const indicatorPadding = useDerivedValue(() => padding.value);
645 const onLayout = useCallback(
646 (e: LayoutChangeEvent) => {
647 onLayoutInternal(e);
648diff --git a/src/components/KeyboardChatScrollView/types.ts b/src/components/KeyboardChatScrollView/types.ts
649index b7c98c8..e1012a8 100644
650--- a/src/components/KeyboardChatScrollView/types.ts
651+++ b/src/components/KeyboardChatScrollView/types.ts
652@@ -93,6 +93,17 @@ export type KeyboardChatScrollViewProps = {
653 * Default is `undefined` (equivalent to `0` — no minimum floor).
654 */
655 blankSpace?: SharedValue<number>;
656+ /**
657+ * Extra bottom inset UIKit adds on top of the raw `contentInset` this
658+ * component writes (e.g. the home-indicator safe area under
659+ * `contentInsetAdjustmentBehavior="automatic"`). Used ONLY in scroll-offset
660+ * math (max scroll / end pinning) — never written into `contentInset`.
661+ *
662+ * Default is `0`.
663+ */
664+ adjustedInsetCompensation?: number;
665+ /** Leading inset UIKit adds outside raw contentInset. Offset math only. */
666+ adjustedStartInsetCompensation?: number;
667 /**
668 * Fires whenever the effective content inset changes — the static `contentInset`
669 * prop combined with the dynamic keyboard-driven padding.
670diff --git a/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts b/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts
671index 37eacd1..3d77ab2 100644
672--- a/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts
673+++ b/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts
674@@ -245,6 +245,7 @@ export const computeIOSContentOffset = (
675 layoutHeight: number,
676 inverted: boolean,
677 totalPaddingForMaxScroll?: number,
678+ startInsetCompensation: number = 0,
679 ): number => {
680 "worklet";
682@@ -262,7 +263,14 @@ export const computeIOSContentOffset = (
683 );
684 }
686- const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, 0);
687+ const minScroll = -startInsetCompensation;
688+ const maxScroll = Math.max(
689+ contentHeight - layoutHeight + paddingForMax,
690+ minScroll,
691+ );
693- return Math.min(Math.max(keyboardHeight + relativeScroll, 0), maxScroll);
694+ return Math.min(
695+ Math.max(keyboardHeight + relativeScroll, minScroll),
696+ maxScroll,
697+ );
698 };
699diff --git a/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts b/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts
700index 129a74b..168ce1a 100644
701--- a/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts
702+++ b/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts
703@@ -43,6 +43,8 @@ function useChatKeyboard(
704 offset,
705 blankSpace,
706 extraContentPadding,
707+ adjustedInsetCompensation,
708+ adjustedStartInsetCompensation,
709 } = options;
711 const padding = useSharedValue(0);
712@@ -80,6 +82,10 @@ function useChatKeyboard(
713 offset,
714 );
716+ if (e.duration === 0) {
717+ currentHeight.value = effective;
718+ }
720 const atEnd = isScrollAtEnd(
721 scroll.value,
722 layout.value.height,
723@@ -105,10 +111,12 @@ function useChatKeyboard(
724 effective,
725 minimumPaddingAbsorbed,
726 );
727- const actualTotalPadding = Math.max(
728- blankSpace.value,
729- effective + extraContentPadding.value,
730- );
731+ // UIKit adds adjustedInsetCompensation (safe area) on top of the raw
732+ // inset; include it here so end/max-scroll targets match the real
733+ // resting offsets.
734+ const actualTotalPadding =
735+ Math.max(blankSpace.value, effective + extraContentPadding.value) +
736+ adjustedInsetCompensation;
738 // `onInteractive` owns the native scroll offset. When its final
739 // keyboardWillHide event arrives, consume the marker so this
740@@ -142,11 +150,11 @@ function useChatKeyboard(
741 } else {
742 const maxScroll = Math.max(
743 size.value.height - layout.value.height + actualTotalPadding,
744- 0,
745+ -adjustedStartInsetCompensation,
746 );
748 contentOffsetY.value = Math.max(
749- 0,
750+ -adjustedStartInsetCompensation,
751 Math.min(scroll.value, maxScroll),
752 );
753 }
754@@ -177,11 +185,11 @@ function useChatKeyboard(
755 } else {
756 const maxScroll = Math.max(
757 size.value.height - layout.value.height + actualTotalPadding,
758- 0,
759+ -adjustedStartInsetCompensation,
760 );
762 contentOffsetY.value = Math.max(
763- 0,
764+ -adjustedStartInsetCompensation,
765 Math.min(scroll.value, maxScroll),
766 );
767 }
768@@ -231,17 +239,36 @@ function useChatKeyboard(
769 layout.value.height,
770 inverted,
771 actualTotalPadding,
772+ adjustedStartInsetCompensation,
773 );
774 },
775- onInteractive: () => {
776+ onMove: (e) => {
777 "worklet";
779- isInteractiveDismissal.value = true;
780+ if (freeze.value) {
781+ return;
782+ }
784+ currentHeight.value = getEffectiveHeight(
785+ e.height,
786+ targetKeyboardHeight.value,
787+ offset,
788+ );
789 },
790- onMove: () => {
791+ onInteractive: (e) => {
792 "worklet";
794- // iOS doesn't need per-frame updates (contentOffset handles it)
795+ isInteractiveDismissal.value = true;
797+ if (freeze.value) {
798+ return;
799+ }
801+ currentHeight.value = getEffectiveHeight(
802+ e.height,
803+ targetKeyboardHeight.value,
804+ offset,
805+ );
806 },
807 onEnd: (e) => {
808 "worklet";
809@@ -256,10 +283,18 @@ function useChatKeyboard(
810 offset,
811 );
813+ currentHeight.value = effective;
814 padding.value = effective;
815 },
816 },
817- [inverted, keyboardLiftBehavior, offset, extraContentPadding],
818+ [
819+ inverted,
820+ keyboardLiftBehavior,
821+ offset,
822+ extraContentPadding,
823+ adjustedInsetCompensation,
824+ adjustedStartInsetCompensation,
825+ ],
826 );
828 return {
829diff --git a/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts b/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts
830index 02abf5c..4ee0ddd 100644
831--- a/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts
832+++ b/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts
833@@ -11,6 +11,10 @@ type UseChatKeyboardOptions = {
834 blankSpace: SharedValue<number>;
835 /** Extra content padding shared value — needed on iOS to correctly clamp contentOffset. */
836 extraContentPadding: SharedValue<number>;
837+ /** Extra bottom inset UIKit adds beyond the raw contentInset (safe area). Offset math only. */
838+ adjustedInsetCompensation: number;
839+ /** Leading inset UIKit adds beyond the raw contentInset. Offset math only. */
840+ adjustedStartInsetCompensation: number;
841 };
843 type UseChatKeyboardReturn = {
844diff --git a/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts b/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
845index c9c93f3..02f95c0 100644
846--- a/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
847+++ b/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
848@@ -16,6 +16,10 @@ type UseExtraContentPaddingOptions = {
849 keyboardPadding: SharedValue<number>;
850 /** Minimum inset floor — used to absorb keyboard and extraContentPadding changes. */
851 blankSpace: SharedValue<number>;
852+ /** Extra bottom inset UIKit adds beyond the raw contentInset (safe area). Offset math only. */
853+ adjustedInsetCompensation: number;
854+ /** Leading inset UIKit adds beyond raw contentInset. Offset math only. */
855+ adjustedStartInsetCompensation: number;
856 /** Current vertical scroll offset. */
857 scroll: SharedValue<number>;
858 /** Visible viewport dimensions. */
859@@ -51,6 +55,8 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
860 extraContentPadding,
861 keyboardPadding,
862 blankSpace,
863+ adjustedInsetCompensation,
864+ adjustedStartInsetCompensation,
865 scroll,
866 layout,
867 size,
868@@ -72,8 +78,13 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
869 // otherwise the native ScrollView clamps to the old range.
870 requestAnimationFrame(() => {
871 // check that view is still mounted and ref is actual
872- // otherwise it may lead to a crash
873- if (!scrollViewRef()) {
874+ // otherwise it may lead to a crash. Reanimated 4.7+ passes the
875+ // ref to the UI runtime as a shareable holding the node in `.value`.
876+ const node =
877+ typeof scrollViewRef === "function"
878+ ? scrollViewRef()
879+ : (scrollViewRef as unknown as { value: unknown }).value;
880+ if (!node) {
881 return;
882 }
883 scrollTo(scrollViewRef, 0, target, false);
884@@ -99,14 +110,12 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
885 }
887 // Compute effective delta considering blankSpace floor
888- const previousTotal = Math.max(
889- blankSpace.value,
890- keyboardPadding.value + previous,
891- );
892- const currentTotal = Math.max(
893- blankSpace.value,
894- keyboardPadding.value + current,
895- );
896+ const previousTotal =
897+ Math.max(blankSpace.value, keyboardPadding.value + previous) +
898+ adjustedInsetCompensation;
899+ const currentTotal =
900+ Math.max(blankSpace.value, keyboardPadding.value + current) +
901+ adjustedInsetCompensation;
902 const effectiveDelta = currentTotal - previousTotal;
904 if (effectiveDelta === 0) {
905@@ -139,16 +148,25 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
907 scrollToTarget(target);
908 } else {
909+ const minScroll = -adjustedStartInsetCompensation;
910 const maxScroll = Math.max(
911 size.value.height - layout.value.height + currentTotal,
912- 0,
913+ minScroll,
914+ );
915+ const target = Math.max(
916+ minScroll,
917+ Math.min(scroll.value + effectiveDelta, maxScroll),
918 );
919- const target = Math.min(scroll.value + effectiveDelta, maxScroll);
921 scrollToTarget(target);
922 }
923 },
924- [inverted, keyboardLiftBehavior],
925+ [
926+ inverted,
927+ keyboardLiftBehavior,
928+ adjustedInsetCompensation,
929+ adjustedStartInsetCompensation,
930+ ],
931 );
932 }