diff --git a/apps/app/ui-tests-app/page/page-status-bar-css.ts b/apps/app/ui-tests-app/page/page-status-bar-css.ts index 44788ca1d..c6ce88bbb 100644 --- a/apps/app/ui-tests-app/page/page-status-bar-css.ts +++ b/apps/app/ui-tests-app/page/page-status-bar-css.ts @@ -58,7 +58,7 @@ export function applyTapWithActionBarHiddenAndSpan(args) { reset(page); page.backgroundSpanUnderStatusBar = true; - page.actionBarHidden = true;; + page.actionBarHidden = true; var css = "#test-element { " + args.object.tag + " }"; page.css = css; } diff --git a/tests/app/app/style_props.ts b/tests/app/app/style_props.ts index 1b3ce7ca1..3ce9cb8ae 100644 --- a/tests/app/app/style_props.ts +++ b/tests/app/app/style_props.ts @@ -29,7 +29,7 @@ import * as stackLayoutDef from "ui/layouts/stack-layout"; // } // else if (view.ios) { // var fontSize = (view._nativeView).titleLabel.font.pointSize; -// (view._nativeView).titleLabel.font = UIFont.fontWithNameSize(nativeValue, fontSize);; +// (view._nativeView).titleLabel.font = UIFont.fontWithNameSize(nativeValue, fontSize); // } // } diff --git a/tests/app/pages/file-load-test.ts b/tests/app/pages/file-load-test.ts index 816588955..11f593177 100644 --- a/tests/app/pages/file-load-test.ts +++ b/tests/app/pages/file-load-test.ts @@ -22,7 +22,7 @@ export function createPage() { var fileName = resolver.resolveFileName(moduleNamePath, "xml"); lbl.text = fileName; - lbl.textWrap = true;; + lbl.textWrap = true; page.content = lbl; return page; diff --git a/tests/app/testRunner.ts b/tests/app/testRunner.ts index ffcee52fc..552c56536 100644 --- a/tests/app/testRunner.ts +++ b/tests/app/testRunner.ts @@ -53,7 +53,7 @@ allTests["FILE-NAME-RESOLVER"] = require("./file-name-resolver-tests/file-name-r allTests["WEAK-EVENTS"] = require("./weak-event-listener-tests"); allTests["CONNECTIVITY"] = require("./connectivity-tests"); -// allTests["PROXY-VIEW-CONTAINER"] = require("./ui/proxy-view-container/proxy-view-container-tests") +allTests["PROXY-VIEW-CONTAINER"] = require("./ui/proxy-view-container/proxy-view-container-tests") allTests["SCROLL-VIEW"] = require("./ui/scroll-view/scroll-view-tests"); allTests["ACTION-BAR"] = require("./ui/action-bar/action-bar-tests"); allTests["XML-DECLARATION"] = require("./xml-declaration/xml-declaration-tests"); @@ -67,12 +67,12 @@ allTests["STYLE-PROPERTIES"] = require("./ui/styling/style-properties-tests"); allTests["FRAME"] = require("./ui/frame/frame-tests"); allTests["VIEW"] = require("./ui/view/view-tests"); allTests["STYLE"] = require("./ui/styling/style-tests"); -// allTests["VISUAL-STATE"] = require("./ui/styling/visual-state-tests"); +allTests["VISUAL-STATE"] = require("./ui/styling/visual-state-tests"); // allTests["VALUE-SOURCE"] = require("./ui/styling/value-source-tests"); allTests["CSS-SELECTOR-PARSER"] = require("./ui/styling/css-selector-parser"); -// allTests["CSS-SELECTOR"] = require("./ui/styling/css-selector"); +allTests["CSS-SELECTOR"] = require("./ui/styling/css-selector"); allTests["BUTTON"] = require("./ui/button/button-tests"); -// allTests["BORDER"] = require("./ui/border/border-tests"); +allTests["BORDER"] = require("./ui/border/border-tests"); allTests["LABEL"] = require("./ui/label/label-tests"); allTests["TAB-VIEW"] = require("./ui/tab-view/tab-view-tests"); // allTests["TAB-VIEW-NAVIGATION"] = require("./ui/tab-view/tab-view-navigation-tests"); @@ -90,9 +90,9 @@ allTests["LIST-PICKER"] = require("./ui/list-picker/list-picker-tests"); allTests["DATE-PICKER"] = require("./ui/date-picker/date-picker-tests"); allTests["TIME-PICKER"] = require("./ui/time-picker/time-picker-tests"); // allTests["WEB-VIEW"] = require("./ui/web-view/web-view-tests"); -// allTests["HTML-VIEW"] = require("./ui/html-view/html-view-tests"); +allTests["HTML-VIEW"] = require("./ui/html-view/html-view-tests"); // allTests["REPEATER"] = require("./ui/repeater/repeater-tests"); -// allTests["SEARCH-BAR"] = require('./ui/search-bar/search-bar-tests'); +allTests["SEARCH-BAR"] = require('./ui/search-bar/search-bar-tests'); allTests["SEGMENTED-BAR"] = require("./ui/segmented-bar/segmented-bar-tests"); // allTests["ANIMATION"] = require("./ui/animation/animation-tests"); // allTests["CSS-ANIMATION"] = require("./ui/animation/css-animation-tests"); diff --git a/tests/app/ui/activity-indicator/activity-indicator-tests.ts b/tests/app/ui/activity-indicator/activity-indicator-tests.ts index 4c5952bcf..2ff292ca6 100644 --- a/tests/app/ui/activity-indicator/activity-indicator-tests.ts +++ b/tests/app/ui/activity-indicator/activity-indicator-tests.ts @@ -51,7 +51,7 @@ if (platform.device.os === platform.platformNames.ios) { ai.color = new color.Color("red"); function testAction(views: Array) { - TKUnit.assertEqual(ai.color.ios.CGColor, ai.ios.color.CGColor, "ai.color"); + TKUnit.assertEqual(ai.color.ios.CGColor, ai.nativeView.color.CGColor, "ai.color"); }; helper.buildUIAndRunTest(ai, testAction); diff --git a/tests/app/ui/proxy-view-container/proxy-view-container-tests.ts b/tests/app/ui/proxy-view-container/proxy-view-container-tests.ts index d140d3dcb..b0d57cecc 100644 --- a/tests/app/ui/proxy-view-container/proxy-view-container-tests.ts +++ b/tests/app/ui/proxy-view-container/proxy-view-container-tests.ts @@ -1,18 +1,18 @@ import * as TKUnit from "../../TKUnit"; import * as helper from "../helper"; -import {View} from "ui/core/view"; -import {Button} from "ui/button"; -import {Page} from "ui/page"; -import {ScrollView} from "ui/scroll-view"; -import {LayoutBase} from "ui/layouts/layout-base" -import {StackLayout} from "ui/layouts/stack-layout" -import {GridLayout} from "ui/layouts/grid-layout" -import {ProxyViewContainer} from "ui/proxy-view-container"; -import {ListView} from "ui/list-view"; +import { View } from "ui/core/view"; +import { Button } from "ui/button"; +import { Page } from "ui/page"; +import { ScrollView } from "ui/scroll-view"; +import { LayoutBase } from "ui/layouts/layout-base"; +import { StackLayout } from "ui/layouts/stack-layout"; +import { GridLayout } from "ui/layouts/grid-layout"; +import { ProxyViewContainer } from "ui/proxy-view-container"; +import { ListView } from "ui/list-view"; export function test_add_children_to_attached_proxy() { - var outer = new StackLayout(); - var proxy = new ProxyViewContainer(); + const outer = new StackLayout(); + const proxy = new ProxyViewContainer(); function testAction(views: Array) { outer.addChild(createBtn("1")); @@ -30,8 +30,8 @@ export function test_add_children_to_attached_proxy() { } export function test_children_immediately_registered_in_parent_grid_layout() { - var outer = new GridLayout(); - var proxy = new ProxyViewContainer(); + const outer = new GridLayout(); + const proxy = new ProxyViewContainer(); function testAction(views: Array) { outer.addChild(proxy); @@ -44,10 +44,11 @@ export function test_children_immediately_registered_in_parent_grid_layout() { } export function test_children_registered_in_parent_grid_layout_on_attach() { - var outer = new GridLayout(); - var proxy = new ProxyViewContainer(); + const outer = new GridLayout(); + const proxy = new ProxyViewContainer(); function testAction(views: Array) { + proxy.addChild(createBtn("1")); outer.addChild(proxy); @@ -58,8 +59,8 @@ export function test_children_registered_in_parent_grid_layout_on_attach() { } export function test_add_children_to_detached_proxy() { - var outer = new StackLayout(); - var proxy = new ProxyViewContainer(); + const outer = new StackLayout(); + const proxy = new ProxyViewContainer(); function testAction(views: Array) { outer.addChild(createBtn("1")); @@ -78,8 +79,8 @@ export function test_add_children_to_detached_proxy() { } export function test_remove_proxy() { - var outer = new StackLayout(); - var proxy = new ProxyViewContainer(); + const outer = new StackLayout(); + const proxy = new ProxyViewContainer(); outer.addChild(createBtn("1")); @@ -100,14 +101,14 @@ export function test_remove_proxy() { } export function test_remove_child_of_attached_proxy() { - var outer = new StackLayout(); - var proxy = new ProxyViewContainer(); + const outer = new StackLayout(); + const proxy = new ProxyViewContainer(); outer.addChild(createBtn("1")); outer.addChild(proxy); proxy.addChild(createBtn("2")); - var testBtn = createBtn("3") + const testBtn = createBtn("3"); proxy.addChild(testBtn); proxy.addChild(createBtn("4")); @@ -122,9 +123,9 @@ export function test_remove_child_of_attached_proxy() { helper.buildUIAndRunTest(outer, testAction); } -export function test_insert_inside_porxy() { - var outer = new StackLayout(); - var proxy = new ProxyViewContainer(); +export function test_insert_inside_proxy() { + const outer = new StackLayout(); + const proxy = new ProxyViewContainer(); outer.addChild(createBtn("1")); @@ -143,9 +144,9 @@ export function test_insert_inside_porxy() { helper.buildUIAndRunTest(outer, testAction); } -export function test_insert_after_porxy() { - var outer = new StackLayout(); - var proxy = new ProxyViewContainer(); +export function test_insert_after_proxy() { + const outer = new StackLayout(); + const proxy = new ProxyViewContainer(); outer.addChild(createBtn("1")); @@ -164,12 +165,12 @@ export function test_insert_after_porxy() { } export function test_proxy_does_not_stop_request_layout_bubble() { - var outer = new StackLayout(); - var proxy = new ProxyViewContainer(); + const outer = new StackLayout(); + const proxy = new ProxyViewContainer(); outer.addChild(createBtn("1")); outer.addChild(proxy); - var btn = createBtn("2"); + const btn = createBtn("2"); proxy.addChild(btn); function testAction(views: Array) { @@ -184,51 +185,51 @@ export function test_proxy_does_not_stop_request_layout_bubble() { } export function test_proxy_iniside_page() { - var proxy = new ProxyViewContainer(); + const proxy = new ProxyViewContainer(); proxy.addChild(createBtn("1")); function testAction(views: Array) { - var page = views[1]; + const page = views[1]; waitUntilElementLayoutIsValid(page); }; helper.buildUIAndRunTest(proxy, testAction); } -export function test_proxy_iniside_scroll_view() { - var scroll = new ScrollView(); +export function test_proxy_inside_scroll_view() { + const scroll = new ScrollView(); + const proxy = new ProxyViewContainer(); scroll.content = proxy; - var proxy = new ProxyViewContainer(); proxy.addChild(createBtn("1")); function testAction(views: Array) { - var page = views[1]; + const page = views[1]; waitUntilElementLayoutIsValid(page); }; helper.buildUIAndRunTest(scroll, testAction); } -export function test_proxy_iniside_border() { - var scroll = new ScrollView(); +export function test_proxy_inside_border() { + const scroll = new ScrollView(); + const proxy = new ProxyViewContainer(); scroll.content = proxy; - var proxy = new ProxyViewContainer(); proxy.addChild(createBtn("1")); function testAction(views: Array) { - var page = views[1]; + const page = views[1]; waitUntilElementLayoutIsValid(page); }; helper.buildUIAndRunTest(scroll, testAction); } -export function test_proxy_iniside_listview_itemtemplate_crash() { +export function test_proxy_inside_listview_itemTemplate_crash() { // Usually reproducible with an Angular component in the template // We use a simple declaration here to simulate it. - var list = new ListView(); + const list = new ListView(); list.items = ["item 1"]; list.itemTemplate = ` @@ -237,7 +238,7 @@ export function test_proxy_iniside_listview_itemtemplate_crash() { `; function testAction(views: Array) { - var page = views[1]; + const page = views[1]; waitUntilElementLayoutIsValid(page); }; @@ -245,17 +246,17 @@ export function test_proxy_iniside_listview_itemtemplate_crash() { } // TODO: Proxy as a direct child to of TabItem is not supported. Not sure if we want to support it. -//export function test_proxy_iniside_tab() { -// var proxy = new ProxyViewContainer(); +//export function test_proxy_inside_tab() { +// const proxy = new ProxyViewContainer(); // proxy.addChild(createBtn("1")); -// var tab = new TabView(); -// var items = new Array(); +// const tab = new TabView(); +// const items = new Array(); // items.push(new TabViewItem({ title: "tab with proxy", view: proxy })); // tab.items = items; - + // function testAction(views: Array) { -// var page = views[1]; +// const page = views[1]; // waitUntilElementLayoutIsValid(page); // }; @@ -263,10 +264,10 @@ export function test_proxy_iniside_listview_itemtemplate_crash() { //} // TODO: Proxy as a direct child to of ActionBar is not supported. Not sure if we want to support it. -//export function test_proxy_iniside_actionBar() { +//export function test_proxy_inside_actionBar() { // function testAction(views: Array) { -// var page = views[1]; -// var proxy = new ProxyViewContainer(); +// const page = views[1]; +// const proxy = new ProxyViewContainer(); // proxy.addChild(createBtn("1")); // page.actionBar.titleView = proxy; // waitUntilElementLayoutIsValid(page); @@ -282,7 +283,7 @@ function waitUntilElementLayoutIsValid(view: View, timeoutSec?: number): void { } function createBtn(text: string): Button { - var b = new Button(); + const b = new Button(); b.text = text; return b; } diff --git a/tests/app/ui/time-picker/time-picker-tests.ts b/tests/app/ui/time-picker/time-picker-tests.ts index c6a7fdcdf..99f3a3b98 100644 --- a/tests/app/ui/time-picker/time-picker-tests.ts +++ b/tests/app/ui/time-picker/time-picker-tests.ts @@ -128,7 +128,7 @@ export class TimePickerTest extends testModule.UITest({ name: "bindingContext" }); bindingContextProperty.register(ViewBase); diff --git a/tns-core-modules/ui/core/view-common.ts b/tns-core-modules/ui/core/view-common.ts index 065ca06dd..3b7a3030c 100644 --- a/tns-core-modules/ui/core/view-common.ts +++ b/tns-core-modules/ui/core/view-common.ts @@ -785,14 +785,6 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { return callback(this); } - _addToSuperview(superview: any, index?: number): boolean { - // IOS specific - return false; - } - _removeFromSuperview(): void { - // IOS specific - } - // public unsetInheritedProperties(): void { // // this._setValue(ProxyObject.bindingContextProperty, undefined, ValueSource.Inherited); // // this._eachSetProperty((property) => { diff --git a/tns-core-modules/ui/core/view.d.ts b/tns-core-modules/ui/core/view.d.ts index 2a9db00ff..b0b2d0afc 100644 --- a/tns-core-modules/ui/core/view.d.ts +++ b/tns-core-modules/ui/core/view.d.ts @@ -536,9 +536,6 @@ declare module "ui/core/view" { _eachLayoutView(callback: (View) => void): void; - _addToSuperview(superview: any, index?: number): boolean; - _removeFromSuperview(); - public _applyXmlAttribute(attribute: string, value: any): boolean; public eachChildView(callback: (view: View) => boolean): void; diff --git a/tns-core-modules/ui/core/view.ios.ts b/tns-core-modules/ui/core/view.ios.ts index b65958833..af30b1c05 100644 --- a/tns-core-modules/ui/core/view.ios.ts +++ b/tns-core-modules/ui/core/view.ios.ts @@ -268,26 +268,6 @@ export class View extends ViewCommon { } } - public _addToSuperview(superview: any, atIndex: number = Number.POSITIVE_INFINITY): boolean { - if (superview && this.nativeView) { - if (atIndex >= superview.subviews.count) { - superview.addSubview(this.nativeView); - } else { - superview.insertSubviewAtIndex(this.nativeView, atIndex); - } - - return true; - } - - return false; - } - - public _removeFromSuperview() { - if (this.nativeView) { - this.nativeView.removeFromSuperview(); - } - } - // By default we update the view's presentation layer when setting backgroundColor and opacity properties. // This is done by calling CATransaction begin and commit methods. // This action should be disabled when updating those properties during an animation. @@ -457,12 +437,27 @@ export class CustomLayoutView extends View { public _addViewToNativeVisualTree(child: View, atIndex: number): boolean { super._addViewToNativeVisualTree(child, atIndex); - return child._addToSuperview(this.nativeView, atIndex); + const parentNativeView = this.nativeView; + const childNativeView = child.nativeView; + + if (parentNativeView && childNativeView) { + if (typeof atIndex !== "number" || atIndex >= parentNativeView.subviews.count) { + parentNativeView.addSubview(childNativeView); + } else { + parentNativeView.insertSubviewAtIndex(childNativeView, atIndex); + } + + return true; + } + + return false; } public _removeViewFromNativeVisualTree(child: View): void { super._removeViewFromNativeVisualTree(child); - child._removeFromSuperview(); + if (child.nativeView) { + child.nativeView.removeFromSuperview(); + } } } diff --git a/tns-core-modules/ui/image/image.ios.ts b/tns-core-modules/ui/image/image.ios.ts index 8ea9400a1..d67361ab4 100644 --- a/tns-core-modules/ui/image/image.ios.ts +++ b/tns-core-modules/ui/image/image.ios.ts @@ -3,7 +3,7 @@ import { traceEnabled, traceWrite, traceCategories } from "./image-common"; -export * from "./image-common";; +export * from "./image-common"; export class Image extends ImageBase { private _ios: UIImageView; diff --git a/tns-core-modules/ui/layouts/layout-base-common.ts b/tns-core-modules/ui/layouts/layout-base-common.ts index 545496dca..8f3e6312d 100644 --- a/tns-core-modules/ui/layouts/layout-base-common.ts +++ b/tns-core-modules/ui/layouts/layout-base-common.ts @@ -126,10 +126,10 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi } } } - + public eachLayoutChild(callback: (child: View, isLast: boolean) => void): void { var lastChild: View = null; - + this.eachChildView((cv) => { cv._eachLayoutView((lv) => { if (lastChild && !lastChild.isCollapsed) { @@ -141,7 +141,7 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi return true; }); - + if (lastChild && !lastChild.isCollapsed) { callback(lastChild, true); } @@ -149,5 +149,5 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi } } -export const clipToBoundsProperty = new Property({name: "clipToBounds", defaultValue: true}); +export const clipToBoundsProperty = new Property({ name: "clipToBounds", defaultValue: true }); clipToBoundsProperty.register(LayoutBaseCommon); \ No newline at end of file diff --git a/tns-core-modules/ui/progress/progress.ios.ts b/tns-core-modules/ui/progress/progress.ios.ts index 251683847..db9bf987f 100644 --- a/tns-core-modules/ui/progress/progress.ios.ts +++ b/tns-core-modules/ui/progress/progress.ios.ts @@ -37,8 +37,8 @@ export class Progress extends ProgressBase { get [colorProperty.native](): UIColor { return this._ios.progressTintColor; } - set [colorProperty.native](value: Color) { - this._ios.progressTintColor = value instanceof Color ? value.ios : value;; + set [colorProperty.native](value: Color | UIColor) { + this._ios.progressTintColor = value instanceof Color ? value.ios : value; } get [backgroundColorProperty.native](): UIColor { diff --git a/tns-core-modules/ui/proxy-view-container/proxy-view-container.ts b/tns-core-modules/ui/proxy-view-container/proxy-view-container.ts index ab322d856..e35fec623 100644 --- a/tns-core-modules/ui/proxy-view-container/proxy-view-container.ts +++ b/tns-core-modules/ui/proxy-view-container/proxy-view-container.ts @@ -6,13 +6,9 @@ import { LayoutBase, View, traceEnabled, traceWrite, traceCategories } from "ui/ */ // Cases to cover: // * Child is added to the attached proxy. Handled in _addViewToNativeVisualTree. -// * Proxy (with children) is added to the DOM. -// - IOS: Handled in _addToSuperview - when the proxy is added, it adds all its children to the new parent. -// - Android: _onAttached calls _addViewToNativeVisualTree recursively when the proxy is added to the parent. +// * Proxy (with children) is added to the DOM. In _addViewToNativeVisualTree _addViewToNativeVisualTree recursively when the proxy is added to the parent. // * Child is removed from attached proxy. Handled in _removeViewFromNativeVisualTree. -// * Proxy (with children) is removed form the DOM. -// - IOS: Handled in _removeFromSuperview - when the proxy is removed, it removes all its children from its parent. -// - Android: _onDetached calls _removeViewFromNativeVisualTree recursively when the proxy is removed from its parent. +// * Proxy (with children) is removed form the DOM. In _removeViewFromNativeVisualTree recursively when the proxy is removed from its parent. export class ProxyViewContainer extends LayoutBase implements ProxyViewContainerDefinition { // No native view for proxy container. get ios(): any { @@ -97,27 +93,6 @@ export class ProxyViewContainer extends LayoutBase implements ProxyViewContainer } } - public _addToSuperview(superview: any, atIndex?: number): boolean { - let index = 0; - this.eachChildView((cv) => { - if (!cv._isAddedToNativeVisualTree) { - cv._isAddedToNativeVisualTree = this._addViewToNativeVisualTree(cv, index++); - } - return true; - }); - - return true; - } - - public _removeFromSuperview() { - this.eachChildView((cv) => { - if (cv._isAddedToNativeVisualTree) { - this._removeViewFromNativeVisualTree(cv); - } - return true; - }); - } - /* * Some layouts (e.g. GridLayout) need to get notified when adding and * removing children, so that they can update private measure data.