@momo-kits/foundation 0.81.41-beta.3 → 0.81.41-beta.8
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.
- package/Application/Components.tsx +19 -29
- package/Application/Navigator.ts +0 -5
- package/Application/types.ts +1 -0
- package/Application/utils.tsx +15 -0
- package/package.json +1 -1
|
@@ -343,7 +343,7 @@ const HeaderRightAction: React.FC<any> = ({children, ...restProps}) => {
|
|
|
343
343
|
return <View style={styles.headerRightButton}>{renderAction()}</View>;
|
|
344
344
|
};
|
|
345
345
|
|
|
346
|
-
const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
|
|
346
|
+
const HeaderToolkitAction: React.FC<any> = ({tintColor, pinnedTool}) => {
|
|
347
347
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
348
348
|
const [toolConfig, setToolConfig] = useState<any>();
|
|
349
349
|
const {appCode, onAction} = toolConfig ?? {};
|
|
@@ -357,29 +357,21 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
|
|
|
357
357
|
if (navigator?.toolkitConfig) {
|
|
358
358
|
setToolConfig(navigator?.toolkitConfig);
|
|
359
359
|
} else {
|
|
360
|
-
navigator?.requestApi('
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
...config?.toolkitConfig?.customTools,
|
|
376
|
-
...config?.toolkitFeatureConfig,
|
|
377
|
-
],
|
|
378
|
-
appCode: config?.appCode,
|
|
379
|
-
});
|
|
380
|
-
},
|
|
381
|
-
);
|
|
382
|
-
}
|
|
360
|
+
navigator?.requestApi('getToolkitConfig', [undefined], (config: any) => {
|
|
361
|
+
navigator.toolkitConfig = {
|
|
362
|
+
configs: [
|
|
363
|
+
...config?.miniappTools?.customTools,
|
|
364
|
+
...config?.defaultTools,
|
|
365
|
+
],
|
|
366
|
+
appCode: config?.appCode,
|
|
367
|
+
};
|
|
368
|
+
setToolConfig({
|
|
369
|
+
configs: [
|
|
370
|
+
...config?.miniappTools?.customTools,
|
|
371
|
+
...config?.defaultTools,
|
|
372
|
+
],
|
|
373
|
+
appCode: config?.appCode,
|
|
374
|
+
});
|
|
383
375
|
});
|
|
384
376
|
}
|
|
385
377
|
}, []);
|
|
@@ -440,18 +432,16 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
|
|
|
440
432
|
};
|
|
441
433
|
|
|
442
434
|
const renderPinnedTool = () => {
|
|
443
|
-
const pinTool = toolConfig?.configs?.find(
|
|
444
|
-
(i: any) => i.key === navigator?.pinnedTool,
|
|
445
|
-
);
|
|
435
|
+
const pinTool = toolConfig?.configs?.find((i: any) => i.key === pinnedTool);
|
|
446
436
|
const {icon} = pinTool || '';
|
|
447
|
-
if (pinTool &&
|
|
437
|
+
if (pinTool && pinnedTool)
|
|
448
438
|
return (
|
|
449
439
|
<NavigationButton
|
|
450
440
|
accessibilityLabel={'UtilityTool'}
|
|
451
441
|
icon={icon as string}
|
|
452
442
|
tintColor={tintColor}
|
|
453
443
|
onPress={() => {
|
|
454
|
-
navigator?.toolkitCallback?.(
|
|
444
|
+
navigator?.toolkitCallback?.(pinnedTool);
|
|
455
445
|
}}
|
|
456
446
|
/>
|
|
457
447
|
);
|
package/Application/Navigator.ts
CHANGED
|
@@ -13,7 +13,6 @@ class Navigator {
|
|
|
13
13
|
maxApi?: any;
|
|
14
14
|
trackingInfo?: TrackingInfo;
|
|
15
15
|
dismissData?: any;
|
|
16
|
-
pinnedTool?: string;
|
|
17
16
|
toolkitCallback?: (item: any) => void;
|
|
18
17
|
|
|
19
18
|
constructor(navigation: any) {
|
|
@@ -110,10 +109,6 @@ class Navigator {
|
|
|
110
109
|
}
|
|
111
110
|
};
|
|
112
111
|
|
|
113
|
-
setPinnedTool = (key: string) => {
|
|
114
|
-
this.pinnedTool = key;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
112
|
setToolkitCallback = (
|
|
118
113
|
callback: (item: {key: string; action: string}) => void,
|
|
119
114
|
) => {
|
package/Application/types.ts
CHANGED
|
@@ -138,6 +138,7 @@ export interface NavigationOptions extends StackNavigationOptions {
|
|
|
138
138
|
surface?: boolean;
|
|
139
139
|
hiddenBack?: boolean;
|
|
140
140
|
customTitle?: TitleCustomProps;
|
|
141
|
+
pinnedTool?: string;
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
export interface HeaderBackProps extends NavigationButtonProps {
|
package/Application/utils.tsx
CHANGED
|
@@ -126,6 +126,21 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
if (params.pinnedTool) {
|
|
130
|
+
options = {
|
|
131
|
+
...options,
|
|
132
|
+
headerRight: (props: any) => {
|
|
133
|
+
return (
|
|
134
|
+
<HeaderToolkitAction
|
|
135
|
+
preventBack={params.preventBack ? params.preventBack : null}
|
|
136
|
+
pinnedTool={params.pinnedTool}
|
|
137
|
+
{...props}
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
129
144
|
return {
|
|
130
145
|
...params,
|
|
131
146
|
...options,
|