提交 3f7673f0 编写于 作者: Q qiang

fix: 优化 picker 组件(pickTime、pickDate)在 iPad 上的显示位置

上级 e9ef5c1c
export function getStatusbarHeight () {
// 横屏时 iOS 获取的状态栏高度错误,进行纠正
return plus.navigator.isImmersedStatusbar() ? Math.round(plus.os.name === 'iOS' ? plus.navigator.getSafeAreaInsets().top : plus.navigator.getStatusbarHeight()) : 0
}
......@@ -2,16 +2,15 @@ import {
callApiSync,
isTabBarPage,
getLastWebview,
getStatusbarHeight,
getScreenInfo
} from '../util'
import {
TITLEBAR_HEIGHT
} from '../../constants'
import { NAVBAR_HEIGHT } from 'uni-helpers/constants'
import tabBar from '../../framework/tab-bar'
import { getStatusbarHeight } from 'uni-platform/helpers/status-bar'
export function getSystemInfoSync () {
return callApiSync(getSystemInfo, Object.create(null), 'getSystemInfo', 'getSystemInfoSync')
}
......@@ -35,7 +34,7 @@ export function getSystemInfo () {
let style = webview.getStyle()
style = style && style.titleNView
if (style && style.type && style.type !== 'none') {
titleNView.height = style.type === 'transparent' ? 0 : (statusBarHeight + TITLEBAR_HEIGHT)
titleNView.height = style.type === 'transparent' ? 0 : (statusBarHeight + NAVBAR_HEIGHT)
titleNView.cover = style.type === 'transparent' || style.type === 'float'
}
safeAreaInsets = webview.getSafeAreaInsets()
......
......@@ -154,11 +154,6 @@ const outOfChina = function (lng, lat) {
return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false)
}
export function getStatusbarHeight () {
// 横屏时 iOS 获取的状态栏高度错误,进行纠正
return plus.navigator.isImmersedStatusbar() ? Math.round(plus.os.name === 'iOS' ? plus.navigator.getSafeAreaInsets().top : plus.navigator.getStatusbarHeight()) : 0
}
export function getScreenInfo () {
const { resolutionWidth, resolutionHeight } = plus.screen.getCurrentSize()
return {
......@@ -210,4 +205,4 @@ export function warpPlusMethod (origin, name, before) {
export function getFileName (path) {
const array = path.split('/')
return array[array.length - 1]
}
}
......@@ -5,8 +5,6 @@ export const ANI_DURATION = 300
export const ANI_CLOSE = downgrade ? 'slide-out-right' : 'pop-out'
export const TITLEBAR_HEIGHT = 44
export const ON_REACH_BOTTOM_DISTANCE = 50
export const VIEW_WEBVIEW_PATH = '_www/__uniappview.html'
......@@ -19,4 +17,4 @@ export const V_SHOW = 'v-show'
export const B_CLASS = 'c'
export const B_STYLE = 's'
export const S_CLASS = 'sc'
export const S_CLASS = 'sc'
......@@ -21,16 +21,15 @@ import {
} from '../../../constants'
import {
ON_REACH_BOTTOM_DISTANCE,
TITLEBAR_HEIGHT
ON_REACH_BOTTOM_DISTANCE
}
from '../../constants'
import { NAVBAR_HEIGHT } from 'uni-helpers/constants'
import tabBar from '../tab-bar'
import {
getStatusbarHeight
} from '../../api/util'
import { getStatusbarHeight } from 'uni-platform/helpers/status-bar'
import {
preloadSubPackages
......@@ -58,7 +57,7 @@ function parsePageCreateOptions (vm, route) {
onReachBottomDistance,
statusbarHeight,
windowTop: windowOptions.titleNView && windowOptions.titleNView.type === 'float' ? (statusbarHeight +
TITLEBAR_HEIGHT) : 0,
NAVBAR_HEIGHT) : 0,
windowBottom: (tabBar.indexOf(route) >= 0 && tabBar.cover) ? tabBar.height : 0
}
}
......@@ -108,9 +107,9 @@ export function initLifecycle (Vue) {
},
mounted () {
if (this.mpType === 'page') {
callPageHook(this.$scope, 'onReady')
callPageHook(this.$scope, 'onReady')
preloadSubPackages(this.$scope.route)
}
}
})
}
}
import {
TITLEBAR_HEIGHT
} from '../../../constants'
import { NAVBAR_HEIGHT } from 'uni-helpers/constants'
import {
backbuttonListener
......@@ -10,9 +8,7 @@ import {
isTabBarPage
} from '../../../bridge'
import {
getStatusbarHeight
} from '../../../api/util'
import { getStatusbarHeight } from 'uni-platform/helpers/status-bar'
import tabBar from '../../tab-bar'
......@@ -100,7 +96,7 @@ function initSubNVue (subNVue, routeOptions, webview) {
style.dock = 'top'
style.top = 0
style.width = '100%'
style.height = TITLEBAR_HEIGHT + getStatusbarHeight()
style.height = NAVBAR_HEIGHT + getStatusbarHeight()
delete style.left
delete style.right
delete style.bottom
......
......@@ -11,6 +11,7 @@
import { emitter } from 'uni-mixins'
import { showPage } from './page'
import * as webview from './webview'
import { getNavigationBarHeight } from '../../utils'
const mode = {
SELECTOR: 'selector',
......@@ -198,17 +199,23 @@ export default {
}
}
},
_show () {
_show (event) {
if (this.disabled) {
return
}
const rect = event.currentTarget.getBoundingClientRect()
this._showPicker(Object.assign({}, this.$props, {
value: this.valueSync
}))
}), {
top: rect.top + getNavigationBarHeight(),
left: rect.left,
width: rect.width,
height: rect.height
})
},
_showPicker (data) {
_showPicker (data, popover) {
if ((data.mode === mode.TIME || data.mode === mode.DATE) && !data.fields) {
this._showNativePicker(data)
this._showNativePicker(data, popover)
} else {
data.fields = Object.values(fields).includes(data.fields) ? data.fields : fields.DAY
webview.exists((exists) => {
......@@ -216,7 +223,7 @@ export default {
})
}
},
_showNativePicker (data) {
_showNativePicker (data, popover) {
plus.nativeUI[this.mode === mode.TIME ? 'pickTime' : 'pickDate']((res) => {
const date = res.date
this.$trigger('change', {}, {
......@@ -225,11 +232,13 @@ export default {
}, () => {
this.$trigger('cancel', {}, {})
}, this.mode === mode.TIME ? {
time: getDate(this.value, mode.TIME)
time: getDate(this.value, mode.TIME),
popover
} : {
date: getDate(this.value, mode.DATE),
minDate: getDate(this.start, mode.DATE),
maxDate: getDate(this.end, mode.DATE)
maxDate: getDate(this.end, mode.DATE),
popover
})
},
_showWeexPicker (data) {
......
......@@ -6,6 +6,9 @@ import {
WEBVIEW_INSERTED,
WEBVIEW_REMOVED
} from '../../../constants'
import { NAVBAR_HEIGHT } from 'uni-helpers/constants'
let webview = false
const insertHTMLWebView = ({
htmlId
......@@ -19,9 +22,9 @@ const insertHTMLWebView = ({
const parentTitleNView = parentWebview.getTitleNView()
if (parentTitleNView) {
if (plus.navigator.isImmersedStatusbar()) {
styles.top = 44 + plus.navigator.getStatusbarHeight()
styles.top = NAVBAR_HEIGHT + plus.navigator.getStatusbarHeight()
} else {
styles.top = 44
styles.top = NAVBAR_HEIGHT
}
styles.bottom = 0
}
......
const TITLEBAR_HEIGHT = 44
function getStatusbarHeight () {
// 横屏时 iOS 获取的状态栏高度错误,进行纠正
return plus.navigator.isImmersedStatusbar() ? Math.round(plus.os.name === 'iOS' ? plus.navigator.getSafeAreaInsets().top : plus.navigator.getStatusbarHeight()) : 0
}
function getNavigationBarHeight () {
const webview = plus.webview.currentWebview()
let style = webview.getStyle()
style = style && style.titleNView
if (style && style.type === 'default') {
return TITLEBAR_HEIGHT + getStatusbarHeight()
}
return 0
}
import { getNavigationBarHeight } from '../utils'
function getFixed ($el) {
let fixed
......
import { getStatusbarHeight } from 'uni-platform/helpers/status-bar'
import { NAVBAR_HEIGHT } from 'uni-helpers/constants'
export function getNavigationBarHeight () {
const webview = plus.webview.currentWebview()
let style = webview.getStyle()
style = style && style.titleNView
if (style && style.type === 'default') {
return NAVBAR_HEIGHT + getStatusbarHeight()
}
return 0
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册