|
| 1 | + |
| 2 | +<page> |
| 3 | + <actionBar > |
| 4 | + <label>Dialogs</label> |
| 5 | + </actionBar> |
| 6 | + |
| 7 | + <gridLayout> |
| 8 | + <contentView |
| 9 | + horizontalAlignment="center" |
| 10 | + verticalAlignment="center"> |
| 11 | + <stackLayout> |
| 12 | + |
| 13 | + <button on:tap={showAlert} padding="8" >Alert</button> |
| 14 | + <button on:tap={showAction} padding="8" >Action</button> |
| 15 | + <button on:tap={showConfirm} padding="8" >Confirm</button> |
| 16 | + <button on:tap={showPrompt} padding="8" >Prompt</button> |
| 17 | + <button on:tap={showLogin} padding="8" >Login</button> |
| 18 | + |
| 19 | + </stackLayout> |
| 20 | + </contentView> |
| 21 | + </gridLayout> |
| 22 | +</page> |
| 23 | + |
| 24 | +<script lang="ts"> |
| 25 | + import { action, login, confirm, prompt } from '@nativescript/core' |
| 26 | +
|
| 27 | + function showAlert() { |
| 28 | + // #region example-alert |
| 29 | + alert({ |
| 30 | + title: 'Alert!', |
| 31 | + message: 'Please try again later.', |
| 32 | + okButtonText: 'OK', |
| 33 | + cancelable: true, |
| 34 | + }) |
| 35 | + // #endregion example-alert |
| 36 | + console.log('Show Alert'); |
| 37 | + } |
| 38 | +
|
| 39 | + function showAction() { |
| 40 | + // #region example-action |
| 41 | + action({ |
| 42 | + title: 'Action!', |
| 43 | + message: 'Choose your language:', |
| 44 | + cancelButtonText: 'Cancel', |
| 45 | + actions: ['TypeScript', 'JavaScript', 'Neither'], |
| 46 | + cancelable: true, |
| 47 | + destructiveActionsIndexes: [2], |
| 48 | + }) |
| 49 | + // #endregion example-action |
| 50 | + } |
| 51 | +
|
| 52 | + function showConfirm() { |
| 53 | + // #region example-confirm |
| 54 | + confirm({ |
| 55 | + title: 'Confirm!', |
| 56 | + message: 'Are you sure you want to do this?', |
| 57 | + okButtonText: 'Yes', |
| 58 | + cancelButtonText: 'No', |
| 59 | + neutralButtonText: 'Cancel', |
| 60 | + }).then((result) => { |
| 61 | + console.log(result) |
| 62 | + }) |
| 63 | + // #endregion example-confirm |
| 64 | + } |
| 65 | +
|
| 66 | + function showPrompt() { |
| 67 | + // #region example-prompt |
| 68 | + prompt({ |
| 69 | + title: 'Prompt!', |
| 70 | + message: 'Enter the name of this framework:', |
| 71 | + defaultText: 'NativeScript', |
| 72 | + okButtonText: 'OK', |
| 73 | + neutralButtonText: 'Cancel', |
| 74 | + // cancelable: true, |
| 75 | + // cancelButtonText: 'Cancel', |
| 76 | + // capitalizationType: 'none', |
| 77 | + // inputType: 'email', |
| 78 | + }); |
| 79 | + // #endregion example-prompt |
| 80 | + } |
| 81 | +
|
| 82 | + function showLogin() { |
| 83 | + // #region example-login |
| 84 | + login({ |
| 85 | + title: 'Login!', |
| 86 | + message: 'Enter your credentials', |
| 87 | + okButtonText: 'Login', |
| 88 | + cancelButtonText: 'Cancel', |
| 89 | + userName: 'NativeScript', |
| 90 | + password: 'hunter2', |
| 91 | + // neutralButtonText: 'Neutral', |
| 92 | + // cancelable: true, |
| 93 | + // passwordHint: 'Your password', |
| 94 | + // userNameHint: 'Your username', |
| 95 | + }); |
| 96 | + } |
| 97 | + // #endregion example-login |
| 98 | +</script> |
| 99 | + |
| 100 | +<style> |
| 101 | +</style> |
0 commit comments