Skip to content

Commit a14a5ce

Browse files
Configurable button bar on iPad #3
1 parent addc987 commit a14a5ce

File tree

8 files changed

+30
-11
lines changed

8 files changed

+30
-11
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ export function pageLoaded(args: observable.EventData) {
9191
returnKeyTitle: "Go!",
9292
locale: "en_US", // or "nl_NL", or any valid locale really (to define the decimal char)
9393
noReturnKey: true,
94-
noDecimals: true
94+
noDecimals: true,
95+
noIpadInputBar: true // suppress the bar with buttons iOS renders on iPad since iOS 9
9596
});
9697
}
9798
```

demo/app/main-page.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export function pageLoaded(args: observable.EventData) {
1515
textView: textView,
1616
returnKeyTitle: "Go!",
1717
locale: "en_US",
18-
noDecimals: true
18+
noDecimals: true,
19+
noIpadInputBar: true
1920
});
2021
}

demo/app/main-page.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<NumKey:NumericKeyboardView row="6" col="1" locale="nl_NL" text="567,89"/>
2727

2828
<Label row="7" col="0" text="No return key"/>
29-
<NumKey:NumericKeyboardView id="noReturnKey" noReturnKey="true" row="7" col="1" text="678"/>
29+
<NumKey:NumericKeyboardView id="noReturnKey" noIpadInputBar="true" noReturnKey="true" row="7" col="1" text="678"/>
3030
</GridLayout>
3131
</ScrollView>
3232
<Button horizontalAlignment="center" text="submit" tap="{{ onSubmit }}"/>

numeric-keyboard.common.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface NumericKeyboardOptions {
55
noReturnKey?: boolean;
66
returnKeyTitle?: string;
77
locale?: string;
8+
noIpadInputBar?: boolean;
89
}
910
export interface NumericKeyboardApi {
1011
decorate(args: NumericKeyboardOptions): Promise<any>;

numeric-keyboard.common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface NumericKeyboardOptions {
66
noReturnKey?: boolean;
77
returnKeyTitle?: string;
88
locale?: string;
9+
noIpadInputBar?: boolean;
910
// onReturnKeyPressed?: (keyboard: any) => boolean;
1011
}
1112

numeric-keyboard.ios.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export declare class NumericKeyboardView extends TextView {
1010
private _locale;
1111
private _noDecimals;
1212
private _noReturnKey;
13+
private _noIpadInputBar;
1314
private _keyboardDelegate;
1415
private _ios;
1516
private _loaded;
@@ -20,4 +21,5 @@ export declare class NumericKeyboardView extends TextView {
2021
noDecimals: boolean;
2122
locale: string;
2223
noReturnKey: boolean;
24+
noIpadInputBar: boolean;
2325
}

numeric-keyboard.ios.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,16 @@ export class NumericKeyboard implements NumericKeyboardApi {
4545
}
4646
}
4747

48-
if (args.textView.ios === undefined) {
49-
(<any>args.textView).inputView = this._keyboard;
50-
} else {
51-
args.textView.ios.inputView = this._keyboard;
52-
if (!args.textView.backgroundColor) {
53-
args.textView.backgroundColor = new Color("transparent");
54-
}
48+
let nativeView = args.textView.ios ? args.textView.ios : args.textView;
49+
nativeView.inputView = this._keyboard;
50+
51+
if (args.textView.ios !== undefined && !args.textView.backgroundColor) {
52+
args.textView.backgroundColor = new Color("transparent");
53+
}
54+
55+
if (args.noIpadInputBar && nativeView.inputAssistantItem) {
56+
nativeView.inputAssistantItem.leadingBarButtonGroups = [];
57+
nativeView.inputAssistantItem.trailingBarButtonGroups = [];
5558
}
5659

5760
resolve();
@@ -64,6 +67,7 @@ export class NumericKeyboardView extends TextView {
6467
private _locale: string;
6568
private _noDecimals: boolean;
6669
private _noReturnKey: boolean;
70+
private _noIpadInputBar: boolean;
6771
private _keyboardDelegate: MMNumberKeyboardDelegateImpl = null;
6872
private _ios: any;
6973
private _loaded: boolean = false;
@@ -102,6 +106,11 @@ export class NumericKeyboardView extends TextView {
102106
// keyboard.returnKeyButtonStyle = MMNumberKeyboardButtonStyleDone; // (Done = default, there's also White and Gray)
103107
this._ios.inputView = this._keyboard;
104108

109+
if (this._noIpadInputBar && this._ios.inputAssistantItem) {
110+
this._ios.inputAssistantItem.leadingBarButtonGroups = [];
111+
this._ios.inputAssistantItem.trailingBarButtonGroups = [];
112+
}
113+
105114
// if not set by the user make it transparent (just like regular TextFields are)
106115
if (!this.backgroundColor) {
107116
this.backgroundColor = new Color("transparent");
@@ -129,6 +138,10 @@ export class NumericKeyboardView extends TextView {
129138
set noReturnKey(value: boolean) {
130139
this._noReturnKey = value;
131140
}
141+
142+
set noIpadInputBar(value: boolean) {
143+
this._noIpadInputBar = value;
144+
}
132145
}
133146

134147
// https://developer.apple.com/reference/homekit/hmaccessorybrowserdelegate?language=objc

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-numeric-keyboard",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "Handy and elegant numeric keyboard for iOS NativeScript apps. On Android we fall back to the regular numeric keyboard for now.",
55
"main": "numeric-keyboard",
66
"typings": "index.d.ts",

0 commit comments

Comments
 (0)