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

react-native-keyboard-controller@1.21.13.patch

869 lines41.5 KB

1diff --git a/lib/commonjs/components/KeyboardChatScrollView/index.js b/lib/commonjs/components/KeyboardChatScrollView/index.js
2index db8cfb1d289f91563f13c4dd842c783c99facc32..64c7e38ad8d9e866b15a53e561509e6b0ad33cb9 100644
3--- a/lib/commonjs/components/KeyboardChatScrollView/index.js
4+++ b/lib/commonjs/components/KeyboardChatScrollView/index.js
5@@ -26,9 +26,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@@ -50,13 +53,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@@ -82,10 +89,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 4d33b3fe426070cf312fc493ce902b2c24d853ea..e619708b95865afd8b43dd8f0a6523fcf67b1f53 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
90diff --git a/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js b/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js
91index 2073da84b8b2be291aa3181700c2b18a75d0fc56..7ae9bb220ce3cc23c788a79677afdc7d9547a27c 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@@ -58,6 +60,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@@ -66,7 +71,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 // persistent mode: when keyboard shrinks, clamp to valid range
123 if (keyboardLiftBehavior === "persistent" && effective < padding.value) {
124@@ -76,8 +81,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@@ -91,8 +96,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@@ -118,12 +123,23 @@ 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+ onMove: e => {
154+ "worklet";
156+ if (freeze.value) {
157+ return;
158+ }
159+ currentHeight.value = (0, _helpers.getEffectiveHeight)(e.height, targetKeyboardHeight.value, offset);
160 },
161- onMove: () => {
162+ onInteractive: e => {
163 "worklet";
165- // iOS doesn't need per-frame updates (contentOffset handles it)
166+ if (freeze.value) {
167+ return;
168+ }
169+ currentHeight.value = (0, _helpers.getEffectiveHeight)(e.height, targetKeyboardHeight.value, offset);
170 },
171 onEnd: e => {
172 "worklet";
173@@ -132,9 +148,10 @@ function useChatKeyboard(scrollViewRef, options) {
174 return;
175 }
176 const effective = (0, _helpers.getEffectiveHeight)(e.height, targetKeyboardHeight.value, offset);
177+ currentHeight.value = effective;
178 padding.value = effective;
179 }
180- }, [inverted, keyboardLiftBehavior, offset, extraContentPadding]);
181+ }, [inverted, keyboardLiftBehavior, offset, extraContentPadding, adjustedInsetCompensation, adjustedStartInsetCompensation]);
182 return {
183 padding,
184 currentHeight,
185diff --git a/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js b/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js
186index 0d50bdfeb7bbc5c14a31ed344f8a690e4fd340b3..e0b73653fd1dd23f0f2e2c85835a3d107e3f666d 100644
187--- a/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js
188+++ b/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js
189@@ -29,6 +29,8 @@ function useExtraContentPadding(options) {
190 extraContentPadding,
191 keyboardPadding,
192 blankSpace,
193+ adjustedInsetCompensation,
194+ adjustedStartInsetCompensation,
195 scroll,
196 layout,
197 size,
198@@ -68,8 +70,8 @@ function useExtraContentPadding(options) {
199 }
201 // Compute effective delta considering blankSpace floor
202- const previousTotal = Math.max(blankSpace.value, keyboardPadding.value + previous);
203- const currentTotal = Math.max(blankSpace.value, keyboardPadding.value + current);
204+ const previousTotal = Math.max(blankSpace.value, keyboardPadding.value + previous) + adjustedInsetCompensation;
205+ const currentTotal = Math.max(blankSpace.value, keyboardPadding.value + current) + adjustedInsetCompensation;
206 const effectiveDelta = currentTotal - previousTotal;
207 if (effectiveDelta === 0) {
208 // blankSpace absorbed the change
209@@ -88,10 +90,11 @@ function useExtraContentPadding(options) {
210 const target = Math.max(scroll.value - effectiveDelta, -currentTotal);
211 scrollToTarget(target);
212 } else {
213- const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, 0);
214- const target = Math.min(scroll.value + effectiveDelta, maxScroll);
215+ const minScroll = -adjustedStartInsetCompensation;
216+ const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, minScroll);
217+ const target = Math.max(minScroll, Math.min(scroll.value + effectiveDelta, maxScroll));
218 scrollToTarget(target);
219 }
220- }, [inverted, keyboardLiftBehavior]);
221+ }, [inverted, keyboardLiftBehavior, adjustedInsetCompensation, adjustedStartInsetCompensation]);
222 }
223 //# sourceMappingURL=index.js.map
224diff --git a/lib/module/components/KeyboardChatScrollView/index.js b/lib/module/components/KeyboardChatScrollView/index.js
225index 612dd8bd9bd6cc3e30a5acac937ea3383eb1b630..76b858a6590ad0592cc663864ea822db55eaeceb 100644
226--- a/lib/module/components/KeyboardChatScrollView/index.js
227+++ b/lib/module/components/KeyboardChatScrollView/index.js
228@@ -1,7 +1,7 @@
229 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); }
230 import React, { forwardRef, useCallback, useMemo } from "react";
231-import { StyleSheet } from "react-native";
232-import { makeMutable, useAnimatedRef, useAnimatedStyle, useDerivedValue } from "react-native-reanimated";
233+import { Platform, StyleSheet } from "react-native";
234+import { makeMutable, runOnJS, useAnimatedReaction, useAnimatedRef, useAnimatedStyle, useDerivedValue } from "react-native-reanimated";
235 import Reanimated from "react-native-reanimated";
236 import useCombinedRef from "../hooks/useCombinedRef";
237 import ScrollViewWithBottomPadding from "../ScrollViewWithBottomPadding";
238@@ -19,9 +19,12 @@ const KeyboardChatScrollView = /*#__PURE__*/forwardRef(({
239 offset = 0,
240 extraContentPadding = ZERO_CONTENT_PADDING,
241 blankSpace = ZERO_BLANK_SPACE,
242+ adjustedInsetCompensation = 0,
243+ adjustedStartInsetCompensation = 0,
244 applyWorkaroundForContentInsetHitTestBug = false,
245 onLayout: onLayoutProp,
246 onContentSizeChange: onContentSizeChangeProp,
247+ onContentInsetChange,
248 onEndVisible,
249 ...rest
250 }, ref) => {
251@@ -43,13 +46,17 @@ const KeyboardChatScrollView = /*#__PURE__*/forwardRef(({
252 freeze: freezeSV,
253 offset,
254 blankSpace,
255- extraContentPadding
256+ extraContentPadding,
257+ adjustedInsetCompensation,
258+ adjustedStartInsetCompensation
259 });
260 useExtraContentPadding({
261 scrollViewRef,
262 extraContentPadding,
263 keyboardPadding: padding,
264 blankSpace,
265+ adjustedInsetCompensation,
266+ adjustedStartInsetCompensation,
267 scroll,
268 layout,
269 size,
270@@ -75,10 +82,26 @@ const KeyboardChatScrollView = /*#__PURE__*/forwardRef(({
271 // a bug for you, please open an issue.
272 const totalPadding = useDerivedValue(() => Math.min(layout.value.height, Math.max(blankSpace.value, padding.value + extraContentPadding.value)));
274+ // iOS applies the destination contentInset and contentOffset together at
275+ // keyboard-animation start. Keep that native target behavior, but report
276+ // the presentation height so virtualized-list layout follows the keyboard.
277+ const reportedPadding = useDerivedValue(() => Platform.OS === "ios" ? Math.min(layout.value.height, Math.max(blankSpace.value, currentHeight.value + extraContentPadding.value)) : totalPadding.value);
279+ // Mirror the effective bottom padding (keyboard + composer + blank floor)
280+ // to the consumer - a virtualized list needs it in its own scroll math or
281+ // its end/maintain targets point at the under-the-keyboard resting offset.
282+ useAnimatedReaction(() => reportedPadding.value, (current, previous) => {
283+ if (onContentInsetChange && current !== previous) {
284+ runOnJS(onContentInsetChange)({
285+ bottom: current
286+ });
287+ }
288+ }, [onContentInsetChange]);
290 // Scroll indicator inset = keyboard + extraContentPadding (excludes blankSpace).
291 // Apps that render into the unsafe area can supply a negative
292 // scrollIndicatorInsets adjustment at the application layer.
293- const indicatorPadding = useDerivedValue(() => padding.value + extraContentPadding.value);
294+ const indicatorPadding = useDerivedValue(() => padding.value);
295 const onLayout = useCallback(e => {
296 onLayoutInternal(e);
297 onLayoutProp === null || onLayoutProp === void 0 || onLayoutProp(e);
298diff --git a/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js b/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js
299index 295e2219b560519b8d033968b5105d1da3e77315..ff7ee3fe0d880c2287a7b70d5ecf952e99357adf 100644
300--- a/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js
301+++ b/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js
302@@ -193,7 +193,7 @@ export const clampedScrollTarget = (offsetBeforeScroll, keyboardHeight, contentH
303 * computeIOSContentOffset(100, 300, 1000, 800, false); // 400
304 * ```
305 */
306-export const computeIOSContentOffset = (relativeScroll, keyboardHeight, contentHeight, layoutHeight, inverted, totalPaddingForMaxScroll) => {
307+export const computeIOSContentOffset = (relativeScroll, keyboardHeight, contentHeight, layoutHeight, inverted, totalPaddingForMaxScroll, startInsetCompensation = 0) => {
308 "worklet";
310 const paddingForMax = totalPaddingForMaxScroll !== undefined ? totalPaddingForMaxScroll : keyboardHeight;
311@@ -201,7 +201,8 @@ export const computeIOSContentOffset = (relativeScroll, keyboardHeight, contentH
312 const maxScroll = Math.max(contentHeight - layoutHeight, 0);
313 return Math.max(Math.min(relativeScroll - keyboardHeight, maxScroll), -paddingForMax);
314 }
315- const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, 0);
316- return Math.min(Math.max(keyboardHeight + relativeScroll, 0), maxScroll);
317+ const minScroll = -startInsetCompensation;
318+ const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, minScroll);
319+ return Math.min(Math.max(keyboardHeight + relativeScroll, minScroll), maxScroll);
320 };
321 //# sourceMappingURL=helpers.js.map
322diff --git a/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js b/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js
323index 52943c3a7d6a68fe2094dc1d112c07e6b9d890e4..cc4bfae859191aeb848179028b7217098cba2340 100644
324--- a/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js
325+++ b/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js
326@@ -25,7 +25,9 @@ function useChatKeyboard(scrollViewRef, options) {
327 freeze,
328 offset,
329 blankSpace,
330- extraContentPadding
331+ extraContentPadding,
332+ adjustedInsetCompensation,
333+ adjustedStartInsetCompensation
334 } = options;
335 const padding = useSharedValue(0);
336 const currentHeight = useSharedValue(0);
337@@ -51,6 +53,9 @@ function useChatKeyboard(scrollViewRef, options) {
338 targetKeyboardHeight.value = e.height;
339 }
340 const effective = getEffectiveHeight(e.height, targetKeyboardHeight.value, offset);
341+ if (e.duration === 0) {
342+ currentHeight.value = effective;
343+ }
344 const atEnd = isScrollAtEnd(scroll.value, layout.value.height, size.value.height, inverted);
346 // Scale minimum padding absorption by how much of it is visible.
347@@ -59,7 +64,7 @@ function useChatKeyboard(scrollViewRef, options) {
348 const visiblePadding = visibleFraction * blankSpace.value;
349 const minimumPaddingAbsorbed = Math.max(0, visiblePadding - extraContentPadding.value);
350 const scrollEffective = getScrollEffective(effective, minimumPaddingAbsorbed);
351- const actualTotalPadding = Math.max(blankSpace.value, effective + extraContentPadding.value);
352+ const actualTotalPadding = Math.max(blankSpace.value, effective + extraContentPadding.value) + adjustedInsetCompensation;
354 // persistent mode: when keyboard shrinks, clamp to valid range
355 if (keyboardLiftBehavior === "persistent" && effective < padding.value) {
356@@ -69,8 +74,8 @@ function useChatKeyboard(scrollViewRef, options) {
357 const maxScroll = Math.max(size.value.height - layout.value.height, 0);
358 contentOffsetY.value = Math.max(-actualTotalPadding, Math.min(scroll.value, maxScroll));
359 } else {
360- const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, 0);
361- contentOffsetY.value = Math.max(0, Math.min(scroll.value, maxScroll));
362+ const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, -adjustedStartInsetCompensation);
363+ contentOffsetY.value = Math.max(-adjustedStartInsetCompensation, Math.min(scroll.value, maxScroll));
364 }
365 return;
366 }
367@@ -84,8 +89,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@@ -111,12 +116,23 @@ function useChatKeyboard(scrollViewRef, options) {
379 contentOffsetY.value = scroll.value;
380 return;
381 }
382- contentOffsetY.value = computeIOSContentOffset(relativeScroll, scrollEffective, size.value.height, layout.value.height, inverted, actualTotalPadding);
383+ contentOffsetY.value = computeIOSContentOffset(relativeScroll, scrollEffective, size.value.height, layout.value.height, inverted, actualTotalPadding, adjustedStartInsetCompensation);
384+ },
385+ onMove: e => {
386+ "worklet";
388+ if (freeze.value) {
389+ return;
390+ }
391+ currentHeight.value = getEffectiveHeight(e.height, targetKeyboardHeight.value, offset);
392 },
393- onMove: () => {
394+ onInteractive: e => {
395 "worklet";
397- // iOS doesn't need per-frame updates (contentOffset handles it)
398+ if (freeze.value) {
399+ return;
400+ }
401+ currentHeight.value = getEffectiveHeight(e.height, targetKeyboardHeight.value, offset);
402 },
403 onEnd: e => {
404 "worklet";
405@@ -125,9 +141,10 @@ function useChatKeyboard(scrollViewRef, options) {
406 return;
407 }
408 const effective = getEffectiveHeight(e.height, targetKeyboardHeight.value, offset);
409+ currentHeight.value = effective;
410 padding.value = effective;
411 }
412- }, [inverted, keyboardLiftBehavior, offset, extraContentPadding]);
413+ }, [inverted, keyboardLiftBehavior, offset, extraContentPadding, adjustedInsetCompensation, adjustedStartInsetCompensation]);
414 return {
415 padding,
416 currentHeight,
417diff --git a/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js b/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js
418index 1afa50987a8d2a5fe3f36b20945efe804d48a873..7b05d0721c50e118cf78c07913b580a31293db77 100644
419--- a/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js
420+++ b/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js
421@@ -23,6 +23,8 @@ function useExtraContentPadding(options) {
422 extraContentPadding,
423 keyboardPadding,
424 blankSpace,
425+ adjustedInsetCompensation,
426+ adjustedStartInsetCompensation,
427 scroll,
428 layout,
429 size,
430@@ -62,8 +64,8 @@ function useExtraContentPadding(options) {
431 }
433 // Compute effective delta considering blankSpace floor
434- const previousTotal = Math.max(blankSpace.value, keyboardPadding.value + previous);
435- const currentTotal = Math.max(blankSpace.value, keyboardPadding.value + current);
436+ const previousTotal = Math.max(blankSpace.value, keyboardPadding.value + previous) + adjustedInsetCompensation;
437+ const currentTotal = Math.max(blankSpace.value, keyboardPadding.value + current) + adjustedInsetCompensation;
438 const effectiveDelta = currentTotal - previousTotal;
439 if (effectiveDelta === 0) {
440 // blankSpace absorbed the change
441@@ -82,11 +84,12 @@ function useExtraContentPadding(options) {
442 const target = Math.max(scroll.value - effectiveDelta, -currentTotal);
443 scrollToTarget(target);
444 } else {
445- const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, 0);
446- const target = Math.min(scroll.value + effectiveDelta, maxScroll);
447+ const minScroll = -adjustedStartInsetCompensation;
448+ const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, minScroll);
449+ const target = Math.max(minScroll, Math.min(scroll.value + effectiveDelta, maxScroll));
450 scrollToTarget(target);
451 }
452- }, [inverted, keyboardLiftBehavior]);
453+ }, [inverted, keyboardLiftBehavior, adjustedInsetCompensation, adjustedStartInsetCompensation]);
454 }
455 export { useExtraContentPadding };
456 //# sourceMappingURL=index.js.map
457diff --git a/lib/typescript/components/KeyboardChatScrollView/types.d.ts b/lib/typescript/components/KeyboardChatScrollView/types.d.ts
458index a036b431f03efb9d5379527c17db6fce62bfee09..5e56bf7edec9161698a745e8e6292bfccd68d3db 100644
459--- a/lib/typescript/components/KeyboardChatScrollView/types.d.ts
460+++ b/lib/typescript/components/KeyboardChatScrollView/types.d.ts
461@@ -86,6 +86,10 @@ export type KeyboardChatScrollViewProps = {
462 * Default is `undefined` (equivalent to `0` — no minimum floor).
463 */
464 blankSpace?: SharedValue<number>;
465+ /** Extra bottom inset UIKit adds beyond the raw contentInset (safe area). Offset math only. */
466+ adjustedInsetCompensation?: number;
467+ /** Leading inset UIKit adds outside raw contentInset. Offset math only. */
468+ adjustedStartInsetCompensation?: number;
469 /**
470 * Fires whenever the effective content inset changes — the static `contentInset`
471 * prop combined with the dynamic keyboard-driven padding.
472diff --git a/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts b/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts
473index 2b51cc4737b4a05b5396da31e67e54177f43c498..3acec1fbddee6227915590a6c8d449757cb4d7b2 100644
474--- a/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts
475+++ b/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts
476@@ -129,4 +129,4 @@ export declare const clampedScrollTarget: (offsetBeforeScroll: number, keyboardH
477 * computeIOSContentOffset(100, 300, 1000, 800, false); // 400
478 * ```
479 */
480-export declare const computeIOSContentOffset: (relativeScroll: number, keyboardHeight: number, contentHeight: number, layoutHeight: number, inverted: boolean, totalPaddingForMaxScroll?: number) => number;
481+export declare const computeIOSContentOffset: (relativeScroll: number, keyboardHeight: number, contentHeight: number, layoutHeight: number, inverted: boolean, totalPaddingForMaxScroll?: number, startInsetCompensation?: number) => number;
482diff --git a/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts b/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts
483index aff9b5a8dbc2464546396437eaf6c5ae955b9f29..fdd83953271123be6caefaa786c469f0d92cce2b 100644
484--- a/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts
485+++ b/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts
486@@ -9,6 +9,10 @@ type UseChatKeyboardOptions = {
487 blankSpace: SharedValue<number>;
488 /** Extra content padding shared value — needed on iOS to correctly clamp contentOffset. */
489 extraContentPadding: SharedValue<number>;
490+ /** Safe-area extra beyond raw contentInset. Offset math only. */
491+ adjustedInsetCompensation: number;
492+ /** Leading inset UIKit adds beyond the raw contentInset. Offset math only. */
493+ adjustedStartInsetCompensation: number;
494 };
495 type UseChatKeyboardReturn = {
496 /** Extra scrollable space (= keyboard height). Used as contentInset on iOS, contentInsetBottom/contentInsetTop on Android. */
497diff --git a/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts b/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts
498index ec73f70544a062fbecfc1d8be92d839d3e0bea6f..45b387446587fd3e611fa02a01534bb5d9fa6bbd 100644
499--- a/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts
500+++ b/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts
501@@ -8,6 +8,10 @@ type UseExtraContentPaddingOptions = {
502 keyboardPadding: SharedValue<number>;
503 /** Minimum inset floor — used to absorb keyboard and extraContentPadding changes. */
504 blankSpace: SharedValue<number>;
505+ /** Safe-area extra beyond raw contentInset. Offset math only. */
506+ adjustedInsetCompensation: number;
507+ /** Leading inset UIKit adds beyond raw contentInset. Offset math only. */
508+ adjustedStartInsetCompensation: number;
509 /** Current vertical scroll offset. */
510 scroll: SharedValue<number>;
511 /** Visible viewport dimensions. */
512diff --git a/src/components/KeyboardChatScrollView/index.tsx b/src/components/KeyboardChatScrollView/index.tsx
513index 03f5f74e9aaaabc75db1c01643a655ee4fdfa5f2..277a1ecada428ffbae517d6edc720d029c8ecc10 100644
514--- a/src/components/KeyboardChatScrollView/index.tsx
515+++ b/src/components/KeyboardChatScrollView/index.tsx
516@@ -1,7 +1,9 @@
517 import React, { forwardRef, useCallback, useMemo } from "react";
518-import { StyleSheet } from "react-native";
519+import { Platform, StyleSheet } from "react-native";
520 import {
521 makeMutable,
522+ runOnJS,
523+ useAnimatedReaction,
524 useAnimatedRef,
525 useAnimatedStyle,
526 useDerivedValue,
527@@ -35,9 +37,12 @@ const KeyboardChatScrollView = forwardRef<
528 offset = 0,
529 extraContentPadding = ZERO_CONTENT_PADDING,
530 blankSpace = ZERO_BLANK_SPACE,
531+ adjustedInsetCompensation = 0,
532+ adjustedStartInsetCompensation = 0,
533 applyWorkaroundForContentInsetHitTestBug = false,
534 onLayout: onLayoutProp,
535 onContentSizeChange: onContentSizeChangeProp,
536+ onContentInsetChange,
537 onEndVisible,
538 ...rest
539 },
540@@ -64,6 +69,8 @@ const KeyboardChatScrollView = forwardRef<
541 offset,
542 blankSpace,
543 extraContentPadding,
544+ adjustedInsetCompensation,
545+ adjustedStartInsetCompensation,
546 });
548 useExtraContentPadding({
549@@ -71,6 +78,8 @@ const KeyboardChatScrollView = forwardRef<
550 extraContentPadding,
551 keyboardPadding: padding,
552 blankSpace,
553+ adjustedInsetCompensation,
554+ adjustedStartInsetCompensation,
555 scroll,
556 layout,
557 size,
558@@ -102,13 +111,40 @@ const KeyboardChatScrollView = forwardRef<
559 ),
560 );
562- // Scroll indicator inset = keyboard + extraContentPadding (excludes blankSpace).
563- // Apps that render into the unsafe area can supply a negative
564- // scrollIndicatorInsets adjustment at the application layer.
565- const indicatorPadding = useDerivedValue(
566- () => padding.value + extraContentPadding.value,
567+ // iOS applies the destination contentInset and contentOffset together at
568+ // keyboard-animation start. Keep that native target behavior, but report
569+ // the presentation height so virtualized-list layout follows the keyboard.
570+ const reportedPadding = useDerivedValue(() =>
571+ Platform.OS === "ios"
572+ ? Math.min(
573+ layout.value.height,
574+ Math.max(
575+ blankSpace.value,
576+ currentHeight.value + extraContentPadding.value,
577+ ),
578+ )
579+ : totalPadding.value,
580 );
582+ // Mirror the effective bottom padding (keyboard + composer + blank floor)
583+ // to the consumer — a virtualized list needs it in its own scroll math or
584+ // its end/maintain targets point at the under-the-keyboard resting offset.
585+ useAnimatedReaction(
586+ () => reportedPadding.value,
587+ (current, previous) => {
588+ if (onContentInsetChange && current !== previous) {
589+ runOnJS(onContentInsetChange)({ bottom: current });
590+ }
591+ },
592+ [onContentInsetChange],
593+ );
595+ // Scroll indicator inset = keyboard only (excludes extraContentPadding and
596+ // blankSpace): with a floating composer the indicator track should run the
597+ // full height of the scroll view, behind the composer, like iOS Messages.
598+ // The keyboard still lifts it so it never disappears under the keyboard.
599+ const indicatorPadding = useDerivedValue(() => padding.value);
601 const onLayout = useCallback(
602 (e: LayoutChangeEvent) => {
603 onLayoutInternal(e);
604diff --git a/src/components/KeyboardChatScrollView/types.ts b/src/components/KeyboardChatScrollView/types.ts
605index dd222b57bc7a71729524670bad3812f30920bd73..7be71b5460eb143ddf460ce5c87b843c66bfb2cd 100644
606--- a/src/components/KeyboardChatScrollView/types.ts
607+++ b/src/components/KeyboardChatScrollView/types.ts
608@@ -90,6 +90,17 @@ export type KeyboardChatScrollViewProps = {
609 * Default is `undefined` (equivalent to `0` — no minimum floor).
610 */
611 blankSpace?: SharedValue<number>;
612+ /**
613+ * Extra bottom inset UIKit adds on top of the raw `contentInset` this
614+ * component writes (e.g. the home-indicator safe area under
615+ * `contentInsetAdjustmentBehavior="automatic"`). Used ONLY in scroll-offset
616+ * math (max scroll / end pinning) — never written into `contentInset`.
617+ *
618+ * Default is `0`.
619+ */
620+ adjustedInsetCompensation?: number;
621+ /** Leading inset UIKit adds outside raw contentInset. Offset math only. */
622+ adjustedStartInsetCompensation?: number;
623 /**
624 * Fires whenever the effective content inset changes — the static `contentInset`
625 * prop combined with the dynamic keyboard-driven padding.
626diff --git a/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts b/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts
627index 37eacd10857cd70c51b3468c4b466e4959d0a415..3d77ab27c614f44b64da8270823942cb670b097b 100644
628--- a/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts
629+++ b/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts
630@@ -245,6 +245,7 @@ export const computeIOSContentOffset = (
631 layoutHeight: number,
632 inverted: boolean,
633 totalPaddingForMaxScroll?: number,
634+ startInsetCompensation: number = 0,
635 ): number => {
636 "worklet";
638@@ -262,7 +263,14 @@ export const computeIOSContentOffset = (
639 );
640 }
642- const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, 0);
643+ const minScroll = -startInsetCompensation;
644+ const maxScroll = Math.max(
645+ contentHeight - layoutHeight + paddingForMax,
646+ minScroll,
647+ );
649- return Math.min(Math.max(keyboardHeight + relativeScroll, 0), maxScroll);
650+ return Math.min(
651+ Math.max(keyboardHeight + relativeScroll, minScroll),
652+ maxScroll,
653+ );
654 };
655diff --git a/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts b/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts
656index 560df54bae1a8c41a2e9ac0e2a8d2fd9b843968a..c375a8c4cc889c2fc2c0c1034788c605633192ed 100644
657--- a/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts
658+++ b/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts
659@@ -43,6 +43,8 @@ function useChatKeyboard(
660 offset,
661 blankSpace,
662 extraContentPadding,
663+ adjustedInsetCompensation,
664+ adjustedStartInsetCompensation,
665 } = options;
667 const padding = useSharedValue(0);
668@@ -79,6 +81,10 @@ function useChatKeyboard(
669 offset,
670 );
672+ if (e.duration === 0) {
673+ currentHeight.value = effective;
674+ }
676 const atEnd = isScrollAtEnd(
677 scroll.value,
678 layout.value.height,
679@@ -104,10 +110,12 @@ function useChatKeyboard(
680 effective,
681 minimumPaddingAbsorbed,
682 );
683- const actualTotalPadding = Math.max(
684- blankSpace.value,
685- effective + extraContentPadding.value,
686- );
687+ // UIKit adds adjustedInsetCompensation (safe area) on top of the raw
688+ // inset; include it here so end/max-scroll targets match the real
689+ // resting offsets.
690+ const actualTotalPadding =
691+ Math.max(blankSpace.value, effective + extraContentPadding.value) +
692+ adjustedInsetCompensation;
694 // persistent mode: when keyboard shrinks, clamp to valid range
695 if (
696@@ -130,11 +138,11 @@ function useChatKeyboard(
697 } else {
698 const maxScroll = Math.max(
699 size.value.height - layout.value.height + actualTotalPadding,
700- 0,
701+ -adjustedStartInsetCompensation,
702 );
704 contentOffsetY.value = Math.max(
705- 0,
706+ -adjustedStartInsetCompensation,
707 Math.min(scroll.value, maxScroll),
708 );
709 }
710@@ -165,11 +173,11 @@ function useChatKeyboard(
711 } else {
712 const maxScroll = Math.max(
713 size.value.height - layout.value.height + actualTotalPadding,
714- 0,
715+ -adjustedStartInsetCompensation,
716 );
718 contentOffsetY.value = Math.max(
719- 0,
720+ -adjustedStartInsetCompensation,
721 Math.min(scroll.value, maxScroll),
722 );
723 }
724@@ -219,12 +227,34 @@ function useChatKeyboard(
725 layout.value.height,
726 inverted,
727 actualTotalPadding,
728+ adjustedStartInsetCompensation,
729 );
730 },
731- onMove: () => {
732+ onMove: (e) => {
733 "worklet";
735- // iOS doesn't need per-frame updates (contentOffset handles it)
736+ if (freeze.value) {
737+ return;
738+ }
740+ currentHeight.value = getEffectiveHeight(
741+ e.height,
742+ targetKeyboardHeight.value,
743+ offset,
744+ );
745+ },
746+ onInteractive: (e) => {
747+ "worklet";
749+ if (freeze.value) {
750+ return;
751+ }
753+ currentHeight.value = getEffectiveHeight(
754+ e.height,
755+ targetKeyboardHeight.value,
756+ offset,
757+ );
758 },
759 onEnd: (e) => {
760 "worklet";
761@@ -239,10 +269,18 @@ function useChatKeyboard(
762 offset,
763 );
765+ currentHeight.value = effective;
766 padding.value = effective;
767 },
768 },
769- [inverted, keyboardLiftBehavior, offset, extraContentPadding],
770+ [
771+ inverted,
772+ keyboardLiftBehavior,
773+ offset,
774+ extraContentPadding,
775+ adjustedInsetCompensation,
776+ adjustedStartInsetCompensation,
777+ ],
778 );
780 return {
781diff --git a/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts b/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts
782index 02abf5cd9490900826678175462b234e07e30e92..4ee0ddd65e0b105568ab43b73997af4be8adae00 100644
783--- a/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts
784+++ b/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts
785@@ -11,6 +11,10 @@ type UseChatKeyboardOptions = {
786 blankSpace: SharedValue<number>;
787 /** Extra content padding shared value — needed on iOS to correctly clamp contentOffset. */
788 extraContentPadding: SharedValue<number>;
789+ /** Extra bottom inset UIKit adds beyond the raw contentInset (safe area). Offset math only. */
790+ adjustedInsetCompensation: number;
791+ /** Leading inset UIKit adds beyond the raw contentInset. Offset math only. */
792+ adjustedStartInsetCompensation: number;
793 };
795 type UseChatKeyboardReturn = {
796diff --git a/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts b/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
797index 833acbe78f1b1245251ddd3431d6546decdd0ade..8f7c10cb6ab392f10df4ca43549b89c25844f0b8 100644
798--- a/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
799+++ b/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
800@@ -16,6 +16,10 @@ type UseExtraContentPaddingOptions = {
801 keyboardPadding: SharedValue<number>;
802 /** Minimum inset floor — used to absorb keyboard and extraContentPadding changes. */
803 blankSpace: SharedValue<number>;
804+ /** Extra bottom inset UIKit adds beyond the raw contentInset (safe area). Offset math only. */
805+ adjustedInsetCompensation: number;
806+ /** Leading inset UIKit adds beyond raw contentInset. Offset math only. */
807+ adjustedStartInsetCompensation: number;
808 /** Current vertical scroll offset. */
809 scroll: SharedValue<number>;
810 /** Visible viewport dimensions. */
811@@ -49,6 +53,8 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
812 extraContentPadding,
813 keyboardPadding,
814 blankSpace,
815+ adjustedInsetCompensation,
816+ adjustedStartInsetCompensation,
817 scroll,
818 layout,
819 size,
820@@ -97,14 +103,12 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
821 }
823 // Compute effective delta considering blankSpace floor
824- const previousTotal = Math.max(
825- blankSpace.value,
826- keyboardPadding.value + previous,
827- );
828- const currentTotal = Math.max(
829- blankSpace.value,
830- keyboardPadding.value + current,
831- );
832+ const previousTotal =
833+ Math.max(blankSpace.value, keyboardPadding.value + previous) +
834+ adjustedInsetCompensation;
835+ const currentTotal =
836+ Math.max(blankSpace.value, keyboardPadding.value + current) +
837+ adjustedInsetCompensation;
838 const effectiveDelta = currentTotal - previousTotal;
840 if (effectiveDelta === 0) {
841@@ -137,16 +141,25 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
843 scrollToTarget(target);
844 } else {
845+ const minScroll = -adjustedStartInsetCompensation;
846 const maxScroll = Math.max(
847 size.value.height - layout.value.height + currentTotal,
848- 0,
849+ minScroll,
850+ );
851+ const target = Math.max(
852+ minScroll,
853+ Math.min(scroll.value + effectiveDelta, maxScroll),
854 );
855- const target = Math.min(scroll.value + effectiveDelta, maxScroll);
857 scrollToTarget(target);
858 }
859 },
860- [inverted, keyboardLiftBehavior],
861+ [
862+ inverted,
863+ keyboardLiftBehavior,
864+ adjustedInsetCompensation,
865+ adjustedStartInsetCompensation,
866+ ],
867 );
868 }