tjvantoll / nativescript-IQKeyboardManager

NativeScript wrapper for the popular IQKeyboardManager iOS framework
MIT License
100 stars 20 forks source link

Use with TextFields which are not direct siblings #19

Closed vcooley closed 7 years ago

vcooley commented 7 years ago

Does anyone have guidance on using this with TextFields which are not direct siblings? In the official documentation I found this.

However, I am not sure what I should pass in to the part that is SpecialView.self. I'm trying to use this to group input fields together, while allowing them to be minimized. Currently my setup looks something like this (simplified):

<!--Name Form Group -->
<StackLayout (tap)="toggleGroupVisibility()">
    <StackLayout>
        <Label text="First Name"></Label>
        <TextField hint="First Name"></TextField>
    </StackLayout>
    <StackLayout>
        <Label text="Last Name"></Label>
        <TextField hint="Last Name"></TextField>
    </StackLayout>
</StackLayout>

<!--Contact Form Group -->
<StackLayout (tap)="toggleGroupVisibility()">
    <StackLayout>
        <Label text="Phone"></Label>
        <TextField hint="Phone"></TextField>
    </StackLayout>
    <StackLayout>
        <Label text="Email"></Label>
        <TextField hint="Email"></TextField>
    </StackLayout>
</StackLayout>

Thanks.

tjvantoll commented 7 years ago

Good question @vcooley. The raw typings that @EddyVerbruggen is exposing in #20 might help implement those APIs more sanely.

triniwiz commented 7 years ago

@tjvantoll there is a way using a custom view they provided

{N} v2

declare const IQPreviousNextView;
import { ContentView } from "ui/content-view";
export class IQPreviousNextViewImpl extends ContentView {
    private _ios: IQPreviousNextView;
    get ios() {
        return this.ios;
    }
    get _nativeView() {
        return this._ios;
    }
    constructor() {
        super();
        this._ios = IQPreviousNextView.new();
    }
}

{N} v3

import { ContentView } from "ui/content-view";
declare const IQPreviousNextView;
export class IQPreviousNextViewImpl extends ContentView {
    private _ios;
    get ios() {
        return this.ios;
    }
    constructor() {
        super();
        this._ios = IQPreviousNextView.new();
    }
    createNativeView() {
        return this._ios;
    }
}
vcooley commented 7 years ago

I just got to look at this. It works great! Thanks @triniwiz!