提交 54e414e2 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

feat(setNavigationBarColor): 补充设置状态栏前景色、背景色示例及测试

上级 dabf8c77
......@@ -63,11 +63,10 @@
}
},
{
"path" : "pages/component/list-view/list-view-multiplex-input",
"style" :
{
"navigationBarTitleText" : "list-view复用input",
"enablePullDownRefresh" : false
"path": "pages/component/list-view/list-view-multiplex-input",
"style": {
"navigationBarTitleText": "list-view复用input",
"enablePullDownRefresh": false
}
},
{
......@@ -381,6 +380,13 @@
"navigationBarTitleText": "设置导航条颜色"
}
},
{
"path": "pages/API/set-navigation-bar-color/set-navigation-bar-color-custom-navigation",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "设置状态栏颜色"
}
},
{
"path": "pages/API/set-navigation-bar-title/set-navigation-bar-title",
"style": {
......
const CURRENT_PAGE_PATH =
'/pages/API/set-navigation-bar-color/set-navigation-bar-color-custom-navigation'
describe('set statusBar color', () => {
if (process.env.uniTestPlatformInfo.startsWith('web')) {
it('dummyTest', async () => {
expect(1).toBe(1)
})
return
}
let page
const adbScreenShotArea = {
x: 880,
y: 0,
width: 60,
height: 60
};
if (process.env.uniTestPlatformInfo.startsWith('android 6')) {
adbScreenShotArea.x = 535
adbScreenShotArea.width = 90
adbScreenShotArea.height = 50
} else if (process.env.uniTestPlatformInfo.startsWith('android 12')) {
adbScreenShotArea.x = 1160
adbScreenShotArea.width = 70
adbScreenShotArea.height = 80
}
beforeAll(async () => {
page = await program.navigateTo(CURRENT_PAGE_PATH)
await page.waitFor(1000)
})
it("setNavigationBarColor1", async () => {
await page.callMethod("setNavigationBarColor1");
const image = await program.screenshot({
adb: true,
area: adbScreenShotArea
});
expect(image).toMatchImageSnapshot();
});
it("setNavigationBarColor2", async () => {
await page.callMethod("setNavigationBarColor2");
const image = await program.screenshot({
adb: true,
area: adbScreenShotArea
});
expect(image).toMatchImageSnapshot();
});
})
<template>
<page-head title="setNavigationBarColor"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<button @tap="setNavigationBarColor1" class="uni-btn">
设置状态栏背景绿色,文字白色
</button>
<button @tap="setNavigationBarColor2" class="uni-btn">
设置状态栏背景红色,文字黑色
</button>
</view>
</template>
<script>
export default {
methods: {
setNavigationBarColor1() {
uni.setNavigationBarColor({
frontColor: "#ffffff",
backgroundColor: "#00ff00",
success: () => {
console.log("setNavigationBarColor success");
},
fail: () => {
console.log("setNavigationBarColor fail");
},
complete: () => {
console.log("setNavigationBarColor complete");
},
});
},
setNavigationBarColor2() {
uni.setNavigationBarColor({
frontColor: "#000000",
backgroundColor: "#ff0000",
success: () => {
console.log("setNavigationBarColor success");
},
fail: () => {
console.log("setNavigationBarColor fail");
},
complete: () => {
console.log("setNavigationBarColor complete");
},
});
},
},
};
</script>
......@@ -7,9 +7,12 @@
<button @tap="setNavigationBarColor2" class="uni-btn">
设置导航条背景红色,标题黑色
</button>
<button @tap="goCustomNavigation" class="uni-btn">
<button @tap="goNavbarLite" class="uni-btn">
跳转自定义导航栏页面
</button>
<button @tap="goCustomNavigation" class="uni-btn">
跳转设置状态栏页面
</button>
</view>
</template>
......@@ -62,10 +65,15 @@
setLifeCycleNum(num : number) {
setLifeCycleNum(num)
},
goCustomNavigation() {
goNavbarLite() {
uni.navigateTo({
url: '/pages/template/navbar-lite/navbar-lite'
})
},
goCustomNavigation(){
uni.navigateTo({
url: '/pages/API/set-navigation-bar-color/set-navigation-bar-color-custom-navigation'
})
}
},
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册