mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(android): Add possibility to choose theme in android dialogs (#9212)
This commit is contained in:
@@ -23,6 +23,11 @@ export interface CancelableOptions {
|
||||
* [Android only] Gets or sets if the dialog can be canceled by taping outside of the dialog.
|
||||
*/
|
||||
cancelable?: boolean;
|
||||
|
||||
/**
|
||||
* [Android only] Sets the theme of the Dialog. Usable themes can be found: https://developer.android.com/reference/android/R.style
|
||||
*/
|
||||
theme?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,7 @@ function isString(value): value is string {
|
||||
}
|
||||
|
||||
function createAlertDialog(options?: DialogOptions): android.app.AlertDialog.Builder {
|
||||
const alert = new android.app.AlertDialog.Builder(androidApp.foregroundActivity);
|
||||
const alert = new android.app.AlertDialog.Builder(androidApp.foregroundActivity, options.theme ? options.theme : -1);
|
||||
alert.setTitle(options && isString(options.title) ? options.title : '');
|
||||
alert.setMessage(options && isString(options.message) ? options.message : '');
|
||||
if (options && options.cancelable === false) {
|
||||
@@ -325,7 +325,7 @@ export function action(...args): Promise<string> {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
try {
|
||||
const activity = androidApp.foregroundActivity || androidApp.startActivity;
|
||||
const alert = new android.app.AlertDialog.Builder(activity);
|
||||
const alert = new android.app.AlertDialog.Builder(activity, options.theme ? options.theme : -1);
|
||||
const message = options && isString(options.message) ? options.message : '';
|
||||
const title = options && isString(options.title) ? options.title : '';
|
||||
if (options && options.cancelable === false) {
|
||||
|
||||
5
packages/core/ui/dialogs/index.d.ts
vendored
5
packages/core/ui/dialogs/index.d.ts
vendored
@@ -142,6 +142,11 @@ export interface CancelableOptions {
|
||||
* [Android only] Gets or sets if the dialog can be canceled by taping outside of the dialog.
|
||||
*/
|
||||
cancelable?: boolean;
|
||||
|
||||
/**
|
||||
* [Android only] Sets the theme of the Dialog. Usable themes can be found: https://developer.android.com/reference/android/R.style
|
||||
*/
|
||||
theme?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user