Skip to content

Commit fd8b367

Browse files
committed
fix(dialogs): ios buttonFont should be working again
1 parent 723c541 commit fd8b367

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/dialogs/dialogs.ios.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -128,29 +128,30 @@ function addButtonsToAlertController(alertController: MDCAlertController, option
128128
}
129129
alertController.dismissModalViewControllerAnimated(true);
130130
}
131+
let buttonsFont;
132+
133+
function addButton(title, emphasis, result) {
134+
const action = MDCAlertAction.actionWithTitleEmphasisHandler(title, emphasis, () => {
135+
raiseCallback(callback, result);
136+
});
137+
alertController.addAction(action);
138+
if (options.buttonFont) {
139+
const titleLabel = alertController.buttonForAction(action).titleLabel;
140+
if (!buttonsFont) {
141+
buttonsFont = options.buttonFont.getUIFont(titleLabel.font);
142+
}
143+
titleLabel.font = buttonsFont;
144+
}
145+
}
131146

132147
if (Utils.isString(options.cancelButtonText)) {
133-
alertController.addAction(
134-
MDCAlertAction.actionWithTitleEmphasisHandler(options.cancelButtonText, MDCActionEmphasis.Low, () => {
135-
raiseCallback(callback, false);
136-
})
137-
);
148+
addButton(options.cancelButtonText, MDCActionEmphasis.Low, false);
138149
}
139-
140150
if (Utils.isString(options.neutralButtonText)) {
141-
alertController.addAction(
142-
MDCAlertAction.actionWithTitleEmphasisHandler(options.neutralButtonText, MDCActionEmphasis.Low, () => {
143-
raiseCallback(callback, undefined);
144-
})
145-
);
151+
addButton(options.neutralButtonText, MDCActionEmphasis.Low, undefined);
146152
}
147-
148153
if (Utils.isString(options.okButtonText)) {
149-
alertController.addAction(
150-
MDCAlertAction.actionWithTitleEmphasisHandler(options.okButtonText, MDCActionEmphasis.Low, () => {
151-
raiseCallback(callback, true);
152-
})
153-
);
154+
addButton(options.okButtonText, MDCActionEmphasis.Low, true);
154155
}
155156
}
156157

0 commit comments

Comments
 (0)