@momo-kits/foundation 0.164.1-beta.10 → 0.164.1-beta.11

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.
@@ -153,7 +153,7 @@ const TabScreen: React.FC<any> = ({ route, navigation }) => {
153
153
  initialParams,
154
154
  bottomTab: 'nested',
155
155
  }}
156
- options={{ ...getStackOptions({ swipeBack: false }) }}
156
+ options={{ ...getStackOptions({ gestureEnabled: false }) }}
157
157
  />
158
158
  </Stack.Navigator>
159
159
  </Animated.View>
@@ -188,7 +188,7 @@ const TabScreen: React.FC<any> = ({ route, navigation }) => {
188
188
  initialParams,
189
189
  bottomTab: 'default',
190
190
  }}
191
- options={{ ...getStackOptions({ swipeBack: false }), ...options }}
191
+ options={{ ...getStackOptions({ gestureEnabled: false }), ...options }}
192
192
  />
193
193
  </Stack.Navigator>
194
194
  </NavigationContainer>
@@ -59,9 +59,9 @@ const forStackTransitionWithOverlay = (
59
59
  /**
60
60
  * default options for stack screen
61
61
  */
62
- const getStackOptions = ({
63
- swipeBack = true,
64
- }: { swipeBack?: boolean } = {}): StackNavigationOptions => {
62
+ const getStackOptions = (
63
+ options: StackNavigationOptions,
64
+ ): StackNavigationOptions => {
65
65
  const base: StackNavigationOptions = {
66
66
  headerTitleAlign: 'left',
67
67
  headerTitle: props => <HeaderTitle {...props} />,
@@ -80,24 +80,9 @@ const getStackOptions = ({
80
80
  headerTintColor: Colors.black_17,
81
81
  };
82
82
 
83
- /**
84
- * A bottom tab stack holds a single route, so the card transition never runs and
85
- * `CardContainer` pins `gestureEnabled` to false at index 0 regardless. What does bite is
86
- * `cardOverlayEnabled`: `current.progress` rests at 1, so the overlay would sit at its full
87
- * 0.6 forever instead of only during a push, tinting any tab screen that paints no
88
- * background of its own. This branch is the option set from before swipe back, unchanged.
89
- */
90
- if (!swipeBack) {
91
- return {
92
- ...base,
93
- gestureEnabled: false,
94
- ...TransitionPresets.SlideFromRightIOS,
95
- };
96
- }
97
-
98
83
  return {
99
84
  ...base,
100
- gestureEnabled: Platform.OS === 'ios',
85
+ ...options,
101
86
  ...TransitionPresets.SlideFromRightIOS,
102
87
  cardStyleInterpolator: forStackTransitionWithOverlay,
103
88
  cardOverlayEnabled: true,
@@ -332,36 +317,26 @@ const getStackDepth = (
332
317
  const useNativeCanGoBack = () => {
333
318
  const lastValue = useRef<boolean | undefined>(undefined);
334
319
 
335
- const report = useCallback((canDismiss: boolean) => {
336
- if (lastValue.current === canDismiss) {
337
- return;
338
- }
339
-
340
- const setCanGoBack = NativeModules?.MiniAppModule?.setCanGoBack;
341
- if (typeof setCanGoBack !== 'function') {
342
- return;
343
- }
344
-
345
- lastValue.current = canDismiss;
346
- try {
347
- setCanGoBack(canDismiss);
348
- } catch (error) {
349
- console.warn('[NavigationContainer] setCanGoBack failed:', error);
350
- }
351
- }, []);
320
+ return useCallback(
321
+ (state?: NavigationState | PartialState<NavigationState>) => {
322
+ const canDismiss = getStackDepth(state) === 0;
323
+ if (lastValue.current === canDismiss) {
324
+ return;
325
+ }
352
326
 
353
- /**
354
- * The flag lives on the host, not in this tree, so leaving it at `false` on unmount
355
- * strands every mini app opened afterwards: the host keeps believing react-navigation
356
- * still has screens to pop, and goes on routing back into a container that is gone.
357
- * Hand ownership back on the way out.
358
- */
359
- useEffect(() => () => report(true), [report]);
327
+ const setCanGoBack = NativeModules?.MiniAppModule?.setCanGoBack;
328
+ if (typeof setCanGoBack !== 'function') {
329
+ return;
330
+ }
360
331
 
361
- return useCallback(
362
- (state?: NavigationState | PartialState<NavigationState>) =>
363
- report(getStackDepth(state) === 0),
364
- [report],
332
+ lastValue.current = canDismiss;
333
+ try {
334
+ setCanGoBack(canDismiss);
335
+ } catch (error) {
336
+ console.warn('[NavigationContainer] setCanGoBack failed:', error);
337
+ }
338
+ },
339
+ [],
365
340
  );
366
341
  };
367
342
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.164.1-beta.10",
3
+ "version": "0.164.1-beta.11",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},