@momo-kits/foundation 0.81.43-beta.2 → 0.81.43-beta.3

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.
@@ -31,74 +31,6 @@ import {Icon} from '../Icon';
31
31
  import {PopupNotify} from '../Popup';
32
32
  import {Badge, BadgeDot} from '../Badge';
33
33
 
34
- const styles = StyleSheet.create({
35
- navigationButton: {
36
- height: 28,
37
- width: 28,
38
- borderRadius: 14,
39
- justifyContent: 'center',
40
- alignItems: 'center',
41
- },
42
- headerBackground: {
43
- width: '100%',
44
- height: undefined,
45
- position: 'absolute',
46
- aspectRatio: 375 / 154,
47
- },
48
- headerTitleContainer: {
49
- alignItems: 'center',
50
- justifyContent: 'center',
51
- width: '100%',
52
- },
53
- circle: {width: 36, height: 36, borderRadius: 18},
54
- square: {width: 36, height: 36, borderRadius: Radius.XS},
55
- dotAvatar: {
56
- position: 'absolute',
57
- width: 12,
58
- height: 12,
59
- borderRadius: 6,
60
- bottom: 0,
61
- right: 0,
62
- borderWidth: 1,
63
- borderColor: Colors.black_01,
64
- },
65
- headerButton: {paddingHorizontal: 4},
66
- headerRightButton: {
67
- flexDirection: 'row',
68
- justifyContent: 'center',
69
- alignItems: 'center',
70
- paddingRight: Spacing.S,
71
- },
72
- toolkitContainer: {
73
- marginLeft: Spacing.S,
74
- padding: Spacing.XS,
75
- height: 28,
76
- borderRadius: 14,
77
- borderColor: '#00000066',
78
- justifyContent: 'center',
79
- alignItems: 'center',
80
- flexDirection: 'row',
81
- },
82
- divider: {
83
- width: 1,
84
- height: 12,
85
- marginHorizontal: 4,
86
- },
87
- headerLeft: {
88
- marginLeft: 12,
89
- },
90
- title: {
91
- fontSize: scaleSize(15),
92
- lineHeight: scaleSize(22),
93
- fontWeight: 'bold',
94
- },
95
- badge: {
96
- position: 'absolute',
97
- top: -8,
98
- right: -8,
99
- },
100
- });
101
-
102
34
  const NavigationButton: React.FC<NavigationButtonProps> = ({
103
35
  icon,
104
36
  tintColor,
@@ -119,25 +51,29 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
119
51
  }
120
52
 
121
53
  const renderBadge = useCallback(() => {
122
- if (!badgeValue && !badgeType) return null;
123
54
  if (badgeType === 'dot') {
124
- return <BadgeDot size="small" style={styles.badge} />;
55
+ return <BadgeDot size="small" style={styles.badgeDot} />;
125
56
  }
57
+
58
+ if (isNaN(Number(badgeValue))) return null;
59
+
126
60
  return <Badge label={badgeValue} style={styles.badge} />;
127
61
  }, [badgeType, badgeValue]);
128
62
 
129
63
  return (
130
- <TouchableOpacity
131
- accessibilityLabel={`NavigationButton/${accessibilityLabel}`}
132
- style={[styles.navigationButton, buttonStyle]}
133
- onPress={onPress}>
134
- <Icon
135
- source={icon}
136
- color={tintColor ?? theme.colors.text.default}
137
- size={20}
138
- />
64
+ <View style={{width: scaleSize(28)}}>
65
+ <TouchableOpacity
66
+ accessibilityLabel={`NavigationButton/${accessibilityLabel}`}
67
+ style={[styles.navigationButton, buttonStyle]}
68
+ onPress={onPress}>
69
+ <Icon
70
+ source={icon}
71
+ color={tintColor ?? theme.colors.text.default}
72
+ size={20}
73
+ />
74
+ </TouchableOpacity>
139
75
  {renderBadge()}
140
- </TouchableOpacity>
76
+ </View>
141
77
  );
142
78
  };
