stream-chat-react-native-core 9.0.0-beta.17 → 9.0.0-beta.19

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.
Files changed (25) hide show
  1. package/lib/commonjs/components/UIComponents/BottomSheetModal.js +120 -125
  2. package/lib/commonjs/components/UIComponents/BottomSheetModal.js.map +1 -1
  3. package/lib/commonjs/components/UIComponents/PortalWhileClosingView.js +4 -3
  4. package/lib/commonjs/components/UIComponents/PortalWhileClosingView.js.map +1 -1
  5. package/lib/commonjs/contexts/overlayContext/MessageOverlayHostLayer.js +70 -31
  6. package/lib/commonjs/contexts/overlayContext/MessageOverlayHostLayer.js.map +1 -1
  7. package/lib/commonjs/version.json +1 -1
  8. package/lib/module/components/UIComponents/BottomSheetModal.js +120 -125
  9. package/lib/module/components/UIComponents/BottomSheetModal.js.map +1 -1
  10. package/lib/module/components/UIComponents/PortalWhileClosingView.js +4 -3
  11. package/lib/module/components/UIComponents/PortalWhileClosingView.js.map +1 -1
  12. package/lib/module/contexts/overlayContext/MessageOverlayHostLayer.js +70 -31
  13. package/lib/module/contexts/overlayContext/MessageOverlayHostLayer.js.map +1 -1
  14. package/lib/module/version.json +1 -1
  15. package/lib/typescript/components/UIComponents/BottomSheetModal.d.ts.map +1 -1
  16. package/lib/typescript/components/UIComponents/PortalWhileClosingView.d.ts.map +1 -1
  17. package/lib/typescript/contexts/overlayContext/MessageOverlayHostLayer.d.ts.map +1 -1
  18. package/package.json +1 -1
  19. package/src/components/MessageInput/__tests__/__snapshots__/AttachButton.test.js.snap +15 -60
  20. package/src/components/MessageInput/__tests__/__snapshots__/SendButton.test.js.snap +10 -40
  21. package/src/components/UIComponents/BottomSheetModal.tsx +140 -173
  22. package/src/components/UIComponents/PortalWhileClosingView.tsx +5 -3
  23. package/src/contexts/overlayContext/MessageOverlayHostLayer.tsx +86 -31
  24. package/src/contexts/overlayContext/__tests__/MessageOverlayHostLayer.test.tsx +17 -8
  25. package/src/version.json +1 -1
@@ -11,6 +11,7 @@ import { Gesture, GestureDetector } from 'react-native-gesture-handler';
11
11
  import Animated, {
12
12
  clamp,
13
13
  runOnJS,
14
+ useAnimatedReaction,
14
15
  useAnimatedStyle,
15
16
  useDerivedValue,
16
17
  useSharedValue,
@@ -64,6 +65,9 @@ export const MessageOverlayHostLayer = ({ BackgroundComponent }: MessageOverlayH
64
65
  const topH = useSharedValue<Rect>(undefined);
65
66
  const bottomH = useSharedValue<Rect>(undefined);
66
67
  const closeCorrectionY = useSharedValue(0);
68
+ const topVisualY = useSharedValue(0);
69
+ const messageVisualY = useSharedValue(0);
70
+ const bottomVisualY = useSharedValue(0);
67
71
 
68
72
  const topInset = insets.top;
69
73
  // Due to edge-to-edge in combination with various libraries, Android sometimes reports
@@ -95,6 +99,9 @@ export const MessageOverlayHostLayer = ({ BackgroundComponent }: MessageOverlayH
95
99
  topH.value = undefined;
96
100
  bottomH.value = undefined;
97
101
  closeCorrectionY.value = 0;
102
+ topVisualY.value = 0;
103
+ messageVisualY.value = 0;
104
+ bottomVisualY.value = 0;
98
105
  },
99
106
  setBottomH: (rect) => {
100
107
  bottomH.value = rect;
@@ -106,7 +113,7 @@ export const MessageOverlayHostLayer = ({ BackgroundComponent }: MessageOverlayH
106
113
  topH.value = rect;
107
114
  },
108
115
  }),
109
- [bottomH, closeCorrectionY, messageH, topH],
116
+ [bottomH, bottomVisualY, closeCorrectionY, messageH, messageVisualY, topH, topVisualY],
110
117
  );
111
118
 
