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

react-native-keyboard-controller@1.22.8.patch

910 lines42.9 KB

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