eddyverbruggen / nativescript-keyboard-toolbar Goto Github PK
View Code? Open in Web Editor NEW⌨️🛠Add a customizable toolbar on top of the soft keyboard
License: Apache License 2.0
⌨️🛠Add a customizable toolbar on top of the soft keyboard
License: Apache License 2.0
First of all, thanks for the great plugin. I have a test on this plugin, and find it works like a charm on the simulator and phones with the virtual navigation bar. But when it runs on the phone with the physical navigation bar, there are 2 problems:
Android (phones with physical navigation bar)
I've debugged with the real device and found out that the problem is caused by the code here
// at this point, topmost().currentPage is null, so do it like this:
let page: any = parent;
while (!page && !page.frame) {
page = page.parent;
}
const {y} = parent.getLocationOnScreen();
const newHeight = parent.getMeasuredHeight();
// this is the bottom navbar - which may be hidden by the user.. so figure out its actual height
this.isNavbarVisible = page.getMeasuredHeight() < Toolbar.getUsableScreenSizeY();
this.navbarHeight = Toolbar.getNavbarHeight();
I find that the page.getMeasuredHeight()
is returning the exact height as the newHeight
which clearly is wrong.
Further more, I tried using parent.page.getMeasuredHeight()
to compare with Toolbar.getUsableScreenSizeY()
which is still not working(maybe because getUsableScreenSizeY
is taking status bar into account).
Anyway, so I change the way to find out if there is a virtual navigation bar. You can see the complete code below.
private showToolbar(parent): void {
const animateToY = this.startPositionY - this.lastKeyboardHeight - (this.showWhenKeyboardHidden === true ? 0 : (this.lastHeight / screen.mainScreen.scale)) - (this.isNavbarVisible ? 0 : this.navbarHeight);
I guess the problem here is that there is actually no need to minus the this.navbarHeight
anymore. Since the only thing changed should just be the lastKeyboardHeight
, right?
You can see the complete changes here, hope this can be helpful.
PS: I'm also using the getViewForId
in android since I've encountered that problem appeared in iOS.
Hey,
Nativescript recenlty introcuded some big changes (for example they changed the compiler option from "ES-5" to "ES2017"). It would be great if you could bring the whole project up to date.
Here's the url with all the instructions: https://nativescript.org/blog/nativescript-7-for-plugin-authors/
Thank you :)
It would be nice to use such a toolbar also for text inputs within web views. Is this possible in any way?
Demo app works
I see the message on console
Please make sure forId="" resolves to a visible view, or the toolbar won't render correctly! Example:
When it does, the keyboard toolbar does not show no matter how many times I click it the triggering textfield. Then I click the Home button (Android) and click the overview button to go back to the app, then the textfield triggers the keyboardtoolbar and everything works fine!
1 out of 10 times the message does not appear and everything works fine on multiple tabs. Sometimes it only affects some of the keyboardtoolbars.
I tried to recreate the issue using an empty tabbed layout and multiple keyboardtoolbars. the issue did not reoccur. I think it might be related to loading times of the tab contents.
I used the sample code, not much of extras:
<TextField #tfFilterTask id="tf2" row="1" col="0" style="placeholder-color: rgba(255,255,255,0.6)"
class="c-white m-l-5" hint="Kod veya isim..." [text]=filterTaskText
(textChange)="onFilterChange($event)"></TextField>
<KeyboardToolbar2 forId="tf2" height="50">
<GridLayout columns="auto, *,auto,auto, auto" class="c-white p-10" backgroundColor="#26252A">
<Label col="0" class="fas fs-24" verticalAlignment="center" text=" Ara: "></Label>
<Label col="1" class="fs-24" verticalAlignment="center" [text]=filterTaskText></Label>
<Label col="2" class="fas c-white p-5 m-l-20" verticalAlignment="center" textWrap="false" text=""></Label>
<Label col="3" class="fas c-white p-5 m-l-20" verticalAlignment="center" textWrap="false" text="" (tap)="clearKeyboard()"></Label>
<Label col="4" class="fas c-white p-5 m-l-20" verticalAlignment="center" textWrap="false" text="" (tap)="closeKeyboard(tfFilterTask)"></Label>
</GridLayout>
</KeyboardToolbar2>
Thank you for this great plugin, I hope we can solve this issue as I'd really like to use it.
@EddyVerbruggen This is your best yet bud, awesome work! I've been wishing for something like this for ages! Can't wait to use it!
Thanks you!!
IQKeyboardManager
scrolls editable text into view but isn't aware of the toolbar. So let's add the toolbar height to whatever height IQKeyboardManager
uses.
Users can add code to accomplish this in their app, but let's make the plugin a little smarter.
There's a problem with frame.topmost()
in N6. It's undefined
in the demo app when I bump it to N6, so let's see if we can get rid of it entirely.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.