@momo-kits/foundation 0.165.1-beta.2 → 0.165.1-beta.4

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.
@@ -8,6 +8,7 @@ import { createStackNavigator } from '@react-navigation/stack';
8
8
  import React, { useContext, useEffect, useLayoutEffect } from 'react';
9
9
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
10
10
  import {
11
+ NativeModules,
11
12
  Platform,
12
13
  StatusBar,
13
14
  StyleSheet,
@@ -24,12 +25,7 @@ import { Icon } from '../../Icon';
24
25
  import { exportFontFamily, Text } from '../../Text';
25
26
  import StackScreen from '../StackScreen';
26
27
  import { BottomTabProps } from '../types';
27
- import {
28
- getOptions,
29
- getStackOptions,
30
- useAppState,
31
- useFloatingArrowBack,
32
- } from '../utils';
28
+ import { getOptions, getStackOptions, useAppState } from '../utils';
33
29
  import BottomTabBar from './BottomTabBar';
34
30
  import { ApplicationContext, MiniAppContext } from '../../Context';
35
31
 
@@ -217,7 +213,6 @@ const BottomTab: React.FC<BottomTabProps> = ({
217
213
  const indicatorAnimated = useSharedValue(0);
218
214
  const activeIndex = React.useRef(initialIndex > 0 ? initialIndex : 0);
219
215
  const itemWidth = dimensions.width / tabs.length;
220
- const reportFloatingArrowBack = useFloatingArrowBack();
221
216
 
222
217
  const indicatorStyle = useAnimatedStyle(() => ({
223
218
  width: itemWidth,
@@ -238,30 +233,18 @@ const BottomTab: React.FC<BottomTabProps> = ({
238
233
  });
239
234
  }, [itemWidth, indicatorAnimated]);
240
235
 
241
- // `initialRouteName` can start on a later tab, so report where we actually begin instead of
242
- // waiting for the first tab switch to correct it.
243
- useEffect(() => {
244
- reportFloatingArrowBack(activeIndex.current !== 0);
245
- }, [reportFloatingArrowBack]);
246
-
247
- /**
248
- * Two halves of one decision, so they are set together.
249
- *
250
- * On the first tab the stack card owns the swipe and runs the usual transition. On any other
251
- * tab it must not: every tab lives inside that single card, and the gesture pops it with
252
- * `StackActions.pop()` aimed at the stack rather than a back the tab router could claim — so
253
- * the swipe would take all the tabs with it instead of returning to the first one. Turning the
254
- * card gesture off there would leave the swipe doing nothing, so hand it to the host's
255
- * floating-arrow interaction instead.
256
- */
257
- const syncBackOwnership = (index: number) => {
258
- const isFirstTab = index === 0;
259
-
260
- navigation?.setOptions({
261
- gestureEnabled: Platform.OS === 'ios' && isFirstTab,
262
- });
263
- reportFloatingArrowBack(!isFirstTab);
264
- };
236
+ // TEMP: commented out to test whether the blur reset is needed on a real host.
237
+ // Without it, pushing a screen from a tab other than the first leaves the flag true, so that
238
+ // pushed screen gets the host floating-arrow instead of its own card swipe-back.
239
+ // useFocusEffect(
240
+ // React.useCallback(() => {
241
+ // NativeModules?.MiniAppModule?.setShouldUseFloatingArrowBack?.(
242
+ // activeIndex.current !== 0,
243
+ // );
244
+ // return () =>
245
+ // NativeModules?.MiniAppModule?.setShouldUseFloatingArrowBack?.(false);
246
+ // }, []),
247
+ // );
265
248
 
266
249
  const onFocus = (e: any) => {
267
250
  activeIndex.current = tabs.findIndex(i => e.target.includes(i.name));
@@ -269,7 +252,11 @@ const BottomTab: React.FC<BottomTabProps> = ({
269
252
  duration: 200,
270
253
  });
271
254
 
272
- syncBackOwnership(activeIndex.current);
255
+ const isFirstTab = activeIndex.current === 0;
256
+ navigation?.setOptions({
257
+ gestureEnabled: Platform.OS === 'ios' && isFirstTab,
258
+ });
259
+ NativeModules?.MiniAppModule?.setShouldUseFloatingArrowBack?.(!isFirstTab);
273
260
  };
274
261
 
275
262
  const handler: {
@@ -334,45 +334,6 @@ const useNativeCanGoBack = () => {
334
334
  );
335
335
  };
336
336
 
337
- /**
338
- * Hands the swipe back to the host's floating-arrow interaction while a bottom tab other than
339
- * the first one is showing.
340
- *
341
- * The whole tab navigator lives inside a single stack card, and the card gesture pops that card
342
- * through `StackActions.pop()` aimed at the stack — it never dispatches a back the tab router
343
- * could claim. So on tab 2 a swipe would take all four tabs with it instead of returning to tab
344
- * 1. The host already owns an interaction for exactly this, so report the state and let it run.
345
- *
346
- * Reports `false` on unmount: the flag lives on the host and would otherwise outlive the tabs
347
- * that asked for it.
348
- */
349
- const useFloatingArrowBack = () => {
350
- const lastValue = useRef<boolean | undefined>(undefined);
351
-
352
- const report = useCallback((shouldUse: boolean) => {
353
- if (lastValue.current === shouldUse) {
354
- return;
355
- }
356
-
357
- const setShouldUseFloatingArrowBack =
358
- NativeModules?.MiniAppModule?.setShouldUseFloatingArrowBack;
359
- if (typeof setShouldUseFloatingArrowBack !== 'function') {
360
- return;
361
- }
362
-
363
- lastValue.current = shouldUse;
364
- try {
365
- setShouldUseFloatingArrowBack(shouldUse);
366
- } catch (error) {
367
- console.warn('[BottomTab] setShouldUseFloatingArrowBack failed:', error);
368
- }
369
- }, []);
370
-
371
- useEffect(() => () => report(false), [report]);
372
-
373
- return report;
374
- };
375
-
376
337
  /**
377
338
  * Union of the two animation runtimes an internal foundation component might
378
339
  * receive. Public Screen props still accept React Native Animated.Value only;
@@ -524,7 +485,6 @@ export {
524
485
  useComponentId,
525
486
  useAppState,
526
487
  useNativeCanGoBack,
527
- useFloatingArrowBack,
528
488
  useNormalizedSharedValue,
529
489
  SwipeBackHaptic,
530
490
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.165.1-beta.2",
3
+ "version": "0.165.1-beta.4",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},