@legendapp/list 3.0.0-beta.21 → 3.0.0-beta.23

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/keyboard.mjs CHANGED
@@ -2,14 +2,11 @@ import * as React from 'react';
2
2
  import { forwardRef, useRef, useCallback } from 'react';
3
3
  import { StyleSheet, Platform } from 'react-native';
4
4
  import { useKeyboardHandler } from 'react-native-keyboard-controller';
5
- import { useAnimatedRef, useSharedValue, useAnimatedScrollHandler, runOnJS, runOnUI, useAnimatedProps, useAnimatedStyle } from 'react-native-reanimated';
5
+ import { useAnimatedRef, useSharedValue, useAnimatedScrollHandler, runOnJS, useAnimatedProps, useAnimatedStyle } from 'react-native-reanimated';
6
6
  import { AnimatedLegendList } from '@legendapp/list/reanimated';
7
7
 
8
8
  // src/integrations/keyboard.tsx
9
9
 
10
- // src/constants-platform.ts
11
- var IsNewArchitecture = true;
12
-
13
10
  // src/utils/helpers.ts
14
11
  function isFunction(obj) {
15
12
  return typeof obj === "function";
@@ -37,17 +34,18 @@ var clampProgress = (progress) => {
37
34
  "worklet";
38
35
  return Math.min(1, Math.max(0, progress));
39
36
  };
40
- var calculateKeyboardInset = (height, safeAreaInsetBottom, isNewArchitecture) => {
41
- "worklet";
42
- return Math.max(0, height - safeAreaInsetBottom) ;
43
- };
44
- var calculateEndPaddingInset = (keyboardHeight, alignItemsAtEndPadding) => {
37
+ var calculateKeyboardInset = (height, safeAreaInsetBottom) => {
45
38
  "worklet";
46
- return Math.min(keyboardHeight, alignItemsAtEndPadding);
39
+ return Math.max(0, height - safeAreaInsetBottom);
47
40
  };
48
- var calculateTopInset = (safeAreaInsetTop, isNewArchitecture, extraTopInset) => {
41
+ var calculateEffectiveKeyboardHeight = (keyboardHeight, contentLength, scrollLength, alignItemsAtEnd) => {
49
42
  "worklet";
50
- return (isNewArchitecture ? 0 : safeAreaInsetTop * 2) + extraTopInset;
43
+ if (alignItemsAtEnd) {
44
+ return keyboardHeight;
45
+ } else {
46
+ const availableSpace = Math.max(0, scrollLength - contentLength);
47
+ return Math.max(0, keyboardHeight - availableSpace);
48
+ }
51
49
  };
52
50
  var calculateKeyboardTargetOffset = (startOffset, keyboardHeight, isOpening, progress) => {
53
51
  "worklet";
@@ -61,10 +59,11 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
61
59
  horizontal,
62
60
  onMetricsChange: onMetricsChangeProp,
63
61
  onScroll: onScrollProp,
64
- safeAreaInsets = { bottom: 0, top: 0 },
62
+ safeAreaInsetBottom = 0,
65
63
  style: styleProp,
66
64
  ...rest
67
65
  } = props;
66
+ const { alignItemsAtEnd } = props;
68
67
  const styleFlattened = StyleSheet.flatten(styleProp);
69
68
  const refLegendList = useRef(null);
70
69
  const combinedRef = useCombinedRef(forwardedRef, refLegendList);
@@ -75,16 +74,19 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
75
74
  const animatedOffsetY = useSharedValue(null);
76
75
  const scrollOffsetAtKeyboardStart = useSharedValue(0);
77
76
  const mode = useSharedValue("idle");
78
- const keyboardInset = useSharedValue({ bottom: 0, top: 0 });
77
+ const keyboardInset = useSharedValue(0);
79
78
  const keyboardHeight = useSharedValue(0);
79
+ const contentLength = useSharedValue(0);
80
+ const scrollLength = useSharedValue(0);
80
81
  const alignItemsAtEndPadding = useSharedValue(0);
81
82
  const isOpening = useSharedValue(false);
82
83
  const didInteractive = useSharedValue(false);
83
- const { top: safeAreaInsetTop, bottom: safeAreaInsetBottom } = safeAreaInsets;
84
84
  const isKeyboardOpen = useSharedValue(false);
85
85
  const scrollHandler = useAnimatedScrollHandler(
86
86
  (event) => {
87
- scrollOffsetY.set(event.contentOffset[horizontal ? "x" : "y"]);
87
+ if (mode.get() !== "running" || didInteractive.get()) {
88
+ scrollOffsetY.set(event.contentOffset[horizontal ? "x" : "y"]);
89
+ }
88
90
  if (onScrollProp) {
89
91
  runOnJS(onScrollProp)(event);
90
92
  }
@@ -98,36 +100,23 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
98
100
  },
99
101
  [refLegendList]
100
102
  );
103
+ const updateScrollMetrics = useCallback(() => {
104
+ var _a;
105
+ const state = (_a = refLegendList.current) == null ? void 0 : _a.getState();
106
+ if (!state) {
107
+ return;
108
+ }
109
+ contentLength.set(state.contentLength);
110
+ scrollLength.set(state.scrollLength);
111
+ }, [contentLength, scrollLength]);
101
112
  const handleMetricsChange = useCallback(
102
113
  (metrics) => {
114
+ updateScrollMetrics();
103
115
  const nextPadding = metrics.alignItemsAtEndPadding || 0;
104
116
  alignItemsAtEndPadding.set(nextPadding);
105
- if (!horizontal) {
106
- runOnUI((padding, safeInsetTop, isNewArchitecture) => {
107
- "worklet";
108
- if (!isKeyboardOpen.get()) {
109
- return;
110
- }
111
- const vKeyboardHeight = keyboardHeight.get();
112
- const vTopInset = calculateEndPaddingInset(vKeyboardHeight, padding);
113
- const topInset = calculateTopInset(safeInsetTop, isNewArchitecture, vTopInset);
114
- keyboardInset.set({
115
- bottom: keyboardInset.get().bottom,
116
- top: topInset
117
- });
118
- })(nextPadding, safeAreaInsetTop, IsNewArchitecture);
119
- }
120
117
  onMetricsChangeProp == null ? void 0 : onMetricsChangeProp(metrics);
121
118
  },
122
- [
123
- alignItemsAtEndPadding,
124
- horizontal,
125
- isKeyboardOpen,
126
- keyboardHeight,
127
- keyboardInset,
128
- onMetricsChangeProp,
129
- safeAreaInsetTop
130
- ]
119
+ [alignItemsAtEndPadding, onMetricsChangeProp, updateScrollMetrics]
131
120
  );
132
121
  useKeyboardHandler(
133
122
  // biome-ignore assist/source/useSortedKeys: prefer start/move/end
@@ -156,18 +145,11 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
156
145
  }
157
146
  mode.set("running");
158
147
  if (!didInteractive.get()) {
159
- if (!isAndroid && !IsNewArchitecture) {
160
- keyboardInset.set({
161
- bottom: keyboardInset.get().bottom,
162
- // Legacy iOS uses a doubled top inset to keep content below the status bar.
163
- top: calculateTopInset(safeAreaInsetTop, IsNewArchitecture, 0)
164
- });
165
- }
166
148
  didInteractive.set(true);
167
149
  }
168
150
  if (isAndroid && !horizontal) {
169
151
  const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
170
- keyboardInset.set({ bottom: newInset, top: safeAreaInsetTop * 2 });
152
+ keyboardInset.set(newInset);
171
153
  }
172
154
  },
173
155
  onMove: (event) => {
@@ -176,11 +158,15 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
176
158
  const progress = clampProgress(event.progress);
177
159
  const vIsOpening = isOpening.get();
178
160
  const vKeyboardHeight = keyboardHeight.get();
179
- const vAlignItemsPadding = alignItemsAtEndPadding.get();
180
- const vTopInset = calculateEndPaddingInset(vKeyboardHeight, vAlignItemsPadding);
161
+ const vEffectiveKeyboardHeight = calculateEffectiveKeyboardHeight(
162
+ vKeyboardHeight,
163
+ contentLength.get(),
164
+ scrollLength.get(),
165
+ alignItemsAtEnd
166
+ );
181
167
  const targetOffset = calculateKeyboardTargetOffset(
182
168
  scrollOffsetAtKeyboardStart.get(),
183
- vKeyboardHeight,
169
+ vEffectiveKeyboardHeight,
184
170
  vIsOpening,
185
171
  progress
186
172
  );
@@ -188,16 +174,7 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
188
174
  animatedOffsetY.set(targetOffset);
189
175
  if (!horizontal) {
190
176
  const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
191
- const topInset = calculateTopInset(
192
- safeAreaInsetTop,
193
- IsNewArchitecture,
194
- vIsOpening ? vTopInset : 0
195
- );
196
- keyboardInset.set({
197
- bottom: newInset,
198
- // Add top padding only while opening to keep end-aligned items visible.
199
- top: topInset
200
- });
177
+ keyboardInset.set(newInset);
201
178
  }
202
179
  }
203
180
  },
@@ -209,13 +186,17 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
209
186
  if (vMode === "running") {
210
187
  const progress = clampProgress(event.progress);
211
188
  const vKeyboardHeight = keyboardHeight.get();
212
- const vAlignItemsPadding = alignItemsAtEndPadding.get();
213
- const vTopInset = calculateEndPaddingInset(vKeyboardHeight, vAlignItemsPadding);
189
+ const vEffectiveKeyboardHeight = calculateEffectiveKeyboardHeight(
190
+ vKeyboardHeight,
191
+ contentLength.get(),
192
+ scrollLength.get(),
193
+ alignItemsAtEnd
194
+ );
214
195
  const vIsOpening = isOpening.get();
215
196
  if (!wasInteractive) {
216
197
  const targetOffset = calculateKeyboardTargetOffset(
217
198
  scrollOffsetAtKeyboardStart.get(),
218
- vKeyboardHeight,
199
+ vEffectiveKeyboardHeight,
219
200
  vIsOpening,
220
201
  progress
221
202
  );
@@ -227,16 +208,7 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
227
208
  isKeyboardOpen.set(event.height > 0);
228
209
  if (!horizontal) {
229
210
  const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
230
- const topInset = calculateTopInset(
231
- safeAreaInsetTop,
232
- IsNewArchitecture,
233
- event.height > 0 ? vTopInset : 0
234
- );
235
- keyboardInset.set({
236
- bottom: newInset,
237
- // Preserve end-aligned padding only while the keyboard is visible.
238
- top: topInset
239
- });
211
+ keyboardInset.set(newInset);
240
212
  if (newInset <= 0) {
241
213
  animatedOffsetY.set(scrollOffsetY.get());
242
214
  }
@@ -244,7 +216,7 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
244
216
  }
245
217
  }
246
218
  },
247
- [scrollViewRef, safeAreaInsetBottom]
219
+ [alignItemsAtEnd, safeAreaInsetBottom, scrollViewRef]
248
220
  );
