@momo-kits/foundation 0.163.1-beta.13 → 0.163.1-beta.15

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.
@@ -38,7 +38,10 @@ const getStackOptions = (): StackNavigationOptions => {
38
38
  headerLeft: (props: any) => <HeaderLeft {...props} />,
39
39
  headerRight: (props: any) => <HeaderRight {...props} />,
40
40
  headerTintColor: Colors.black_17,
41
- gestureEnabled: false,
41
+ /**
42
+ * swipe back for iOS only, Android keeps the hardware back button
43
+ */
44
+ gestureEnabled: Platform.OS === 'ios',
42
45
  ...TransitionPresets.SlideFromRightIOS,
43
46
  };
44
47
  };
@@ -54,9 +57,23 @@ const getModalOptions = (): StackNavigationOptions => {
54
57
  cardOverlayEnabled: true,
55
58
  animation: 'none',
56
59
  presentation: 'transparentModal',
60
+ /**
61
+ * modal & bottom sheet dismiss through their own overlay/pan gesture
62
+ */
63
+ gestureEnabled: false,
57
64
  };
58
65
  };
59
66
 
67
+ /**
68
+ * screen owns its back flow (guard popup, custom handler or no back button),
69
+ * so swipe back must not bypass it
70
+ */
71
+ const hasCustomBackHandling = (params: NavigationOptions) =>
72
+ params.preventBack !== undefined ||
73
+ params.hiddenBack === true ||
74
+ typeof params.onBackHandler === 'function' ||
75
+ typeof params.onPressLeftHeader === 'function';
76
+
60
77
  /**
61
78
  * build react-navigation options
62
79
  */
@@ -125,6 +142,13 @@ const getOptions = (
125
142
  };
126
143
  }
127
144
 
145
+ /**
146
+ * only ever turns swipe back off, screens opt in via gestureEnabled
147
+ */
148
+ if (params.gestureEnabled === undefined && hasCustomBackHandling(params)) {
149
+ options.gestureEnabled = false;
150
+ }
151
+
128
152
  return {
129
153
  ...params,
130
154
  ...options,
package/Layout/Screen.tsx CHANGED
@@ -51,13 +51,6 @@ import {
51
51
  SearchHeader,
52
52
  } from '../Application';
53
53
 
54
- /**
55
- * Scroll distance (px) over which the animated search header collapses from its
56
- * expanded to its docked state — the input range consumed by `HeaderExtendHeader`
57
- * and the settle threshold in `handleScrollEnd`.
58
- */
59
- const SEARCH_HEADER_COLLAPSE_DISTANCE = 100;
60
-
61
54
  export interface ScreenProps extends ViewProps {
62
55
  /**
63
56
  * ReactNode representing the content of the screen.
@@ -199,8 +192,8 @@ const Screen = forwardRef(
199
192
  ref: any,
200
193
  ) => {
201
194
  const screenRef = useRef<View | ScrollView>(null);
202
- const { width: widthDevice, height: heightDevice } = useWindowDimensions();
203
- const { theme } = useContext(ApplicationContext);
195
+ const { width: widthDevice } = useWindowDimensions();
196
+ const { theme, navigator } = useContext(ApplicationContext);
204
197
  const screen: any = useContext(ScreenContext);
205
198
  const insets = useSafeAreaInsets();
206
199
  const heightHeader = useHeaderHeight();
@@ -239,7 +232,7 @@ const Screen = forwardRef(
239
232
  }, [customAnimatedValue, internalShared]);
240
233
 
241
234
  const currentTint = useRef<string | undefined>(undefined);
242
-
235
+
243
236
  const isTab = !!screen?.bottomTab;
244
237
 
245
238
  let handleScroll;
@@ -658,17 +651,6 @@ const Screen = forwardRef(
658
651
  style={[Styles.flex]}
659
652
  contentContainerStyle={[
660
653
  scrollable && !Footer && !isTab && { paddingBottom: bottomInset },
661
- // The animated search header collapses as the body scrolls. When the
662
- // body is short (e.g. no search history) the ScrollView is barely
663
- // scrollable, so overscroll bounce feeds the scroll-driven animation
664
- // and the input jitters on its way up to the header. A ScrollView
665
- // frame can never exceed the window, so forcing the content to be at
666
- // least one screen plus the collapse distance guarantees the animation
667
- // always has room to complete smoothly, independent of body content.
668
- scrollable &&
669
- inputSearchProps && {
670
- minHeight: heightDevice + SEARCH_HEADER_COLLAPSE_DISTANCE,
671
- },
672
654
  scrollViewProps?.contentContainerStyle,
673
655
  ]}
674
656
  >
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.163.1-beta.13",
3
+ "version": "0.163.1-beta.15",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},