143
79
 
@@ -347,10 +283,14 @@ const HeaderRightAction: React.FC<any> = ({children, ...restProps}) => {
347
283
  return <View style={styles.headerRightButton}>{renderAction()}</View>;
348
284
  };
349
285
 
350
- const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
286
+ const HeaderToolkitAction: React.FC<any> = ({
287
+ tintColor,
288
+ pinnedTool,
289
+ preventBack,
290
+ }) => {
351
291
  const {theme, navigator} = useContext(ApplicationContext);
352
- const [toolConfig, setToolConfig] = useState<HeaderToolkitProps>();
353
- const {appCode, hidden, type, onAction} = toolConfig ?? {};
292
+ const [toolConfig, setToolConfig] = useState<any>();
293
+ const {appCode, onAction} = toolConfig ?? {};
354
294
 
355
295
  let backgroundColor;
356
296
  if (tintColor != Colors.black_01) {
@@ -361,21 +301,7 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
361
301
  if (navigator?.toolkitConfig) {
362
302
  setToolConfig(navigator?.toolkitConfig);
363
303
  } else {
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
- }
378
- });
304
+ getToolkitConfig();
379
305
  }
380
306
  }, []);
381
307
 
@@ -390,10 +316,7 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
390
316
  [addSchema],
391
317
  (data: any) => {
392
318
  if (data?.status) {
393
- setToolConfig({
394
- ...(toolConfig as HeaderToolkitProps),
395
- hidden: true,
396
- });
319
+ getToolkitConfig();
397
320
  }
398
321
  },
399
322
  );
@@ -402,10 +325,7 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
402
325
  [removeSchema],
403
326
  (data: any) => {
404
327
  if (data?.status) {
405
- setToolConfig({
406
- ...(toolConfig as HeaderToolkitProps),
407
- hidden: false,
408
- });
328
+ getToolkitConfig();
409
329
  }
410
330
  },
411
331
  );
@@ -417,39 +337,72 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
417
337
  };
418
338
  }, [appCode]);
419
339
 
