MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / showUIAlertController

Function showUIAlertController

packages/core/ui/dialogs/index.ios.ts:47–84  ·  view source on GitHub ↗
(alertController: UIAlertController)

Source from the content-addressed store, hash-verified

45}
46
47function 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
86export function alert(arg: any): Promise<void> {
87 return new Promise<void>((resolve, reject) => {

Callers 5

alertFunction · 0.85
confirmFunction · 0.85
promptFunction · 0.85
loginFunction · 0.85
actionFunction · 0.85

Calls 4

getiOSWindowFunction · 0.90
getButtonColorsFunction · 0.90
getLabelColorFunction · 0.90
writeMethod · 0.65

Tested by

no test coverage detected