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