420
- const onUtilityTool = () => {
421
- onAction?.('onUtilityTool');
422
- navigator?.requestApi(type, undefined, undefined);
340
+ const getToolkitConfig = () => {
341
+ navigator?.requestApi('getToolsConfig', [undefined], (config: any) => {
342
+ navigator.toolkitConfig = config;
343
+ setToolConfig(navigator?.toolkitConfig);
344
+ });
423
345
  };
424
346
 
425
347
  const onMore = () => {
426
348
  onAction?.('onMore');
427
- navigator?.requestApi('showToolkit', [toolConfig], undefined);
349
+ navigator?.requestApi(
350
+ 'showTools',
351
+ [undefined],
352
+ (res: {item: {action?: string; key: string}}) => {
353
+ const {item} = res;
354
+ navigator?.toolkitCallback?.(item);
355
+ },
356
+ );
428
357
  };
429
358
 
430
359
  const onClose = () => {
431
- onAction?.('onClose');
432
- navigator?.requestApi('dismiss', undefined, undefined);
360
+ if (preventBack) {
361
+ navigator?.showModal({
362
+ screen: () => (
363
+ <PopupNotify
364
+ {...preventBack}
365
+ primary={{
366
+ title: preventBack.primary.title,
367
+ onPress: () => {
368
+ preventBack?.primary.onPress();
369
+ navigator?.requestApi('dismiss', undefined, undefined);
370
+ },
371
+ }}
372
+ />
373
+ ),
374
+ });
375
+ } else {
376
+ navigator?.requestApi('dismiss', undefined, undefined);
377
+ }
433
378
  };
434
379
 
435
- const renderUtilityTool = () => {
436
- if (hidden === false) {
380
+ const renderPinnedTool = () => {
381
+ const pinTool = toolConfig?.tools?.find(
382
+ (i: any) => i.key === pinnedTool?.key,
383
+ );
384
+ const {badgeValue, badgeType} = pinnedTool ?? {};
385
+
386
+ if (pinTool)
437
387
  return (
438
388
  <NavigationButton
439
389
  accessibilityLabel={'UtilityTool'}
440
- icon={type as string}
390
+ icon={pinTool.icon as string}
441
391
  tintColor={tintColor}
442
- onPress={onUtilityTool}
392
+ badgeValue={badgeValue}
393
+ badgeType={badgeType}
394
+ onPress={() => {
395
+ navigator?.requestApi('onToolAction', [pinTool?.key], () => {});
396
+ navigator?.toolkitCallback?.(pinTool.key);
397
+ }}
443
398
  />
444
399
  );
445
- }
446
- return null;
447
400
  };
448
401
 
449
402
  if (toolConfig) {
450
403
  return (
451
404
  <View style={styles.headerRightButton}>
452
- {renderUtilityTool()}
405
+ {renderPinnedTool()}
453
406
  <View
454
407
  style={[
455
408
  styles.toolkitContainer,
@@ -521,6 +474,79 @@ const HeaderAnimated: React.FC<HeaderAnimatedProps> = ({
521
474
  );
522
475
  };
523
476
 
477
+ const styles = StyleSheet.create({
478
+ navigationButton: {
479
+ height: 28,
480
+ width: 28,
481
+ borderRadius: 14,
482
+ justifyContent: 'center',
483
+ alignItems: 'center',
484
+ },
485
+ headerBackground: {
486
+ width: '100%',
487
+ height: undefined,
488
+ position: 'absolute',
489
+ aspectRatio: 375 / 154,
490
+ },
491
+ headerTitleContainer: {
492
+ alignItems: 'center',
493
+ justifyContent: 'center',
494
+ width: '100%',
495
+ },
496
+ circle: {width: 36, height: 36, borderRadius: 18},
497
+ square: {width: 36, height: 36, borderRadius: Radius.XS},
498
+ dotAvatar: {
499
+ position: 'absolute',
500
+ width: 12,
501
+ height: 12,
502
+ borderRadius: 6,
503
+ bottom: 0,
504
+ right: 0,
505
+ borderWidth: 1,
506
+ borderColor: Colors.black_01,
507
+ },
508
+ headerButton: {paddingHorizontal: 4},
509
+ headerRightButton: {
510
+ flexDirection: 'row',
511
+ justifyContent: 'center',
512
+ alignItems: 'center',
513
+ paddingRight: Spacing.S,
514
+ },
515
+ toolkitContainer: {
516
+ marginLeft: Spacing.S,
517
+ padding: Spacing.XS,
518
+ height: 28,
519
+ borderRadius: 14,
520
+ borderColor: '#00000066',
521
+ justifyContent: 'center',
522
+ alignItems: 'center',
523
+ flexDirection: 'row',
524
+ },
525
+ divider: {
526
+ width: 1,
527
+ height: 12,
528
+ marginHorizontal: 4,
529
+ },
530
+ headerLeft: {
531
+ marginLeft: 12,
532
+ },
533
+ title: {
534
+ fontSize: scaleSize(15),
535
+ lineHeight: scaleSize(22),
536
+ fontWeight: 'bold',
537
+ },
538
+ badge: {
539
+ position: 'absolute',
540
+ top: -Spacing.S,
541
+ right: -6,
542
+ },
543
+ badgeDot: {
544
+ position: 'absolute',
545
+ top: -Spacing.XS,
546
+ right: -Spacing.XS,
547
+ },
548
+ });
549
+
524
550
  export {
525
551
  NavigationButton,
526
552
  HeaderTitle,
@@ -13,6 +13,7 @@ class Navigator {
13
13
  maxApi?: any;
14
14
  trackingInfo?: TrackingInfo;
15
15
  dismissData?: any;
16
+ toolkitCallback?: (item: any) => void;
16
17
 
17
18
  constructor(navigation: any) {
18
19
  this.ref = navigation;
@@ -121,6 +122,12 @@ class Navigator {
121
122
  this.maxApi[func]?.(...args, callback);
122
123
  }
123
124
  };
125
+
126
+ setToolkitCallback = (
127
+ callback: (item: {key: string; action: string}) => void,
128
+ ) => {
129
+ this.toolkitCallback = callback;
130
+ };
124
131
  }
125
132
 
126
133
  export default Navigator;
@@ -128,8 +128,14 @@ export type NavigationButtonProps = {
128
128
  useBorder?: boolean;
129
129
  onPress: () => void;
130
130
  accessibilityLabel?: string;
131
- badgeType?: 'dot' | 'number' | 'string';
132
- badgeValue?: number | string;
131
+ badgeType?: 'dot' | 'number';
132
+ badgeValue?: number;
133
+ };
134
+
135
+ export type PinnedToolType = {
136
+ key: string;
137
+ badgeValue?: number;
138
+ badgeType?: 'number' | 'dot';
133
139
  };
134
140
 
135
141
  export interface NavigationOptions extends StackNavigationOptions {
@@ -138,6 +144,7 @@ export interface NavigationOptions extends StackNavigationOptions {
138
144
  surface?: boolean;
139
145
  hiddenBack?: boolean;
140
146
  customTitle?: TitleCustomProps;
147
+ pinnedTool?: PinnedToolType;
141
148
  }
142
149
 
143
150
  export interface HeaderBackProps extends NavigationButtonProps {
@@ -166,9 +173,7 @@ export type TitleCustomProps = {
166
173
  export type HeaderToolkitProps = {
167
174
  [key: string]: any;
168
175
  appCode: string;
169
- hidden: boolean;
170
- type: string;
171
- onAction?: (action: string) => void;
176
+ configs: any[];
172
177
  };
173
178
 
174
179
  export type HeaderAnimatedProps = {
@@ -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}
136
+ pinnedTool={params.pinnedTool}
137
+ {...props}
138
+ />
139
+ );
140
+ },
141
+ };
142
+ }
143
+
129
144
  return {
130
145
  ...params,
131
146
  ...options,
package/Badge/styles.ts CHANGED
@@ -4,13 +4,16 @@ import {scaleSize} from '../Text';
4
4
 
5
5
  export default StyleSheet.create({
6
6
  badge: {
7
+ paddingHorizontal: Spacing.XS,
7
8
  borderRadius: Radius.M,
8
9
  justifyContent: 'center',
10
+ alignItems: 'center',
9
11
  height: scaleSize(16),
12
+ minWidth: scaleSize(16),
10
13
  flexDirection: 'row',
14
+ borderWidth: 1,
11
15
  borderColor: Colors.black_01,
12
- paddingHorizontal: Spacing.XS,
13
- alignItems: 'center',
16
+ alignSelf: 'baseline',
14
17
  },
15
18
  dot: {
16
19
  width: 16,
package/Text/index.tsx CHANGED
@@ -84,6 +84,7 @@ const Text: React.FC<TextProps> = ({
84
84
  }
85
85
 
86
86
  return {
87
+ ...typoStyle,
87
88
  fontFamily,
88
89
  fontSize: scaleSize(fontSize),
89
90
  lineHeight: scaleSize(lineHeight),
@@ -104,7 +105,7 @@ const Text: React.FC<TextProps> = ({
104
105
  };
105
106
 
106
107
  Text.defaultProps = {
107
- typography: 'paragraph_default',
108
+ typography: 'body_default_regular',
108
109
  };
109
110
 
110
111
  export {Text, scaleSize};
package/Text/styles.ts CHANGED
@@ -1,4 +1,42 @@
1
1
  export default {
2
+ headline_default_bold: {fontSize: 24, lineHeight: 32, fontWeight: '700'},
3
+ header_m_bold: {fontSize: 18, lineHeight: 28, fontWeight: '700'},
4
+ header_default_bold: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
5
+ header_s_semibold: {fontSize: 14, lineHeight: 20, fontWeight: '600'},
6
+ header_xs_semibold: {fontSize: 12, lineHeight: 16, fontWeight: '600'},
7
+ body_default_regular: {fontSize: 14, lineHeight: 20, fontWeight: '400'},
8
+ body_default_regularstrikethrought: {
9
+ fontSize: 14,
10
+ lineHeight: 20,
11
+ fontWeight: '400',
12
+ textDecorationLine: 'line-through',
13
+ },
14
+ description_default_regular: {
15
+ fontSize: 12,
16
+ lineHeight: 16,
17
+ fontWeight: '400',
18
+ },
19
+ description_default_regularstrikethrought: {
20
+ fontSize: 12,
21
+ lineHeight: 16,
22
+ fontWeight: '400',
23
+ textDecorationLine: 'line-through',
24
+ },
25
+ description_xs_regular: {fontSize: 10, lineHeight: 14, fontWeight: '400'},
26
+ description_xs_regularstrikethrought: {
27
+ fontSize: 10,
28
+ lineHeight: 14,
29
+ fontWeight: '400',
30
+ textDecorationLine: 'line-through',
31
+ },
32
+ label_default_medium: {fontSize: 14, lineHeight: 20, fontWeight: '500'},
33
+ label_s_medium: {fontSize: 12, lineHeight: 16, fontWeight: '500'},
34
+ label_xs_medium: {fontSize: 10, lineHeight: 14, fontWeight: '500'},
35
+ action_default_bold: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
36
+ action_s_bold: {fontSize: 14, lineHeight: 20, fontWeight: '700'},
37
+ action_xs_bold: {fontSize: 12, lineHeight: 16, fontWeight: '700'},
38
+ action_xxs_bold: {fontSize: 10, lineHeight: 14, fontWeight: '700'},
39
+ /**non-support**/
2
40
  headline_default: {
3
41
  fontSize: 28,
4
42
  lineHeight: 34,
package/Text/types.ts CHANGED
@@ -14,27 +14,21 @@ export type TypographyWeight = {
14
14
  };
15
15
 
16
16
  export type Typography =
17
- | 'headline_default'
18
- | 'headline_s'
19
- | 'headline_l'
20
- | 'headline_xl'
21
- | 'title_default'
22
- | 'title_xs'
23
- | 'title_s'
24
- | 'header_default'
25
- | 'header_xs'
26
- | 'header_s'
27
- | 'paragraph_default'
28
- | 'paragraph_bold'
29
- | 'paragraph_italic'
30
- | 'description_default'
31
- | 'description_xs'
32
- | 'description_s'
33
- | 'label_default'
34
- | 'label_xxs'
35
- | 'label_xs'
36
- | 'label_s'
37
- | 'action_default'
38
- | 'action_xxs'
39
- | 'action_xs'
40
- | 'action_s';
17
+ | 'headline_default_bold'
18
+ | 'header_m_bold'
19
+ | 'header_default_bold'
20
+ | 'header_s_semibold'
21
+ | 'header_xs_semibold'
22
+ | 'body_default_regular'
23
+ | 'body_default_regularstrikethrought'
24
+ | 'description_default_regular'
25
+ | 'description_default_regularstrikethrought'
26
+ | 'description_xs_regular'
27
+ | 'description_xs_regularstrikethrought'
28
+ | 'label_default_medium'
29
+ | 'label_s_medium'
30
+ | 'label_xs_medium'
31
+ | 'action_default_bold'
32
+ | 'action_s_bold'
33
+ | 'action_xs_bold'
34
+ | 'action_xxs_bold';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.81.43-beta.2",
3
+ "version": "0.81.43-beta.3",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {