From cce0a2d42fd61d3475933237d089ce6ac7142db9 Mon Sep 17 00:00:00 2001 From: Rossen Hristov Date: Wed, 4 Jan 2017 10:20:33 +0200 Subject: [PATCH] Fix all property types --- tns-core-modules/ui/core/properties.ts | 12 +- tns-core-modules/ui/core/view-common.ts | 188 ++++++++++++------ tns-core-modules/ui/core/view.d.ts | 22 +- tns-core-modules/ui/definitions.d.ts | 10 +- .../flexbox-layout/flexbox-layout-common.ts | 4 +- .../ui/layouts/layout-base-common.ts | 34 +++- tns-core-modules/ui/layouts/layout-base.d.ts | 42 ++-- tns-core-modules/ui/styling/style.d.ts | 6 +- tns-core-modules/ui/styling/style.ts | 6 +- .../ui/text-base/text-base-common.ts | 37 +++- tns-core-modules/ui/text-base/text-base.d.ts | 27 ++- .../ui/text-field/text-field.ios.ts | 38 +++- 12 files changed, 308 insertions(+), 118 deletions(-) diff --git a/tns-core-modules/ui/core/properties.ts b/tns-core-modules/ui/core/properties.ts index 4f57a1df7..1c81ac8bd 100644 --- a/tns-core-modules/ui/core/properties.ts +++ b/tns-core-modules/ui/core/properties.ts @@ -44,11 +44,11 @@ export interface CoerciblePropertyOptions extends PropertyOptions { readonly coerceValue: (t: T, u: U) => U; } -export interface ShorthandPropertyOptions { +export interface ShorthandPropertyOptions

{ name: string; cssName: string; - converter(this: void, value: string): [CssProperty, any][]; - getter(this: Style): string; + converter(this: void, value: string | P): [CssProperty, any][]; + getter(this: Style): string | P; } export interface CssPropertyOptions extends PropertyOptions { @@ -684,7 +684,7 @@ export class InheritedCssProperty extends CssProperty } } -export class ShorthandProperty { +export class ShorthandProperty { private registered: boolean; public readonly key: symbol; @@ -697,7 +697,7 @@ export class ShorthandProperty { public readonly native: symbol; public readonly sourceKey: symbol; - constructor(options: ShorthandPropertyOptions) { + constructor(options: ShorthandPropertyOptions

) { const name = options.name; this.name = name; @@ -712,7 +712,7 @@ export class ShorthandProperty { const converter = options.converter; - function setLocalValue(this: T, value: string): void { + function setLocalValue(this: T, value: string| P): void { this[sourceKey] = ValueSource.Local; if (this[key] !== value) { this[key] = value; diff --git a/tns-core-modules/ui/core/view-common.ts b/tns-core-modules/ui/core/view-common.ts index ef201ac03..fdd4671fc 100644 --- a/tns-core-modules/ui/core/view-common.ts +++ b/tns-core-modules/ui/core/view-common.ts @@ -219,10 +219,10 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { this.style.borderLeftColor = value; } - get borderWidth(): string | number { + get borderWidth(): string | Length { return this.style.borderWidth; } - set borderWidth(value: string | number) { + set borderWidth(value: string | Length) { this.style.borderWidth = value; } @@ -338,10 +338,10 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { this.style.height = value; } - get margin(): string { + get margin(): string | PercentLength { return this.style.margin; } - set margin(value: string) { + set margin(value: string | PercentLength) { this.style.margin = value; } @@ -1116,9 +1116,16 @@ widthProperty.register(Style); export const heightProperty = new CssProperty({ name: "height", cssName: "height", defaultValue: "auto", affectsLayout: isIOS, equalityComparer: Length.equals, valueConverter: PercentLength.parse }); heightProperty.register(Style); -const marginProperty = new ShorthandProperty