@momo-kits/foundation 0.81.41-beta.9 → 0.81.42

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.
@@ -347,14 +347,10 @@ const HeaderRightAction: React.FC<any> = ({children, ...restProps}) => {
347
347
  return <View style={styles.headerRightButton}>{renderAction()}</View>;
348
348
  };
349
349
 
350
- const HeaderToolkitAction: React.FC<any> = ({
351
- tintColor,
352
- pinnedTool,
353
- preventBack,
354
- }) => {
350
+ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
355
351
  const {theme, navigator} = useContext(ApplicationContext);
356
- const [toolConfig, setToolConfig] = useState<any>();
357
- const {appCode, onAction} = toolConfig ?? {};
352
+ const [toolConfig, setToolConfig] = useState<HeaderToolkitProps>();
353
+ const {appCode, hidden, type, onAction} = toolConfig ?? {};
358
354
 
359
355
  let backgroundColor;
360
356
  if (tintColor != Colors.black_01) {
@@ -365,21 +361,20 @@ const HeaderToolkitAction: React.FC<any> = ({
365
361
  if (navigator?.toolkitConfig) {
366
362
  setToolConfig(navigator?.toolkitConfig);
367
363
  } else {
368
- navigator?.requestApi('getToolkitConfig', [undefined], (config: any) => {
369
- navigator.toolkitConfig = {
370
- configs: [
371
- ...config?.miniappTools?.customTools,
372
- ...config?.defaultTools,
373
- ],
374
- appCode: config?.appCode,
375
- };
376
- setToolConfig({
377
- configs: [
378
- ...config?.miniappTools?.customTools,
379
- ...config?.defaultTools,
380
- ],
381
- appCode: config?.appCode,
382
- });
364
+ navigator?.requestApi('getToolkit', [undefined], (result: boolean) => {
365
+ if (result) {
366
+ navigator?.requestApi(
367
+ 'getToolkitConfig',
368
+ [undefined],
369
+ (config: any) => {
370
+ navigator.toolkitConfig = {
371
+ ...config?.utilityToolConfig,
372
+ appCode: config?.appCode,
373
+ };
374
+ setToolConfig(navigator?.toolkitConfig);
375
+ },
376
+ );
377
+ }
383
378
  });
384
379
  }
385
380
  }, []);
@@ -422,59 +417,39 @@ const HeaderToolkitAction: React.FC<any> = ({
422
417
  };
423
418
  }, [appCode]);
424
419
 
420
+ const onUtilityTool = () => {
421
+ onAction?.('onUtilityTool');
422
+ navigator?.requestApi(type, undefined, undefined);
423
+ };
424
+
425
425
  const onMore = () => {
426
426
  onAction?.('onMore');
427
- navigator?.requestApi(
428
- 'showTools',
429
- [toolConfig],
430
- (res: {item: {action?: string; key: string}}) => {
431
- const {item} = res;
432
- navigator?.toolkitCallback?.(item);
433
- },
434
- );
427
+ navigator?.requestApi('showToolkit', [toolConfig], undefined);
435
428
  };
436
429
 
437
430
  const onClose = () => {
438
- if (preventBack) {
439
- navigator?.showModal({
440
- screen: () => (
441
- <PopupNotify
442
- {...preventBack}
443
- primary={{
444
- title: preventBack.primary.title,
445
- onPress: () => {
446
- preventBack?.primary.onPress();
447
- navigator?.requestApi('dismiss', undefined, undefined);
448
- },
449
- }}
450
- />
451
- ),
452
- });
453
- } else {
454
- navigator?.requestApi('dismiss', undefined, undefined);
455
- }
431
+ onAction?.('onClose');
432
+ navigator?.requestApi('dismiss', undefined, undefined);
456
433
  };
457
434
 
458
- const renderPinnedTool = () => {
459
- const pinTool = toolConfig?.configs?.find((i: any) => i.key === pinnedTool);
460
- const {icon} = pinTool || '';
461
- if (pinTool && pinnedTool)
435
+ const renderUtilityTool = () => {
436
+ if (hidden === false) {
462
437
  return (
463
438
  <NavigationButton
464
439
  accessibilityLabel={'UtilityTool'}
465
- icon={icon as string}
440
+ icon={type as string}
466
441
  tintColor={tintColor}
467
- onPress={() => {
468
- navigator?.toolkitCallback?.(pinnedTool);
469
- }}
442
+ onPress={onUtilityTool}
470
443
  />
471
444
  );
445
+ }
446
+ return null;
472
447
  };
473
448
 
474
449
  if (toolConfig) {
475
450
  return (
476
451
  <View style={styles.headerRightButton}>
477
- {renderPinnedTool()}
452
+ {renderUtilityTool()}
478
453
  <View
479
454
  style={[
480
455
  styles.toolkitContainer,
@@ -13,7 +13,6 @@ class Navigator {
13
13
  maxApi?: any;
14
14
  trackingInfo?: TrackingInfo;
15
15
  dismissData?: any;
16
- toolkitCallback?: (item: any) => void;
17
16
 
18
17
  constructor(navigation: any) {
19
18
  this.ref = navigation;
@@ -122,12 +121,6 @@ class Navigator {
122
121
  this.maxApi[func]?.(...args, callback);
123
122
  }
124
123
  };
125
-
126
- setToolkitCallback = (
127
- callback: (item: {key: string; action: string}) => void,
128
- ) => {
129
- this.toolkitCallback = callback;
130
- };
131
124
  }
132
125
 
133
126
  export default Navigator;
@@ -138,7 +138,6 @@ export interface NavigationOptions extends StackNavigationOptions {
138
138
  surface?: boolean;
139
139
  hiddenBack?: boolean;
140
140
  customTitle?: TitleCustomProps;
141
- pinnedTool?: string;
142
141
  }
143
142
 
144
143
  export interface HeaderBackProps extends NavigationButtonProps {
@@ -167,7 +166,9 @@ export type TitleCustomProps = {
167
166
  export type HeaderToolkitProps = {
168
167
  [key: string]: any;
169
168
  appCode: string;
170
- configs: any[];
169
+ hidden: boolean;
170
+ type: string;
171
+ onAction?: (action: string) => void;
171
172
  };
172
173
 
173
174
  export type HeaderAnimatedProps = {
@@ -126,21 +126,6 @@ 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}
136
- pinnedTool={params.pinnedTool}
137
- {...props}
138
- />
139
- );
140
- },
141
- };
142
- }
143
-
144
129
  return {
145
130
  ...params,
146
131
  ...options,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.81.41-beta.9",
3
+ "version": "0.81.42",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {