|
1 |
| -import { themer } from 'nativescript-material-core/core'; |
2 |
| -import { TextField } from 'nativescript-material-textfield'; |
3 | 1 | import { getRootView, ios } from '@nativescript/core/application';
|
| 2 | +import { getSystemCssClasses, MODAL_ROOT_VIEW_CSS_CLASS } from '@nativescript/core/css/system-classes'; |
4 | 3 | import { fromObject } from '@nativescript/core/data/observable';
|
5 | 4 | import { createViewFromEntry } from '@nativescript/core/ui/builder/builder';
|
6 |
| -import { ios as iosView, View } from '@nativescript/core/ui/core/view'; |
7 |
| -import { layout } from '@nativescript/core/utils/utils'; |
8 |
| -import { |
9 |
| - ActionOptions, |
10 |
| - CANCEL, |
11 |
| - capitalizationType, |
12 |
| - ConfirmOptions, |
13 |
| - DialogOptions, |
14 |
| - getButtonColors, |
15 |
| - getCurrentPage, |
16 |
| - getLabelColor, |
17 |
| - inputType, |
18 |
| - LOGIN, |
19 |
| - LoginResult, |
20 |
| - OK, |
21 |
| - PromptResult |
22 |
| -} from '@nativescript/core/ui/dialogs'; |
| 5 | +import { View } from '@nativescript/core/ui/core/view'; |
| 6 | +import { ActionOptions, CANCEL, capitalizationType, ConfirmOptions, DialogOptions, getButtonColors, getCurrentPage, getLabelColor, inputType, LoginResult, OK, PromptResult } from '@nativescript/core/ui/dialogs'; |
23 | 7 | import { StackLayout } from '@nativescript/core/ui/layouts/stack-layout';
|
24 | 8 | import { isDefined, isFunction, isString } from '@nativescript/core/utils/types';
|
| 9 | +import { layout } from '@nativescript/core/utils/utils'; |
| 10 | +import { themer } from 'nativescript-material-core/core'; |
| 11 | +import { TextField } from 'nativescript-material-textfield'; |
25 | 12 | import { LoginOptions, MDCAlertControlerOptions, PromptOptions } from './dialogs';
|
26 | 13 | import { isDialogOptions } from './dialogs-common';
|
27 | 14 |
|
@@ -95,7 +82,6 @@ const MDCAlertControllerImpl: MDCAlertControllerImpl = (MDCAlertController as an
|
95 | 82 | const nativeViewProtected = this._customContentView.nativeViewProtected;
|
96 | 83 | if (contentScrollView && nativeViewProtected) {
|
97 | 84 | contentScrollView.addSubview(nativeViewProtected);
|
98 |
| - |
99 | 85 | }
|
100 | 86 | },
|
101 | 87 | get customContentView() {
|
@@ -134,23 +120,21 @@ const MDCAlertControllerImpl: MDCAlertControllerImpl = (MDCAlertController as an
|
134 | 120 | if (hasTitleOrMessage) {
|
135 | 121 | const index = contentScrollView.subviews.indexOfObject(view.nativeViewProtected);
|
136 | 122 | if (index === -1) {
|
137 |
| - originY =layout.toDevicePixels(contentSize.height) |
| 123 | + originY = layout.toDevicePixels(contentSize.height); |
138 | 124 | } else {
|
139 |
| - const viewOnTopFrame = contentScrollView.subviews.objectAtIndex(index-1).frame; |
| 125 | + const viewOnTopFrame = contentScrollView.subviews.objectAtIndex(index - 1).frame; |
140 | 126 | // the +24 is MDCDialogContentInsets
|
141 |
| - originY =layout.toDevicePixels(viewOnTopFrame.origin.y + viewOnTopFrame.size.height + 24) |
142 |
| - |
| 127 | + originY = layout.toDevicePixels(viewOnTopFrame.origin.y + viewOnTopFrame.size.height + 24); |
143 | 128 | }
|
144 | 129 | }
|
145 | 130 |
|
146 | 131 | const measuredWidth = view.getMeasuredWidth(); // pixels
|
147 | 132 | const measuredHeight = view.getMeasuredHeight(); // pixels
|
148 | 133 | View.layoutChild(null, view, 0, originY, measuredWidth, originY + measuredHeight);
|
149 | 134 |
|
150 |
| - |
151 | 135 | // TODO: for a reload of the preferredContentSize. Find a better solution!
|
152 |
| - const pW = this.super.preferredContentSize.width |
153 |
| - const pH = this.super.preferredContentSize.height |
| 136 | + const pW = this.super.preferredContentSize.width; |
| 137 | + const pH = this.super.preferredContentSize.height; |
154 | 138 | this.preferredContentSize = CGSizeMake(pW, pH + 0.00000000001);
|
155 | 139 | this.preferredContentSize = CGSizeMake(pW, pH);
|
156 | 140 | return true;
|
@@ -182,7 +166,6 @@ const MDCAlertControllerImpl: MDCAlertControllerImpl = (MDCAlertController as an
|
182 | 166 | },
|
183 | 167 | viewDidLayoutSubviews() {
|
184 | 168 | this.updateContentViewSize();
|
185 |
| - |
186 | 169 | },
|
187 | 170 | viewDidAppear() {
|
188 | 171 | if (this.autoFocusTextField) {
|
@@ -329,6 +312,11 @@ function createAlertController(options: DialogOptions & MDCAlertControlerOptions
|
329 | 312 | : createViewFromEntry({
|
330 | 313 | moduleName: options.view as string
|
331 | 314 | });
|
| 315 | + |
| 316 | + view.cssClasses.add(MODAL_ROOT_VIEW_CSS_CLASS); |
| 317 | + const modalRootViewCssClasses = getSystemCssClasses(); |
| 318 | + modalRootViewCssClasses.forEach(c => view.cssClasses.add(c)); |
| 319 | + |
332 | 320 | alertController.customContentView = view;
|
333 | 321 | alertController._resolveFunction = resolve;
|
334 | 322 | const context = options.context || {};
|
@@ -658,7 +646,7 @@ function showUIAlertController(alertController: MDCAlertController) {
|
658 | 646 |
|
659 | 647 | // for now we need to use the rootController because of a bug in {N}
|
660 | 648 | let viewController = ios.rootController;
|
661 |
| - |
| 649 | + |
662 | 650 | // let viewController: UIViewController = currentView.ios;
|
663 | 651 |
|
664 | 652 | // if (!(currentView.ios instanceof UIViewController)) {
|
|
0 commit comments