249
221
  const animatedProps = useAnimatedProps(() => {
250
222
  "worklet";
@@ -256,24 +228,21 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
256
228
  y: vAnimatedOffsetY
257
229
  }
258
230
  };
259
- const { top: keyboardInsetTop, bottom: keyboardInsetBottom } = keyboardInset.get();
231
+ const keyboardInsetBottom = keyboardInset.get();
260
232
  return isIos ? Object.assign(baseProps, {
261
233
  contentInset: {
262
234
  bottom: ((_a = contentInsetProp == null ? void 0 : contentInsetProp.bottom) != null ? _a : 0) + (horizontal ? 0 : keyboardInsetBottom),
263
235
  left: (_b = contentInsetProp == null ? void 0 : contentInsetProp.left) != null ? _b : 0,
264
236
  right: (_c = contentInsetProp == null ? void 0 : contentInsetProp.right) != null ? _c : 0,
265
- top: ((_d = contentInsetProp == null ? void 0 : contentInsetProp.top) != null ? _d : 0) - keyboardInsetTop
237
+ top: (_d = contentInsetProp == null ? void 0 : contentInsetProp.top) != null ? _d : 0
266
238
  }
267
239
  }) : baseProps;
268
240
  });
269
241
  const style = isAndroid ? useAnimatedStyle(
270
- () => {
271
- var _a;
272
- return {
273
- ...styleFlattened || {},
274
- marginBottom: (_a = keyboardInset.get().bottom) != null ? _a : 0
275
- };
276
- },
242
+ () => ({
243
+ ...styleFlattened || {},
244
+ marginBottom: keyboardInset.get()
245
+ }),
277
246
  [styleProp, keyboardInset]
278
247
  ) : void 0;
