From d36c928aec5bef8936214111285e5e478959c2b9 Mon Sep 17 00:00:00 2001 From: Gorit Date: Thu, 14 Mar 2024 07:52:39 +0000 Subject: [PATCH] feat: add commonLayout of base layout Signed-off-by: Gorit --- .../src/main/ets/common/constants/Const.ets | 1 + .../entry/src/main/ets/pages/Index.ets | 7 ++++ .../ets/pages/commonLayout/CommonLayout.ets | 34 +++++++++++++++++++ .../resources/base/profile/main_pages.json | 3 +- 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 layout/CommonLayout/entry/src/main/ets/pages/commonLayout/CommonLayout.ets diff --git a/layout/CommonLayout/entry/src/main/ets/common/constants/Const.ets b/layout/CommonLayout/entry/src/main/ets/common/constants/Const.ets index 44a406f..3f089ef 100644 --- a/layout/CommonLayout/entry/src/main/ets/common/constants/Const.ets +++ b/layout/CommonLayout/entry/src/main/ets/common/constants/Const.ets @@ -5,6 +5,7 @@ const Const = { Index: "pages/Index", HEADER: "pages/header/Header", FOOTER: "pages/footer/Footer", + COMMON_LAYOUT: "pages/commonLayout/CommonLayout", } } diff --git a/layout/CommonLayout/entry/src/main/ets/pages/Index.ets b/layout/CommonLayout/entry/src/main/ets/pages/Index.ets index 383f125..edcd578 100644 --- a/layout/CommonLayout/entry/src/main/ets/pages/Index.ets +++ b/layout/CommonLayout/entry/src/main/ets/pages/Index.ets @@ -26,6 +26,13 @@ struct Index { url: Const.RouterPath.FOOTER }) }) + Button("CommonLayout") + .width(CommonConstant.COMMON_WIDTH) + .onClick(() => { + router.pushUrl({ + url: Const.RouterPath.COMMON_LAYOUT + }) + }) } .width('100%') } diff --git a/layout/CommonLayout/entry/src/main/ets/pages/commonLayout/CommonLayout.ets b/layout/CommonLayout/entry/src/main/ets/pages/commonLayout/CommonLayout.ets new file mode 100644 index 0000000..22de153 --- /dev/null +++ b/layout/CommonLayout/entry/src/main/ets/pages/commonLayout/CommonLayout.ets @@ -0,0 +1,34 @@ +import CommonConstant from '../../common/constants/CommonConstant' +import NavigationBar from '../../components/NavigationBar' + +@Entry +@Component +struct CommonLayout { + @State message: string = 'Hello World' + + build() { + Column() { + NavigationBar({ title: "通用布局" }) + Grid() { + GridItem() { + Button("login") + } + GridItem() { + Button("login") + } + GridItem() { + Button("login") + } + GridItem() { + Button("login") + } + } + .columnsTemplate('1fr 1fr 1fr') + .rowsGap(10) + .columnsGap(10) + .width(CommonConstant.COMMON_WIDTH) + } + .width('100%') + .backgroundColor(0xFAEEE0) + } +} \ No newline at end of file diff --git a/layout/CommonLayout/entry/src/main/resources/base/profile/main_pages.json b/layout/CommonLayout/entry/src/main/resources/base/profile/main_pages.json index bc9c608..a2598f5 100644 --- a/layout/CommonLayout/entry/src/main/resources/base/profile/main_pages.json +++ b/layout/CommonLayout/entry/src/main/resources/base/profile/main_pages.json @@ -2,6 +2,7 @@ "src": [ "pages/Index", "pages/header/Header", - "pages/footer/Footer" + "pages/footer/Footer", + "pages/commonLayout/CommonLayout" ] } \ No newline at end of file -- Gitee