@momo-kits/foundation 0.150.2-image.1 → 0.150.2-navigate.1

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.
@@ -14,9 +14,84 @@ import { HeaderTitleProps, NavigationOptions } from './types';
14
14
  import { Colors, Spacing } from '../Consts';
15
15
  import { Animated, Platform } from 'react-native';
16
16
  import { MiniAppContext, ScreenContext, TrackingScopeContext } from './index';
17
+ import { Easing } from 'react-native-reanimated';
17
18
 
18
19
  /**
19
- * default options for stack screen
20
+ * Custom reanimated transition specs for smoother animations
21
+ */
22
+ const customTransitionSpec = {
23
+ open: {
24
+ animation: 'timing' as const,
25
+ config: {
26
+ duration: 300,
27
+ easing: Easing.out(Easing.cubic),
28
+ },
29
+ },
30
+ close: {
31
+ animation: 'timing' as const,
32
+ config: {
33
+ duration: 250,
34
+ easing: Easing.in(Easing.cubic),
35
+ },
36
+ },
37
+ };
38
+
39
+ const customSpringTransitionSpec = {
40
+ open: {
41
+ animation: 'spring' as const,
42
+ config: {
43
+ damping: 30,
44
+ mass: 1,
45
+ stiffness: 300,
46
+ overshootClamping: false,
47
+ restDisplacementThreshold: 0.01,
48
+ restSpeedThreshold: 0.01,
49
+ },
50
+ },
51
+ close: {
52
+ animation: 'spring' as const,
53
+ config: {
54
+ damping: 35,
55
+ mass: 1,
56
+ stiffness: 400,
57
+ overshootClamping: false,
58
+ restDisplacementThreshold: 0.01,
59
+ restSpeedThreshold: 0.01,
60
+ },
61
+ },
62
+ };
63
+
64
+ /**
65
+ * Custom slide from right interpolator
66
+ */
67
+ const slideFromRightInterpolator = ({
68
+ current,
69
+ _next,
70
+ inverted,
71
+ layouts: { screen },
72
+ }: any) => {
73
+ const progress = current.progress.interpolate({
74
+ inputRange: [0, 1],
75
+ outputRange: [0, 1],
76
+ extrapolate: 'clamp',
77
+ });
78
+
79
+ return {
80
+ cardStyle: {
81
+ transform: [
82
+ {
83
+ translateX: progress.interpolate({
84
+ inputRange: [0, 1],
85
+ outputRange: inverted ? [screen.width, 0] : [-screen.width, 0],
86
+ }),
87
+ },
88
+ ],
89
+ },
90
+ };
91
+ };
92
+
93
+ /**
94
+ * default options for stack screen with reanimated transitions
20
95
  */
21
96
  const getStackOptions = (): StackNavigationOptions => {
22
97
  return {
@@ -36,7 +111,11 @@ const getStackOptions = (): StackNavigationOptions => {
36
111
  headerRight: (props: any) => <HeaderRight {...props} />,
37
112
  headerTintColor: Colors.black_17,
38
113
  gestureEnabled: false,
39
- ...TransitionPresets.SlideFromRightIOS,
114
+ transitionSpec: {
115
+ open: customTransitionSpec.open,
116
+ close: customTransitionSpec.close,
117
+ },
118
+ cardStyleInterpolator: slideFromRightInterpolator,
40
119
  };
41
120
  };
42
121
 
package/Image/index.tsx CHANGED
@@ -66,7 +66,7 @@ const Image: React.FC<ImageProps> = ({
66
66
  {...rest}
67
67
  {...{ accessibilityLabel: rest.accessibilityLabel ?? accessibilityLabel }}
68
68
  source={source}
69
- style={style}
69
+ style={[styles.container, style]}
70
70
  onProgress={() => {
71
71
  error.current = false;
72
72
  if (status !== 'loading' && loading) {
@@ -90,7 +90,7 @@ const Image: React.FC<ImageProps> = ({
90
90
  error.current = true;
91
91
  }}
92
92
  >
93
- <View style={styles.container}>{renderContent()}</View>
93
+ {renderContent()}
94
94
  </FastImage>
95
95
  );
96
96
  };
package/Image/styles.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { StyleSheet } from 'react-native';
1
+ import {StyleSheet} from 'react-native';
2
2
 
3
3
  export default StyleSheet.create({
4
- container: { zIndex: -1, flex: 1 },
5
- });
4
+ container: {},
5
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.150.2-image.1",
3
+ "version": "0.150.2-navigate.1",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},