112
119
  useEffect(() => {
@@ -156,51 +163,111 @@ export const MessageOverlayHostLayer = ({ BackgroundComponent }: MessageOverlayH
156
163
  return solvedBottomTop - bottomH.value.y;
157
164
  });
158
165
 
166
+ useAnimatedReaction(
167
+ () => {
168
+ if (!topH.value) return undefined;
169
+ const correction = isActive ? (closing ? closeCorrectionY.value : messageShiftY.value) : 0;
170
+ return topH.value.y + correction;
171
+ },
172
+ (next, previous) => {
173
+ if (next === undefined) {
174
+ topVisualY.value = 0;
175
+ return;
176
+ }
177
+
178
+ if (previous === undefined) {
179
+ topVisualY.value = next;
180
+ return;
181
+ }
182
+
183
+ topVisualY.value = withSpring(next, { duration: DURATION });
184
+ },
185
+ [isActive, closing],
186
+ );
187
+
188
+ useAnimatedReaction(
189
+ () => {
190
+ if (!messageH.value) return undefined;
191
+ const correction = isActive ? (closing ? closeCorrectionY.value : messageShiftY.value) : 0;
192
+ return messageH.value.y + correction;
193
+ },
194
+ (next, previous) => {
195
+ if (next === undefined) {
196
+ messageVisualY.value = 0;
197
+ return;
198
+ }
199
+
200
+ if (previous === undefined) {
201
+ messageVisualY.value = next;
202
+ return;
203
+ }
204
+
205
+ messageVisualY.value = withSpring(next, { duration: DURATION });
206
+ },
207
+ [isActive, closing],
208
+ );
209
+
210
+ useAnimatedReaction(
211
+ () => {
212
+ if (!bottomH.value) return undefined;
213
+ const correction = isActive ? (closing ? closeCorrectionY.value : bottomShiftY.value) : 0;
214
+ return bottomH.value.y + correction;
215
+ },
216
+ (next, previous) => {
217
+ if (next === undefined) {
218
+ bottomVisualY.value = 0;
219
+ return;
220
+ }
221
+
222
+ if (previous === undefined) {
223
+ bottomVisualY.value = next;
224
+ return;
225
+ }
226
+
227
+ bottomVisualY.value = withSpring(next, { duration: DURATION });
228
+ },
229
+ [isActive, closing],
230
+ );
231
+
159
232
  const topItemStyle = useAnimatedStyle(() => {
160
- if (!topH.value) return { height: 0 };
233
+ if (!topVisualY.value || !topH.value) return { opacity: 0 };
161
234
  const horizontalPosition = I18nManager.isRTL ? { right: topH.value.x } : { left: topH.value.x };
162
235
  return {
163
236
  height: topH.value.h,
164
237
  position: 'absolute',
165
- top: topH.value.y,
238
+ top: topVisualY.value,
239
+ opacity: 1,
166
240
  width: topH.value.w,
167
241
  ...horizontalPosition,
168
242
  };
169
243
  });
170
244
 
171
245
  const topItemTranslateStyle = useAnimatedStyle(() => {
172
- const target = isActive ? (closing ? closeCorrectionY.value : messageShiftY.value) : 0;
173
246
  return {
174
- transform: [
175
- { scale: backdrop.value },
176
- { translateY: withSpring(target, { duration: DURATION }) },
177
- ],
247
+ transform: [{ scale: backdrop.value }],
178
248
  };
179
- }, [isActive, closing]);
249
+ });
180
250
 
181
251
  const bottomItemStyle = useAnimatedStyle(() => {
182
- if (!bottomH.value) return { height: 0 };
252
+ if (!bottomVisualY.value || !bottomH.value) return { opacity: 0 };
183
253
  const horizontalPosition = I18nManager.isRTL
184
254
  ? { right: bottomH.value.x }
185
255
  : { left: bottomH.value.x };
186
256
  return {
187
257
  height: bottomH.value.h,
188
258
  position: 'absolute',
189
- top: bottomH.value.y,
259
+ top: bottomVisualY.value,
260
+ opacity: 1,
190
261
  width: bottomH.value.w,
191
262
  ...horizontalPosition,
192
263
  };
193
264
  });
194
265
 
195
266
  const bottomItemTranslateStyle = useAnimatedStyle(() => {
196
- const target = isActive ? (closing ? closeCorrectionY.value : bottomShiftY.value) : 0;
197
267
  return {
198
- transform: [
199
- { scale: backdrop.value },
200
- { translateY: withSpring(target, { duration: DURATION }) },
201
- ],
268
+ transform: [{ scale: backdrop.value }],
202
269
  };
203
- }, [isActive, closing]);
270
+ });
204
271
 
