@momo-kits/foundation 0.81.41-beta.5 → 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.
@@ -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('getToolkit', [undefined], (result: boolean) => {
361
- if (result) {
362
- navigator?.requestApi(
363
- 'getToolkitConfig',
364
- [undefined],
365
- (config: any) => {
366
- navigator.toolkitConfig = {
367
- configs: [
368
- ...config?.toolkitConfig?.customTools,
369
- ...config?.toolkitFeatureConfig,
370
- ],
371
- appCode: config?.appCode,
372
- };
373
- setToolConfig({
374
- configs: [
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 && navigator?.pinnedTool)
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?.(navigator?.pinnedTool);
444
+ navigator?.toolkitCallback?.(pinnedTool);
455
445
  }}
456
446
  />
457
447
  );
@@ -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
  ) => {
@@ -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 {
@@ -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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.81.41-beta.5",
3
+ "version": "0.81.41-beta.8",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {