Skip to content

Commit b685897

Browse files
committed
event handler for mobile navigation
1 parent 6d528d5 commit b685897

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

client/packages/lowcoder/src/comps/comps/layout/mobileTabLayout.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ import { AlignCenter } from "lowcoder-design";
3131
import { AlignLeft } from "lowcoder-design";
3232
import { AlignRight } from "lowcoder-design";
3333
import { LayoutActionComp } from "./layoutActionComp";
34+
import { clickEvent, eventHandlerControl } from "@lowcoder-ee/index.sdk";
3435

3536
const TabBar = React.lazy(() => import("antd-mobile/es/components/tab-bar"));
3637
const TabBarItem = React.lazy(() =>
3738
import("antd-mobile/es/components/tab-bar/tab-bar").then((module) => ({
3839
default: module.TabBarItem,
3940
}))
4041
);
42+
const EventOptions = [clickEvent] as const;
4143

4244
const AppViewContainer = styled.div`
4345
position: absolute;
@@ -172,6 +174,7 @@ type JsonItemNode = {
172174
}
173175

174176
type TabBarProps = {
177+
onEvent:any;
175178
tabs: Array<{
176179
title: string;
177180
icon?: React.ReactNode;
@@ -225,6 +228,7 @@ function TabBarView(props: TabBarProps & {
225228
<StyledTabBar
226229
onChange={(key: string) => {
227230
if (key) {
231+
props.onEvent('click')
228232
props.onChange(key);
229233
}
230234
}}
@@ -282,8 +286,9 @@ const TabOptionComp = (function () {
282286

283287
let MobileTabLayoutTmp = (function () {
284288
const childrenMap = {
289+
onEvent: eventHandlerControl(EventOptions),
285290
dataOptionType: dropdownControl(DataOptionType, DataOption.Manual),
286-
jsonItems: jsonControl<JsonItemNode[]>(convertTreeData, mobileNavJsonMenuItems),
291+
jsonItems: jsonControl<JsonItemNode[]>(convertTreeData, mobileNavJsonMenuItems),
287292
tabs: manualOptionsControl(TabOptionComp, {
288293
initOptions: [
289294
{
@@ -350,6 +355,9 @@ let MobileTabLayoutTmp = (function () {
350355
<Section name={trans("navLayout.navStyle")}>
351356
{ children.navStyle.getPropertyView() }
352357
</Section>
358+
<Section name={trans("eventHandler.eventHandlers")}>
359+
{ children.onEvent.getPropertyView() }
360+
</Section>
353361
<Section name={trans("navLayout.navItemStyle")}>
354362
{controlItem({}, (
355363
<Segmented
@@ -391,6 +399,7 @@ MobileTabLayoutTmp = withViewFn(MobileTabLayoutTmp, (comp) => {
391399
const verticalAlignment = comp.children.verticalAlignment.getView();
392400
const showSeparator = comp.children.showSeparator.getView();
393401
const bgColor = (useContext(ThemeContext)?.theme || defaultTheme).canvas;
402+
const onEvent = comp.children.onEvent.getView();
394403

395404
useEffect(() => {
396405
comp.children.jsonTabs.dispatchChangeValueAction({
@@ -434,6 +443,7 @@ MobileTabLayoutTmp = withViewFn(MobileTabLayoutTmp, (comp) => {
434443

435444
const tabBarView = (
436445
<TabBarView
446+
onEvent={onEvent}
437447
tabs={tabViews.map((tab, index) => ({
438448
key: index,
439449
title: tab.children.label.getView(),

0 commit comments

Comments
 (0)