提交 ff5bff1e 编写于 作者: Q qiang

fix: app-v3 输入组件支持 show-confirm-bar 属性

上级 bc217da0
...@@ -17,6 +17,10 @@ export default { ...@@ -17,6 +17,10 @@ export default {
type: [Number, String], type: [Number, String],
default: 0 default: 0
}, },
showConfirmBar: {
type: [Boolean, String],
default: 'auto'
},
adjustPosition: { adjustPosition: {
type: Boolean, type: Boolean,
default: true default: true
...@@ -42,9 +46,10 @@ export default { ...@@ -42,9 +46,10 @@ export default {
el.addEventListener('focus', () => { el.addEventListener('focus', () => {
UniViewJSBridge.subscribe('hideKeyboard', hideKeyboard) UniViewJSBridge.subscribe('hideKeyboard', hideKeyboard)
document.addEventListener('click', iosHideKeyboard, false) document.addEventListener('click', iosHideKeyboard, false)
this.setSoftinputNavBar()
this.setSoftinputTemporary() this.setSoftinputTemporary()
}) })
el.addEventListener('blur', this.onKeyboardHide) el.addEventListener('blur', this.onKeyboardHide.bind(this))
}, },
showSoftKeybord () { showSoftKeybord () {
plusReady(() => { plusReady(() => {
...@@ -53,12 +58,12 @@ export default { ...@@ -53,12 +58,12 @@ export default {
}, },
setSoftinputTemporary () { setSoftinputTemporary () {
plusReady(() => { plusReady(() => {
var currentWebview = plus.webview.currentWebview() const currentWebview = plus.webview.currentWebview()
var style = currentWebview.getStyle() || {} const style = currentWebview.getStyle() || {}
if (style.softinputMode === 'adjustResize') { if (style.softinputMode === 'adjustResize') {
return return
} }
var rect = this.$el.getBoundingClientRect() const rect = this.$el.getBoundingClientRect()
currentWebview.setSoftinputTemporary && currentWebview.setSoftinputTemporary({ currentWebview.setSoftinputTemporary && currentWebview.setSoftinputTemporary({
mode: this.adjustPosition ? 'adjustPan' : 'nothing', mode: this.adjustPosition ? 'adjustPan' : 'nothing',
position: { position: {
...@@ -68,9 +73,40 @@ export default { ...@@ -68,9 +73,40 @@ export default {
}) })
}) })
}, },
setSoftinputNavBar () {
if (this.showConfirmBar === 'auto') {
delete this.__softinputNavBar
return
}
plusReady(() => {
const currentWebview = plus.webview.currentWebview()
const { softinputNavBar } = currentWebview.getStyle() || {}
const showConfirmBar = softinputNavBar !== 'none'
if (showConfirmBar !== this.showConfirmBar) {
this.__softinputNavBar = softinputNavBar || 'auto'
currentWebview.setStyle({
softinputNavBar: this.showConfirmBar ? 'auto' : 'none'
})
} else {
delete this.__softinputNavBar
}
})
},
resetSoftinputNavBar () {
const softinputNavBar = this.__softinputNavBar
if (softinputNavBar) {
plusReady(() => {
const currentWebview = plus.webview.currentWebview()
currentWebview.setStyle({
softinputNavBar
})
})
}
},
onKeyboardHide () { onKeyboardHide () {
UniViewJSBridge.unsubscribe('hideKeyboard', hideKeyboard) UniViewJSBridge.unsubscribe('hideKeyboard', hideKeyboard)
document.removeEventListener('click', iosHideKeyboard, false) document.removeEventListener('click', iosHideKeyboard, false)
this.resetSoftinputNavBar()
} }
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册