feat(android): Add possibility to choose theme in android dialogs (#9212)

This commit is contained in:
ReazerDev
2021-02-20 20:15:03 +01:00
committed by GitHub
parent d8b045e705
commit e7951b320f
3 changed files with 12 additions and 2 deletions

View File

@@ -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;
}
/**

View File

@@ -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) {

View File

@@ -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;
}
/**