@momo-kits/foundation 0.109.1-beta.13 → 0.109.1-beta.15
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.
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import {ApplicationContext, MiniAppContext, NavigationButton} from '../index';
|
|
10
10
|
import {Colors, Spacing, Styles} from '../../Consts';
|
|
11
11
|
import {PopupNotify} from '../../Popup';
|
|
12
|
-
import {Tool} from '../types';
|
|
12
|
+
import {Tool, ToolGroup} from '../types';
|
|
13
13
|
import {Icon} from '../../Icon';
|
|
14
14
|
import {scaleSize, Text} from '../../Text';
|
|
15
15
|
|
|
@@ -70,7 +70,6 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
70
70
|
}) => {
|
|
71
71
|
const {navigator} = useContext(ApplicationContext);
|
|
72
72
|
const context = useContext<any>(MiniAppContext);
|
|
73
|
-
const showIconMore = tools && tools.length > 1;
|
|
74
73
|
|
|
75
74
|
const [isFavorite, setIsFavorite] = useState<boolean>(false);
|
|
76
75
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -154,26 +153,39 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
154
153
|
|
|
155
154
|
const onPressIconMore = () => {
|
|
156
155
|
navigator?.maxApi?.dispatchFunction?.('showTools', tools, (key: string) => {
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
for (const group of tools) {
|
|
157
|
+
const pressedTool = group.items.find((tool: Tool) => tool.key === key);
|
|
158
|
+
if (pressedTool) {
|
|
159
|
+
pressedTool?.onPress();
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
160
162
|
}
|
|
161
163
|
});
|
|
162
164
|
};
|
|
163
165
|
|
|
164
166
|
let iconShortcut = isFavorite ? 'pin_star_checked' : 'pin_star';
|
|
165
167
|
let shortcutOnPress = onPressShortcut;
|
|
166
|
-
|
|
168
|
+
const totalTools = tools.reduce(
|
|
169
|
+
(count: number, group: ToolGroup) => count + group.items.length,
|
|
170
|
+
0
|
|
171
|
+
);
|
|
172
|
+
const showIconMore = tools && totalTools > 1;
|
|
173
|
+
const isHaveOneTool = tools && totalTools === 1;
|
|
167
174
|
|
|
168
175
|
if (showIconMore || (useMore && isHaveOneTool)) {
|
|
169
176
|
iconShortcut = 'navigation_more_icon';
|
|
170
177
|
shortcutOnPress = onPressIconMore;
|
|
171
178
|
} else if (isHaveOneTool) {
|
|
172
|
-
|
|
173
|
-
|
|
179
|
+
const singleTool = tools.find(
|
|
180
|
+
(group: ToolGroup) => group.items.length === 1
|
|
181
|
+
)?.items[0];
|
|
182
|
+
iconShortcut = singleTool?.icon;
|
|
183
|
+
shortcutOnPress = singleTool?.onPress;
|
|
174
184
|
}
|
|
175
185
|
|
|
176
|
-
const showBadge = tools.some((
|
|
186
|
+
const showBadge = tools.some((group: ToolGroup) =>
|
|
187
|
+
group.items.some(tool => tool.showBadge)
|
|
188
|
+
);
|
|
177
189
|
|
|
178
190
|
return (
|
|
179
191
|
<View style={Styles.row}>
|
|
@@ -76,9 +76,13 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
76
76
|
navigator?.maxApi?.setObserver('CURRENT_SCREEN', {screenName});
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
|
-
navigator?.maxApi?.startTraceScreenLoad?.(
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
navigator?.maxApi?.startTraceScreenLoad?.(
|
|
80
|
+
screenName,
|
|
81
|
+
context,
|
|
82
|
+
(data: any) => {
|
|
83
|
+
tracking.current.traceIdLoad = data?.traceId;
|
|
84
|
+
}
|
|
85
|
+
);
|
|
82
86
|
navigator?.maxApi?.startTraceScreenInteraction?.(
|
|
83
87
|
screenName,
|
|
84
88
|
(data: any) => {
|
package/Application/types.ts
CHANGED
|
@@ -83,9 +83,14 @@ export type LocalizationObject = {
|
|
|
83
83
|
};
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
+
export type ToolGroup = {
|
|
87
|
+
title: LocalizationObject;
|
|
88
|
+
items: Tool[];
|
|
89
|
+
};
|
|
90
|
+
|
|
86
91
|
export type Tool = {
|
|
87
92
|
icon: string;
|
|
88
|
-
name:
|
|
93
|
+
name: LocalizationObject;
|
|
89
94
|
key: string;
|
|
90
95
|
showBadge?: boolean;
|
|
91
96
|
onPress: () => void;
|
|
@@ -164,7 +169,7 @@ export type OnBoarding = {
|
|
|
164
169
|
|
|
165
170
|
export type HeaderRightToolkit = {
|
|
166
171
|
useShortcut?: boolean;
|
|
167
|
-
tools?:
|
|
172
|
+
tools?: ToolGroup[];
|
|
168
173
|
preventClose?: PopupNotifyProps;
|
|
169
174
|
useMore?: boolean;
|
|
170
175
|
};
|