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