UNPKG

@cdev38399/nativescript-keyboard-toolbar

Version:

NativeScript Keyboard Toolbar plugin

59 lines (58 loc) 1.85 kB
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); this.hasFocus = false; } _layout(left, top, right, bottom) { } log(what) { if (ToolbarBase.DEBUG) { console.log("⌨︎ " + what); } } onLoaded() { super.onLoaded(); 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);