| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1232d1e commit ae6a661
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,5 +8,9 @@ | |||
| 8 | 8 | <Button text="promptText" tap="{{ promptText }}" /> | |
| 9 | 9 | <Button text="promptPass" tap="{{ promptPass }}" /> | |
| 10 | 10 | <Button text="promptEmail" tap="{{ promptEmail }}" /> | |
| 11 | + <Button text="promptCapitalizationNone" tap="{{ promptCapitalizationNone }}" /> | ||
| 12 | + <Button text="promptCapitalizationAll" tap="{{ promptCapitalizationAll }}" /> | ||
| 13 | + <Button text="promptCapitalizationSentences" tap="{{ promptCapitalizationSentences }}" /> | ||
| 14 | + <Button text="promptCapitalizationWords" tap="{{ promptCapitalizationWords }}" /> | ||
| 11 | 15 | </StackLayout> | |
| 12 | 16 | </Page> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -137,5 +137,81 @@ export class SettingsViewModel extends observable.Observable { | |||
| 137 | 137 | } | |
| 138 | 138 | }); | |
| 139 | 139 | } | |
| 140 | + | ||
| 141 | + public promptCapitalizationNone(args: observable.EventData) { | ||
| 142 | + dialogs.prompt({ | ||
| 143 | + title: "Name", | ||
| 144 | + message: "Enter name:", | ||
| 145 | + cancelButtonText: "Cancel", | ||
| 146 | + okButtonText: "OK", | ||
| 147 | + inputType: dialogs.inputType.text, | ||
| 148 | + capitalizationType: dialogs.capitalizationType.none | ||
| 149 | + }).then((promptResult) => { | ||
| 150 | + console.log("### Result: " + promptResult.result + ", Text: " + promptResult.text); | ||
| 151 | + if (promptResult.result) { | ||
| 152 | + this.set("name", promptResult.text); | ||
| 153 | + } | ||
| 154 | + else { | ||
| 155 | + this.set("name", "Harold Finch"); | ||
| 156 | + } | ||
| 157 | + }); | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + public promptCapitalizationAll(args: observable.EventData) { | ||
| 161 | + dialogs.prompt({ | ||
| 162 | + title: "Name", | ||
| 163 | + message: "Enter name:", | ||
| 164 | + cancelButtonText: "Cancel", | ||
| 165 | + okButtonText: "OK", | ||
| 166 | + inputType: dialogs.inputType.text, | ||
| 167 | + capitalizationType: dialogs.capitalizationType.all | ||
| 168 | + }).then((promptResult) => { | ||
| 169 | + console.log("### Result: " + promptResult.result + ", Text: " + promptResult.text); | ||
| 170 | + if (promptResult.result) { | ||
| 171 | + this.set("name", promptResult.text); | ||
| 172 | + } | ||
| 173 | + else { | ||
| 174 | + this.set("name", "Harold Finch"); | ||
| 175 | + } | ||
| 176 | + }); | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + public promptCapitalizationSentences(args: observable.EventData) { | ||
| 180 | + dialogs.prompt({ | ||
| 181 | + title: "Name", | ||
| 182 | + message: "Enter name:", | ||
| 183 | + cancelButtonText: "Cancel", | ||
| 184 | + okButtonText: "OK", | ||
| 185 | + inputType: dialogs.inputType.text, | ||
| 186 | + capitalizationType: dialogs.capitalizationType.sentences | ||
| 187 | + }).then((promptResult) => { | ||
| 188 | + console.log("### Result: " + promptResult.result + ", Text: " + promptResult.text); | ||
| 189 | + if (promptResult.result) { | ||
| 190 | + this.set("name", promptResult.text); | ||
| 191 | + } | ||
| 192 | + else { | ||
| 193 | + this.set("name", "Harold Finch"); | ||
| 194 | + } | ||
| 195 | + }); | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + public promptCapitalizationWords(args: observable.EventData) { | ||
| 199 | + dialogs.prompt({ | ||
| 200 | + title: "Name", | ||
| 201 | + message: "Enter name:", | ||
| 202 | + cancelButtonText: "Cancel", | ||
| 203 | + okButtonText: "OK", | ||
| 204 | + inputType: dialogs.inputType.text, | ||
| 205 | + capitalizationType: dialogs.capitalizationType.words | ||
| 206 | + }).then((promptResult) => { | ||
| 207 | + console.log("### Result: " + promptResult.result + ", Text: " + promptResult.text); | ||
| 208 | + if (promptResult.result) { | ||
| 209 | + this.set("name", promptResult.text); | ||
| 210 | + } | ||
| 211 | + else { | ||
| 212 | + this.set("name", "Harold Finch"); | ||
| 213 | + } | ||
| 214 | + }); | ||
| 215 | + } | ||
| 140 | 216 | } | |
| 141 | 217 | export var settingsViewModel = new SettingsViewModel(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,6 +33,31 @@ export module inputType { | |||
| 33 | 33 | export const email: string = "email"; | |
| 34 | 34 | } | |
| 35 | 35 | ||
| 36 | + /** | ||
| 37 | + * Defines the capitalization type for prompt dialog. | ||
| 38 | + */ | ||
| 39 | + export module capitalizationType { | ||
| 40 | + /** | ||
| 41 | + * No automatic capitalization. | ||
| 42 | + */ | ||
| 43 | + export const none: string = "none"; | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * Capitalizes every character. | ||
| 47 | + */ | ||
| 48 | + export const all: string = "all"; | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * Capitalize the first word of each sentence. | ||
| 52 | + */ | ||
| 53 | + export const sentences: string = "sentences"; | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * Capitalize the first letter of every word. | ||
| 57 | + */ | ||
| 58 | + export const words: string = "words"; | ||
| 59 | + } | ||
| 60 | + | ||
| 36 | 61 | let frame: typeof frameModule; | |
| 37 | 62 | export function getCurrentPage(): Page { | |
| 38 | 63 | if (!frame) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ | |||
| 2 | 2 | * Android specific dialogs functions implementation. | |
| 3 | 3 | */ | |
| 4 | 4 | import { DialogOptions, ConfirmOptions, PromptOptions, PromptResult, LoginOptions, LoginResult, ActionOptions } from "."; | |
| 5 | - import { getLabelColor, getButtonColors, isDialogOptions, inputType, ALERT, OK, CONFIRM, CANCEL, PROMPT, LOGIN } from "./dialogs-common"; | ||
| 5 | + import { getLabelColor, getButtonColors, isDialogOptions, inputType, capitalizationType, ALERT, OK, CONFIRM, CANCEL, PROMPT, LOGIN } from "./dialogs-common"; | ||
| 6 | 6 | import { android as androidApp } from "../../application"; | |
| 7 | 7 | ||
| 8 | 8 | export * from "./dialogs-common"; | |
@@ -185,6 +185,21 @@ export function prompt(arg: any): Promise<PromptResult> { | |||
| 185 | 185 | } else if (options.inputType === inputType.email) { | |
| 186 | 186 | input.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); | |
| 187 | 187 | } | |
| 188 | + | ||
| 189 | + switch (options.capitalizationType) { | ||
| 190 | + case capitalizationType.all: { | ||
| 191 | + input.setInputType(input.getInputType() | android.text.InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS); | ||
| 192 | + break; | ||
| 193 | + } | ||
| 194 | + case capitalizationType.sentences: { | ||
| 195 | + input.setInputType(input.getInputType() | android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); | ||
| 196 | + break; | ||
| 197 | + } | ||
| 198 | + case capitalizationType.words: { | ||
| 199 | + input.setInputType(input.getInputType() | android.text.InputType.TYPE_TEXT_FLAG_CAP_WORDS); | ||
| 200 | + break; | ||
| 201 | + } | ||
| 202 | + } | ||
| 188 | 203 | } | |
| 189 | 204 | ||
| 190 | 205 | input.setText(options && options.defaultText || ""); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,31 @@ export module inputType { | |||
| 23 | 23 | export var email: string; | |
| 24 | 24 | } | |
| 25 | 25 | ||
| 26 | + /** | ||
| 27 | + * Defines the capitalization type for prompt dialog. | ||
| 28 | + */ | ||
| 29 | + export module capitalizationType { | ||
| 30 | + /** | ||
| 31 | + * No automatic capitalization. | ||
| 32 | + */ | ||
| 33 | + export var none: string; | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * Capitalizes every character. | ||
| 37 | + */ | ||
| 38 | + export var all: string; | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * Capitalize the first word of each sentence. | ||
| 42 | + */ | ||
| 43 | + export var sentences: string; | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * Capitalize the first letter of every word. | ||
| 47 | + */ | ||
| 48 | + export var words: string; | ||
| 49 | + } | ||
| 50 | + | ||
| 26 | 51 | /** | |
| 27 | 52 | * The alert() method displays an alert box with a specified message. | |
| 28 | 53 | * @param message Specifies the text to display in the alert box. | |
@@ -177,6 +202,11 @@ export interface PromptOptions extends ConfirmOptions { | |||
| 177 | 202 | * Gets or sets the prompt input type (plain text, password, or email). | |
| 178 | 203 | */ | |
| 179 | 204 | inputType?: string; | |
| 205 | + | ||
| 206 | + /** | ||
| 207 | + * Gets or sets the prompt capitalizationType (none, all, sentences, or words). | ||
| 208 | + */ | ||
| 209 | + capitalizationType?: string; | ||
| 180 | 210 | } | |
| 181 | 211 | ||
| 182 | 212 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ | |||
| 3 | 3 | */ | |
| 4 | 4 | import { View, ios as iosView } from "../core/view"; | |
| 5 | 5 | import { ConfirmOptions, PromptOptions, PromptResult, LoginOptions, LoginResult, ActionOptions } from "."; | |
| 6 | - import { getCurrentPage, getLabelColor, getButtonColors, getTextFieldColor, isDialogOptions, inputType, ALERT, OK, CONFIRM, CANCEL, PROMPT, LOGIN } from "./dialogs-common"; | ||
| 6 | + import { getCurrentPage, getLabelColor, getButtonColors, getTextFieldColor, isDialogOptions, inputType, capitalizationType, ALERT, OK, CONFIRM, CANCEL, PROMPT, LOGIN } from "./dialogs-common"; | ||
| 7 | 7 | import { isString, isDefined, isFunction } from "../../utils/types"; | |
| 8 | 8 | import { getRootView } from "../../application"; | |
| 9 | 9 | ||
@@ -114,6 +114,23 @@ export function prompt(arg: any): Promise<PromptResult> { | |||
| 114 | 114 | ||
| 115 | 115 | textField = alertController.textFields.firstObject; | |
| 116 | 116 | ||
| 117 | + if (options) { | ||
| 118 | + switch (options.capitalizationType) { | ||
| 119 | + case capitalizationType.all: { | ||
| 120 | + textField.autocapitalizationType = UITextAutocapitalizationType.AllCharacters; break; | ||
| 121 | + } | ||
| 122 | + case capitalizationType.sentences: { | ||
| 123 | + textField.autocapitalizationType = UITextAutocapitalizationType.Sentences; break; | ||
| 124 | + } | ||
| 125 | + case capitalizationType.words: { | ||
| 126 | + textField.autocapitalizationType = UITextAutocapitalizationType.Words; break; | ||
| 127 | + } | ||
| 128 | + default: { | ||
| 129 | + textField.autocapitalizationType = UITextAutocapitalizationType.None; | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | + } | ||
| 133 | + | ||
| 117 | 134 | addButtonsToAlertController(alertController, options, | |
| 118 | 135 | (r) => { resolve({ result: r, text: textField.text }); }); | |
| 119 | 136 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments