@nativescript/keyboard-toolbar
Version:
NativeScript Keyboard Toolbar
60 lines • 2.15 kB
JavaScript
import { ContentView, Property, booleanConverter } from '@nativescript/core';
export const forIdProperty = new Property({
name: 'forId',
});
export const showWhenKeyboardHiddenProperty = new Property({
name: 'showWhenKeyboardHidden',
defaultValue: false,
valueConverter: booleanConverter,
});
export const showAtBottomWhenKeyboardHiddenProperty = new Property({
name: 'showAtBottomWhenKeyboardHidden',
defaultValue: false,
valueConverter: booleanConverter,
});
export class ToolbarBase extends ContentView {
constructor() {
super(...arguments);
// if the keyboard is hidden without blurring the textfield (and vice versa) then the blur/focus events don't fire, so track focus manually
this.hasFocus = false;
}
_layout(left, top, right, bottom) { }
log(what) {
if (ToolbarBase.DEBUG) {
console.log('⌨︎ ' + what);
}
}
onLoaded() {
super.onLoaded();
// TODO figure out how to determine and apply the parent's height automatically based on the child's height
if (isNaN(+this.height)) {
console.log(`\n⌨ ⌨ ⌨ Please specify height="<nr of px>" or the toolbar won't render correctly! Example: <Toolbar forId="${this.forId}" height="44">\n\n`);
}
this._loaded();
}
onUnloaded() {
super.onUnloaded();
this._unloaded();
}
onLayout(left, top, right, bottom) {
super.onLayout(left, top, right, bottom);
this._layout(left, top, right, bottom);
}
_addChildFromBuilder(name, value) {
this.content = value;
}
[forIdProperty.setNative](value) {
this.forId = value;
}
[showWhenKeyboardHiddenProperty.setNative](value) {
this.showWhenKeyboardHidden = value;
}
[showAtBottomWhenKeyboardHiddenProperty.setNative](value) {
this.showAtBottomWhenKeyboardHidden = value;
}
}
ToolbarBase.DEBUG = false;
forIdProperty.register(ToolbarBase);
showWhenKeyboardHiddenProperty.register(ToolbarBase);
showAtBottomWhenKeyboardHiddenProperty.register(ToolbarBase);
//# sourceMappingURL=common.js.map