You need to sign in or sign up before continuing.
提交 4024f429 编写于 作者: Q qiang

fix: v3-app 支持 windowBottom

上级 b257c342
...@@ -125,8 +125,7 @@ const PLATFORMS = { ...@@ -125,8 +125,7 @@ const PLATFORMS = {
filterTag: 'wxs', filterTag: 'wxs',
subPackages: false, subPackages: false,
cssVars: { cssVars: {
'--window-top': '0px', '--window-top': '0px'
'--window-bottom': '0px'
}, },
copyWebpackOptions ({ copyWebpackOptions ({
assetsDir, assetsDir,
......
...@@ -48,8 +48,9 @@ export function getSystemInfo () { ...@@ -48,8 +48,9 @@ export function getSystemInfo () {
} else { } else {
safeAreaInsets = ios ? plus.navigator.getSafeAreaInsets() : getSafeAreaInsets() safeAreaInsets = ios ? plus.navigator.getSafeAreaInsets() : getSafeAreaInsets()
} }
var windowBottom = isTabBarPage() && tabBar.visible && tabBar.cover ? tabBar.height : 0
var windowHeight = Math.min(screenHeight - (titleNView ? (statusBarHeight + TITLEBAR_HEIGHT) var windowHeight = Math.min(screenHeight - (titleNView ? (statusBarHeight + TITLEBAR_HEIGHT)
: 0) - (isTabBarPage() && tabBar.visible ? tabBar.height : 0), screenHeight) : 0) - windowBottom, screenHeight)
var windowWidth = screenWidth var windowWidth = screenWidth
var safeArea = { var safeArea = {
left: safeAreaInsets.left, left: safeAreaInsets.left,
...@@ -77,7 +78,7 @@ export function getSystemInfo () { ...@@ -77,7 +78,7 @@ export function getSystemInfo () {
platform, platform,
SDKVersion: '', SDKVersion: '',
windowTop: 0, windowTop: 0,
windowBottom: 0, windowBottom,
safeArea safeArea
} }
} }
...@@ -20,6 +20,8 @@ import { ...@@ -20,6 +20,8 @@ import {
} }
from '../../constants' from '../../constants'
import tabBar from '../tab-bar'
function parsePageCreateOptions (vm, route) { function parsePageCreateOptions (vm, route) {
const pagePath = '/' + route const pagePath = '/' + route
const routeOptions = __uniRoutes.find(route => route.path === pagePath) const routeOptions = __uniRoutes.find(route => route.path === pagePath)
...@@ -39,7 +41,7 @@ function parsePageCreateOptions (vm, route) { ...@@ -39,7 +41,7 @@ function parsePageCreateOptions (vm, route) {
onPageReachBottom, onPageReachBottom,
onReachBottomDistance, onReachBottomDistance,
windowTop: 0, // TODO windowTop: 0, // TODO
windowBottom: 0 // TODO windowBottom: (tabBar.indexOf(route) >= 0 && tabBar.cover) ? tabBar.height : 0
} }
} }
......
...@@ -7,8 +7,10 @@ import { ...@@ -7,8 +7,10 @@ import {
requireNativePlugin requireNativePlugin
} from '../bridge' } from '../bridge'
const TABBAR_HEIGHT = 50 import safeAreaInsets from './safe-area-insets'
const TABBAR_HEIGHT = 50
const isIOS = plus.os.name === 'iOS'
let config let config
/** /**
...@@ -73,7 +75,7 @@ function setTabBarStyle (style) { ...@@ -73,7 +75,7 @@ function setTabBarStyle (style) {
} }
/** /**
* 隐藏 tabBar * 隐藏 tabBar
* @param {boolean} animation 是否需要动画效果 暂未支持 * @param {boolean} animation 是否需要动画效果
*/ */
function hideTabBar (animation) { function hideTabBar (animation) {
visible = false visible = false
...@@ -83,7 +85,7 @@ function hideTabBar (animation) { ...@@ -83,7 +85,7 @@ function hideTabBar (animation) {
} }
/** /**
* 显示 tabBar * 显示 tabBar
* @param {boolean} animation 是否需要动画效果 暂未支持 * @param {boolean} animation 是否需要动画效果
*/ */
function showTabBar (animation) { function showTabBar (animation) {
visible = true visible = true
...@@ -110,7 +112,7 @@ export default { ...@@ -110,7 +112,7 @@ export default {
publish('onTabBarMidButtonTap', {}) publish('onTabBarMidButtonTap', {})
}) })
}, },
switchTab (page) { indexOf (page) {
const itemLength = config.list.length const itemLength = config.list.length
if (itemLength) { if (itemLength) {
for (let i = 0; i < itemLength; i++) { for (let i = 0; i < itemLength; i++) {
...@@ -118,13 +120,20 @@ export default { ...@@ -118,13 +120,20 @@ export default {
config.list[i].pagePath === page || config.list[i].pagePath === page ||
config.list[i].pagePath === `${page}.html` config.list[i].pagePath === `${page}.html`
) { ) {
return i
}
}
}
return -1
},
switchTab (page) {
const index = this.indexOf(page)
if (index >= 0) {
tabBar && tabBar.switchSelect({ tabBar && tabBar.switchSelect({
index: i index
}) })
return true return true
} }
}
}
return false return false
}, },
setTabBarBadge, setTabBarBadge,
...@@ -148,7 +157,13 @@ export default { ...@@ -148,7 +157,13 @@ export default {
return visible return visible
}, },
get height () { get height () {
return config && config.height ? parseFloat(config.height) : TABBAR_HEIGHT return (config && config.height ? parseFloat(config.height) : TABBAR_HEIGHT) + safeAreaInsets.bottom
},
// tabBar是否遮挡内容区域
get cover () {
const array = ['extralight', 'light', 'dark']
// 设置背景颜色会失效
return isIOS && array.indexOf(config.blurEffect) >= 0 && !config.backgroundColor
}, },
setStyle ({ mask }) { setStyle ({ mask }) {
tabBar.setMask({ tabBar.setMask({
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册