diff --git a/tests/app/testRunner.ts b/tests/app/testRunner.ts index af5d61a13..f869ee90b 100644 --- a/tests/app/testRunner.ts +++ b/tests/app/testRunner.ts @@ -2,6 +2,7 @@ import * as TKUnit from "./TKUnit"; import { messageType } from "tns-core-modules/trace"; import { topmost, Frame } from "tns-core-modules/ui/frame"; +import { Page } from "tns-core-modules/ui/page"; import { TextView } from "tns-core-modules/ui/text-view"; import { Button } from "tns-core-modules/ui/button"; import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout"; @@ -282,7 +283,7 @@ function printRunTestStats() { let finalMessage = `\n` + `=== ALL TESTS COMPLETE ===\n` + `${(allTests.length - failedTestCount)} OK, ${failedTestCount} failed\n` + - `DURATION: ${totalTime} ms\n` + + `DURATION: ${totalTime} ms\n` + `=== END OF TESTS ===\n`; TKUnit.write(finalMessage, messageType.info); @@ -341,23 +342,24 @@ function showReportPage(finalMessage: string) { messageContainer.text = finalMessage; stack.addChild(messageContainer); - const page = topmost().currentPage; - page.id = unsetValue; - page.className = unsetValue; - page.bindingContext = unsetValue; - page.style.color = unsetValue; - page.backgroundColor = "white"; - page.content = stack; - messageContainer.focus(); - page.style.fontSize = 11; - if (page.android) { - setTimeout(() => { - messageContainer.dismissSoftInput(); - (messageContainer.nativeViewProtected).scrollTo(0, 0); - }, 10); - } -} + topmost().navigate({ + create: () => { + const page = new Page(); + page.content = stack; + messageContainer.focus(); + page.style.fontSize = 11; + if (page.android) { + setTimeout(() => { + messageContainer.dismissSoftInput(); + (messageContainer.nativeViewProtected).scrollTo(0, 0); + }, 500); + } + return page; + }, + clearHistory: true + }); +} function startLog(): void { let testsName: string = this.name; diff --git a/tns-core-modules/application/application.ios.ts b/tns-core-modules/application/application.ios.ts index 4f007ec40..443e74350 100644 --- a/tns-core-modules/application/application.ios.ts +++ b/tns-core-modules/application/application.ios.ts @@ -118,7 +118,13 @@ class IOSApplication implements IOSApplicationDefinition { this._rootView = rootView; const controller = getViewController(rootView); this._window.rootViewController = controller; - rootView._setupAsRootView({}); + if (createRootFrame) { + // Don't setup as styleScopeHost + rootView._setupUI({}); + } else { + // setup view as styleScopeHost + rootView._setupAsRootView({}); + } this._window.makeKeyAndVisible(); } diff --git a/tns-core-modules/ui/core/view/view-common.ts b/tns-core-modules/ui/core/view/view-common.ts index e78f7a31e..da66c2925 100644 --- a/tns-core-modules/ui/core/view/view-common.ts +++ b/tns-core-modules/ui/core/view/view-common.ts @@ -592,6 +592,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { public requestLayout(): void { this._isLayoutValid = false; + super.requestLayout(); } public abstract onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void; diff --git a/tns-core-modules/ui/core/view/view.ios.ts b/tns-core-modules/ui/core/view/view.ios.ts index e7cb9bf6f..4da715592 100644 --- a/tns-core-modules/ui/core/view/view.ios.ts +++ b/tns-core-modules/ui/core/view/view.ios.ts @@ -57,11 +57,6 @@ export class View extends ViewCommon { super.requestLayout(); this._privateFlags |= PFLAG_FORCE_LAYOUT; - const parent = this.parent; - if (parent) { - parent.requestLayout(); - } - const nativeView = this.nativeViewProtected; if (nativeView) { nativeView.setNeedsLayout(); @@ -346,7 +341,6 @@ export class View extends ViewCommon { } protected _hideNativeModalView(parent: View) { - parent.requestLayout(); const parentController = parent.viewController; const animated = (this.viewController).animated; parentController.dismissModalViewControllerAnimated(animated); @@ -589,13 +583,6 @@ const majorVersion = iosUtils.MajorVersion; export namespace ios { export function updateConstraints(controller: UIViewController, owner: View): void { const root = controller.view; - root.autoresizesSubviews = false; - - // const view = controller.view.subviews.length > 0 ? controller.view.subviews[0] : null; - // if (view) { - // view.translatesAutoresizingMaskIntoConstraints = false; - // } - if (!root.safeAreaLayoutGuide) { const layoutGuide = (root).safeAreaLayoutGuide = UILayoutGuide.alloc().init(); root.addLayoutGuide(layoutGuide); diff --git a/tns-core-modules/ui/frame/fragment.transitions.android.ts b/tns-core-modules/ui/frame/fragment.transitions.android.ts index 25651c48d..342604ecf 100644 --- a/tns-core-modules/ui/frame/fragment.transitions.android.ts +++ b/tns-core-modules/ui/frame/fragment.transitions.android.ts @@ -175,7 +175,6 @@ export function _setAndroidFragmentTransitions( } } - initDefaultAnimations(manager); setupDefaultAnimations(newEntry, new DefaultTransition(0, null)); printTransitions(currentEntry); diff --git a/tns-core-modules/ui/frame/frame-common.ts b/tns-core-modules/ui/frame/frame-common.ts index f7e4269f9..4b7ecfa9a 100644 --- a/tns-core-modules/ui/frame/frame-common.ts +++ b/tns-core-modules/ui/frame/frame-common.ts @@ -142,7 +142,6 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition { if (frame) { frame._removeView(page); } else { - console.log(`---- Removing enrty that was not added to Frame: ${removed.fragmentTag}`); page._tearDownUI(true); } } diff --git a/tns-core-modules/ui/frame/frame.android.ts b/tns-core-modules/ui/frame/frame.android.ts index 715da11cc..ff4ab0f8e 100644 --- a/tns-core-modules/ui/frame/frame.android.ts +++ b/tns-core-modules/ui/frame/frame.android.ts @@ -1,6 +1,6 @@ // Definitions. import { - AndroidFrame as AndroidFrameDefinition, BackstackEntry, NavigationEntry, + AndroidFrame as AndroidFrameDefinition, BackstackEntry, NavigationEntry, NavigationTransition, AndroidFragmentCallbacks, AndroidActivityCallbacks } from "."; import { Page } from "../page"; @@ -8,7 +8,7 @@ import { Page } from "../page"; // Types. import * as application from "../../application"; import { - FrameBase, NavigationContext, stack, goBack, View, Observable, topmost, + FrameBase, NavigationContext, stack, goBack, View, Observable, topmost, traceEnabled, traceWrite, traceCategories } from "./frame-common"; @@ -65,8 +65,8 @@ export function reloadPage(): void { return; } } - - frame.navigate(newEntry); + + frame.navigate(newEntry); } } @@ -185,7 +185,7 @@ export class Frame extends FrameBase { if (!entry.recreated) { clearEntry(entry); } - + if (current && !current.recreated) { clearEntry(current); } @@ -317,7 +317,7 @@ export class Frame extends FrameBase { if (removed.fragment) { _clearEntry(removed); } - + removed.fragment = null; removed.viewSavedState = null; } @@ -661,7 +661,7 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { } // Load page here even if root view is not loaded yet. - // Otherwiaw it will show as blank, + // Otherwise it will show as blank, // The case is Tab->Frame->Page activity recreated, fragments are // created before Tab loads its items. // TODO: addCheck if the fragment is visible so we don't load pages @@ -927,7 +927,14 @@ function setActivityContent(activity: android.app.Activity, savedInstanceState: } // Initialize native visual tree; - rootView._setupAsRootView(activity); + if (shouldCreateRootFrame) { + // Don't setup as styleScopeHost + rootView._setupUI(activity); + } else { + // setup view as styleScopeHost + rootView._setupAsRootView(activity); + } + activity.setContentView(rootView.nativeViewProtected, new org.nativescript.widgets.CommonLayoutParams()); } diff --git a/tns-core-modules/ui/text-view/text-view.ios.ts b/tns-core-modules/ui/text-view/text-view.ios.ts index dcf9b6960..9be4312e3 100644 --- a/tns-core-modules/ui/text-view/text-view.ios.ts +++ b/tns-core-modules/ui/text-view/text-view.ios.ts @@ -6,12 +6,14 @@ import { paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty, Length, _updateCharactersInRangeReplacementString, Color, layout } from "../editable-text-base"; + +import { ios } from "../../utils/utils"; import { profile } from "../../profiling"; export * from "../editable-text-base"; -class UITextViewDelegateImpl extends NSObject implements UIScrollViewDelegate, UITextViewDelegate { - public static ObjCProtocols = [UITextViewDelegate, UIScrollViewDelegate]; +class UITextViewDelegateImpl extends NSObject implements UITextViewDelegate { + public static ObjCProtocols = [UITextViewDelegate]; private _owner: WeakRef; @@ -31,7 +33,7 @@ class UITextViewDelegateImpl extends NSObject implements UIScrollViewDelegate, U } public textViewDidBeginEditing(textView: UITextView): void { - const owner = this._owner.get(); + const owner = this._owner.get(); if (owner) { owner._isEditing = true; owner.notify({ eventName: TextView.focusEvent, object: owner }); @@ -57,6 +59,7 @@ class UITextViewDelegateImpl extends NSObject implements UIScrollViewDelegate, U if (owner.updateTextTrigger === "textChanged") { textProperty.nativeValueChange(owner, textView.text); } + owner.requestLayout(); } } @@ -101,9 +104,9 @@ export class TextView extends EditableTextBase implements TextViewDefinition { constructor() { super(); - this.nativeViewProtected = this._ios = UITextView.new(); - if (!this._ios.font) { - this._ios.font = UIFont.systemFontOfSize(12); + const textView = this.nativeViewProtected = this._ios = UITextView.new(); + if (!textView.font) { + textView.font = UIFont.systemFontOfSize(12); } this._delegate = UITextViewDelegateImpl.initWithOwner(new WeakRef(this)); } @@ -123,10 +126,6 @@ export class TextView extends EditableTextBase implements TextViewDefinition { return this._ios; } - // get nativeView(): UITextView { - // return this._ios; - // } - public _refreshHintState(hint: string, text: string) { if (this.formattedText) { return; @@ -182,6 +181,7 @@ export class TextView extends EditableTextBase implements TextViewDefinition { this._isShowingHint = false; this._refreshColor(); this._setNativeText(); + this.requestLayout(); } [textProperty.getDefault](): string { diff --git a/tns-core-modules/utils/utils.ios.ts b/tns-core-modules/utils/utils.ios.ts index 7d684bb21..214e99ee3 100644 --- a/tns-core-modules/utils/utils.ios.ts +++ b/tns-core-modules/utils/utils.ios.ts @@ -3,6 +3,7 @@ import { write as traceWrite, categories as traceCategories, messageType as traceMessageType } from "../trace"; +import { layout as layoutCommon } from "./utils-common"; export * from "./utils-common"; let mainScreenScale; @@ -38,8 +39,8 @@ export module layout { height: heightMode === 0 /* layout.UNSPECIFIED */ ? Number.POSITIVE_INFINITY : toDeviceIndependentPixels(height) }); - nativeSize.width = toDevicePixels(nativeSize.width); - nativeSize.height = toDevicePixels(nativeSize.height); + nativeSize.width = layoutCommon.round(toDevicePixels(nativeSize.width)); + nativeSize.height = layoutCommon.round(toDevicePixels(nativeSize.height)); return nativeSize; } }