From 01395aaf33760bbb0de5e9ce735e89139d5ba34d Mon Sep 17 00:00:00 2001
From: zhenyuWang <13641039885@163.com>
Date: Mon, 18 Sep 2023 12:59:31 +0800
Subject: [PATCH] feat: set custom navigation bar color
---
pages.json | 74 ++++++------
.../set-custom-navigation-bar-color.test.js | 30 +++++
.../set-custom-navigation-bar-color.uvue | 105 ++++++++++++++++++
.../set-navigation-bar-color.test.js | 3 +-
.../set-navigation-bar-color.uvue | 51 ++++-----
5 files changed, 202 insertions(+), 61 deletions(-)
create mode 100644 pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js
create mode 100644 pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue
diff --git a/pages.json b/pages.json
index 58b26c60..dab0a970 100644
--- a/pages.json
+++ b/pages.json
@@ -243,6 +243,13 @@
"navigationBarTitleText": "设置导航条颜色"
}
},
+ {
+ "path": "pages/API/set-navigation-bar-color/set-custom-navigation-bar-color",
+ "style": {
+ "navigationBarTitleText": "设置自定义导航栏颜色",
+ "navigationStyle": "custom"
+ }
+ },
{
"path": "pages/API/navigator/new-page/new-page-1",
"style": {
@@ -335,48 +342,48 @@
"style": {
"navigationBarTitleText": "background-image"
}
- },
- {
- "path": "pages/CSS/border/border-bottom",
- "style": {
- "navigationBarTitleText": "border-bottom"
- }
+ },
+ {
+ "path": "pages/CSS/border/border-bottom",
+ "style": {
+ "navigationBarTitleText": "border-bottom"
+ }
},
{
"path": "pages/CSS/border/border-color",
"style": {
"navigationBarTitleText": "border-color"
}
- },
- {
- "path": "pages/CSS/border/border-left",
- "style": {
- "navigationBarTitleText": "border-left"
- }
+ },
+ {
+ "path": "pages/CSS/border/border-left",
+ "style": {
+ "navigationBarTitleText": "border-left"
+ }
},
{
"path": "pages/CSS/border/border-radius",
"style": {
"navigationBarTitleText": "border-radius"
}
- },
- {
- "path": "pages/CSS/border/border-right",
- "style": {
- "navigationBarTitleText": "border-right"
- }
+ },
+ {
+ "path": "pages/CSS/border/border-right",
+ "style": {
+ "navigationBarTitleText": "border-right"
+ }
},
{
"path": "pages/CSS/border/border-style",
"style": {
"navigationBarTitleText": "border-style"
}
- },
- {
- "path": "pages/CSS/border/border-top",
- "style": {
- "navigationBarTitleText": "border-top"
- }
+ },
+ {
+ "path": "pages/CSS/border/border-top",
+ "style": {
+ "navigationBarTitleText": "border-top"
+ }
},
{
"path": "pages/CSS/border/border-width",
@@ -901,30 +908,33 @@
"style": {
"navigationStyle": "custom"
}
- }, {
+ },
+ {
"path": "pages/API/unicloud-file-api/unicloud-file-api",
"style": {
"navigationBarTitleText": ""
}
-
- }, {
+ },
+ {
"path": "pages/API/unicloud-database/unicloud-database",
"style": {
"navigationBarTitleText": ""
}
-
- }, {
+ },
+ {
"path": "pages/template/navbar-lite/navbar-lite",
"style": {
"navigationBarTitleText": "自定义导航栏",
"navigationStyle": "custom"
}
- }, {
+ },
+ {
"path": "pages/template/custom-tab-bar/custom-tab-bar",
"style": {
"navigationBarTitleText": "自定义TabBar"
}
- }, {
+ },
+ {
"path": "pages/template/custom-tab-bar2/custom-tab-bar2",
"style": {
"navigationBarTitleText": "自定义TabBar2"
@@ -980,4 +990,4 @@
"query": "" //启动参数,在页面的onLoad函数里面得到
}]
}
-}
\ No newline at end of file
+}
diff --git a/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js
new file mode 100644
index 00000000..6fa9e793
--- /dev/null
+++ b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js
@@ -0,0 +1,30 @@
+const CURRENT_PAGE_PATH =
+ "/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color";
+
+describe("setCustomNavigationBarColor", () => {
+ let page;
+ let originLifeCycleNum;
+ beforeAll(async () => {
+ page = await program.navigateTo(CURRENT_PAGE_PATH);
+ await page.waitFor(1000);
+ originLifeCycleNum = await page.callMethod("getLifeCycleNum");
+ });
+
+ afterAll(async () => {
+ await page.callMethod("setLifeCycleNum", originLifeCycleNum);
+ const lifeCycleNum = await page.callMethod("getLifeCycleNum");
+ expect(lifeCycleNum).toBe(originLifeCycleNum);
+ });
+
+ it("setNavigationBarColor2", async () => {
+ await page.callMethod("setNavigationBarColor2");
+ const image = await program.screenshot();
+ expect(image).toMatchImageSnapshot();
+ });
+
+ it("setNavigationBarColor1", async () => {
+ await page.callMethod("setNavigationBarColor1");
+ const image = await program.screenshot();
+ expect(image).toMatchImageSnapshot();
+ });
+});
diff --git a/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue
new file mode 100644
index 00000000..dac025f6
--- /dev/null
+++ b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue
@@ -0,0 +1,105 @@
+
+
+
+ {{ backIcon }}
+ 自定义导航栏
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js b/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js
index aeb3a668..a293b96b 100644
--- a/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js
+++ b/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js
@@ -4,7 +4,6 @@ const CURRENT_PAGE_PATH =
describe('setNavigationBarColor', () => {
let page
let originLifeCycleNum
- let lifeCycleNum
beforeAll(async () => {
page = await program.navigateTo(CURRENT_PAGE_PATH)
await page.waitFor(1000)
@@ -13,7 +12,7 @@ describe('setNavigationBarColor', () => {
afterAll(async () => {
await page.callMethod('setLifeCycleNum', originLifeCycleNum)
- lifeCycleNum = await page.callMethod('getLifeCycleNum')
+ const lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(originLifeCycleNum)
})
diff --git a/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue b/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue
index ee5d7a76..913daf0a 100644
--- a/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue
+++ b/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue
@@ -8,19 +8,17 @@
+
--
GitLab