Skip to content

Commit a60f2a1

Browse files
committed
fix: ios disableContentInsets fix for dialogs
1 parent 8861e82 commit a60f2a1

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/dialogs/dialogs.ios.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ declare class IMDCAlertControllerImpl extends MDCAlertController {
7878
_resolveFunction?: Function;
7979
actions: NSArray<any>;
8080
viewLayedOut: boolean;
81+
_disableContentInsets: boolean;
8182
}
8283
const MDCAlertControllerImpl = (MDCAlertController as any).extend({
8384
viewDidAppear() {
@@ -105,7 +106,8 @@ const MDCAlertControllerImpl = (MDCAlertController as any).extend({
105106
},
106107
viewDidLoad() {
107108
this.super.viewDidLoad();
108-
if (this.disableContentInsets) {
109+
if (this._disableContentInsets) {
110+
console.log('removing contentInsets');
109111
(this.view as MDCAlertControllerView).contentInsets = UIEdgeInsetsZero;
110112
}
111113
},
@@ -257,10 +259,16 @@ function createAlertController(options: DialogOptions & MDCAlertControlerOptions
257259
};
258260
view.bindingContext = fromObject(context);
259261
alertController.accessoryView = createUIViewAutoSizeUIViewAutoSize(view);
262+
260263
// if no title or message disable contentInsets to be like android
261-
// if (!options.title && !options.message) {
262-
// (alertController as any).disableContentInsets = true;
263-
// }
264+
if (!options.title && !options.message) {
265+
if (alertController.view) {
266+
(alertController.view as MDCAlertControllerView).contentInsets = UIEdgeInsetsZero;
267+
} else {
268+
alertController._disableContentInsets = true;
269+
270+
}
271+
}
264272
view.viewController = alertController; // needed to prevent a crash in layoutChild
265273
}
266274
const dialogPresentationControllerDelegate = MDCDialogPresentationControllerDelegateImpl.initWithCallback(() => {

0 commit comments

Comments
 (0)