@momo-kits/foundation 0.111.1-beta.4 → 0.111.1-beta.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.
|
@@ -91,7 +91,7 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
91
91
|
* check app is favorite
|
|
92
92
|
*/
|
|
93
93
|
const checkAppIsFavorite = () =>
|
|
94
|
-
navigator?.maxApi?.dispatchFunction
|
|
94
|
+
navigator?.maxApi?.dispatchFunction(
|
|
95
95
|
'isFavoriteApp',
|
|
96
96
|
context?.code,
|
|
97
97
|
(result: boolean) => {
|
|
@@ -147,12 +147,13 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
147
147
|
screenName: currentRoute?.params?.screen?.name ?? currentRoute?.name,
|
|
148
148
|
});
|
|
149
149
|
setIsLoading(true);
|
|
150
|
-
navigator?.maxApi?.dispatchFunction
|
|
150
|
+
navigator?.maxApi?.dispatchFunction(
|
|
151
151
|
'onToolAction',
|
|
152
152
|
{
|
|
153
153
|
item: {
|
|
154
154
|
key: 'onFavorite',
|
|
155
155
|
},
|
|
156
|
+
code: context?.code,
|
|
156
157
|
},
|
|
157
158
|
({success}: {success: boolean}) => {
|
|
158
159
|
if (success) {
|
|
@@ -217,17 +218,22 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
217
218
|
screenName: currentRoute?.params?.screen?.name ?? currentRoute?.name,
|
|
218
219
|
});
|
|
219
220
|
|
|
220
|
-
navigator?.maxApi?.dispatchFunction
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
pressedTool?.
|
|
227
|
-
|
|
221
|
+
navigator?.maxApi?.dispatchFunction(
|
|
222
|
+
'showTools',
|
|
223
|
+
tools,
|
|
224
|
+
context,
|
|
225
|
+
(key: string) => {
|
|
226
|
+
for (const group of tools) {
|
|
227
|
+
const pressedTool = group?.items?.find?.(
|
|
228
|
+
(tool: Tool) => tool?.key === key
|
|
229
|
+
);
|
|
230
|
+
if (pressedTool) {
|
|
231
|
+
pressedTool?.onPress();
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
228
234
|
}
|
|
229
235
|
}
|
|
230
|
-
|
|
236
|
+
);
|
|
231
237
|
};
|
|
232
238
|
|
|
233
239
|
let iconShortcut = isFavorite ? 'pin_star_checked' : 'pin_star';
|
|
@@ -34,6 +34,7 @@ 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({});
|
|
37
38
|
|
|
38
39
|
let config: any = null;
|
|
39
40
|
try {
|
|
@@ -107,88 +108,100 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
107
108
|
const headerBackground = config?.headerBar || theme.assets?.headerBackground;
|
|
108
109
|
const headerGradient = config?.headerGradient || theme.colors?.gradient;
|
|
109
110
|
|
|
111
|
+
navigator.current.setCurrentContext = setCurrentContext;
|
|
112
|
+
|
|
110
113
|
return (
|
|
111
114
|
<SafeAreaProvider>
|
|
112
|
-
<
|
|
115
|
+
<MiniAppContext.Provider
|
|
113
116
|
value={{
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
...theme,
|
|
117
|
-
colors: {
|
|
118
|
-
...theme.colors,
|
|
119
|
-
gradient: headerGradient,
|
|
120
|
-
},
|
|
121
|
-
assets: {
|
|
122
|
-
...theme.assets,
|
|
123
|
-
headerBackground,
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
showGrid,
|
|
127
|
-
translate,
|
|
117
|
+
...context,
|
|
118
|
+
...currentContext,
|
|
128
119
|
}}>
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
...theme
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
+
},
|
|
139
133
|
},
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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;
|
|
157
169
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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>
|
|
192
205
|
</SafeAreaProvider>
|
|
193
206
|
);
|
|
194
207
|
};
|
package/Application/Navigator.ts
CHANGED
|
@@ -6,7 +6,6 @@ class Navigator {
|
|
|
6
6
|
isReady?: any;
|
|
7
7
|
maxApi?: any;
|
|
8
8
|
dismissData?: any;
|
|
9
|
-
toolkitCallback?: (key: string) => void;
|
|
10
9
|
|
|
11
10
|
constructor(navigation: any, isReady: any) {
|
|
12
11
|
this.ref = navigation;
|
|
@@ -148,11 +147,16 @@ class Navigator {
|
|
|
148
147
|
};
|
|
149
148
|
|
|
150
149
|
/**
|
|
151
|
-
* set
|
|
152
|
-
* @param
|
|
150
|
+
* set app context using for features of kit
|
|
151
|
+
* @param context
|
|
153
152
|
*/
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
setCurrentContext = (context: {
|
|
154
|
+
code?: string;
|
|
155
|
+
name?: {vi: string; en: string};
|
|
156
|
+
description?: {vi: string; en: string};
|
|
157
|
+
icon?: string;
|
|
158
|
+
}) => {
|
|
159
|
+
console.log(context);
|
|
156
160
|
};
|
|
157
161
|
}
|
|
158
162
|
|
package/Input/Input.tsx
CHANGED
package/package.json
CHANGED
package/publish.sh
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
+
npm config set registry https://registry.npmjs.org/
|
|
4
|
+
|
|
3
5
|
if [ "$1" == "stable" ]; then
|
|
4
6
|
npm version $(npm view @momo-kits/foundation@stable version)
|
|
5
7
|
npm version patch
|
|
6
|
-
npm publish --tag stable --access=public
|
|
8
|
+
npm publish --registry https://registry.npmjs.org/ --tag stable --access=public
|
|
7
9
|
elif [ "$1" == "latest" ]; then
|
|
8
10
|
npm version $(npm view @momo-kits/foundation@latest version)
|
|
9
11
|
npm version prerelease --preid=rc
|
|
10
|
-
npm publish --tag latest --access=public
|
|
12
|
+
npm publish --registry https://registry.npmjs.org/ --tag latest --access=public
|
|
11
13
|
else
|
|
12
14
|
npm version $(npm view @momo-kits/foundation@beta version)
|
|
13
15
|
npm version prerelease --preid=beta
|
|
14
|
-
npm publish --tag beta --access=public
|
|
16
|
+
npm publish --registry https://registry.npmjs.org/ --tag beta --access=public
|
|
15
17
|
fi
|
|
16
18
|
PACKAGE_NAME=$(npm pkg get name)
|
|
17
19
|
NEW_PACKAGE_VERSION=$(npm pkg get version)
|