Skip to content

Commit 162facc

Browse files
fix mobile nav layout app view + fix styles of pc/mobile nav
1 parent 9f32f30 commit 162facc

File tree

4 files changed

+35
-16
lines changed

4 files changed

+35
-16
lines changed

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

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import { AlignRight } from "lowcoder-design";
3333
import { LayoutActionComp } from "./layoutActionComp";
3434
import { defaultTheme } from "@lowcoder-ee/constants/themeConstants";
3535
import { clickEvent, eventHandlerControl } from "@lowcoder-ee/comps/controls/eventHandlerControl";
36+
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
37+
import { childrenToProps } from "@lowcoder-ee/comps/generators/multi";
3638

3739
const TabBar = React.lazy(() => import("antd-mobile/es/components/tab-bar"));
3840
const TabBarItem = React.lazy(() =>
@@ -228,9 +230,10 @@ function TabBarView(props: TabBarProps & {
228230
>
229231
<StyledTabBar
230232
onChange={(key: string) => {
233+
console.log(key)
231234
if (key) {
232-
props.onEvent('click')
233235
props.onChange(key);
236+
props.onEvent('click')
234237
}
235238
}}
236239
activeKey={props.selectedKey}
@@ -289,7 +292,7 @@ let MobileTabLayoutTmp = (function () {
289292
const childrenMap = {
290293
onEvent: eventHandlerControl(EventOptions),
291294
dataOptionType: dropdownControl(DataOptionType, DataOption.Manual),
292-
jsonItems: jsonControl<JsonItemNode[]>(convertTreeData, mobileNavJsonMenuItems),
295+
jsonItems: jsonControl<JsonItemNode[]>(convertTreeData, mobileNavJsonMenuItems),
293296
tabs: manualOptionsControl(TabOptionComp, {
294297
initOptions: [
295298
{
@@ -315,12 +318,12 @@ let MobileTabLayoutTmp = (function () {
315318
maxWidth: withDefault(NumberControl, 450),
316319
verticalAlignment: dropdownControl(VerticalAlignmentOptions, "stretch"),
317320
showSeparator: withDefault(BoolCodeControl, true),
318-
navStyle: withDefault(styleControl(NavLayoutStyle), defaultStyle),
319-
navItemStyle: withDefault(styleControl(NavLayoutItemStyle), defaultStyle),
320-
navItemHoverStyle: withDefault(styleControl(NavLayoutItemHoverStyle), {}),
321-
navItemActiveStyle: withDefault(styleControl(NavLayoutItemActiveStyle), {}),
321+
navStyle: styleControl(NavLayoutStyle, 'navStyle'),
322+
navItemStyle: styleControl(NavLayoutItemStyle, 'navItemStyle'),
323+
navItemHoverStyle: styleControl(NavLayoutItemHoverStyle, 'navItemHoverStyle'),
324+
navItemActiveStyle: styleControl(NavLayoutItemActiveStyle, 'navItemActiveStyle'),
322325
};
323-
return new MultiCompBuilder(childrenMap, (props) => {
326+
return new MultiCompBuilder(childrenMap, (props, dispatch) => {
324327
return null;
325328
})
326329
.setPropertyViewFn((children) => {
@@ -402,6 +405,8 @@ MobileTabLayoutTmp = withViewFn(MobileTabLayoutTmp, (comp) => {
402405
const bgColor = (useContext(ThemeContext)?.theme || defaultTheme).canvas;
403406
const onEvent = comp.children.onEvent.getView();
404407

408+
useMergeCompStyles(childrenToProps(comp.children), comp.dispatch);
409+
405410
useEffect(() => {
406411
comp.children.jsonTabs.dispatchChangeValueAction({
407412
manual: jsonItems as unknown as Array<ConstructorToDataType<typeof TabOptionComp>>
@@ -427,9 +432,20 @@ MobileTabLayoutTmp = withViewFn(MobileTabLayoutTmp, (comp) => {
427432
const appView = useMemo(() => {
428433
const currentTab = tabViews[tabIndex];
429434

435+
if (dataOptionType === DataOption.Json) {
436+
return (currentTab &&
437+
currentTab.children.app.getAppId() &&
438+
currentTab.children.app.getView()) || (
439+
<EmptyContent
440+
text={readOnly ? "" : trans("aggregation.emptyTabTooltip")}
441+
style={{ height: "100%", backgroundColor: "white" }}
442+
/>
443+
);
444+
}
445+
430446
return (currentTab &&
431-
currentTab.children.app.getAppId() &&
432-
currentTab.children.app.getView()) || (
447+
// currentTab.children.app.getAppId() &&
448+
currentTab.children.action.getView()) || (
433449
<EmptyContent
434450
text={readOnly ? "" : trans("aggregation.emptyTabTooltip")}
435451
style={{ height: "100%", backgroundColor: "white" }}

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { trans } from "i18n";
1616
import { EditorContainer, EmptyContent } from "pages/common/styledComponent";
1717
import { useCallback, useEffect, useMemo, useState } from "react";
1818
import styled from "styled-components";
19-
import { isUserViewMode, useAppPathParam } from "util/hooks";
19+
import { isUserViewMode, useAppPathParam, useMergeCompStyles } from "util/hooks";
2020
import { BoolCodeControl, StringControl, jsonControl } from "comps/controls/codeControl";
2121
import { styleControl } from "comps/controls/styleControl";
2222
import {
@@ -41,6 +41,7 @@ import {
4141
menuItemStyleOptions
4242
} from "./navLayoutConstants";
4343
import { clickEvent, eventHandlerControl } from "@lowcoder-ee/comps/controls/eventHandlerControl";
44+
import { childrenToProps } from "@lowcoder-ee/comps/generators/multi";
4445

4546
const { Header } = Layout;
4647

@@ -198,10 +199,10 @@ let NavTmpLayout = (function () {
198199
backgroundImage: withDefault(StringControl, ""),
199200
mode: dropdownControl(ModeOptions, "inline"),
200201
collapse: BoolCodeControl,
201-
navStyle: withDefault(styleControl(NavLayoutStyle), {...defaultStyle, padding: '1px'}),
202-
navItemStyle: withDefault(styleControl(NavLayoutItemStyle), defaultStyle),
203-
navItemHoverStyle: withDefault(styleControl(NavLayoutItemHoverStyle), {}),
204-
navItemActiveStyle: withDefault(styleControl(NavLayoutItemActiveStyle), {}),
202+
navStyle: styleControl(NavLayoutStyle, 'navStyle'),
203+
navItemStyle: styleControl(NavLayoutItemStyle, 'navItemStyle'),
204+
navItemHoverStyle: styleControl(NavLayoutItemHoverStyle, 'navItemHoverStyle'),
205+
navItemActiveStyle: styleControl(NavLayoutItemActiveStyle, 'navItemActiveStyle'),
205206
};
206207
return new MultiCompBuilder(childrenMap, (props) => {
207208
return null;
@@ -290,6 +291,8 @@ NavTmpLayout = withViewFn(NavTmpLayout, (comp) => {
290291
const dataOptionType = comp.children.dataOptionType.getView();
291292
const onEvent = comp.children.onEvent.getView();
292293

294+
useMergeCompStyles(childrenToProps(comp.children), comp.dispatch);
295+
293296
// filter out hidden. unauthorised items filtered by server
294297
const filterItem = useCallback((item: LayoutMenuItemComp): boolean => {
295298
return !item.children.hidden.getView();

client/packages/lowcoder/src/comps/controls/styleControl.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ export function styleControl<T extends readonly SingleColorConfig[]>(
876876
...(theme?.theme?.components?.[compType]?.[styleKey] || {}) as unknown as Record<string, string>
877877
}
878878
: undefined;
879-
const styleProps = preventStyleOverwriting || preventAppStylesOverwriting || appliedThemeId === themeId
879+
const styleProps = (!comp && !compType) || preventStyleOverwriting || preventAppStylesOverwriting || appliedThemeId === themeId
880880
? props as ColorMap
881881
: {} as ColorMap;
882882

client/packages/lowcoder/src/util/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export function useMergeCompStyles(
177177
const compTheme = theme?.theme?.components?.[compType];
178178
const themeId = theme?.themeId;
179179

180-
const styleKeys = Object.keys(props).filter(key => key.toLowerCase().endsWith('style'));
180+
const styleKeys = Object.keys(props).filter(key => key.toLowerCase().endsWith('style' || 'styles'));
181181
const styleProps: Record<string, any> = {};
182182
styleKeys.forEach((key: string) => {
183183
styleProps[key] = (props as any)[key];

0 commit comments

Comments
 (0)