react-native-keyboard-controller 1.21.6 → 1.21.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +58 -25
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +11 -1
- package/ios/observers/movement/KeyboardViewLocator.swift +1 -1
- package/ios/views/ClippingScrollViewDecoratorViewManager.mm +6 -0
- package/lib/commonjs/components/KeyboardChatScrollView/index.js +9 -0
- package/lib/commonjs/components/KeyboardChatScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardChatScrollView/types.js.map +1 -1
- package/lib/commonjs/components/KeyboardChatScrollView/useEndVisible.js +40 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useEndVisible.js.map +1 -0
- package/lib/commonjs/components/KeyboardStickyView/index.js +10 -14
- package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js +34 -13
- package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js.map +1 -1
- package/lib/module/components/KeyboardChatScrollView/index.js +9 -0
- package/lib/module/components/KeyboardChatScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardChatScrollView/types.js.map +1 -1
- package/lib/module/components/KeyboardChatScrollView/useEndVisible.js +33 -0
- package/lib/module/components/KeyboardChatScrollView/useEndVisible.js.map +1 -0
- package/lib/module/components/KeyboardStickyView/index.js +11 -15
- package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/module/components/ScrollViewWithBottomPadding/index.js +35 -14
- package/lib/module/components/ScrollViewWithBottomPadding/index.js.map +1 -1
- package/lib/typescript/components/KeyboardChatScrollView/index.d.ts +2 -0
- package/lib/typescript/components/KeyboardChatScrollView/types.d.ts +25 -1
- package/lib/typescript/components/KeyboardChatScrollView/useEndVisible.d.ts +17 -0
- package/lib/typescript/components/ScrollViewWithBottomPadding/index.d.ts +12 -0
- package/package.json +1 -1
- package/src/components/KeyboardChatScrollView/index.tsx +10 -0
- package/src/components/KeyboardChatScrollView/types.ts +28 -1
- package/src/components/KeyboardChatScrollView/useEndVisible.ts +66 -0
- package/src/components/KeyboardStickyView/index.tsx +18 -19
- package/src/components/ScrollViewWithBottomPadding/index.tsx +65 -16
|
@@ -31,6 +31,13 @@ import kotlin.math.abs
|
|
|
31
31
|
private val TAG = KeyboardAnimationCallback::class.qualifiedName
|
|
32
32
|
private val isResizeHandledInCallbackMethods = Keyboard.IS_ANIMATION_EMULATED
|
|
33
33
|
|
|
34
|
+
private data class PendingKeyboardStartEvent(
|
|
35
|
+
val keyboardHeight: Double,
|
|
36
|
+
val progress: Double,
|
|
37
|
+
val duration: Int,
|
|
38
|
+
val target: Int,
|
|
39
|
+
)
|
|
40
|
+
|
|
34
41
|
data class KeyboardAnimationCallbackConfig(
|
|
35
42
|
val persistentInsetTypes: Int,
|
|
36
43
|
val deferredInsetTypes: Int,
|
|
@@ -63,6 +70,7 @@ class KeyboardAnimationCallback(
|
|
|
63
70
|
private var isTransitioning = false
|
|
64
71
|
private var duration = 0
|
|
65
72
|
private var viewTagFocused = -1
|
|
73
|
+
private var pendingStartEvent: PendingKeyboardStartEvent? = null
|
|
66
74
|
private var animationsToSkip = hashSetOf<WindowInsetsAnimationCompat>()
|
|
67
75
|
private val isKeyboardInteractive: Boolean
|
|
68
76
|
get() = duration == -1
|
|
@@ -177,6 +185,7 @@ class KeyboardAnimationCallback(
|
|
|
177
185
|
}
|
|
178
186
|
|
|
179
187
|
isTransitioning = true
|
|
188
|
+
pendingStartEvent = null
|
|
180
189
|
isKeyboardVisible = isKeyboardVisible()
|
|
181
190
|
duration = animation.durationMillis.toInt()
|
|
182
191
|
val keyboardHeight = getCurrentKeyboardHeight()
|
|
@@ -205,18 +214,16 @@ class KeyboardAnimationCallback(
|
|
|
205
214
|
)
|
|
206
215
|
|
|
207
216
|
Logger.i(TAG, "HEIGHT:: $keyboardHeight TAG:: $viewTagFocused")
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
KeyboardTransitionEvent.Start,
|
|
217
|
+
// AOSP calls app onStart before its internal listener.onReady. Dispatching
|
|
218
|
+
// a RN event here lets Reanimated synchronously mutate Fabric and can
|
|
219
|
+
// cancel the pending IME controller before Android starts its animator.
|
|
220
|
+
pendingStartEvent =
|
|
221
|
+
PendingKeyboardStartEvent(
|
|
214
222
|
keyboardHeight,
|
|
215
223
|
if (!isKeyboardVisible) 0.0 else 1.0,
|
|
216
224
|
duration,
|
|
217
225
|
viewTagFocused,
|
|
218
|
-
)
|
|
219
|
-
)
|
|
226
|
+
)
|
|
220
227
|
|
|
221
228
|
return super.onStart(animation, bounds)
|
|
222
229
|
}
|
|
@@ -265,24 +272,27 @@ class KeyboardAnimationCallback(
|
|
|
265
272
|
"DiffY: $diffY $height $progress ${InteractiveKeyboardProvider.isInteractive} $viewTagFocused",
|
|
266
273
|
)
|
|
267
274
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
surfaceId,
|
|
275
|
+
flushPendingStartEvent()
|
|
276
|
+
if (isTransitioning) {
|
|
277
|
+
val event =
|
|
278
|
+
if (InteractiveKeyboardProvider.isInteractive) {
|
|
279
|
+
KeyboardTransitionEvent.Interactive
|
|
280
|
+
} else {
|
|
281
|
+
KeyboardTransitionEvent.Move
|
|
282
|
+
}
|
|
283
|
+
context.dispatchEvent(
|
|
278
284
|
eventPropagationView.id,
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
285
|
+
KeyboardTransitionEvent(
|
|
286
|
+
surfaceId,
|
|
287
|
+
eventPropagationView.id,
|
|
288
|
+
event,
|
|
289
|
+
height,
|
|
290
|
+
progress,
|
|
291
|
+
duration,
|
|
292
|
+
viewTagFocused,
|
|
293
|
+
),
|
|
294
|
+
)
|
|
295
|
+
}
|
|
286
296
|
|
|
287
297
|
return insets
|
|
288
298
|
}
|
|
@@ -306,10 +316,13 @@ class KeyboardAnimationCallback(
|
|
|
306
316
|
|
|
307
317
|
if (animation in animationsToSkip) {
|
|
308
318
|
duration = 0
|
|
319
|
+
pendingStartEvent = null
|
|
309
320
|
animationsToSkip.remove(animation)
|
|
310
321
|
return@Runnable
|
|
311
322
|
}
|
|
312
323
|
|
|
324
|
+
flushPendingStartEvent()
|
|
325
|
+
|
|
313
326
|
context.emitEvent(
|
|
314
327
|
"KeyboardController::" + if (!isKeyboardVisible) "keyboardDidHide" else "keyboardDidShow",
|
|
315
328
|
getEventParams(keyboardHeight),
|
|
@@ -352,6 +365,7 @@ class KeyboardAnimationCallback(
|
|
|
352
365
|
prevKeyboardHeight = keyboardHeight
|
|
353
366
|
isTransitioning = false
|
|
354
367
|
duration = 0
|
|
368
|
+
pendingStartEvent = null
|
|
355
369
|
|
|
356
370
|
context.emitEvent(
|
|
357
371
|
"KeyboardController::" + if (!isKeyboardVisible) "keyboardDidHide" else "keyboardDidShow",
|
|
@@ -375,6 +389,7 @@ class KeyboardAnimationCallback(
|
|
|
375
389
|
}
|
|
376
390
|
|
|
377
391
|
fun destroy() {
|
|
392
|
+
pendingStartEvent = null
|
|
378
393
|
view.viewTreeObserver.removeOnGlobalFocusChangeListener(focusListener)
|
|
379
394
|
layoutObserver?.destroy()
|
|
380
395
|
}
|
|
@@ -430,6 +445,24 @@ class KeyboardAnimationCallback(
|
|
|
430
445
|
return (keyboardHeight - navigationBar).toFloat().dp.coerceAtLeast(0.0)
|
|
431
446
|
}
|
|
432
447
|
|
|
448
|
+
private fun flushPendingStartEvent() {
|
|
449
|
+
val event = pendingStartEvent ?: return
|
|
450
|
+
|
|
451
|
+
pendingStartEvent = null
|
|
452
|
+
context.dispatchEvent(
|
|
453
|
+
eventPropagationView.id,
|
|
454
|
+
KeyboardTransitionEvent(
|
|
455
|
+
surfaceId,
|
|
456
|
+
eventPropagationView.id,
|
|
457
|
+
KeyboardTransitionEvent.Start,
|
|
458
|
+
event.keyboardHeight,
|
|
459
|
+
event.progress,
|
|
460
|
+
event.duration,
|
|
461
|
+
event.target,
|
|
462
|
+
),
|
|
463
|
+
)
|
|
464
|
+
}
|
|
465
|
+
|
|
433
466
|
private fun getEventParams(height: Double): WritableMap {
|
|
434
467
|
val params: WritableMap = Arguments.createMap()
|
|
435
468
|
params.putDouble("height", height)
|
|
@@ -8,14 +8,18 @@ import com.facebook.react.bridge.Arguments
|
|
|
8
8
|
import com.facebook.react.bridge.Promise
|
|
9
9
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
10
10
|
import com.facebook.react.bridge.UiThreadUtil
|
|
11
|
+
import com.facebook.react.uimanager.IllegalViewOperationException
|
|
11
12
|
import com.reactnativekeyboardcontroller.extensions.dp
|
|
12
13
|
import com.reactnativekeyboardcontroller.extensions.screenLocation
|
|
13
14
|
import com.reactnativekeyboardcontroller.extensions.uiManager
|
|
14
15
|
import com.reactnativekeyboardcontroller.extensions.windowSoftInputMode
|
|
15
16
|
import com.reactnativekeyboardcontroller.interactive.KeyboardAnimationController
|
|
17
|
+
import com.reactnativekeyboardcontroller.log.Logger
|
|
16
18
|
import com.reactnativekeyboardcontroller.traversal.FocusedInputHolder
|
|
17
19
|
import com.reactnativekeyboardcontroller.traversal.ViewHierarchyNavigator
|
|
18
20
|
|
|
21
|
+
private val TAG = KeyboardControllerModuleImpl::class.qualifiedName
|
|
22
|
+
|
|
19
23
|
class KeyboardControllerModuleImpl(
|
|
20
24
|
private val mReactContext: ReactApplicationContext,
|
|
21
25
|
) {
|
|
@@ -89,7 +93,13 @@ class KeyboardControllerModuleImpl(
|
|
|
89
93
|
promise: Promise,
|
|
90
94
|
) {
|
|
91
95
|
UiThreadUtil.runOnUiThread {
|
|
92
|
-
val view =
|
|
96
|
+
val view =
|
|
97
|
+
try {
|
|
98
|
+
uiManager?.resolveView(viewTag.toInt())
|
|
99
|
+
} catch (e: IllegalViewOperationException) {
|
|
100
|
+
Logger.w(TAG, "Could not resolve view for tag ${viewTag.toInt()}", e)
|
|
101
|
+
null
|
|
102
|
+
}
|
|
93
103
|
if (view == null) {
|
|
94
104
|
promise.reject("E_VIEW_NOT_FOUND", "Could not find view for tag")
|
|
95
105
|
return@runOnUiThread
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
#import "RCTFabricComponentsPlugins.h"
|
|
17
17
|
#endif
|
|
18
18
|
|
|
19
|
+
#import <TargetConditionals.h>
|
|
19
20
|
#import <UIKit/UIKit.h>
|
|
20
21
|
#import <objc/runtime.h>
|
|
21
22
|
|
|
@@ -213,11 +214,16 @@ RCT_EXPORT_VIEW_PROPERTY(applyWorkaroundForContentInsetHitTestBug, BOOL)
|
|
|
213
214
|
{
|
|
214
215
|
[super didMoveToWindow];
|
|
215
216
|
if (self.window) {
|
|
217
|
+
#if TARGET_OS_MACCATALYST
|
|
218
|
+
// Catalyst UIScrollView is AppKit-backed; avoid runtime subclassing it.
|
|
219
|
+
return;
|
|
220
|
+
#else
|
|
216
221
|
UIScrollView *scrollView = KCFindFirstScrollView(self);
|
|
217
222
|
KCApplyNoopScrollRectToVisible(scrollView);
|
|
218
223
|
if (self.applyWorkaroundForContentInsetHitTestBug) {
|
|
219
224
|
KCApplyFixedHitTest(scrollView);
|
|
220
225
|
}
|
|
226
|
+
#endif
|
|
221
227
|
}
|
|
222
228
|
}
|
|
223
229
|
|
|
@@ -10,6 +10,7 @@ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reani
|
|
|
10
10
|
var _useCombinedRef = _interopRequireDefault(require("../hooks/useCombinedRef"));
|
|
11
11
|
var _ScrollViewWithBottomPadding = _interopRequireDefault(require("../ScrollViewWithBottomPadding"));
|
|
12
12
|
var _useChatKeyboard = require("./useChatKeyboard");
|
|
13
|
+
var _useEndVisible = require("./useEndVisible");
|
|
13
14
|
var _useExtraContentPadding = require("./useExtraContentPadding");
|
|
14
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
16
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
@@ -28,6 +29,7 @@ const KeyboardChatScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
28
29
|
applyWorkaroundForContentInsetHitTestBug = false,
|
|
29
30
|
onLayout: onLayoutProp,
|
|
30
31
|
onContentSizeChange: onContentSizeChangeProp,
|
|
32
|
+
onEndVisible,
|
|
31
33
|
...rest
|
|
32
34
|
}, ref) => {
|
|
33
35
|
const scrollViewRef = (0, _reactNativeReanimated.useAnimatedRef)();
|
|
@@ -63,6 +65,13 @@ const KeyboardChatScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
63
65
|
keyboardLiftBehavior,
|
|
64
66
|
freeze: freezeSV
|
|
65
67
|
});
|
|
68
|
+
(0, _useEndVisible.useEndVisible)({
|
|
69
|
+
scroll,
|
|
70
|
+
layout,
|
|
71
|
+
size,
|
|
72
|
+
inverted,
|
|
73
|
+
onEndVisible
|
|
74
|
+
});
|
|
66
75
|
const totalPadding = (0, _reactNativeReanimated.useDerivedValue)(() => Math.max(blankSpace.value, padding.value + extraContentPadding.value));
|
|
67
76
|
|
|
68
77
|
// Scroll indicator inset = keyboard + extraContentPadding (excludes blankSpace).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_useCombinedRef","_interopRequireDefault","_ScrollViewWithBottomPadding","_useChatKeyboard","_useExtraContentPadding","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","ZERO_CONTENT_PADDING","makeMutable","ZERO_BLANK_SPACE","KeyboardChatScrollView","forwardRef","children","ScrollViewComponent","Reanimated","ScrollView","inverted","keyboardLiftBehavior","freeze","offset","extraContentPadding","blankSpace","applyWorkaroundForContentInsetHitTestBug","onLayout","onLayoutProp","onContentSizeChange","onContentSizeChangeProp","rest","ref","scrollViewRef","useAnimatedRef","onRef","useCombinedRef","freezeSV","useDerivedValue","value","padding","currentHeight","contentOffsetY","scroll","layout","size","onLayoutInternal","onContentSizeChangeInternal","useChatKeyboard","useExtraContentPadding","keyboardPadding","totalPadding","Math","max","indicatorPadding","useCallback","w","h","commitStyle","useAnimatedStyle","transform","translateY","commit","useMemo","styles","commitView","createElement","Fragment","bottomPadding","scrollIndicatorPadding","View","style","StyleSheet","create","display","position","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { StyleSheet } from \"react-native\";\nimport {\n makeMutable,\n useAnimatedRef,\n useAnimatedStyle,\n useDerivedValue,\n} from \"react-native-reanimated\";\nimport Reanimated from \"react-native-reanimated\";\n\nimport useCombinedRef from \"../hooks/useCombinedRef\";\nimport ScrollViewWithBottomPadding from \"../ScrollViewWithBottomPadding\";\n\nimport { useChatKeyboard } from \"./useChatKeyboard\";\nimport { useExtraContentPadding } from \"./useExtraContentPadding\";\n\nimport type { KeyboardChatScrollViewProps } from \"./types\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nconst ZERO_CONTENT_PADDING = makeMutable(0);\nconst ZERO_BLANK_SPACE = makeMutable(0);\n\nconst KeyboardChatScrollView = forwardRef<\n Reanimated.ScrollView,\n React.PropsWithChildren<KeyboardChatScrollViewProps>\n>(\n (\n {\n children,\n ScrollViewComponent = Reanimated.ScrollView,\n inverted = false,\n keyboardLiftBehavior = \"always\",\n freeze = false,\n offset = 0,\n extraContentPadding = ZERO_CONTENT_PADDING,\n blankSpace = ZERO_BLANK_SPACE,\n applyWorkaroundForContentInsetHitTestBug = false,\n onLayout: onLayoutProp,\n onContentSizeChange: onContentSizeChangeProp,\n ...rest\n },\n ref,\n ) => {\n const scrollViewRef = useAnimatedRef<Reanimated.ScrollView>();\n const onRef = useCombinedRef(ref, scrollViewRef);\n const freezeSV = useDerivedValue(() =>\n typeof freeze === \"boolean\" ? freeze : freeze.value,\n );\n const {\n padding,\n currentHeight,\n contentOffsetY,\n scroll,\n layout,\n size,\n onLayout: onLayoutInternal,\n onContentSizeChange: onContentSizeChangeInternal,\n } = useChatKeyboard(scrollViewRef, {\n inverted,\n keyboardLiftBehavior,\n freeze: freezeSV,\n offset,\n blankSpace,\n extraContentPadding,\n });\n\n useExtraContentPadding({\n scrollViewRef,\n extraContentPadding,\n keyboardPadding: padding,\n blankSpace,\n scroll,\n layout,\n size,\n contentOffsetY,\n inverted,\n keyboardLiftBehavior,\n freeze: freezeSV,\n });\n\n const totalPadding = useDerivedValue(() =>\n Math.max(blankSpace.value, padding.value + extraContentPadding.value),\n );\n\n // Scroll indicator inset = keyboard + extraContentPadding (excludes blankSpace).\n // Apps that render into the unsafe area can supply a negative\n // scrollIndicatorInsets adjustment at the application layer.\n const indicatorPadding = useDerivedValue(\n () => padding.value + extraContentPadding.value,\n );\n\n const onLayout = useCallback(\n (e: LayoutChangeEvent) => {\n onLayoutInternal(e);\n onLayoutProp?.(e);\n },\n [onLayoutInternal, onLayoutProp],\n );\n\n const onContentSizeChange = useCallback(\n (w: number, h: number) => {\n onContentSizeChangeInternal(w, h);\n onContentSizeChangeProp?.(w, h);\n },\n [onContentSizeChangeInternal, onContentSizeChangeProp],\n );\n\n // Invisible view whose animated style changes every frame during keyboard\n // animation. On Fabric, this forces Reanimated to schedule a commit,\n // which flushes the scrollTo call in the same frame (fixing de-synchronization).\n // see https://github.com/software-mansion/react-native-reanimated/issues/9000\n const commitStyle = useAnimatedStyle(\n () => ({\n transform: [{ translateY: -currentHeight.value }],\n }),\n [],\n );\n const commit = useMemo(\n () => [styles.commitView, commitStyle],\n [commitStyle],\n );\n\n return (\n <>\n <ScrollViewWithBottomPadding\n ref={onRef}\n {...rest}\n applyWorkaroundForContentInsetHitTestBug={\n applyWorkaroundForContentInsetHitTestBug\n }\n bottomPadding={totalPadding}\n contentOffsetY={contentOffsetY}\n inverted={inverted}\n scrollIndicatorPadding={indicatorPadding}\n ScrollViewComponent={ScrollViewComponent}\n onContentSizeChange={onContentSizeChange}\n onLayout={onLayout}\n >\n {children}\n </ScrollViewWithBottomPadding>\n <Reanimated.View style={commit} />\n </>\n );\n },\n);\n\nconst styles = StyleSheet.create({\n commitView: {\n display: \"none\",\n position: \"absolute\",\n },\n});\n\nexport default KeyboardChatScrollView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAQA,IAAAG,eAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,4BAAA,GAAAD,sBAAA,CAAAJ,OAAA;AAEA,IAAAM,gBAAA,GAAAN,OAAA;AACA,IAAAO,uBAAA,GAAAP,OAAA;AAAkE,SAAAI,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAb,uBAAA,YAAAA,CAAAS,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,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2B,EAAAiB,QAAA;IAC1B2B,GAAG,EAAEG;EAAM,GACPJ,IAAI;IACRL,wCAAwC,EACtCA,wCACD;IACD0C,aAAa,EAAEjB,YAAa;IAC5BT,cAAc,EAAEA,cAAe;IAC/BtB,QAAQ,EAAEA,QAAS;IACnBiD,sBAAsB,EAAEf,gBAAiB;IACzCrC,mBAAmB,EAAEA,mBAAoB;IACzCY,mBAAmB,EAAEA,mBAAoB;IACzCF,QAAQ,EAAEA;EAAS,IAElBX,QAC0B,CAAC,eAC9BxC,MAAA,CAAAY,OAAA,CAAA8E,aAAA,CAACtF,sBAAA,CAAAQ,OAAU,CAACkF,IAAI;IAACC,KAAK,EAAET;EAAO,CAAE,CACjC,CAAC;AAEP,CACF,CAAC;AAED,MAAME,MAAM,GAAGQ,uBAAU,CAACC,MAAM,CAAC;EAC/BR,UAAU,EAAE;IACVS,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAzF,OAAA,GAEY0B,sBAAsB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_useCombinedRef","_interopRequireDefault","_ScrollViewWithBottomPadding","_useChatKeyboard","_useEndVisible","_useExtraContentPadding","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","ZERO_CONTENT_PADDING","makeMutable","ZERO_BLANK_SPACE","KeyboardChatScrollView","forwardRef","children","ScrollViewComponent","Reanimated","ScrollView","inverted","keyboardLiftBehavior","freeze","offset","extraContentPadding","blankSpace","applyWorkaroundForContentInsetHitTestBug","onLayout","onLayoutProp","onContentSizeChange","onContentSizeChangeProp","onEndVisible","rest","ref","scrollViewRef","useAnimatedRef","onRef","useCombinedRef","freezeSV","useDerivedValue","value","padding","currentHeight","contentOffsetY","scroll","layout","size","onLayoutInternal","onContentSizeChangeInternal","useChatKeyboard","useExtraContentPadding","keyboardPadding","useEndVisible","totalPadding","Math","max","indicatorPadding","useCallback","w","h","commitStyle","useAnimatedStyle","transform","translateY","commit","useMemo","styles","commitView","createElement","Fragment","bottomPadding","scrollIndicatorPadding","View","style","StyleSheet","create","display","position","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { StyleSheet } from \"react-native\";\nimport {\n makeMutable,\n useAnimatedRef,\n useAnimatedStyle,\n useDerivedValue,\n} from \"react-native-reanimated\";\nimport Reanimated from \"react-native-reanimated\";\n\nimport useCombinedRef from \"../hooks/useCombinedRef\";\nimport ScrollViewWithBottomPadding from \"../ScrollViewWithBottomPadding\";\n\nimport { useChatKeyboard } from \"./useChatKeyboard\";\nimport { useEndVisible } from \"./useEndVisible\";\nimport { useExtraContentPadding } from \"./useExtraContentPadding\";\n\nimport type { KeyboardChatScrollViewProps } from \"./types\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nconst ZERO_CONTENT_PADDING = makeMutable(0);\nconst ZERO_BLANK_SPACE = makeMutable(0);\n\nconst KeyboardChatScrollView = forwardRef<\n Reanimated.ScrollView,\n React.PropsWithChildren<KeyboardChatScrollViewProps>\n>(\n (\n {\n children,\n ScrollViewComponent = Reanimated.ScrollView,\n inverted = false,\n keyboardLiftBehavior = \"always\",\n freeze = false,\n offset = 0,\n extraContentPadding = ZERO_CONTENT_PADDING,\n blankSpace = ZERO_BLANK_SPACE,\n applyWorkaroundForContentInsetHitTestBug = false,\n onLayout: onLayoutProp,\n onContentSizeChange: onContentSizeChangeProp,\n onEndVisible,\n ...rest\n },\n ref,\n ) => {\n const scrollViewRef = useAnimatedRef<Reanimated.ScrollView>();\n const onRef = useCombinedRef(ref, scrollViewRef);\n const freezeSV = useDerivedValue(() =>\n typeof freeze === \"boolean\" ? freeze : freeze.value,\n );\n const {\n padding,\n currentHeight,\n contentOffsetY,\n scroll,\n layout,\n size,\n onLayout: onLayoutInternal,\n onContentSizeChange: onContentSizeChangeInternal,\n } = useChatKeyboard(scrollViewRef, {\n inverted,\n keyboardLiftBehavior,\n freeze: freezeSV,\n offset,\n blankSpace,\n extraContentPadding,\n });\n\n useExtraContentPadding({\n scrollViewRef,\n extraContentPadding,\n keyboardPadding: padding,\n blankSpace,\n scroll,\n layout,\n size,\n contentOffsetY,\n inverted,\n keyboardLiftBehavior,\n freeze: freezeSV,\n });\n\n useEndVisible({\n scroll,\n layout,\n size,\n inverted,\n onEndVisible,\n });\n\n const totalPadding = useDerivedValue(() =>\n Math.max(blankSpace.value, padding.value + extraContentPadding.value),\n );\n\n // Scroll indicator inset = keyboard + extraContentPadding (excludes blankSpace).\n // Apps that render into the unsafe area can supply a negative\n // scrollIndicatorInsets adjustment at the application layer.\n const indicatorPadding = useDerivedValue(\n () => padding.value + extraContentPadding.value,\n );\n\n const onLayout = useCallback(\n (e: LayoutChangeEvent) => {\n onLayoutInternal(e);\n onLayoutProp?.(e);\n },\n [onLayoutInternal, onLayoutProp],\n );\n\n const onContentSizeChange = useCallback(\n (w: number, h: number) => {\n onContentSizeChangeInternal(w, h);\n onContentSizeChangeProp?.(w, h);\n },\n [onContentSizeChangeInternal, onContentSizeChangeProp],\n );\n\n // Invisible view whose animated style changes every frame during keyboard\n // animation. On Fabric, this forces Reanimated to schedule a commit,\n // which flushes the scrollTo call in the same frame (fixing de-synchronization).\n // see https://github.com/software-mansion/react-native-reanimated/issues/9000\n const commitStyle = useAnimatedStyle(\n () => ({\n transform: [{ translateY: -currentHeight.value }],\n }),\n [],\n );\n const commit = useMemo(\n () => [styles.commitView, commitStyle],\n [commitStyle],\n );\n\n return (\n <>\n <ScrollViewWithBottomPadding\n ref={onRef}\n {...rest}\n applyWorkaroundForContentInsetHitTestBug={\n applyWorkaroundForContentInsetHitTestBug\n }\n bottomPadding={totalPadding}\n contentOffsetY={contentOffsetY}\n inverted={inverted}\n scrollIndicatorPadding={indicatorPadding}\n ScrollViewComponent={ScrollViewComponent}\n onContentSizeChange={onContentSizeChange}\n onLayout={onLayout}\n >\n {children}\n </ScrollViewWithBottomPadding>\n <Reanimated.View style={commit} />\n </>\n );\n },\n);\n\nconst styles = StyleSheet.create({\n commitView: {\n display: \"none\",\n position: \"absolute\",\n },\n});\n\nexport default KeyboardChatScrollView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAQA,IAAAG,eAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,4BAAA,GAAAD,sBAAA,CAAAJ,OAAA;AAEA,IAAAM,gBAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAP,OAAA;AACA,IAAAQ,uBAAA,GAAAR,OAAA;AAAkE,SAAAI,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAd,uBAAA,YAAAA,CAAAU,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA,CAAAX,CAAA,UAAAO,CAAA,CAAAK,GAAA,CAAAZ,CAAA,GAAAO,CAAA,CAAAM,GAAA,CAAAb,CAAA,EAAAS,CAAA,gBAAAN,CAAA,IAAAH,CAAA,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EAAEA,mBAAoB;IACzCF,QAAQ,EAAEA;EAAS,IAElBX,QAC0B,CAAC,eAC9BzC,MAAA,CAAAa,OAAA,CAAAgF,aAAA,CAACzF,sBAAA,CAAAS,OAAU,CAACoF,IAAI;IAACC,KAAK,EAAET;EAAO,CAAE,CACjC,CAAC;AAEP,CACF,CAAC;AAED,MAAME,MAAM,GAAGQ,uBAAU,CAACC,MAAM,CAAC;EAC/BR,UAAU,EAAE;IACVS,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA3F,OAAA,GAEY0B,sBAAsB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n AnimatedScrollViewComponent,\n ScrollViewContentInsets,\n} from \"../ScrollViewWithBottomPadding\";\nimport type { KeyboardLiftBehavior } from \"./useChatKeyboard/types\";\nimport type { ScrollViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nexport type KeyboardChatScrollViewProps = {\n /** Custom component for `ScrollView`. Default is `ScrollView`. */\n ScrollViewComponent?: AnimatedScrollViewComponent;\n /** Whether list are using `inverted` prop. Default is `false`. */\n inverted?: boolean;\n /**\n * The distance between the bottom of the screen and the `ScrollView`.\n * When the keyboard appears, the `ScrollView` will only push content by the effective\n * distance (`keyboardHeight - offset`) instead of the full keyboard height.\n *\n * Useful when the input is not at the very bottom of the screen (e.g., above safe area, above\n * bottom tabs, etc. - in this case offset should be equal to the height of the elements between\n * `ScrollView` and bottom of the screen).\n *\n * Default is `0`.\n */\n offset?: number;\n /**\n * Determines how the chat content should behave when the keyboard appears, specifically whether\n * the scroll view should automatically lift its content to keep it visible above the keyboard.\n *\n * Possible values:\n * - `'always'`: The content always lifts along with the keyboard, ensuring the messages from the bottom part of screen\n * remain visible regardless of the current scroll position. This is the default behavior for most chat applications (used in Telegram).\n * - `'whenAtEnd'`: The content lifts only if the scroll view is at the end (i.e., the last message\n * is visible or near the bottom). This prevents unnecessary adjustments when the user is scrolling\n * through older messages (ChatGPT mobile app behavior).\n * - `'persistent'`: The content always lifts when the keyboard appears (similar to `'always'`), but\n * does not reset (lower) when the keyboard hides. This mimics behaviors where the view remains adjusted\n * after keyboard dismissal to maintain focus on the latest content without shifting back (Claude mobile app behavior).\n * - `'never'`: The content does not lift at all when the keyboard appears. Use this for scenarios\n * when you don't want to disturb user attention with animations (Perplexity mobile app behavior).\n *\n * Default is `'always'`.\n */\n keyboardLiftBehavior?: KeyboardLiftBehavior;\n /**\n * When `true`, freezes all keyboard-driven layout changes (padding, content offset, scroll position).\n * Useful when dismissing the keyboard to open a bottom sheet — prevents visual disruption\n * while the sheet is visible.\n *\n * Default is `false`.\n */\n freeze?: boolean | SharedValue<boolean>;\n /**\n * A shared value representing additional padding from external elements\n * (e.g., a growing multiline `TextInput` in a `KeyboardStickyView`).\n *\n * When this value changes:\n * - The scrollable range is always extended/contracted (via `contentInset`).\n * - The scroll position is conditionally adjusted based on `keyboardLiftBehavior`.\n *\n * Default is `undefined` (no extra padding).\n */\n extraContentPadding?: SharedValue<number>;\n /**\n * When `true`, applies a runtime workaround for a React Native 0.81+ bug\n * where the ScrollView's `contentInset` area does not respond to touch/scroll\n * gestures (facebook/react-native#54123).\n *\n * This uses Objective-C runtime method swizzling on the ScrollView's container\n * view, which is inherently fragile. Only enable if you are affected by the\n * upstream bug and understand the risks.\n *\n * iOS only. Default is `false`.\n */\n applyWorkaroundForContentInsetHitTestBug?: boolean;\n /**\n * A shared value representing a minimum inset floor (in pixels).\n *\n * When set, the total bottom padding is computed as:\n * `max(blankSpace, keyboardPadding + extraContentPadding)`\n *\n * This means the keyboard \"absorbs\" into the minimum padding rather than adding to it:\n * - When `blankSpace >= keyboard + extraContentPadding`: content does NOT move on keyboard open/close.\n * - When `blankSpace < keyboard + extraContentPadding`: content moves, but only by the excess amount.\n *\n * Useful in AI chat apps where a sent message needs space below it (to push it to the top\n * of the viewport) while the AI response streams in, without that space causing extra movement\n * when the keyboard opens.\n *\n * Default is `undefined` (equivalent to `0` — no minimum floor).\n */\n blankSpace?: SharedValue<number>;\n /**\n * Fires whenever the effective content inset changes — the static `contentInset`\n * prop combined with the dynamic keyboard-driven padding.\n *\n * Useful on Android, where the synthetic content inset is not reflected in the native\n * `onScroll` event payload. Consumers such as virtualized lists computing their own\n * `scrollToEnd` target can use this to track the current inset alongside scroll offsets.\n */\n onContentInsetChange?: (insets: ScrollViewContentInsets) => void;\n /**\n * Fires whenever the visibility of the content \"end\" changes — both when the user\n * arrives at the end and when they leave it. The boolean parameter reflects the new state.\n *\n * For non-inverted lists, the \"end\" is the bottom of the content. For inverted lists\n * (`inverted={true}`), the \"end\" is the top of the scroll view, where the latest messages\n * are rendered. The same internal detection drives `keyboardLiftBehavior=\"whenAtEnd\"`.\n *\n * The callback can be either a plain JS function or a Reanimated worklet — the type is\n * detected automatically. Worklets run on the UI thread; plain functions are dispatched\n * via `runOnJS`.\n *\n * Fires once on mount with the initial state (after the scroll view has been measured).\n */\n onEndVisible?: (visible: boolean) => void;\n} & ScrollViewProps;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useEndVisible = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
9
|
+
var _helpers = require("./useChatKeyboard/helpers");
|
|
10
|
+
const hasWorkletHash = value => typeof value === "function" && !!value.__workletHash;
|
|
11
|
+
const useEndVisible = ({
|
|
12
|
+
scroll,
|
|
13
|
+
layout,
|
|
14
|
+
size,
|
|
15
|
+
inverted,
|
|
16
|
+
onEndVisible
|
|
17
|
+
}) => {
|
|
18
|
+
const isWorklet = (0, _react.useMemo)(() => hasWorkletHash(onEndVisible), [onEndVisible]);
|
|
19
|
+
const isAtEnd = (0, _reactNativeReanimated.useDerivedValue)(() => {
|
|
20
|
+
// Wait until the scroll view has been measured to avoid a spurious initial
|
|
21
|
+
// `true` on a (0,0,0) layout (the helper would otherwise treat unmeasured
|
|
22
|
+
// state as "at end" because 0 + 0 >= 0 - threshold).
|
|
23
|
+
if (layout.value.height === 0 || size.value.height === 0) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return (0, _helpers.isScrollAtEnd)(scroll.value, layout.value.height, size.value.height, inverted);
|
|
27
|
+
});
|
|
28
|
+
(0, _reactNativeReanimated.useAnimatedReaction)(() => isAtEnd.value, (current, previous) => {
|
|
29
|
+
if (current === null || current === previous || !onEndVisible) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (isWorklet) {
|
|
33
|
+
onEndVisible(current);
|
|
34
|
+
} else {
|
|
35
|
+
(0, _reactNativeReanimated.runOnJS)(onEndVisible)(current);
|
|
36
|
+
}
|
|
37
|
+
}, [onEndVisible, isWorklet, inverted]);
|
|
38
|
+
};
|
|
39
|
+
exports.useEndVisible = useEndVisible;
|
|
40
|
+
//# sourceMappingURL=useEndVisible.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNativeReanimated","_helpers","hasWorkletHash","value","__workletHash","useEndVisible","scroll","layout","size","inverted","onEndVisible","isWorklet","useMemo","isAtEnd","useDerivedValue","height","isScrollAtEnd","useAnimatedReaction","current","previous","runOnJS","exports"],"sources":["useEndVisible.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport {\n runOnJS,\n useAnimatedReaction,\n useDerivedValue,\n} from \"react-native-reanimated\";\n\nimport { isScrollAtEnd } from \"./useChatKeyboard/helpers\";\n\nimport type { SharedValue } from \"react-native-reanimated\";\n\ntype EndVisibleCallback = (visible: boolean) => void;\n\ntype Options = {\n scroll: SharedValue<number>;\n layout: SharedValue<{ width: number; height: number }>;\n size: SharedValue<{ width: number; height: number }>;\n inverted: boolean;\n onEndVisible?: EndVisibleCallback;\n};\n\nconst hasWorkletHash = (value: unknown): boolean =>\n typeof value === \"function\" &&\n !!(value as unknown as Record<string, unknown>).__workletHash;\n\nexport const useEndVisible = ({\n scroll,\n layout,\n size,\n inverted,\n onEndVisible,\n}: Options) => {\n const isWorklet = useMemo(() => hasWorkletHash(onEndVisible), [onEndVisible]);\n\n const isAtEnd = useDerivedValue(() => {\n // Wait until the scroll view has been measured to avoid a spurious initial\n // `true` on a (0,0,0) layout (the helper would otherwise treat unmeasured\n // state as \"at end\" because 0 + 0 >= 0 - threshold).\n if (layout.value.height === 0 || size.value.height === 0) {\n return null;\n }\n\n return isScrollAtEnd(\n scroll.value,\n layout.value.height,\n size.value.height,\n inverted,\n );\n });\n\n useAnimatedReaction(\n () => isAtEnd.value,\n (current, previous) => {\n if (current === null || current === previous || !onEndVisible) {\n return;\n }\n\n if (isWorklet) {\n onEndVisible(current);\n } else {\n runOnJS(onEndVisible)(current);\n }\n },\n [onEndVisible, isWorklet, inverted],\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AAMA,IAAAE,QAAA,GAAAF,OAAA;AAcA,MAAMG,cAAc,GAAIC,KAAc,IACpC,OAAOA,KAAK,KAAK,UAAU,IAC3B,CAAC,CAAEA,KAAK,CAAwCC,aAAa;AAExD,MAAMC,aAAa,GAAGA,CAAC;EAC5BC,MAAM;EACNC,MAAM;EACNC,IAAI;EACJC,QAAQ;EACRC;AACO,CAAC,KAAK;EACb,MAAMC,SAAS,GAAG,IAAAC,cAAO,EAAC,MAAMV,cAAc,CAACQ,YAAY,CAAC,EAAE,CAACA,YAAY,CAAC,CAAC;EAE7E,MAAMG,OAAO,GAAG,IAAAC,sCAAe,EAAC,MAAM;IACpC;IACA;IACA;IACA,IAAIP,MAAM,CAACJ,KAAK,CAACY,MAAM,KAAK,CAAC,IAAIP,IAAI,CAACL,KAAK,CAACY,MAAM,KAAK,CAAC,EAAE;MACxD,OAAO,IAAI;IACb;IAEA,OAAO,IAAAC,sBAAa,EAClBV,MAAM,CAACH,KAAK,EACZI,MAAM,CAACJ,KAAK,CAACY,MAAM,EACnBP,IAAI,CAACL,KAAK,CAACY,MAAM,EACjBN,QACF,CAAC;EACH,CAAC,CAAC;EAEF,IAAAQ,0CAAmB,EACjB,MAAMJ,OAAO,CAACV,KAAK,EACnB,CAACe,OAAO,EAAEC,QAAQ,KAAK;IACrB,IAAID,OAAO,KAAK,IAAI,IAAIA,OAAO,KAAKC,QAAQ,IAAI,CAACT,YAAY,EAAE;MAC7D;IACF;IAEA,IAAIC,SAAS,EAAE;MACbD,YAAY,CAACQ,OAAO,CAAC;IACvB,CAAC,MAAM;MACL,IAAAE,8BAAO,EAACV,YAAY,CAAC,CAACQ,OAAO,CAAC;IAChC;EACF,CAAC,EACD,CAACR,YAAY,EAAEC,SAAS,EAAEF,QAAQ,CACpC,CAAC;AACH,CAAC;AAACY,OAAA,CAAAhB,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var
|
|
8
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
9
9
|
var _hooks = require("../../hooks");
|
|
10
10
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
11
|
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); }
|
|
@@ -35,21 +35,17 @@ const KeyboardStickyView = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
35
35
|
const {
|
|
36
36
|
height,
|
|
37
37
|
progress
|
|
38
|
-
} = (0, _hooks.
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
const styles = (0, _react.useMemo)(() => {
|
|
44
|
-
const disabled = _reactNative.Animated.add(_reactNative.Animated.multiply(height, 0), closed);
|
|
45
|
-
const active = _reactNative.Animated.add(height, offset);
|
|
46
|
-
return [{
|
|
38
|
+
} = (0, _hooks.useReanimatedKeyboardAnimation)();
|
|
39
|
+
const stickyViewStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
40
|
+
const offset = (0, _reactNativeReanimated.interpolate)(progress.value, [0, 1], [closed, opened]);
|
|
41
|
+
return {
|
|
47
42
|
transform: [{
|
|
48
|
-
translateY: enabled ?
|
|
43
|
+
translateY: enabled ? height.value + offset : closed
|
|
49
44
|
}]
|
|
50
|
-
}
|
|
51
|
-
}, [closed,
|
|
52
|
-
|
|
45
|
+
};
|
|
46
|
+
}, [closed, opened, enabled]);
|
|
47
|
+
const styles = (0, _react.useMemo)(() => [style, stickyViewStyle], [style, stickyViewStyle]);
|
|
48
|
+
return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, _extends({
|
|
53
49
|
ref: ref,
|
|
54
50
|
style: styles
|
|
55
51
|
}, props), children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNativeReanimated","_hooks","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","KeyboardStickyView","forwardRef","children","offset","closed","opened","style","enabled","props","ref","height","progress","useReanimatedKeyboardAnimation","stickyViewStyle","useAnimatedStyle","interpolate","value","transform","translateY","styles","useMemo","createElement","View","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useMemo } from \"react\";\nimport Reanimated, {\n interpolate,\n useAnimatedStyle,\n} from \"react-native-reanimated\";\n\nimport { useReanimatedKeyboardAnimation } from \"../../hooks\";\n\nimport type { View, ViewProps } from \"react-native\";\n\nexport type KeyboardStickyViewProps = {\n /**\n * Specify additional offset to the view for given keyboard state.\n */\n offset?: {\n /**\n * Adds additional `translateY` when keyboard is close. By default `0`.\n */\n closed?: number;\n /**\n * Adds additional `translateY` when keyboard is open. By default `0`.\n */\n opened?: number;\n };\n\n /** Controls whether this `KeyboardStickyView` instance should take effect. Default is `true`. */\n enabled?: boolean;\n} & ViewProps;\n\n/**\n * A View component that sticks to the keyboard and moves with it when it appears or disappears.\n * The view can be configured with custom offsets for both closed and open keyboard states.\n *\n * @returns An animated View component that sticks to the keyboard.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-sticky-view|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardStickyView offset={{ closed: 0, opened: 20 }}>\n * <Button title=\"Submit\" />\n * </KeyboardStickyView>\n * ```\n */\nconst KeyboardStickyView = forwardRef<\n View,\n React.PropsWithChildren<KeyboardStickyViewProps>\n>(\n (\n {\n children,\n offset: { closed = 0, opened = 0 } = {},\n style,\n enabled = true,\n ...props\n },\n ref,\n ) => {\n const { height, progress } = useReanimatedKeyboardAnimation();\n\n const stickyViewStyle = useAnimatedStyle(() => {\n const offset = interpolate(progress.value, [0, 1], [closed, opened]);\n\n return {\n transform: [{ translateY: enabled ? height.value + offset : closed }],\n };\n }, [closed, opened, enabled]);\n\n const styles = useMemo(\n () => [style, stickyViewStyle],\n [style, stickyViewStyle],\n );\n\n return (\n <Reanimated.View ref={ref} style={styles} {...props}>\n {children}\n </Reanimated.View>\n );\n },\n);\n\nexport default KeyboardStickyView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAF,uBAAA,CAAAC,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AAA6D,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CA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,MAAM,EAAEE,OAAO,CAAC,CAAC;EAE7B,MAAMY,MAAM,GAAG,IAAAC,cAAO,EACpB,MAAM,CAACd,KAAK,EAAEO,eAAe,CAAC,EAC9B,CAACP,KAAK,EAAEO,eAAe,CACzB,CAAC;EAED,oBACE3C,MAAA,CAAAe,OAAA,CAAAoC,aAAA,CAAChD,sBAAA,CAAAY,OAAU,CAACqC,IAAI,EAAA5B,QAAA;IAACe,GAAG,EAAEA,GAAI;IAACH,KAAK,EAAEa;EAAO,GAAKX,KAAK,GAChDN,QACc,CAAC;AAEtB,CACF,CAAC;AAAC,IAAAqB,QAAA,GAAAC,OAAA,CAAAvC,OAAA,GAEae,kBAAkB","ignoreList":[]}
|
|
@@ -23,26 +23,47 @@ const ScrollViewWithBottomPadding = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
23
23
|
inverted,
|
|
24
24
|
contentOffsetY,
|
|
25
25
|
applyWorkaroundForContentInsetHitTestBug,
|
|
26
|
+
onContentInsetChange,
|
|
26
27
|
children,
|
|
27
28
|
...rest
|
|
28
29
|
}, ref) => {
|
|
29
30
|
const prevContentOffsetY = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
31
|
+
const insets = (0, _reactNativeReanimated.useDerivedValue)(() => {
|
|
32
|
+
const dynamicTop = inverted ? bottomPadding.value : 0;
|
|
33
|
+
const dynamicBottom = !inverted ? bottomPadding.value : 0;
|
|
34
|
+
return {
|
|
35
|
+
dynamic: {
|
|
36
|
+
top: dynamicTop,
|
|
37
|
+
bottom: dynamicBottom
|
|
38
|
+
},
|
|
39
|
+
effective: {
|
|
40
|
+
top: dynamicTop + ((contentInset === null || contentInset === void 0 ? void 0 : contentInset.top) || 0),
|
|
41
|
+
bottom: dynamicBottom + ((contentInset === null || contentInset === void 0 ? void 0 : contentInset.bottom) || 0),
|
|
42
|
+
left: (contentInset === null || contentInset === void 0 ? void 0 : contentInset.left) || 0,
|
|
43
|
+
right: (contentInset === null || contentInset === void 0 ? void 0 : contentInset.right) || 0
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}, [inverted, contentInset === null || contentInset === void 0 ? void 0 : contentInset.top, contentInset === null || contentInset === void 0 ? void 0 : contentInset.bottom, contentInset === null || contentInset === void 0 ? void 0 : contentInset.left, contentInset === null || contentInset === void 0 ? void 0 : contentInset.right]);
|
|
47
|
+
(0, _reactNativeReanimated.useAnimatedReaction)(() => insets.value.effective, (current, previous) => {
|
|
48
|
+
if (!onContentInsetChange) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (previous && current.top === previous.top && current.bottom === previous.bottom && current.left === previous.left && current.right === previous.right) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
(0, _reactNativeReanimated.runOnJS)(onContentInsetChange)(current);
|
|
55
|
+
}, [onContentInsetChange]);
|
|
30
56
|
const animatedProps = (0, _reactNativeReanimated.useAnimatedProps)(() => {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
57
|
+
const {
|
|
58
|
+
dynamic,
|
|
59
|
+
effective
|
|
60
|
+
} = insets.value;
|
|
35
61
|
const indicatorPadding = scrollIndicatorPadding ?? bottomPadding;
|
|
36
62
|
const indicatorTop = (inverted ? indicatorPadding.value : 0) + ((scrollIndicatorInsets === null || scrollIndicatorInsets === void 0 ? void 0 : scrollIndicatorInsets.top) || 0);
|
|
37
63
|
const indicatorBottom = (!inverted ? indicatorPadding.value : 0) + ((scrollIndicatorInsets === null || scrollIndicatorInsets === void 0 ? void 0 : scrollIndicatorInsets.bottom) || 0);
|
|
38
64
|
const result = {
|
|
39
65
|
// iOS prop
|
|
40
|
-
contentInset:
|
|
41
|
-
bottom: bottom,
|
|
42
|
-
top: top,
|
|
43
|
-
right: contentInset === null || contentInset === void 0 ? void 0 : contentInset.right,
|
|
44
|
-
left: contentInset === null || contentInset === void 0 ? void 0 : contentInset.left
|
|
45
|
-
},
|
|
66
|
+
contentInset: effective,
|
|
46
67
|
scrollIndicatorInsets: {
|
|
47
68
|
bottom: indicatorBottom,
|
|
48
69
|
top: indicatorTop,
|
|
@@ -50,8 +71,8 @@ const ScrollViewWithBottomPadding = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
50
71
|
left: scrollIndicatorInsets === null || scrollIndicatorInsets === void 0 ? void 0 : scrollIndicatorInsets.left
|
|
51
72
|
},
|
|
52
73
|
// Android prop
|
|
53
|
-
contentInsetBottom:
|
|
54
|
-
contentInsetTop:
|
|
74
|
+
contentInsetBottom: dynamic.bottom,
|
|
75
|
+
contentInsetTop: dynamic.top
|
|
55
76
|
};
|
|
56
77
|
if (contentOffsetY) {
|
|
57
78
|
const curr = contentOffsetY.value;
|
|
@@ -65,7 +86,7 @@ const ScrollViewWithBottomPadding = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
65
86
|
}
|
|
66
87
|
}
|
|
67
88
|
return result;
|
|
68
|
-
}, [
|
|
89
|
+
}, [scrollIndicatorInsets === null || scrollIndicatorInsets === void 0 ? void 0 : scrollIndicatorInsets.bottom, scrollIndicatorInsets === null || scrollIndicatorInsets === void 0 ? void 0 : scrollIndicatorInsets.top, scrollIndicatorInsets === null || scrollIndicatorInsets === void 0 ? void 0 : scrollIndicatorInsets.right, scrollIndicatorInsets === null || scrollIndicatorInsets === void 0 ? void 0 : scrollIndicatorInsets.left, inverted, contentOffsetY]);
|
|
69
90
|
return /*#__PURE__*/_react.default.createElement(ReanimatedClippingScrollView, {
|
|
70
91
|
animatedProps: animatedProps,
|
|
71
92
|
applyWorkaroundForContentInsetHitTestBug: applyWorkaroundForContentInsetHitTestBug,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_bindings","_styles","_interopRequireDefault","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","OS","Platform","ReanimatedClippingScrollView","Reanimated","createAnimatedComponent","ClippingScrollView","ScrollViewWithBottomPadding","forwardRef","ScrollViewComponent","bottomPadding","scrollIndicatorPadding","contentInset","scrollIndicatorInsets","inverted","contentOffsetY","applyWorkaroundForContentInsetHitTestBug","children","rest","ref","prevContentOffsetY","useSharedValue","animatedProps","useAnimatedProps","insetTop","value","insetBottom","bottom","top","indicatorPadding","indicatorTop","indicatorBottom","result","right","left","contentInsetBottom","contentInsetTop","curr","contentOffset","x","y","createElement","style","styles","container","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\nimport { Platform } from \"react-native\";\nimport Reanimated, {\n useAnimatedProps,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { ClippingScrollView } from \"../../bindings\";\n\nimport styles from \"./styles\";\n\nimport type { ScrollViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nconst OS = Platform.OS;\nconst ReanimatedClippingScrollView =\n OS === \"android\"\n ? Reanimated.createAnimatedComponent(ClippingScrollView)\n : ClippingScrollView;\n\ntype AnimatedScrollViewProps = React.ComponentProps<\n typeof Reanimated.ScrollView\n>;\n\nexport type AnimatedScrollViewComponent = React.ForwardRefExoticComponent<\n AnimatedScrollViewProps & React.RefAttributes<Reanimated.ScrollView>\n>;\n\ntype ScrollViewWithBottomPaddingProps = {\n ScrollViewComponent: AnimatedScrollViewComponent;\n children?: React.ReactNode;\n inverted?: boolean;\n bottomPadding: SharedValue<number>;\n /** Padding for scroll indicator insets (excludes blankSpace). Falls back to bottomPadding when not provided. */\n scrollIndicatorPadding?: SharedValue<number>;\n /** Absolute Y content offset (iOS only, for KeyboardChatScrollView). */\n contentOffsetY?: SharedValue<number>;\n applyWorkaroundForContentInsetHitTestBug?: boolean;\n} & ScrollViewProps;\n\nconst ScrollViewWithBottomPadding = forwardRef<\n Reanimated.ScrollView,\n ScrollViewWithBottomPaddingProps\n>(\n (\n {\n ScrollViewComponent,\n bottomPadding,\n scrollIndicatorPadding,\n contentInset,\n scrollIndicatorInsets,\n inverted,\n contentOffsetY,\n applyWorkaroundForContentInsetHitTestBug,\n children,\n ...rest\n },\n ref,\n ) => {\n const prevContentOffsetY = useSharedValue<number | null>(null);\n\n const animatedProps = useAnimatedProps(() => {\n const insetTop = inverted ? bottomPadding.value : 0;\n const insetBottom = !inverted ? bottomPadding.value : 0;\n const bottom = insetBottom + (contentInset?.bottom || 0);\n const top = insetTop + (contentInset?.top || 0);\n\n const indicatorPadding = scrollIndicatorPadding ?? bottomPadding;\n const indicatorTop =\n (inverted ? indicatorPadding.value : 0) +\n (scrollIndicatorInsets?.top || 0);\n const indicatorBottom =\n (!inverted ? indicatorPadding.value : 0) +\n (scrollIndicatorInsets?.bottom || 0);\n\n const result: Record<string, unknown> = {\n // iOS prop\n contentInset: {\n bottom: bottom,\n top: top,\n right: contentInset?.right,\n left: contentInset?.left,\n },\n scrollIndicatorInsets: {\n bottom: indicatorBottom,\n top: indicatorTop,\n right: scrollIndicatorInsets?.right,\n left: scrollIndicatorInsets?.left,\n },\n // Android prop\n contentInsetBottom: insetBottom,\n contentInsetTop: insetTop,\n };\n\n if (contentOffsetY) {\n const curr = contentOffsetY.value;\n\n if (curr !== prevContentOffsetY.value) {\n // eslint-disable-next-line react-compiler/react-compiler\n prevContentOffsetY.value = curr;\n result.contentOffset = { x: 0, y: curr };\n }\n }\n\n return result;\n }, [\n contentInset?.bottom,\n contentInset?.top,\n contentInset?.right,\n contentInset?.left,\n scrollIndicatorInsets?.bottom,\n scrollIndicatorInsets?.top,\n scrollIndicatorInsets?.right,\n scrollIndicatorInsets?.left,\n inverted,\n contentOffsetY,\n ]);\n\n return (\n <ReanimatedClippingScrollView\n animatedProps={animatedProps}\n applyWorkaroundForContentInsetHitTestBug={\n applyWorkaroundForContentInsetHitTestBug\n }\n style={styles.container}\n >\n <ScrollViewComponent ref={ref} animatedProps={animatedProps} {...rest}>\n {children}\n </ScrollViewComponent>\n </ReanimatedClippingScrollView>\n );\n },\n);\n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AAI;QAC/BL,MAAM,CAACM,aAAa,GAAG;UAAEC,CAAC,EAAE,CAAC;UAAEC,CAAC,EAAEH;QAAK,CAAC;MAC1C;IACF;IAEA,OAAOL,MAAM;EACf,CAAC,EAAE,CACDpB,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEe,MAAM,EACpBf,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEgB,GAAG,EACjBhB,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEqB,KAAK,EACnBrB,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEsB,IAAI,EAClBrB,qBAAqB,aAArBA,qBAAqB,uBAArBA,qBAAqB,CAAEc,MAAM,EAC7Bd,qBAAqB,aAArBA,qBAAqB,uBAArBA,qBAAqB,CAAEe,GAAG,EAC1Bf,qBAAqB,aAArBA,qBAAqB,uBAArBA,qBAAqB,CAAEoB,KAAK,EAC5BpB,qBAAqB,aAArBA,qBAAqB,uBAArBA,qBAAqB,CAAEqB,IAAI,EAC3BpB,QAAQ,EACRC,cAAc,CACf,CAAC;EAEF,oBACE/C,MAAA,CAAAU,OAAA,CAAA+D,aAAA,CAACtC,4BAA4B;IAC3BmB,aAAa,EAAEA,aAAc;IAC7BN,wCAAwC,EACtCA,wCACD;IACD0B,KAAK,EAAEC,eAAM,CAACC;EAAU,gBAExB5E,MAAA,CAAAU,OAAA,CAAA+D,aAAA,CAAChC,mBAAmB,EAAAd,QAAA;IAACwB,GAAG,EAAEA,GAAI;IAACG,aAAa,EAAEA;EAAc,GAAKJ,IAAI,GAClED,QACkB,CACO,CAAC;AAEnC,CACF,CAAC;AAAC,IAAA4B,QAAA,GAAAC,OAAA,CAAApE,OAAA,GAEa6B,2BAA2B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_bindings","_styles","_interopRequireDefault","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","OS","Platform","ReanimatedClippingScrollView","Reanimated","createAnimatedComponent","ClippingScrollView","ScrollViewWithBottomPadding","forwardRef","ScrollViewComponent","bottomPadding","scrollIndicatorPadding","contentInset","scrollIndicatorInsets","inverted","contentOffsetY","applyWorkaroundForContentInsetHitTestBug","onContentInsetChange","children","rest","ref","prevContentOffsetY","useSharedValue","insets","useDerivedValue","dynamicTop","value","dynamicBottom","dynamic","top","bottom","effective","left","right","useAnimatedReaction","current","previous","runOnJS","animatedProps","useAnimatedProps","indicatorPadding","indicatorTop","indicatorBottom","result","contentInsetBottom","contentInsetTop","curr","contentOffset","x","y","createElement","style","styles","container","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\nimport { Platform } from \"react-native\";\nimport Reanimated, {\n runOnJS,\n useAnimatedProps,\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { ClippingScrollView } from \"../../bindings\";\n\nimport styles from \"./styles\";\n\nimport type { ScrollViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nconst OS = Platform.OS;\nconst ReanimatedClippingScrollView =\n OS === \"android\"\n ? Reanimated.createAnimatedComponent(ClippingScrollView)\n : ClippingScrollView;\n\ntype AnimatedScrollViewProps = React.ComponentProps<\n typeof Reanimated.ScrollView\n>;\n\nexport type AnimatedScrollViewComponent = React.ForwardRefExoticComponent<\n AnimatedScrollViewProps & React.RefAttributes<Reanimated.ScrollView>\n>;\n\nexport type ScrollViewContentInsets = {\n top: number;\n bottom: number;\n left: number;\n right: number;\n};\n\ntype ScrollViewWithBottomPaddingProps = {\n ScrollViewComponent: AnimatedScrollViewComponent;\n children?: React.ReactNode;\n inverted?: boolean;\n bottomPadding: SharedValue<number>;\n /** Padding for scroll indicator insets (excludes blankSpace). Falls back to bottomPadding when not provided. */\n scrollIndicatorPadding?: SharedValue<number>;\n /** Absolute Y content offset (iOS only, for KeyboardChatScrollView). */\n contentOffsetY?: SharedValue<number>;\n applyWorkaroundForContentInsetHitTestBug?: boolean;\n /**\n * Fires whenever the effective content inset changes (combines the static `contentInset`\n * prop with the dynamic keyboard-driven padding). Useful on Android where the synthetic\n * inset is not reflected in `onScroll` events.\n */\n onContentInsetChange?: (insets: ScrollViewContentInsets) => void;\n} & ScrollViewProps;\n\nconst ScrollViewWithBottomPadding = forwardRef<\n Reanimated.ScrollView,\n ScrollViewWithBottomPaddingProps\n>(\n (\n {\n ScrollViewComponent,\n bottomPadding,\n scrollIndicatorPadding,\n contentInset,\n scrollIndicatorInsets,\n inverted,\n contentOffsetY,\n applyWorkaroundForContentInsetHitTestBug,\n onContentInsetChange,\n children,\n ...rest\n },\n ref,\n ) => {\n const prevContentOffsetY = useSharedValue<number | null>(null);\n\n const insets = useDerivedValue(() => {\n const dynamicTop = inverted ? bottomPadding.value : 0;\n const dynamicBottom = !inverted ? bottomPadding.value : 0;\n\n return {\n dynamic: {\n top: dynamicTop,\n bottom: dynamicBottom,\n },\n effective: {\n top: dynamicTop + (contentInset?.top || 0),\n bottom: dynamicBottom + (contentInset?.bottom || 0),\n left: contentInset?.left || 0,\n right: contentInset?.right || 0,\n } as ScrollViewContentInsets,\n };\n }, [\n inverted,\n contentInset?.top,\n contentInset?.bottom,\n contentInset?.left,\n contentInset?.right,\n ]);\n\n useAnimatedReaction(\n () => insets.value.effective,\n (current, previous) => {\n if (!onContentInsetChange) {\n return;\n }\n if (\n previous &&\n current.top === previous.top &&\n current.bottom === previous.bottom &&\n current.left === previous.left &&\n current.right === previous.right\n ) {\n return;\n }\n runOnJS(onContentInsetChange)(current);\n },\n [onContentInsetChange],\n );\n\n const animatedProps = useAnimatedProps(() => {\n const { dynamic, effective } = insets.value;\n\n const indicatorPadding = scrollIndicatorPadding ?? bottomPadding;\n const indicatorTop =\n (inverted ? indicatorPadding.value : 0) +\n (scrollIndicatorInsets?.top || 0);\n const indicatorBottom =\n (!inverted ? indicatorPadding.value : 0) +\n (scrollIndicatorInsets?.bottom || 0);\n\n const result: Record<string, unknown> = {\n // iOS prop\n contentInset: effective,\n scrollIndicatorInsets: {\n bottom: indicatorBottom,\n top: indicatorTop,\n right: scrollIndicatorInsets?.right,\n left: scrollIndicatorInsets?.left,\n },\n // Android prop\n contentInsetBottom: dynamic.bottom,\n contentInsetTop: dynamic.top,\n };\n\n if (contentOffsetY) {\n const curr = contentOffsetY.value;\n\n if (curr !== prevContentOffsetY.value) {\n // eslint-disable-next-line react-compiler/react-compiler\n prevContentOffsetY.value = curr;\n result.contentOffset = { x: 0, y: curr };\n }\n }\n\n return result;\n }, [\n scrollIndicatorInsets?.bottom,\n scrollIndicatorInsets?.top,\n scrollIndicatorInsets?.right,\n scrollIndicatorInsets?.left,\n inverted,\n contentOffsetY,\n ]);\n\n return (\n <ReanimatedClippingScrollView\n animatedProps={animatedProps}\n applyWorkaroundForContentInsetHitTestBug={\n applyWorkaroundForContentInsetHitTestBug\n }\n style={styles.container}\n >\n <ScrollViewComponent ref={ref} animatedProps={animatedProps} {...rest}>\n {children}\n </ScrollViewComponent>\n </ReanimatedClippingScrollView>\n );\n },\n);\n\nexport default ScrollViewWithBottomPadding;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAQA,IAAAG,SAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAC,sBAAA,CAAAL,OAAA;AAA8B,SAAAK,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAP,wBAAAO,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAX,uBAAA,YAAAA,CAAAO,CAAA,EAAAG,C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,aAAa,EAAEA;EAAc,GAAKnB,IAAI,GAClED,QACkB,CACO,CAAC;AAEnC,CACF,CAAC;AAAC,IAAAoC,QAAA,GAAAC,OAAA,CAAA7E,OAAA,GAEa6B,2BAA2B","ignoreList":[]}
|
|
@@ -6,6 +6,7 @@ import Reanimated from "react-native-reanimated";
|
|
|
6
6
|
import useCombinedRef from "../hooks/useCombinedRef";
|
|
7
7
|
import ScrollViewWithBottomPadding from "../ScrollViewWithBottomPadding";
|
|
8
8
|
import { useChatKeyboard } from "./useChatKeyboard";
|
|
9
|
+
import { useEndVisible } from "./useEndVisible";
|
|
9
10
|
import { useExtraContentPadding } from "./useExtraContentPadding";
|
|
10
11
|
const ZERO_CONTENT_PADDING = makeMutable(0);
|
|
11
12
|
const ZERO_BLANK_SPACE = makeMutable(0);
|
|
@@ -21,6 +22,7 @@ const KeyboardChatScrollView = /*#__PURE__*/forwardRef(({
|
|
|
21
22
|
applyWorkaroundForContentInsetHitTestBug = false,
|
|
22
23
|
onLayout: onLayoutProp,
|
|
23
24
|
onContentSizeChange: onContentSizeChangeProp,
|
|
25
|
+
onEndVisible,
|
|
24
26
|
...rest
|
|
25
27
|
}, ref) => {
|
|
26
28
|
const scrollViewRef = useAnimatedRef();
|
|
@@ -56,6 +58,13 @@ const KeyboardChatScrollView = /*#__PURE__*/forwardRef(({
|
|
|
56
58
|
keyboardLiftBehavior,
|
|
57
59
|
freeze: freezeSV
|
|
58
60
|
});
|
|
61
|
+
useEndVisible({
|
|
62
|
+
scroll,
|
|
63
|
+
layout,
|
|
64
|
+
size,
|
|
65
|
+
inverted,
|
|
66
|
+
onEndVisible
|
|
67
|
+
});
|
|
59
68
|
const totalPadding = useDerivedValue(() => Math.max(blankSpace.value, padding.value + extraContentPadding.value));
|
|
60
69
|
|
|
61
70
|
// Scroll indicator inset = keyboard + extraContentPadding (excludes blankSpace).
|