@momo-kits/foundation 0.81.40 → 0.81.41-beta.2

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.
@@ -183,7 +183,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
183
183
  const canGoBack = navigator?.ref.current?.canGoBack();
184
184
  if (!canGoBack && navigator?.trackingInfo) {
185
185
  const currentRoute = navigator?.ref?.current.getCurrentRoute();
186
- navigator?.maxApi?.trackEvent?.('service_icon_clicked', {
186
+ navigator?.maxApi?.trackEvent('service_icon_clicked', {
187
187
  feature_code: navigator.trackingInfo.code,
188
188
  app_id: navigator.trackingInfo.appId,
189
189
  miniapp_version: navigator.trackingInfo.buildNumber,
@@ -345,8 +345,8 @@ const HeaderRightAction: React.FC<any> = ({children, ...restProps}) => {
345
345
 
346
346
  const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
347
347
  const {theme, navigator} = useContext(ApplicationContext);
348
- const [toolConfig, setToolConfig] = useState<HeaderToolkitProps>();
349
- const {appCode, hidden, type, onAction} = toolConfig ?? {};
348
+ const [toolConfig, setToolConfig] = useState<any>();
349
+ const {appCode, onAction} = toolConfig ?? {};
350
350
 
351
351
  let backgroundColor;
352
352
  if (tintColor != Colors.black_01) {
@@ -364,10 +364,19 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
364
364
  [undefined],
365
365
  (config: any) => {
366
366
  navigator.toolkitConfig = {
367
- ...config?.utilityToolConfig,
367
+ configs: [
368
+ ...config?.toolkitConfig?.customTools,
369
+ ...config?.toolkitFeatureConfig,
370
+ ],
368
371
  appCode: config?.appCode,
369
372
  };
370
- setToolConfig(navigator?.toolkitConfig);
373
+ setToolConfig({
374
+ configs: [
375
+ ...config?.toolkitConfig?.customTools,
376
+ ...config?.toolkitFeatureConfig,
377
+ ],
378
+ appCode: config?.appCode,
379
+ });
371
380
  },
372
381
  );
373
382
  }
@@ -413,14 +422,16 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
413
422
  };
414
423
  }, [appCode]);
415
424
 
416
- const onUtilityTool = () => {
417
- onAction?.('onUtilityTool');
418
- navigator?.requestApi(type, undefined, undefined);
419
- };
420
-
421
425
  const onMore = () => {
422
426
  onAction?.('onMore');
423
- navigator?.requestApi('showToolkit', [toolConfig], undefined);
427
+ navigator?.requestApi(
428
+ 'showTools',
429
+ [toolConfig],
430
+ (res: {item: {action?: string; key: string}}) => {
431
+ const {item} = res;
432
+ navigator?.toolkitCallback?.(item);
433
+ },
434
+ );
424
435
  };
425
436
 
426
437
  const onClose = () => {
@@ -428,24 +439,28 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
428
439
  navigator?.requestApi('dismiss', undefined, undefined);
429
440
  };
430
441
 
431
- const renderUtilityTool = () => {
432
- if (hidden === false) {
442
+ const renderPinnedTool = () => {
443
+ const pinTool = toolConfig?.configs?.find(
444
+ (i: any) => i.key === navigator?.pinnedTool,
445
+ );
446
+ const {icon} = pinTool || '';
447
+ if (pinTool && navigator?.pinnedTool)
433
448
  return (
434
449
  <NavigationButton
435
450
  accessibilityLabel={'UtilityTool'}
436
- icon={type as string}
451
+ icon={icon as string}
437
452
  tintColor={tintColor}
438
- onPress={onUtilityTool}
453
+ onPress={() => {
454
+ navigator?.toolkitCallback?.(navigator?.pinnedTool);
455
+ }}
439
456
  />
440
457
  );
441
- }
442
- return null;
443
458
  };
444
459
 
445
460
  if (toolConfig) {
446
461
  return (
447
462
  <View style={styles.headerRightButton}>
448
- {renderUtilityTool()}
463
+ {renderPinnedTool()}
449
464
  <View
450
465
  style={[
451
466
  styles.toolkitContainer,
@@ -13,6 +13,8 @@ class Navigator {
13
13
  maxApi?: any;
14
14
  trackingInfo?: TrackingInfo;
15
15
  dismissData?: any;
16
+ pinnedTool?: string;
17
+ toolkitCallback?: (item: any) => void;
16
18
 
17
19
  constructor(navigation: any) {
18
20
  this.ref = navigation;
@@ -107,6 +109,16 @@ class Navigator {
107
109
  this.maxApi[func]?.(...args, callback);
108
110
  }
109
111
  };
112
+
113
+ setPinnedTool = (key: string) => {
114
+ this.pinnedTool = key;
115
+ };
116
+
117
+ setToolkitCallback = (
118
+ callback: (item: {key: string; action: string}) => void,
119
+ ) => {
120
+ this.toolkitCallback = callback;
121
+ };
110
122
  }
111
123
 
112
124
  export default Navigator;
@@ -166,9 +166,7 @@ export type TitleCustomProps = {
166
166
  export type HeaderToolkitProps = {
167
167
  [key: string]: any;
168
168
  appCode: string;
169
- hidden: boolean;
170
- type: string;
171
- onAction?: (action: string) => void;
169
+ configs: any[];
172
170
  };
173
171
 
174
172
  export type HeaderAnimatedProps = {
@@ -45,9 +45,7 @@ const InputMoney = forwardRef(
45
45
  return formatNumberToMoney(valueFormat, 'đ');
46
46
  };
47
47
 
48
- const [value, setValue] = useState(
49
- defaultValue ? validateText(defaultValue) : '',
50
- );
48
+ const [value, setValue] = useState(validateText(defaultValue));
51
49
 
52
50
  const onClearText = () => {
53
51
  inputRef?.current?.clear();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.81.40",
3
+ "version": "0.81.41-beta.2",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {