From 0082dfbdb0338542ecc55700f2c8d7f68b445c45 Mon Sep 17 00:00:00 2001 From: Alexander Djenkov Date: Tue, 3 Jul 2018 10:23:51 +0300 Subject: [PATCH] fix(dialogs-ios): dialogs not showing in single page apps (non Frame based apps) (#6000) --- tns-core-modules/ui/dialogs/dialogs.ios.ts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/tns-core-modules/ui/dialogs/dialogs.ios.ts b/tns-core-modules/ui/dialogs/dialogs.ios.ts index 4cb1afaa9..776c0add1 100644 --- a/tns-core-modules/ui/dialogs/dialogs.ios.ts +++ b/tns-core-modules/ui/dialogs/dialogs.ios.ts @@ -5,6 +5,7 @@ import { View, ios as iosView } from "../core/view"; import { ConfirmOptions, PromptOptions, PromptResult, LoginOptions, LoginResult, ActionOptions } from "."; import { getCurrentPage, getLabelColor, getButtonColors, getTextFieldColor, isDialogOptions, inputType, ALERT, OK, CONFIRM, CANCEL, PROMPT, LOGIN } from "./dialogs-common"; import { isString, isDefined, isFunction } from "../../utils/types"; +import { getRootView } from "../../application"; export * from "./dialogs-common"; @@ -198,20 +199,16 @@ export function login(): Promise { } function showUIAlertController(alertController: UIAlertController) { - let currentPage = getCurrentPage(); - if (currentPage) { - let view: View = currentPage; - let viewController: UIViewController = currentPage.ios; + let currentView = getCurrentPage() || getRootView(); - if (currentPage.modal) { - view = currentPage.modal; + if (currentView) { + currentView = currentView.modal || currentView; - if (view.ios instanceof UIViewController) { - viewController = view.ios; - } else { - const parentWithController = iosView.getParentWithViewController(view); - viewController = parentWithController ? parentWithController.viewController : undefined; - } + let viewController: UIViewController = currentView.ios; + + if (!(currentView.ios instanceof UIViewController)) { + const parentWithController = iosView.getParentWithViewController(currentView); + viewController = parentWithController ? parentWithController.viewController : undefined; } if (viewController) {