@momo-kits/foundation 0.111.1-optimize.5 → 0.111.1-optimize.7

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.
@@ -19,6 +19,32 @@ const BackgroundImageView: FC<BackgroundImageViewProps> = ({
19
19
  opacityBackground,
20
20
  }) => {
21
21
  const {theme} = useContext(ApplicationContext);
22
+ if (Platform.OS === 'android') {
23
+ return (
24
+ <Animated.View
25
+ style={[
26
+ useShadowHeader ? styles.shadowHeader : styles.dividerHeader,
27
+ {
28
+ position: 'absolute',
29
+ width: '100%',
30
+ zIndex: 1,
31
+ height: heightHeader,
32
+ backgroundColor: theme.colors.background.surface,
33
+ opacity: opacityBackground,
34
+ overflow: 'hidden',
35
+ },
36
+ ]}>
37
+ {headerBackground && (
38
+ <Image
39
+ style={styles.headerBackground}
40
+ source={{uri: headerBackground}}
41
+ loading={false}
42
+ />
43
+ )}
44
+ </Animated.View>
45
+ );
46
+ }
47
+
22
48
  return (
23
49
  <>
24
50
  <Animated.View
@@ -31,10 +57,21 @@ const BackgroundImageView: FC<BackgroundImageViewProps> = ({
31
57
  height: heightHeader,
32
58
  backgroundColor: theme.colors.background.surface,
33
59
  opacity: opacityBackground,
34
- overflow: Platform.OS === 'android' ? 'hidden' : 'visible',
60
+ },
61
+ ]}
62
+ />
63
+ <Animated.View
64
+ style={[
65
+ {
66
+ position: 'absolute',
67
+ width: '100%',
68
+ zIndex: 1,
69
+ height: heightHeader,
70
+ opacity: opacityBackground,
71
+ overflow: 'hidden',
35
72
  },
36
73
  ]}>
37
- {Platform.OS === 'android' && headerBackground && (
74
+ {headerBackground && (
38
75
  <Image
39
76
  style={styles.headerBackground}
40
77
  source={{uri: headerBackground}}
@@ -42,26 +79,6 @@ const BackgroundImageView: FC<BackgroundImageViewProps> = ({
42
79
  />
43
80
  )}
44
81
  </Animated.View>
45
- {Platform.OS === 'ios' && (
46
- <Animated.View
47
- style={[
48
- {
49
- position: 'absolute',
50
- width: '100%',
51
- zIndex: 1,
52
- height: heightHeader,
53
- overflow: 'hidden',
54
- },
55
- ]}>
56
- {headerBackground && (
57
- <Image
58
- style={styles.headerBackground}
59
- source={{uri: headerBackground}}
60
- loading={false}
61
- />
62
- )}
63
- </Animated.View>
64
- )}
65
82
  </>
66
83
  );
67
84
  };
@@ -69,14 +69,14 @@ const styles = StyleSheet.create({
69
69
  overflow: 'hidden',
70
70
  },
71
71
  extendedHeader: {
72
- aspectRatio: 2.43,
72
+ aspectRatio: 375 / 154,
73
73
  position: 'absolute',
74
74
  width: '100%',
75
75
  },
76
76
  headerBackground: {
77
77
  width: '100%',
78
78
  position: 'absolute',
79
- aspectRatio: 375 / 152,
79
+ aspectRatio: 375 / 154,
80
80
  },
81
81
  });
82
82
 
@@ -204,7 +204,7 @@ const styles = StyleSheet.create({
204
204
  aspectRatio: 375 / 154,
205
205
  },
206
206
  extendedHeader: {
207
- aspectRatio: 2.43,
207
+ aspectRatio: 375 / 154,
208
208
  position: 'absolute',
209
209
  width: '100%',
210
210
  },
@@ -34,7 +34,6 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
34
34
  const isReady = useRef(false);
35
35
  const navigator = useRef(new Navigator(navigationRef, isReady));
36
36
  const [showGrid, setShowGrid] = useState(false);
37
- const [currentContext, setCurrentContext] = useState({});
38
37
 
39
38
  let config: any = null;
40
39
  try {
@@ -105,103 +104,91 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
105
104
  });
106
105
  };
107
106
 
108
- const headerBackground = config?.headerBar || theme.assets?.headerBackground;
107
+ const headerBackground = theme.assets?.headerBackground || config?.headerBar;
109
108
  const headerGradient = config?.headerGradient || theme.colors?.gradient;
110
109
 
111
- navigator.current.setCurrentContext = setCurrentContext;
112
-
113
110
  return (
114
111
  <SafeAreaProvider>
115
- <MiniAppContext.Provider
112
+ <ApplicationContext.Provider
116
113
  value={{
117
- ...context,
118
- ...currentContext,
114
+ navigator: navigator.current,
115
+ theme: {
116
+ ...theme,
117
+ colors: {
118
+ ...theme.colors,
119
+ gradient: headerGradient,
120
+ },
121
+ assets: {
122
+ ...theme.assets,
123
+ headerBackground,
124
+ },
125
+ },
126
+ showGrid,
127
+ translate,
119
128
  }}>
120
- <ApplicationContext.Provider
121
- value={{
122
- navigator: navigator.current,
123
- theme: {
124
- ...theme,
125
- colors: {
126
- ...theme.colors,
127
- gradient: headerGradient,
128
- },
129
- assets: {
130
- ...theme.assets,
131
- headerBackground,
132
- },
129
+ <ReactNavigationContainer
130
+ theme={{
131
+ ...theme,
132
+ colors: {
133
+ ...theme.colors,
134
+ background: theme.colors.background.default,
135
+ card: theme.colors.background.surface,
136
+ text: theme.colors.text.default,
137
+ border: theme.colors.border.default,
138
+ notification: theme.colors.error.primary,
133
139
  },
134
- showGrid,
135
- translate,
136
- }}>
137
- <ReactNavigationContainer
138
- theme={{
139
- ...theme,
140
- colors: {
141
- ...theme.colors,
142
- background: theme.colors.background.default,
143
- card: theme.colors.background.surface,
144
- text: theme.colors.text.default,
145
- border: theme.colors.border.default,
146
- notification: theme.colors.error.primary,
147
- },
148
- }}
149
- ref={navigationRef}
150
- onReady={() => {
151
- isReady.current = true;
152
- routes.current = navigationRef.current?.getRootState?.()?.routes;
153
- maxApi?.getDataObserver('CURRENT_SCREEN', (data: any) => {
154
- onScreenNavigated(data?.screenName, screen?.name, 'push');
155
- maxApi?.setObserver('CURRENT_SCREEN', {
156
- screenName: screen?.name,
157
- });
158
- });
159
- }}
160
- onStateChange={state => {
161
- const lastedRoute: any =
162
- state?.routes?.[state?.routes?.length - 1];
163
- const oldRoute: any =
164
- routes.current?.[routes.current?.length - 1];
165
- const lasted = lastedRoute?.params?.screen;
166
- const previous = oldRoute?.params?.screen;
167
- const preScreenName = previous?.name ?? previous?.type?.name;
168
- const screenName = lasted?.name ?? lasted?.type?.name;
140
+ }}
141
+ ref={navigationRef}
142
+ onReady={() => {
143
+ isReady.current = true;
144
+ routes.current = navigationRef.current?.getRootState?.()?.routes;
145
+ maxApi?.getDataObserver('CURRENT_SCREEN', (data: any) => {
146
+ onScreenNavigated(data?.screenName, screen?.name, 'push');
147
+ maxApi?.setObserver('CURRENT_SCREEN', {screenName: screen?.name});
148
+ });
149
+ }}
150
+ onStateChange={state => {
151
+ const lastedRoute: any = state?.routes?.[state?.routes?.length - 1];
152
+ const oldRoute: any = routes.current?.[routes.current?.length - 1];
153
+ const lasted = lastedRoute?.params?.screen;
154
+ const previous = oldRoute?.params?.screen;
155
+ const preScreenName = previous?.name ?? previous?.type?.name;
156
+ const screenName = lasted?.name ?? lasted?.type?.name;
169
157
 
170
- let action = 'push';
171
- if (routes.current?.length > (state?.routes?.length ?? 0)) {
172
- action = 'back';
173
- }
174
- onScreenNavigated(preScreenName, screenName, action);
175
- maxApi?.setObserver('CURRENT_SCREEN', {screenName});
176
- routes.current = state?.routes;
177
- }}
178
- independent={true}>
179
- <Stack.Navigator initialRouteName="Stack" headerMode="screen">
180
- <Stack.Screen
181
- name="Stack"
182
- component={StackScreen}
183
- initialParams={{screen, initialParams}}
184
- options={{
185
- ...getStackOptions(),
186
- ...(options as StackNavigationOptions),
187
- }}
188
- />
189
- <Stack.Screen
190
- name="Dialog"
191
- component={StackScreen}
192
- options={getDialogOptions()}
193
- initialParams={{screen}}
194
- />
195
- <Stack.Screen
196
- name="Modal"
197
- component={ModalScreen}
198
- options={getModalOptions()}
199
- initialParams={{screen}}
200
- />
201
- </Stack.Navigator>
202
- </ReactNavigationContainer>
203
- </ApplicationContext.Provider>
204
- </MiniAppContext.Provider>
158
+ let action = 'push';
159
+ if (routes.current?.length > (state?.routes?.length ?? 0)) {
160
+ action = 'back';
161
+ }
162
+ onScreenNavigated(preScreenName, screenName, action);
163
+ maxApi?.setObserver('CURRENT_SCREEN', {screenName});
164
+ routes.current = state?.routes;
165
+ }}
166
+ independent={true}>
167
+ <Stack.Navigator initialRouteName="Stack" headerMode="screen">
168
+ <Stack.Screen
169
+ name="Stack"
170
+ component={StackScreen}
171
+ initialParams={{screen, initialParams}}
172
+ options={{
173
+ ...getStackOptions(),
174
+ ...(options as StackNavigationOptions),
175
+ }}
176
+ />
177
+ <Stack.Screen
178
+ name="Dialog"
179
+ component={StackScreen}
180
+ options={getDialogOptions()}
181
+ initialParams={{screen}}
182
+ />
183
+ <Stack.Screen
184
+ name="Modal"
185
+ component={ModalScreen}
186
+ options={getModalOptions()}
187
+ initialParams={{screen}}
188
+ />
189
+ </Stack.Navigator>
190
+ </ReactNavigationContainer>
191
+ </ApplicationContext.Provider>
205
192
  </SafeAreaProvider>
206
193
  );
207
194
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.111.1-optimize.5",
3
+ "version": "0.111.1-optimize.7",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},