From 3962ac11a250c9f33b1928d6feccb6b63c46ecc3 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 14 Jun 2016 16:44:09 +0300 Subject: [PATCH] AffectsLayout done only for iOS. Android will invalidate itself when needed. (#2307) --- tests/app/app/style_props.ts | 9 ++- tests/app/ui/label/label-tests.ts | 8 --- .../activity-indicator-common.ts | 12 ++-- .../activity-indicator.ios.ts | 11 +++- tns-core-modules/ui/button/button-common.ts | 62 ++++++++---------- tns-core-modules/ui/button/button.d.ts | 6 ++ tns-core-modules/ui/label/label-common.ts | 32 ++------- .../ui/progress/progress-common.ts | 20 ++---- .../ui/search-bar/search-bar-common.ts | 45 ++++++------- .../ui/tab-view/tab-view-common.ts | 65 +++++++------------ tsconfig.json | 1 + 11 files changed, 106 insertions(+), 165 deletions(-) diff --git a/tests/app/app/style_props.ts b/tests/app/app/style_props.ts index a94b19a69..5b55e8fc3 100644 --- a/tests/app/app/style_props.ts +++ b/tests/app/app/style_props.ts @@ -1,13 +1,16 @@ import style = require("ui/styling/style"); -import observable = require("ui/core/dependency-observable"); +import {PropertyMetadata, PropertyMetadataSettings} from "ui/core/dependency-observable"; import styleProperty = require("ui/styling/style-property"); import view = require("ui/core/view"); import buttonModule = require("ui/button"); import pages = require("ui/page"); import stackLayoutDef = require("ui/layouts/stack-layout"); +import {isAndroid} from "platform"; -export var fontFamilyProperty = new styleProperty.Property("fontFamily", "font-family", - new observable.PropertyMetadata(undefined, observable.PropertyMetadataSettings.AffectsLayout)); +// on Android we explicitly set propertySettings to None because android will invalidate its layout (skip unnecessary native call). +let AffectsLayout = isAndroid ? PropertyMetadataSettings.None : PropertyMetadataSettings.AffectsLayout; + +export var fontFamilyProperty = new styleProperty.Property("fontFamily", "font-family", new PropertyMetadata(undefined, AffectsLayout)); export class MyTextViewStyler implements style.Styler { public static setFontFamilyProperty(view: view.View, newValue: any) { diff --git a/tests/app/ui/label/label-tests.ts b/tests/app/ui/label/label-tests.ts index 000e5ed5a..faa1e8184 100644 --- a/tests/app/ui/label/label-tests.ts +++ b/tests/app/ui/label/label-tests.ts @@ -152,14 +152,6 @@ export class LabelTest extends testModule.UITest { } } - public test_Set_TextWrap_TNS() { - var label = this.testView; - label.textWrap = true; - - var actual = label._getValue(LabelModule.Label.textWrapProperty); - TKUnit.assertEqual(actual, true); - } - public test_Set_TextWrap_Native() { var testLabel = this.testView; testLabel.textWrap = true; diff --git a/tns-core-modules/ui/activity-indicator/activity-indicator-common.ts b/tns-core-modules/ui/activity-indicator/activity-indicator-common.ts index 1427f74e9..0bf93bfc9 100644 --- a/tns-core-modules/ui/activity-indicator/activity-indicator-common.ts +++ b/tns-core-modules/ui/activity-indicator/activity-indicator-common.ts @@ -1,15 +1,11 @@ -import view = require("ui/core/view"); +import {View} from "ui/core/view"; import definition = require("ui/activity-indicator"); -import dependencyObservable = require("ui/core/dependency-observable"); +import {PropertyMetadataSettings, Property} from "ui/core/dependency-observable"; import proxy = require("ui/core/proxy"); -var busyProperty = new dependencyObservable.Property( - "busy", - "ActivityIndicator", - new proxy.PropertyMetadata(false, dependencyObservable.PropertyMetadataSettings.AffectsLayout) - ); +let busyProperty = new Property("busy", "ActivityIndicator", new proxy.PropertyMetadata(false)); -export class ActivityIndicator extends view.View implements definition.ActivityIndicator { +export class ActivityIndicator extends View implements definition.ActivityIndicator { public static busyProperty = busyProperty; diff --git a/tns-core-modules/ui/activity-indicator/activity-indicator.ios.ts b/tns-core-modules/ui/activity-indicator/activity-indicator.ios.ts index 7897d5263..b4acec49b 100644 --- a/tns-core-modules/ui/activity-indicator/activity-indicator.ios.ts +++ b/tns-core-modules/ui/activity-indicator/activity-indicator.ios.ts @@ -9,11 +9,16 @@ function onBusyPropertyChanged(data: dependencyObservable.PropertyChangeData) { if (!indicator.ios) { return; } - + + let activityIndicator = indicator.ios; if (data.newValue) { - indicator.ios.startAnimating(); + activityIndicator.startAnimating(); } else { - indicator.ios.stopAnimating(); + activityIndicator.stopAnimating(); + } + + if (activityIndicator.hidesWhenStopped) { + indicator.requestLayout(); } } diff --git a/tns-core-modules/ui/button/button-common.ts b/tns-core-modules/ui/button/button-common.ts index 09f97a833..edf7dd924 100644 --- a/tns-core-modules/ui/button/button-common.ts +++ b/tns-core-modules/ui/button/button-common.ts @@ -1,11 +1,16 @@ -import dependencyObservable = require("ui/core/dependency-observable"); +import {Property, PropertyMetadataSettings, PropertyChangeData} from "ui/core/dependency-observable"; import view = require("ui/core/view"); import definition = require("ui/button"); import proxy = require("ui/core/proxy"); import formattedString = require("text/formatted-string"); import observable = require("data/observable"); import * as weakEventListenerModule from "ui/core/weak-event-listener"; -import * as enumsModule from "ui/enums"; +import {WhiteSpace} from "ui/enums"; + +import {isAndroid} from "platform"; + +// on Android we explicitly set propertySettings to None because android will invalidate its layout (skip unnecessary native call). +let AffectsLayout = isAndroid ? PropertyMetadataSettings.None : PropertyMetadataSettings.AffectsLayout; var weakEvents: typeof weakEventListenerModule; function ensureWeakEvents() { @@ -14,35 +19,20 @@ function ensureWeakEvents() { } } -var enums: typeof enumsModule; -function ensureEnums() { - if (!enums) { - enums = require("ui/enums"); - } -} +const textProperty = new Property("text", "Button", new proxy.PropertyMetadata("", AffectsLayout)); +const formattedTextProperty = new Property("formattedText", "Button", new proxy.PropertyMetadata("", AffectsLayout)); +const textWrapProperty = new Property("textWrap", "Button", new proxy.PropertyMetadata(false, AffectsLayout)); -var textProperty = new dependencyObservable.Property( - "text", - "Button", - new proxy.PropertyMetadata("", dependencyObservable.PropertyMetadataSettings.AffectsLayout) -); - -var formattedTextProperty = new dependencyObservable.Property( - "formattedText", - "Button", - new proxy.PropertyMetadata("", dependencyObservable.PropertyMetadataSettings.AffectsLayout) -); - -function onTextPropertyChanged(data: dependencyObservable.PropertyChangeData) { +function onTextPropertyChanged(data: PropertyChangeData) { var button =