205
272
  const hostStyle = useAnimatedStyle(() => {
206
273
  if (!messageH.value) return { height: 0 };
@@ -208,23 +275,11 @@ export const MessageOverlayHostLayer = ({ BackgroundComponent }: MessageOverlayH
208
275
  height: messageH.value.h,
209
276
  left: messageH.value.x,
210
277
  position: 'absolute',
211
- top: messageH.value.y,
278
+ top: messageVisualY.value,
212
279
  width: messageH.value.w,
213
280
  };
214
281
  });
215
282
 
216
- const hostTranslateStyle = useAnimatedStyle(() => {
217
- const target = isActive ? (closing ? closeCorrectionY.value : messageShiftY.value) : 0;
218
-
219
- return {
220
- transform: [
221
- {
222
- translateY: withSpring(target, { duration: DURATION }),
223
- },
224
- ],
225
- };
226
- }, [isActive, closing]);
227
-
228
283
  const tap = useMemo(
229
284
  () =>
230
285
  Gesture.Tap()
@@ -288,7 +343,7 @@ export const MessageOverlayHostLayer = ({ BackgroundComponent }: MessageOverlayH
288
343
 
289
344
  <Animated.View
290
345
  pointerEvents='box-none'
291
- style={[hostStyle, hostTranslateStyle]}
346
+ style={hostStyle}
292
347
  testID='message-overlay-message'
293
348
  >
294
349
  <PortalHost name='message-overlay' style={StyleSheet.absoluteFillObject} />
@@ -75,6 +75,12 @@ jest.mock('react-native-reanimated', () => {
75
75
  },
76
76
  clamp: (value: number, min: number, max: number) => Math.min(Math.max(value, min), max),
77
77
  runOnJS: (fn: (...args: unknown[]) => unknown) => fn,
78
+ useAnimatedReaction: (
79
+ prepare: () => unknown,
80
+ react: (current: unknown, previous: unknown) => void,
81
+ ) => {
82
+ react(prepare(), undefined);
83
+ },
78
84
  useAnimatedStyle: (updater: () => unknown) => updater(),
79
85
  useDerivedValue: (updater: () => unknown) => ({ value: updater() }),
80
86
  useSharedValue: useStableSharedValue,
@@ -175,25 +181,26 @@ describe('MessageOverlayHostLayer', () => {
175
181
  expect(StyleSheet.flatten(topSlot.props.style)).toMatchObject({
176
182
  height: TOP_RECT.h,
177
183
  left: TOP_RECT.x,
184
+ opacity: 1,
178
185
  position: 'absolute',
179
- top: TOP_RECT.y,
180
- transform: [{ scale: 1 }, { translateY: 38 }],
186
+ top: 38,
187
+ transform: [{ scale: 1 }],
181
188
  width: TOP_RECT.w,
182
189
  });
183
190
  expect(StyleSheet.flatten(messageSlot.props.style)).toMatchObject({
184
191
  height: MESSAGE_RECT.h,
185
192
  left: MESSAGE_RECT.x,
186
193
  position: 'absolute',
187
- top: MESSAGE_RECT.y,
188
- transform: [{ translateY: 38 }],
194
+ top: 38,
189
195
  width: MESSAGE_RECT.w,
190
196
  });
191
197
  expect(StyleSheet.flatten(bottomSlot.props.style)).toMatchObject({
192
198
  height: BOTTOM_RECT.h,
193
199
  left: BOTTOM_RECT.x,
200
+ opacity: 1,
194
201
  position: 'absolute',
195
- top: BOTTOM_RECT.y,
196
- transform: [{ scale: 1 }, { translateY: -12 }],
202
+ top: 88,
203
+ transform: [{ scale: 1 }],
197
204
  width: BOTTOM_RECT.w,
198
205
  });
199
206
  });
@@ -227,7 +234,8 @@ describe('MessageOverlayHostLayer', () => {
227
234
 
228
235
  expect(StyleSheet.flatten(screen.getByTestId('message-overlay-top').props.style)).toMatchObject(
229
236
  {
230
- height: 0,
237
+ opacity: 0,
238
+ transform: [{ scale: 0 }],
231
239
  },
232
240
  );
233
241
  expect(
@@ -236,7 +244,8 @@ describe('MessageOverlayHostLayer', () => {
236
244
  expect(
237
245
  StyleSheet.flatten(screen.getByTestId('message-overlay-bottom').props.style),
238
246
  ).toMatchObject({
239
- height: 0,
247
+ opacity: 0,
248
+ transform: [{ scale: 0 }],
240
249
  });
241
250
  });
242
251
  });
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "9.0.0-beta.17"
2
+ "version": "9.0.0-beta.19"
3
3
  }