Skip to content

Commit e7951b3

Browse files
authored
feat(android): Add possibility to choose theme in android dialogs (#9212)
1 parent d8b045e commit e7951b3

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎packages/core/ui/dialogs/dialogs-common.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ export interface CancelableOptions {
2323
* [Android only] Gets or sets if the dialog can be canceled by taping outside of the dialog.
2424
*/
2525
cancelable?: boolean;
26+
27+
/**
28+
* [Android only] Sets the theme of the Dialog. Usable themes can be found: https://developer.android.com/reference/android/R.style
29+
*/
30+
theme?: number;
2631
}
2732

2833
/**

‎packages/core/ui/dialogs/index.android.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function isString(value): value is string {
1212
}
1313

1414
function createAlertDialog(options?: DialogOptions): android.app.AlertDialog.Builder {
15-
const alert = new android.app.AlertDialog.Builder(androidApp.foregroundActivity);
15+
const alert = new android.app.AlertDialog.Builder(androidApp.foregroundActivity, options.theme ? options.theme : -1);
1616
alert.setTitle(options && isString(options.title) ? options.title : '');
1717
alert.setMessage(options && isString(options.message) ? options.message : '');
1818
if (options && options.cancelable === false) {
@@ -325,7 +325,7 @@ export function action(...args): Promise<string> {
325325
return new Promise<string>((resolve, reject) => {
326326
try {
327327
const activity = androidApp.foregroundActivity || androidApp.startActivity;
328-
const alert = new android.app.AlertDialog.Builder(activity);
328+
const alert = new android.app.AlertDialog.Builder(activity, options.theme ? options.theme : -1);
329329
const message = options && isString(options.message) ? options.message : '';
330330
const title = options && isString(options.title) ? options.title : '';
331331
if (options && options.cancelable === false) {

‎packages/core/ui/dialogs/index.d.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ export interface CancelableOptions {
142142
* [Android only] Gets or sets if the dialog can be canceled by taping outside of the dialog.
143143
*/
144144
cancelable?: boolean;
145+
146+
/**
147+
* [Android only] Sets the theme of the Dialog. Usable themes can be found: https://developer.android.com/reference/android/R.style
148+
*/
149+
theme?: number;
145150
}
146151

147152
/**

0 commit comments

Comments
 (0)