mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(dialog): add decimal input type for prompt dialog (#6805)
This commit is contained in:
committed by
Manol Donev
parent
672c821d14
commit
408614dd45
@@ -1,18 +0,0 @@
|
||||
<Page loaded="pageLoaded">
|
||||
<StackLayout>
|
||||
<Label text="{{ name }}" id="label" style="text-align:center;" />
|
||||
<Button text="action" tap="{{ actionName }}" />
|
||||
<Button text="alert" tap="{{ alertName }}" />
|
||||
<Button text="confirm" tap="{{ confirmName }}" />
|
||||
<Button text="login" tap="{{ loginName }}" />
|
||||
<Button text="promptText" tap="{{ promptText }}" />
|
||||
<Button text="promptPass" tap="{{ promptPass }}" />
|
||||
<Button text="promptEmail" tap="{{ promptEmail }}" />
|
||||
<Button text="promptNumber" tap="{{ promptNumber }}" />
|
||||
<Button text="promptPhone" tap="{{ promptPhone }}" />
|
||||
<Button text="promptCapitalizationNone" tap="{{ promptCapitalizationNone }}" />
|
||||
<Button text="promptCapitalizationAll" tap="{{ promptCapitalizationAll }}" />
|
||||
<Button text="promptCapitalizationSentences" tap="{{ promptCapitalizationSentences }}" />
|
||||
<Button text="promptCapitalizationWords" tap="{{ promptCapitalizationWords }}" />
|
||||
</StackLayout>
|
||||
</Page>
|
||||
13
apps/app/ui-tests-app/dialogs/main-page-common.css
Normal file
13
apps/app/ui-tests-app/dialogs/main-page-common.css
Normal file
@@ -0,0 +1,13 @@
|
||||
Button.even, Button.odd {
|
||||
border-radius: 5;
|
||||
color: white;
|
||||
margin: 0 5 5 0;
|
||||
}
|
||||
|
||||
Button.even {
|
||||
background-color: #0000cc;
|
||||
}
|
||||
|
||||
Button.odd {
|
||||
background-color: #33cc33;
|
||||
}
|
||||
7
apps/app/ui-tests-app/dialogs/main-page.android.css
Normal file
7
apps/app/ui-tests-app/dialogs/main-page.android.css
Normal file
@@ -0,0 +1,7 @@
|
||||
@import './main-page-common.css';
|
||||
|
||||
Button.even, Button.odd {
|
||||
height: 25;
|
||||
font-size: 10;
|
||||
padding: 0;
|
||||
}
|
||||
5
apps/app/ui-tests-app/dialogs/main-page.ios.css
Normal file
5
apps/app/ui-tests-app/dialogs/main-page.ios.css
Normal file
@@ -0,0 +1,5 @@
|
||||
@import './main-page-common.css';
|
||||
|
||||
Button.even, Button.odd {
|
||||
padding: 5;
|
||||
}
|
||||
21
apps/app/ui-tests-app/dialogs/main-page.xml
Normal file
21
apps/app/ui-tests-app/dialogs/main-page.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<Page loaded="pageLoaded">
|
||||
<GridLayout rows="auto, *">
|
||||
<Label text="{{ name }}" id="label" style="text-align:center;" />
|
||||
<WrapLayout row="1">
|
||||
<Button class="even" text="action" tap="{{ actionName }}" />
|
||||
<Button class="odd" text="alert" tap="{{ alertName }}" />
|
||||
<Button class="even" text="confirm" tap="{{ confirmName }}" />
|
||||
<Button class="odd" text="login" tap="{{ loginName }}" />
|
||||
<Button class="even" text="promptText" tap="{{ promptText }}" />
|
||||
<Button class="odd" text="promptPass" tap="{{ promptPass }}" />
|
||||
<Button class="even" text="promptEmail" tap="{{ promptEmail }}" />
|
||||
<Button class="odd" text="promptNumber" tap="{{ promptNumber }}" />
|
||||
<Button class="even" text="promptDecimal" tap="{{ promptDecimal }}" />
|
||||
<Button class="odd" text="promptPhone" tap="{{ promptPhone }}" />
|
||||
<Button class="even" text="promptCapitalizationNone" tap="{{ promptCapitalizationNone }}" />
|
||||
<Button class="odd" text="promptCapitalizationAll" tap="{{ promptCapitalizationAll }}" />
|
||||
<Button class="even" text="promptCapitalizationSentences" tap="{{ promptCapitalizationSentences }}" />
|
||||
<Button class="odd" text="promptCapitalizationWords" tap="{{ promptCapitalizationWords }}" />
|
||||
</WrapLayout>
|
||||
</GridLayout>
|
||||
</Page>
|
||||
@@ -121,11 +121,11 @@ export class SettingsViewModel extends observable.Observable {
|
||||
public promptEmail(args: observable.EventData) {
|
||||
dialogs.prompt({
|
||||
title: "Name",
|
||||
message: "Enter name:",
|
||||
message: "Enter email:",
|
||||
cancelButtonText: "Cancel",
|
||||
neutralButtonText: "Ignore",
|
||||
okButtonText: "OK",
|
||||
defaultText: "John Reese",
|
||||
defaultText: "john.reese@nativescript.org",
|
||||
inputType: dialogs.inputType.email
|
||||
}).then((promptResult) => {
|
||||
console.log("### Result: " + promptResult.result + ", Text: " + promptResult.text);
|
||||
@@ -158,6 +158,26 @@ export class SettingsViewModel extends observable.Observable {
|
||||
});
|
||||
}
|
||||
|
||||
public promptDecimal(args: observable.EventData) {
|
||||
dialogs.prompt({
|
||||
title: "Name",
|
||||
message: "Enter a decimal number:",
|
||||
cancelButtonText: "Cancel",
|
||||
neutralButtonText: "Ignore",
|
||||
okButtonText: "OK",
|
||||
defaultText: "13.50",
|
||||
inputType: dialogs.inputType.decimal
|
||||
}).then((promptResult) => {
|
||||
console.log("### Result: " + promptResult.result + ", Text: " + promptResult.text);
|
||||
if (promptResult.result) {
|
||||
this.set("name", promptResult.text);
|
||||
}
|
||||
else {
|
||||
this.set("name", "13.50");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public promptPhone(args: observable.EventData) {
|
||||
dialogs.prompt({
|
||||
title: "Name",
|
||||
|
||||
@@ -12,7 +12,7 @@ export function pageLoaded(args: EventData) {
|
||||
examples.set("bindings", "bindings/main-page");
|
||||
examples.set("button", "button/main-page");
|
||||
examples.set("css", "css/main-page");
|
||||
examples.set("dialogs", "dialogs/dialogs");
|
||||
examples.set("dialogs", "dialogs/main-page");
|
||||
examples.set("events", "events/main-page");
|
||||
examples.set("fonts", "font/main-page");
|
||||
examples.set("flexbox", "flexbox/flexbox-main-page");
|
||||
|
||||
Reference in New Issue
Block a user