@momo-kits/foundation 0.81.42 → 0.81.43-beta.6
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 +64 -32
- package/Application/Navigator.ts +7 -0
- package/Application/types.ts +10 -5
- package/Application/utils.tsx +15 -0
- package/Badge/styles.ts +4 -2
- package/package.json +1 -1
|
@@ -347,10 +347,14 @@ 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> = ({
|
|
350
|
+
const HeaderToolkitAction: React.FC<any> = ({
|
|
351
|
+
tintColor,
|
|
352
|
+
pinnedTool = {key: '', badgeValue: undefined, badgeTye: undefined},
|
|
353
|
+
preventBack,
|
|
354
|
+
}) => {
|
|
351
355
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
352
|
-
const [toolConfig, setToolConfig] = useState<
|
|
353
|
-
const {appCode,
|
|
356
|
+
const [toolConfig, setToolConfig] = useState<any>();
|
|
357
|
+
const {appCode, onAction} = toolConfig ?? {};
|
|
354
358
|
|
|
355
359
|
let backgroundColor;
|
|
356
360
|
if (tintColor != Colors.black_01) {
|
|
@@ -361,20 +365,21 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
|
|
|
361
365
|
if (navigator?.toolkitConfig) {
|
|
362
366
|
setToolConfig(navigator?.toolkitConfig);
|
|
363
367
|
} else {
|
|
364
|
-
navigator?.requestApi('
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
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
|
+
});
|
|
378
383
|
});
|
|
379
384
|
}
|
|
380
385
|
}, []);
|
|
@@ -417,39 +422,66 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
|
|
|
417
422
|
};
|
|
418
423
|
}, [appCode]);
|
|
419
424
|
|
|
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(
|
|
427
|
+
navigator?.requestApi(
|
|
428
|
+
'showTools',
|
|
429
|
+
[toolConfig],
|
|
430
|
+
(res: {item: {action?: string; key: string}}) => {
|
|
431
|
+
const {item} = res;
|
|
432
|
+
navigator?.toolkitCallback?.(item);
|
|
433
|
+
},
|
|
434
|
+
);
|
|
428
435
|
};
|
|
429
436
|
|
|
430
437
|
const onClose = () => {
|
|
431
|
-
|
|
432
|
-
|
|
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
|
+
}
|
|
433
456
|
};
|
|
434
457
|
|
|
435
|
-
const
|
|
436
|
-
|
|
458
|
+
const renderPinnedTool = () => {
|
|
459
|
+
const pinTool = toolConfig?.configs?.find(
|
|
460
|
+
(i: any) => i.key === pinnedTool.key,
|
|
461
|
+
);
|
|
462
|
+
|
|
463
|
+
const {badgeValue, badgeType} = pinnedTool;
|
|
464
|
+
const {icon} = pinTool || '';
|
|
465
|
+
|
|
466
|
+
if (pinTool && pinnedTool)
|
|
437
467
|
return (
|
|
438
468
|
<NavigationButton
|
|
439
469
|
accessibilityLabel={'UtilityTool'}
|
|
440
|
-
icon={
|
|
470
|
+
icon={icon as string}
|
|
441
471
|
tintColor={tintColor}
|
|
442
|
-
|
|
472
|
+
badgeValue={badgeValue}
|
|
473
|
+
badgeType={badgeType}
|
|
474
|
+
onPress={() => {
|
|
475
|
+
navigator?.toolkitCallback?.(pinnedTool.key);
|
|
476
|
+
}}
|
|
443
477
|
/>
|
|
444
478
|
);
|
|
445
|
-
}
|
|
446
|
-
return null;
|
|
447
479
|
};
|
|
448
480
|
|
|
449
481
|
if (toolConfig) {
|
|
450
482
|
return (
|
|
451
483
|
<View style={styles.headerRightButton}>
|
|
452
|
-
{
|
|
484
|
+
{renderPinnedTool()}
|
|
453
485
|
<View
|
|
454
486
|
style={[
|
|
455
487
|
styles.toolkitContainer,
|
package/Application/Navigator.ts
CHANGED
|
@@ -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;
|
package/Application/types.ts
CHANGED
|
@@ -128,8 +128,14 @@ export type NavigationButtonProps = {
|
|
|
128
128
|
useBorder?: boolean;
|
|
129
129
|
onPress: () => void;
|
|
130
130
|
accessibilityLabel?: string;
|
|
131
|
-
badgeType?: 'dot' | 'number'
|
|
132
|
-
badgeValue?: number
|
|
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
|
-
|
|
170
|
-
type: string;
|
|
171
|
-
onAction?: (action: string) => void;
|
|
176
|
+
configs: any[];
|
|
172
177
|
};
|
|
173
178
|
|
|
174
179
|
export type HeaderAnimatedProps = {
|
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}
|
|
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,15 @@ 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),
|
|
10
12
|
flexDirection: 'row',
|
|
13
|
+
borderWidth: 1,
|
|
11
14
|
borderColor: Colors.black_01,
|
|
12
|
-
|
|
13
|
-
alignItems: 'center',
|
|
15
|
+
alignSelf: 'baseline',
|
|
14
16
|
},
|
|
15
17
|
dot: {
|
|
16
18
|
width: 16,
|