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