From c71b4d4bf1c94aab9eb000b14b48f1d93a44133e Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 19 Dec 2016 17:52:18 +0200 Subject: [PATCH] Hhristov/modules30 fixes (#3321) * Fixed bindings, several css properties, attached properties * Fix valueChanged handlers Fix double registration of width/height property handlers * fix broken merge --- package.json | 2 +- tns-core-modules/ui/core/bindable.ts | 2 +- tns-core-modules/ui/core/properties.ts | 3 +- tns-core-modules/ui/core/view-common.ts | 56 ++++----- tns-core-modules/ui/core/view.android.ts | 116 +----------------- .../absolute-layout.android.ts | 2 +- .../dock-layout/dock-layout.android.ts | 2 +- .../flexbox-layout/flexbox-layout.android.ts | 2 +- .../flexbox-layout/flexbox-layout.ios.ts | 2 +- .../layouts/grid-layout/grid-layout-common.ts | 8 +- .../grid-layout/grid-layout.android.ts | 4 +- 11 files changed, 47 insertions(+), 152 deletions(-) diff --git a/package.json b/package.json index e2778da42..a41db7586 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "time-grunt": "1.3.0", "tslint": "^3.15.1", "typedoc": "0.4.5", - "typescript": "~2.0.10" + "typescript": "~2.1.4" }, "scripts": { "setup": "npm run dev-link-tns-platform-declarations && npm run dev-link-tns-core-modules && npm run dev-link-tests && npm run dev-link-apps", diff --git a/tns-core-modules/ui/core/bindable.ts b/tns-core-modules/ui/core/bindable.ts index e5f31b65d..b00668225 100644 --- a/tns-core-modules/ui/core/bindable.ts +++ b/tns-core-modules/ui/core/bindable.ts @@ -642,7 +642,7 @@ export class Binding { this.updating = true; try { - if (optionsInstance instanceof Bindable && + if (optionsInstance instanceof ViewBase && isEventOrGesture(options.property, optionsInstance) && types.isFunction(value)) { // calling off method with null as handler will remove all handlers for options.property event diff --git a/tns-core-modules/ui/core/properties.ts b/tns-core-modules/ui/core/properties.ts index aaff8c711..131fab1bd 100644 --- a/tns-core-modules/ui/core/properties.ts +++ b/tns-core-modules/ui/core/properties.ts @@ -41,7 +41,7 @@ export interface PropertyOptions { } export interface CoerciblePropertyOptions extends PropertyOptions { - readonly coerceValue: (T, U) => U; + readonly coerceValue: (t: T, u: U) => U; } export interface ShorthandPropertyOptions { @@ -53,7 +53,6 @@ export interface ShorthandPropertyOptions { export interface CssPropertyOptions extends PropertyOptions { cssName: string; - dependentProperty?: CssProperty; } export class Property implements PropertyDescriptor { diff --git a/tns-core-modules/ui/core/view-common.ts b/tns-core-modules/ui/core/view-common.ts index ce754cc88..e9d5ddd5f 100644 --- a/tns-core-modules/ui/core/view-common.ts +++ b/tns-core-modules/ui/core/view-common.ts @@ -1147,7 +1147,7 @@ export const zeroLength: Length = { value: 0, unit: "px" }; export const minWidthProperty = new CssProperty({ name: "minWidth", cssName: "min-width", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals, - valueChanged: (target, newValue) => { + valueChanged: (target, oldValue, newValue) => { target.effectiveMinWidth = Length.toDevicePixels(newValue, 0); }, valueConverter: Length.parse }); @@ -1155,7 +1155,7 @@ minWidthProperty.register(Style); export const minHeightProperty = new CssProperty({ name: "minHeight", cssName: "min-height", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals, - valueChanged: (target, newValue) => { + valueChanged: (target, oldValue, newValue) => { target.effectiveMinHeight = Length.toDevicePixels(newValue, 0); }, valueConverter: Length.parse }); @@ -1197,7 +1197,7 @@ paddingProperty.register(Style); export const paddingLeftProperty = new CssProperty({ name: "paddingLeft", cssName: "padding-left", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals, - valueChanged: (target, newValue) => { + valueChanged: (target, oldValue, newValue) => { target.effectivePaddingLeft = Length.toDevicePixels(newValue, 0); }, valueConverter: Length.parse }); @@ -1205,7 +1205,7 @@ paddingLeftProperty.register(Style); export const paddingRightProperty = new CssProperty({ name: "paddingRight", cssName: "padding-right", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals, - valueChanged: (target, newValue) => { + valueChanged: (target, oldValue, newValue) => { target.effectivePaddingRight = Length.toDevicePixels(newValue, 0); }, valueConverter: Length.parse }); @@ -1213,7 +1213,7 @@ paddingRightProperty.register(Style); export const paddingTopProperty = new CssProperty({ name: "paddingTop", cssName: "padding-top", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals, - valueChanged: (target, newValue) => { + valueChanged: (target, oldValue, newValue) => { target.effectivePaddingTop = Length.toDevicePixels(newValue, 0); }, valueConverter: Length.parse }); @@ -1221,7 +1221,7 @@ paddingTopProperty.register(Style); export const paddingBottomProperty = new CssProperty({ name: "paddingBottom", cssName: "padding-bottom", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals, - valueChanged: (target, newValue) => { + valueChanged: (target, oldValue, newValue) => { target.effectivePaddingBottom = Length.toDevicePixels(newValue, 0); }, valueConverter: Length.parse }); @@ -1513,7 +1513,7 @@ export const backgroundImageProperty = new CssProperty({ backgroundImageProperty.register(Style); export const backgroundColorProperty = new CssProperty({ - name: "backgroundColor", cssName: "background-color", valueChanged: (target, newValue) => { + name: "backgroundColor", cssName: "background-color", valueChanged: (target, oldValue, newValue) => { printUnregisteredProperties(); let background = target.backgroundInternal; target.backgroundInternal = background.withColor(newValue); @@ -1532,7 +1532,7 @@ export namespace BackgroundRepeat { } export const backgroundRepeatProperty = new CssProperty({ - name: "backgroundRepeat", cssName: "background-repeat", valueConverter: BackgroundRepeat.parse, valueChanged: (target, newValue) => { + name: "backgroundRepeat", cssName: "background-repeat", valueConverter: BackgroundRepeat.parse, valueChanged: (target, oldValue, newValue) => { let background = target.backgroundInternal; target.backgroundInternal = background.withRepeat(newValue); } @@ -1540,7 +1540,7 @@ export const backgroundRepeatProperty = new CssProperty backgroundRepeatProperty.register(Style); export const backgroundSizeProperty = new CssProperty({ - name: "backgroundSize", cssName: "background-size", valueChanged: (target, newValue) => { + name: "backgroundSize", cssName: "background-size", valueChanged: (target, oldValue, newValue) => { let background = target.backgroundInternal; target.backgroundInternal = background.withSize(newValue); } @@ -1548,7 +1548,7 @@ export const backgroundSizeProperty = new CssProperty({ backgroundSizeProperty.register(Style); export const backgroundPositionProperty = new CssProperty({ - name: "backgroundPosition", cssName: "background-position", valueChanged: (target, newValue) => { + name: "backgroundPosition", cssName: "background-position", valueChanged: (target, oldValue, newValue) => { let background = target.backgroundInternal; target.backgroundInternal = background.withPosition(newValue); } @@ -1635,7 +1635,7 @@ const borderColorProperty = new ShorthandProperty