@momo-kits/foundation 0.163.1-beta.14 → 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
@@ -25,12 +25,7 @@ import {
25
25
  View,
26
26
  ViewProps,
27
27
  } from 'react-native';
28
- import Reanimated, {
29
- useAnimatedKeyboard,
30
- useAnimatedStyle,
31
- useSharedValue,
32
- withTiming,
33
- } from 'react-native-reanimated';
28
+ import { useSharedValue, withTiming } from 'react-native-reanimated';
34
29
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
35
30
  import { ApplicationContext, ScreenContext } from '../Context';
36
31
  import Navigation from '../Application/Navigation';
@@ -203,24 +198,6 @@ const Screen = forwardRef(
203
198
  const insets = useSafeAreaInsets();
204
199
  const heightHeader = useHeaderHeight();
205
200
 
206
- /**
207
- * On Android, the native root view already pads for the full IME inset
208
- * (which itself includes the navigation bar's height) as soon as the
209
- * keyboard shows. `useSafeAreaInsets()`'s own bottom recompute is JS-thread
210
- * work (its own native listener, then a bridge crossing, then a React
211
- * re-render) and always lands at least one frame after that native padding
212
- * change, so any JS-driven correction (state + re-render, regardless of
213
- * which event triggers it) has the same lag — the nav bar height gets
214
- * counted twice for that window, visible as the footer overshooting
215
- * before settling back down.
216
- * `useAnimatedKeyboard()` sidesteps this: its worklet callback updates a
217
- * shared value directly from the same native WindowInsetsAnimation
218
- * callback driving the keyboard's own motion, on the UI thread, with no
219
- * bridge crossing — so the footer's compensating style below can react
220
- * in the same frame instead of a JS tick later.
221
- */
222
- const keyboard = useAnimatedKeyboard();
223
-
224
201
  /**
225
202
  * Dual animation source:
226
203
  * - `animatedValue` is a react-native `Animated.Value` driven natively by the
@@ -267,25 +244,6 @@ const Screen = forwardRef(
267
244
  keyboardOffset = -bottomInset;
268
245
  }
269
246
 
270
- /**
271
- * Android only: while the keyboard is up, MainActivity's own native inset
272
- * listener already accounts for the full space it needs (keyboard height
273
- * plus nav bar) on the root view, so the footer here should only add its
274
- * usual Spacing.S gap — not `bottomInset` on top, which would double-count
275
- * the nav bar for as long as the keyboard is visible.
276
- *
277
- * `isAndroid` is read here (not inside the worklet) because referencing
278
- * `Platform.OS` directly inside `useAnimatedStyle` captures the whole
279
- * `Platform` module into the worklet closure — Reanimated then fails
280
- * trying to serialize that module object for the UI thread.
281
- */
282
- const isAndroid = Platform.OS === 'android';
283
- const footerAnimatedStyle = useAnimatedStyle(() => {
284
- const paddingBottom =
285
- isAndroid && keyboard.height.value > 0 ? Spacing.S : bottomInset + Spacing.S;
286
- return { paddingBottom };
287
- });
288
-
289
247
  /**
290
248
  * inject params for screen tracking
291
249
  */
@@ -712,15 +670,17 @@ const Screen = forwardRef(
712
670
  )}
713
671
 
714
672
  {Footer && (
715
- <Reanimated.View
673
+ <View
716
674
  style={[
717
675
  styles.shadow,
718
- { backgroundColor: theme.colors.background.surface },
719
- footerAnimatedStyle,
676
+ {
677
+ paddingBottom: bottomInset + Spacing.S,
678
+ backgroundColor: theme.colors.background.surface,
679
+ },
720
680
  ]}
721
681
  >
722
682
  <Section>{Footer}</Section>
723
- </Reanimated.View>
683
+ </View>
724
684
  )}
725
685
  </KeyboardAvoidingView>
726
686
  </View>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.163.1-beta.14",
3
+ "version": "0.163.1-beta.15",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},