Skip to content

Commit 629f68a

Browse files
committed
feat: resolve action for AlertDialog
1 parent c326907 commit 629f68a

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

src/dialogs/dialogs.android.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,11 @@ export function alert(arg: any): Promise<void> {
274274
export class AlertDialog {
275275
dialog: androidx.appcompat.app.AlertDialog;
276276
constructor(private options: any) {}
277-
show() {
277+
show(resolve?) {
278278
if (!this.dialog) {
279279
const alert = createAlertDialogBuilder(this.options);
280280
this.dialog = alert.create();
281-
this.dialog = prepareAndCreateAlertDialog(alert, this.options, null);
281+
this.dialog = prepareAndCreateAlertDialog(alert, this.options, resolve);
282282
showDialog(this.dialog, this.options);
283283
}
284284
}

src/dialogs/dialogs.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,6 @@ export function action(options: ActionOptions & MDCAlertControlerOptions): Promi
118118

119119
export class AlertDialog {
120120
constructor(options: AlertOptions & MDCAlertControlerOptions);
121-
show();
121+
show(resolve?);
122122
hide();
123123
}

src/dialogs/dialogs.ios.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ export { capitalizationType, inputType };
2727

2828
const UIViewAutoSizeUIViewAutoSize = (UIView as any).extend({
2929
systemLayoutSizeFittingSizeWithHorizontalFittingPriorityVerticalFittingPriority(boundsSize: CGSize) {
30-
31-
const actualWidth = Math.min(boundsSize.width,Screen.mainScreen.widthPixels);
30+
const actualWidth = Math.min(boundsSize.width, Screen.mainScreen.widthPixels);
3231
const widthSpec = Utils.layout.makeMeasureSpec(Utils.layout.toDevicePixels(actualWidth), Utils.layout.EXACTLY);
3332
const heighthSpec = Utils.layout.makeMeasureSpec(Utils.layout.toDevicePixels(boundsSize.height), Utils.layout.UNSPECIFIED);
3433
const view = this._view as View;
@@ -42,7 +41,7 @@ const UIViewAutoSizeUIViewAutoSize = (UIView as any).extend({
4241
const view = this._view as View;
4342
const size = this.frame.size;
4443
View.layoutChild(null, view, 0, 0, Utils.layout.toDevicePixels(size.width), Utils.layout.toDevicePixels(size.height));
45-
}
44+
},
4645
});
4746

4847
function createUIViewAutoSizeUIViewAutoSize(view: View) {
@@ -166,7 +165,13 @@ function addButtonsToAlertController(alertController: MDCAlertController, option
166165

167166
function createAlertController(options: DialogOptions & MDCAlertControlerOptions, resolve?: Function) {
168167
const alertController = MDCAlertControllerImpl.alloc().init() as IMDCAlertControllerImpl;
169-
168+
const colorScheme = themer.getAppColorScheme() as MDCSemanticColorScheme;
169+
const scheme = MDCContainerScheme.alloc().init();
170+
if (colorScheme) {
171+
scheme.colorScheme = colorScheme;
172+
}
173+
// Step 3: Apply the container scheme to your component using the desired alert style
174+
alertController.applyThemeWithScheme(scheme);
170175
if (options.title) {
171176
alertController.title = options.title;
172177
}
@@ -253,9 +258,9 @@ function createAlertController(options: DialogOptions & MDCAlertControlerOptions
253258
view.bindingContext = fromObject(context);
254259
alertController.accessoryView = createUIViewAutoSizeUIViewAutoSize(view);
255260
// if no title or message disable contentInsets to be like android
256-
if (!options.title && !options.message) {
257-
(alertController as any).disableContentInsets = true;
258-
}
261+
// if (!options.title && !options.message) {
262+
// (alertController as any).disableContentInsets = true;
263+
// }
259264
view.viewController = alertController; // needed to prevent a crash in layoutChild
260265
}
261266
const dialogPresentationControllerDelegate = MDCDialogPresentationControllerDelegateImpl.initWithCallback(() => {
@@ -301,9 +306,9 @@ export class AlertDialog {
301306
alertController: MDCAlertController;
302307
presentingController: UIViewController;
303308
constructor(private options: any) {}
304-
show() {
309+
show(resolve?) {
305310
if (!this.alertController) {
306-
this.alertController = createAlertController(this.options);
311+
this.alertController = createAlertController(this.options, resolve);
307312
this.presentingController = showUIAlertController(this.alertController);
308313
}
309314
}

0 commit comments

Comments
 (0)