279
248
  return /* @__PURE__ */ React.createElement(
@@ -281,6 +250,7 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
281
250
  {
282
251
  ...rest,
283
252
  animatedProps,
253
+ automaticallyAdjustContentInsets: false,
284
254
  keyboardDismissMode: "interactive",
285
255
  onMetricsChange: handleMetricsChange,
286
256
  onScroll: scrollHandler,
@@ -4,13 +4,10 @@ import { ReanimatedScrollEvent } from 'react-native-reanimated/lib/typescript/ho
4
4
  import { LegendListRef } from '@legendapp/list';
5
5
  import { AnimatedLegendListProps } from '@legendapp/list/reanimated';
6
6
 
7
- declare const KeyboardAvoidingLegendList: <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "onScroll" | "contentInset"> & {
7
+ declare const KeyboardAvoidingLegendList: <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "onScroll" | "automaticallyAdjustContentInsets" | "contentInset"> & {
8
8
  onScroll?: (event: ReanimatedScrollEvent) => void;
9
9
  contentInset?: Insets | undefined;
10
- safeAreaInsets?: {
11
- top: number;
12
- bottom: number;
13
- };
10
+ safeAreaInsetBottom?: number;
14
11
  } & React.RefAttributes<LegendListRef>) => React.ReactNode;
15
12
 
16
13
  export { KeyboardAvoidingLegendList, KeyboardAvoidingLegendList as LegendList };
@@ -4,13 +4,10 @@ import { ReanimatedScrollEvent } from 'react-native-reanimated/lib/typescript/ho
4
4
  import { LegendListRef } from '@legendapp/list';
5
5
  import { AnimatedLegendListProps } from '@legendapp/list/reanimated';
6
6
 
7
- declare const KeyboardAvoidingLegendList: <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "onScroll" | "contentInset"> & {
7
+ declare const KeyboardAvoidingLegendList: <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "onScroll" | "automaticallyAdjustContentInsets" | "contentInset"> & {
8
8
  onScroll?: (event: ReanimatedScrollEvent) => void;
9
9
  contentInset?: Insets | undefined;
10
- safeAreaInsets?: {
11
- top: number;
12
- bottom: number;
13
- };
10
+ safeAreaInsetBottom?: number;
14
11
  } & React.RefAttributes<LegendListRef>) => React.ReactNode;
15
12
 
16
13
  export { KeyboardAvoidingLegendList, KeyboardAvoidingLegendList as LegendList };
@@ -28,10 +28,6 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
28
 
29
29
  // src/integrations/keyboard.tsx
30
30
 
31
- // src/constants-platform.native.ts
32
- var f = global.nativeFabricUIManager;
33
- var IsNewArchitecture = f !== void 0 && f != null;
34
-
35
31
  // src/utils/helpers.ts
36
32
  function isFunction(obj) {
37
33
  return typeof obj === "function";
@@ -59,17 +55,18 @@ var clampProgress = (progress) => {
59
55
  "worklet";
60
56
  return Math.min(1, Math.max(0, progress));
61
57
  };
62
- var calculateKeyboardInset = (height, safeAreaInsetBottom, isNewArchitecture) => {
63
- "worklet";
64
- return isNewArchitecture ? Math.max(0, height - safeAreaInsetBottom) : Math.max(isNewArchitecture ? 0 : -safeAreaInsetBottom, height - safeAreaInsetBottom * 2);
65
- };
66
- var calculateEndPaddingInset = (keyboardHeight, alignItemsAtEndPadding) => {
58
+ var calculateKeyboardInset = (height, safeAreaInsetBottom) => {
67
59
  "worklet";
68
- return Math.min(keyboardHeight, alignItemsAtEndPadding);
60
+ return Math.max(0, height - safeAreaInsetBottom);
69
61
  };
70
- var calculateTopInset = (safeAreaInsetTop, isNewArchitecture, extraTopInset) => {
62
+ var calculateEffectiveKeyboardHeight = (keyboardHeight, contentLength, scrollLength, alignItemsAtEnd) => {
71
63
  "worklet";
72
- return (isNewArchitecture ? 0 : safeAreaInsetTop * 2) + extraTopInset;
64
+ if (alignItemsAtEnd) {
65
+ return keyboardHeight;
66
+ } else {
67
+ const availableSpace = Math.max(0, scrollLength - contentLength);
68
+ return Math.max(0, keyboardHeight - availableSpace);
69
+ }
73
70
  };
74
71
  var calculateKeyboardTargetOffset = (startOffset, keyboardHeight, isOpening, progress) => {
75
72
  "worklet";
@@ -83,10 +80,11 @@ var KeyboardAvoidingLegendList = React.forwardRef(function KeyboardAvoidingLegen
83
80
  horizontal,
84
81
  onMetricsChange: onMetricsChangeProp,
85
82
  onScroll: onScrollProp,
86
- safeAreaInsets = { bottom: 0, top: 0 },
83
+ safeAreaInsetBottom = 0,
87
84
  style: styleProp,
88
85
  ...rest
89
86
  } = props;
87
+ const { alignItemsAtEnd } = props;
90
88
  const styleFlattened = reactNative.StyleSheet.flatten(styleProp);
91
89
  const refLegendList = React.useRef(null);
92
90
  const combinedRef = useCombinedRef(forwardedRef, refLegendList);
@@ -97,16 +95,19 @@ var KeyboardAvoidingLegendList = React.forwardRef(function KeyboardAvoidingLegen
97
95
  const animatedOffsetY = reactNativeReanimated.useSharedValue(null);
98
96
  const scrollOffsetAtKeyboardStart = reactNativeReanimated.useSharedValue(0);
99
97
  const mode = reactNativeReanimated.useSharedValue("idle");
100
- const keyboardInset = reactNativeReanimated.useSharedValue({ bottom: 0, top: 0 });
98
+ const keyboardInset = reactNativeReanimated.useSharedValue(0);
101
99
  const keyboardHeight = reactNativeReanimated.useSharedValue(0);
100
+ const contentLength = reactNativeReanimated.useSharedValue(0);
101
+ const scrollLength = reactNativeReanimated.useSharedValue(0);
102
102
  const alignItemsAtEndPadding = reactNativeReanimated.useSharedValue(0);
103
103
  const isOpening = reactNativeReanimated.useSharedValue(false);
104
104
  const didInteractive = reactNativeReanimated.useSharedValue(false);
105
- const { top: safeAreaInsetTop, bottom: safeAreaInsetBottom } = safeAreaInsets;
106
105
  const isKeyboardOpen = reactNativeReanimated.useSharedValue(false);
107
106
  const scrollHandler = reactNativeReanimated.useAnimatedScrollHandler(
108
107
  (event) => {
109
- scrollOffsetY.set(event.contentOffset[horizontal ? "x" : "y"]);
108
+ if (mode.get() !== "running" || didInteractive.get()) {
109
+ scrollOffsetY.set(event.contentOffset[horizontal ? "x" : "y"]);
110
+ }
110
111
  if (onScrollProp) {
111
112
  reactNativeReanimated.runOnJS(onScrollProp)(event);
112
113
  }
@@ -120,36 +121,23 @@ var KeyboardAvoidingLegendList = React.forwardRef(function KeyboardAvoidingLegen
120
121
  },
121
122
  [refLegendList]
122
123
  );
124
+ const updateScrollMetrics = React.useCallback(() => {
125
+ var _a;
126
+ const state = (_a = refLegendList.current) == null ? void 0 : _a.getState();
127
+ if (!state) {
128
+ return;
129
+ }
130
+ contentLength.set(state.contentLength);
131
+ scrollLength.set(state.scrollLength);
132
+ }, [contentLength, scrollLength]);
123
133
  const handleMetricsChange = React.useCallback(
124
134
  (metrics) => {
135
+ updateScrollMetrics();
125
136
  const nextPadding = metrics.alignItemsAtEndPadding || 0;
126
137
  alignItemsAtEndPadding.set(nextPadding);
127
- if (!horizontal) {
128
- reactNativeReanimated.runOnUI((padding, safeInsetTop, isNewArchitecture) => {
129
- "worklet";
130
- if (!isKeyboardOpen.get()) {
131
- return;
132
- }
133
- const vKeyboardHeight = keyboardHeight.get();
134
- const vTopInset = calculateEndPaddingInset(vKeyboardHeight, padding);
135
- const topInset = calculateTopInset(safeInsetTop, isNewArchitecture, vTopInset);
136
- keyboardInset.set({
137
- bottom: keyboardInset.get().bottom,
138
- top: topInset
139
- });
140
- })(nextPadding, safeAreaInsetTop, IsNewArchitecture);
141
- }
142
138
  onMetricsChangeProp == null ? void 0 : onMetricsChangeProp(metrics);
143
139
  },
144
- [
145
- alignItemsAtEndPadding,
146
- horizontal,
147
- isKeyboardOpen,
148
- keyboardHeight,
149
- keyboardInset,
150
- onMetricsChangeProp,
151
- safeAreaInsetTop
152
- ]
140
+ [alignItemsAtEndPadding, onMetricsChangeProp, updateScrollMetrics]
153
141
  );
154
142
  reactNativeKeyboardController.useKeyboardHandler(
155
143
  // biome-ignore assist/source/useSortedKeys: prefer start/move/end
@@ -178,18 +166,11 @@ var KeyboardAvoidingLegendList = React.forwardRef(function KeyboardAvoidingLegen
178
166
  }
179
167
  mode.set("running");
180
168
  if (!didInteractive.get()) {
181
- if (!isAndroid && !IsNewArchitecture) {
182
- keyboardInset.set({
183
- bottom: keyboardInset.get().bottom,
184
- // Legacy iOS uses a doubled top inset to keep content below the status bar.
185
- top: calculateTopInset(safeAreaInsetTop, IsNewArchitecture, 0)
186
- });
187
- }
188
169
  didInteractive.set(true);
189
170
  }
190
171
  if (isAndroid && !horizontal) {
191
- const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom, IsNewArchitecture);
192
- keyboardInset.set({ bottom: newInset, top: safeAreaInsetTop * 2 });
172
+ const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
173
+ keyboardInset.set(newInset);
193
174
  }
194
175
  },
195
176
  onMove: (event) => {
@@ -198,28 +179,23 @@ var KeyboardAvoidingLegendList = React.forwardRef(function KeyboardAvoidingLegen
198
179
  const progress = clampProgress(event.progress);
199
180
  const vIsOpening = isOpening.get();
200
181
  const vKeyboardHeight = keyboardHeight.get();
201
- const vAlignItemsPadding = alignItemsAtEndPadding.get();
202
- const vTopInset = calculateEndPaddingInset(vKeyboardHeight, vAlignItemsPadding);
182
+ const vEffectiveKeyboardHeight = calculateEffectiveKeyboardHeight(
183
+ vKeyboardHeight,
184
+ contentLength.get(),
185
+ scrollLength.get(),
186
+ alignItemsAtEnd
187
+ );
203
188
  const targetOffset = calculateKeyboardTargetOffset(
204
189
  scrollOffsetAtKeyboardStart.get(),
205
- vKeyboardHeight,
190
+ vEffectiveKeyboardHeight,
206
191
  vIsOpening,
207
192
  progress
208
193
  );
209
194
  scrollOffsetY.set(targetOffset);
210
195
  animatedOffsetY.set(targetOffset);
211
196
  if (!horizontal) {
212
- const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom, IsNewArchitecture);
213
- const topInset = calculateTopInset(
214
- safeAreaInsetTop,
215
- IsNewArchitecture,
216
- vIsOpening ? vTopInset : 0
217
- );
218
- keyboardInset.set({
219
- bottom: newInset,
220
- // Add top padding only while opening to keep end-aligned items visible.
221
- top: topInset
222
- });
197
+ const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
198
+ keyboardInset.set(newInset);
223
199
  }
224
200
  }
225
201
  },
@@ -231,13 +207,17 @@ var KeyboardAvoidingLegendList = React.forwardRef(function KeyboardAvoidingLegen
231
207
  if (vMode === "running") {
232
208
  const progress = clampProgress(event.progress);
233
209
  const vKeyboardHeight = keyboardHeight.get();
234
- const vAlignItemsPadding = alignItemsAtEndPadding.get();
235
- const vTopInset = calculateEndPaddingInset(vKeyboardHeight, vAlignItemsPadding);
210
+ const vEffectiveKeyboardHeight = calculateEffectiveKeyboardHeight(
211
+ vKeyboardHeight,
212
+ contentLength.get(),
213
+ scrollLength.get(),
214
+ alignItemsAtEnd
215
+ );
236
216
  const vIsOpening = isOpening.get();
237
217
  if (!wasInteractive) {
238
218
  const targetOffset = calculateKeyboardTargetOffset(
239
219
  scrollOffsetAtKeyboardStart.get(),
240
- vKeyboardHeight,
220
+ vEffectiveKeyboardHeight,
241
221
  vIsOpening,
242
222
  progress
243
223
  );
@@ -248,17 +228,8 @@ var KeyboardAvoidingLegendList = React.forwardRef(function KeyboardAvoidingLegen
248
228
  didInteractive.set(false);
249
229
  isKeyboardOpen.set(event.height > 0);
250
230
  if (!horizontal) {
251
- const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom, IsNewArchitecture);
252
- const topInset = calculateTopInset(
253
- safeAreaInsetTop,
254
- IsNewArchitecture,
255
- event.height > 0 ? vTopInset : 0
256
- );
257
- keyboardInset.set({
258
- bottom: newInset,
259
- // Preserve end-aligned padding only while the keyboard is visible.
260
- top: topInset
261
- });
231
+ const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
232
+ keyboardInset.set(newInset);
262
233
  if (newInset <= 0) {
263
234
  animatedOffsetY.set(scrollOffsetY.get());
264
235
  }
@@ -266,7 +237,7 @@ var KeyboardAvoidingLegendList = React.forwardRef(function KeyboardAvoidingLegen
266
237
  }
267
238
  }
268
239
  },
269
- [scrollViewRef, safeAreaInsetBottom]
240
+ [alignItemsAtEnd, safeAreaInsetBottom, scrollViewRef]
270
241
  );
271
242
  const animatedProps = reactNativeReanimated.useAnimatedProps(() => {
272
243
  "worklet";
@@ -278,24 +249,21 @@ var KeyboardAvoidingLegendList = React.forwardRef(function KeyboardAvoidingLegen
278
249
  y: vAnimatedOffsetY
279
250
  }
280
251
  };
281
- const { top: keyboardInsetTop, bottom: keyboardInsetBottom } = keyboardInset.get();
252
+ const keyboardInsetBottom = keyboardInset.get();
282
253
  return isIos ? Object.assign(baseProps, {
283
254
  contentInset: {
284
255
  bottom: ((_a = contentInsetProp == null ? void 0 : contentInsetProp.bottom) != null ? _a : 0) + (horizontal ? 0 : keyboardInsetBottom),
285
256
  left: (_b = contentInsetProp == null ? void 0 : contentInsetProp.left) != null ? _b : 0,
286
257
  right: (_c = contentInsetProp == null ? void 0 : contentInsetProp.right) != null ? _c : 0,
287
- top: ((_d = contentInsetProp == null ? void 0 : contentInsetProp.top) != null ? _d : 0) - keyboardInsetTop
258
+ top: (_d = contentInsetProp == null ? void 0 : contentInsetProp.top) != null ? _d : 0
288
259
  }
289
260
  }) : baseProps;
290
261
  });
291
262
  const style = isAndroid ? reactNativeReanimated.useAnimatedStyle(
292
- () => {
293
- var _a;
294
- return {
295
- ...styleFlattened || {},
296
- marginBottom: (_a = keyboardInset.get().bottom) != null ? _a : 0
297
- };
298
- },
263
+ () => ({
264
+ ...styleFlattened || {},
265
+ marginBottom: keyboardInset.get()
266
+ }),
299
267
  [styleProp, keyboardInset]
300
268
  ) : void 0;
301
269
  return /* @__PURE__ */ React__namespace.createElement(
@@ -303,6 +271,7 @@ var KeyboardAvoidingLegendList = React.forwardRef(function KeyboardAvoidingLegen
303
271
  {
304
272
  ...rest,
305
273
  animatedProps,
274
+ automaticallyAdjustContentInsets: false,
306
275
  keyboardDismissMode: "interactive",
307
276
  onMetricsChange: handleMetricsChange,
308
277
  onScroll: scrollHandler,