(alertController: UIAlertController)
| 45 | } |
| 46 | |
| 47 | function showUIAlertController(alertController: UIAlertController) { |
| 48 | let viewController = getiOSWindow()?.rootViewController; |
| 49 | |
| 50 | while (viewController && viewController.presentedViewController && !viewController.presentedViewController.beingDismissed) { |
| 51 | viewController = viewController.presentedViewController; |
| 52 | } |
| 53 | |
| 54 | if (!viewController) { |
| 55 | Trace.write(`No root controller found to open dialog.`, Trace.categories.Error, Trace.messageType.warn); |
| 56 | |
| 57 | return; |
| 58 | } |
| 59 | |
| 60 | if (alertController.popoverPresentationController) { |
| 61 | alertController.popoverPresentationController.sourceView = viewController.view; |
| 62 | alertController.popoverPresentationController.sourceRect = CGRectMake(viewController.view.bounds.size.width / 2.0, viewController.view.bounds.size.height / 2.0, 1.0, 1.0); |
| 63 | alertController.popoverPresentationController.permittedArrowDirections = 0 as UIPopoverArrowDirection; |
| 64 | } |
| 65 | |
| 66 | const color = getButtonColors().color; |
| 67 | if (color) { |
| 68 | alertController.view.tintColor = color.ios; |
| 69 | } |
| 70 | |
| 71 | const lblColor = getLabelColor(); |
| 72 | if (lblColor) { |
| 73 | if (alertController.title) { |
| 74 | const title = NSAttributedString.alloc().initWithStringAttributes(alertController.title, <any>{ [NSForegroundColorAttributeName]: lblColor.ios }); |
| 75 | alertController.setValueForKey(title, 'attributedTitle'); |
| 76 | } |
| 77 | if (alertController.message) { |
| 78 | const message = NSAttributedString.alloc().initWithStringAttributes(alertController.message, <any>{ [NSForegroundColorAttributeName]: lblColor.ios }); |
| 79 | alertController.setValueForKey(message, 'attributedMessage'); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | viewController.presentModalViewControllerAnimated(alertController, true); |
| 84 | } |
| 85 | |
| 86 | export function alert(arg: any): Promise<void> { |
| 87 | return new Promise<void>((resolve, reject) => { |
no test coverage detected