mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Split get/set native to getDefault setNative
This commit is contained in:
@@ -285,18 +285,18 @@ class TestView extends Layout {
|
||||
this.setMeasuredDimension(100, 100);
|
||||
}
|
||||
|
||||
get [customCssProperty.native](): string {
|
||||
[customCssProperty.getDefault](): string {
|
||||
return "customCssPropertyDefaultValue";
|
||||
}
|
||||
set [customCssProperty.native](value: string) {
|
||||
[customCssProperty.setNative](value: string) {
|
||||
this.cssPropCounter++;
|
||||
this.cssPropNativeValue = value;
|
||||
}
|
||||
|
||||
get [customViewProperty.native](): string {
|
||||
[customViewProperty.getDefault](): string {
|
||||
return "customViewPropertyDefaultValue";
|
||||
}
|
||||
set [customViewProperty.native](value: string) {
|
||||
[customViewProperty.setNative](value: string) {
|
||||
this.viewPropCounter++;
|
||||
this.viewPropNativeValue = value;
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ global.moduleMerge(commonTests, exports);
|
||||
class MyGrid extends grid.GridLayout {
|
||||
public backgroundSetterCount: number = 0;
|
||||
|
||||
get [view.backgroundInternalProperty.native](): any {
|
||||
[view.backgroundInternalProperty.getDefault](): any {
|
||||
return null;
|
||||
}
|
||||
set [view.backgroundInternalProperty.native](value: any) {
|
||||
[view.backgroundInternalProperty.setNative](value: any) {
|
||||
this.backgroundSetterCount ++;
|
||||
}
|
||||
|
||||
|
||||
@@ -355,7 +355,7 @@ export class ActionBar extends ActionBarBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [colorProperty.native](): number {
|
||||
[colorProperty.getDefault](): number {
|
||||
if (!defaultTitleTextColor) {
|
||||
let textView = new android.widget.TextView(this._context);
|
||||
defaultTitleTextColor = textView.getTextColors().getDefaultColor();
|
||||
@@ -363,7 +363,7 @@ export class ActionBar extends ActionBarBase {
|
||||
|
||||
return defaultTitleTextColor;
|
||||
}
|
||||
set [colorProperty.native](value: number | Color) {
|
||||
[colorProperty.setNative](value: number | Color) {
|
||||
let color = value instanceof Color ? value.android : value;
|
||||
this.nativeView.setTitleTextColor(color);
|
||||
}
|
||||
|
||||
@@ -306,10 +306,10 @@ export class ActionBar extends ActionBarBase {
|
||||
return (<UINavigationController>page.frame.ios.controller).navigationBar;
|
||||
}
|
||||
|
||||
get [colorProperty.native](): UIColor {
|
||||
[colorProperty.getDefault](): UIColor {
|
||||
return null;
|
||||
}
|
||||
set [colorProperty.native](color: Color) {
|
||||
[colorProperty.setNative](color: Color) {
|
||||
const navBar = this.navBar;
|
||||
if (color) {
|
||||
navBar.tintColor = color.ios;
|
||||
@@ -320,12 +320,12 @@ export class ActionBar extends ActionBarBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [backgroundColorProperty.native](): UIColor {
|
||||
[backgroundColorProperty.getDefault](): UIColor {
|
||||
// This getter is never called.
|
||||
// CssAnimationProperty use default value form their constructor.
|
||||
return null;
|
||||
}
|
||||
set [backgroundColorProperty.native](value: UIColor | Color) {
|
||||
[backgroundColorProperty.setNative](value: UIColor | Color) {
|
||||
let navBar = this.navBar;
|
||||
if (navBar) {
|
||||
let color = value instanceof Color ? value.ios : value;
|
||||
@@ -333,9 +333,9 @@ export class ActionBar extends ActionBarBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [backgroundInternalProperty.native](): UIColor {
|
||||
[backgroundInternalProperty.getDefault](): UIColor {
|
||||
return null;
|
||||
}
|
||||
set [backgroundInternalProperty.native](value: UIColor) { // tslint:disable-line
|
||||
[backgroundInternalProperty.setNative](value: UIColor) { // tslint:disable-line
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,19 +16,19 @@ export class ActivityIndicator extends ActivityIndicatorBase {
|
||||
return this._progressBar;
|
||||
}
|
||||
|
||||
get [busyProperty.native](): boolean {
|
||||
[busyProperty.getDefault](): boolean {
|
||||
return false;
|
||||
}
|
||||
set [busyProperty.native](value: boolean) {
|
||||
[busyProperty.setNative](value: boolean) {
|
||||
if (this.visibility === Visibility.VISIBLE) {
|
||||
this._progressBar.setVisibility(value ? android.view.View.VISIBLE : android.view.View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
get [visibilityProperty.native](): Visibility {
|
||||
[visibilityProperty.getDefault](): Visibility {
|
||||
return Visibility.HIDDEN;
|
||||
}
|
||||
set [visibilityProperty.native](value: Visibility) {
|
||||
[visibilityProperty.setNative](value: Visibility) {
|
||||
switch (value) {
|
||||
case Visibility.VISIBLE:
|
||||
this._progressBar.setVisibility(this.busy ? android.view.View.VISIBLE : android.view.View.INVISIBLE);
|
||||
@@ -44,14 +44,13 @@ export class ActivityIndicator extends ActivityIndicatorBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [colorProperty.native](): number {
|
||||
[colorProperty.getDefault](): number {
|
||||
return -1;
|
||||
}
|
||||
set [colorProperty.native](value: number | Color) {
|
||||
[colorProperty.setNative](value: number | Color) {
|
||||
if (value instanceof Color) {
|
||||
this._progressBar.getIndeterminateDrawable().setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this._progressBar.getIndeterminateDrawable().clearColorFilter();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ export class ActivityIndicator extends ActivityIndicatorBase {
|
||||
return this.nativeView;
|
||||
}
|
||||
|
||||
get [busyProperty.native](): boolean {
|
||||
[busyProperty.getDefault](): boolean {
|
||||
if ((<any>this.nativeView).isAnimating) {
|
||||
return (<any>this.nativeView).isAnimating();
|
||||
}
|
||||
@@ -23,7 +23,7 @@ export class ActivityIndicator extends ActivityIndicatorBase {
|
||||
return this.nativeView.animating;
|
||||
}
|
||||
}
|
||||
set [busyProperty.native](value: boolean) {
|
||||
[busyProperty.setNative](value: boolean) {
|
||||
let nativeView = this.nativeView;
|
||||
if (value) {
|
||||
nativeView.startAnimating();
|
||||
@@ -36,10 +36,10 @@ export class ActivityIndicator extends ActivityIndicatorBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [colorProperty.native](): UIColor {
|
||||
[colorProperty.getDefault](): UIColor {
|
||||
return this.nativeView.color;
|
||||
}
|
||||
set [colorProperty.native](value: UIColor | Color) {
|
||||
[colorProperty.setNative](value: UIColor | Color) {
|
||||
this.nativeView.color = value instanceof Color ? value.ios : value;
|
||||
}
|
||||
}
|
||||
@@ -259,7 +259,7 @@ export class Animation extends AnimationBase {
|
||||
propertyAnimation.target.style[opacityProperty.keyframe] = originalValue1;
|
||||
}
|
||||
if (propertyAnimation.target.nativeView) {
|
||||
propertyAnimation.target[opacityProperty.native] = propertyAnimation.target.style.opacity;
|
||||
propertyAnimation.target[opacityProperty.setNative](propertyAnimation.target.style.opacity);
|
||||
}
|
||||
}));
|
||||
animators.push(android.animation.ObjectAnimator.ofFloat(nativeView, "alpha", nativeArray));
|
||||
@@ -287,8 +287,8 @@ export class Animation extends AnimationBase {
|
||||
propertyAnimation.target.style[backgroundColorProperty.name] = originalValue1;
|
||||
} else {
|
||||
propertyAnimation.target.style[backgroundColorProperty.keyframe] = originalValue1;
|
||||
if (propertyAnimation.target.nativeView) {
|
||||
propertyAnimation.target[backgroundColorProperty.native] = propertyAnimation.target.style.backgroundColor;
|
||||
if (propertyAnimation.target.nativeView && propertyAnimation.target[backgroundColorProperty.setNative]) {
|
||||
propertyAnimation.target[backgroundColorProperty.setNative](propertyAnimation.target.style.backgroundColor);
|
||||
}
|
||||
}
|
||||
}));
|
||||
@@ -324,8 +324,8 @@ export class Animation extends AnimationBase {
|
||||
propertyAnimation.target.style[translateXProperty.keyframe] = originalValue1;
|
||||
propertyAnimation.target.style[translateYProperty.keyframe] = originalValue2;
|
||||
if (propertyAnimation.target.nativeView) {
|
||||
propertyAnimation.target[translateXProperty.native] = propertyAnimation.target.style.translateX;
|
||||
propertyAnimation.target[translateYProperty.native] = propertyAnimation.target.style.translateY;
|
||||
propertyAnimation.target[translateXProperty.setNative](propertyAnimation.target.style.translateX);
|
||||
propertyAnimation.target[translateYProperty.setNative](propertyAnimation.target.style.translateY);
|
||||
}
|
||||
}
|
||||
}));
|
||||
@@ -365,8 +365,8 @@ export class Animation extends AnimationBase {
|
||||
propertyAnimation.target.style[scaleXProperty.keyframe] = originalValue1;
|
||||
propertyAnimation.target.style[scaleYProperty.keyframe] = originalValue2;
|
||||
if (propertyAnimation.target.nativeView) {
|
||||
propertyAnimation.target[scaleXProperty.native] = propertyAnimation.target.style.scaleX;
|
||||
propertyAnimation.target[scaleYProperty.native] = propertyAnimation.target.style.scaleY;
|
||||
propertyAnimation.target[scaleXProperty.setNative](propertyAnimation.target.style.scaleX);
|
||||
propertyAnimation.target[scaleYProperty.setNative](propertyAnimation.target.style.scaleY);
|
||||
}
|
||||
}
|
||||
}));
|
||||
@@ -390,7 +390,7 @@ export class Animation extends AnimationBase {
|
||||
} else {
|
||||
propertyAnimation.target.style[rotateProperty.keyframe] = originalValue1;
|
||||
if (propertyAnimation.target.nativeView) {
|
||||
propertyAnimation.target[rotateProperty.native] = propertyAnimation.target.style.rotate;
|
||||
propertyAnimation.target[rotateProperty.setNative](propertyAnimation.target.style.rotate);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -65,38 +65,38 @@ export class Button extends ButtonBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [paddingTopProperty.native](): Length {
|
||||
[paddingTopProperty.getDefault](): Length {
|
||||
return { value: this._defaultPaddingTop, unit: "px" }
|
||||
}
|
||||
set [paddingTopProperty.native](value: Length) {
|
||||
[paddingTopProperty.setNative](value: Length) {
|
||||
org.nativescript.widgets.ViewHelper.setPaddingTop(this.nativeView, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderTopWidth, 0));
|
||||
}
|
||||
|
||||
get [paddingRightProperty.native](): Length {
|
||||
[paddingRightProperty.getDefault](): Length {
|
||||
return { value: this._defaultPaddingRight, unit: "px" }
|
||||
}
|
||||
set [paddingRightProperty.native](value: Length) {
|
||||
[paddingRightProperty.setNative](value: Length) {
|
||||
org.nativescript.widgets.ViewHelper.setPaddingRight(this.nativeView, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderRightWidth, 0));
|
||||
}
|
||||
|
||||
get [paddingBottomProperty.native](): Length {
|
||||
[paddingBottomProperty.getDefault](): Length {
|
||||
return { value: this._defaultPaddingBottom, unit: "px" }
|
||||
}
|
||||
set [paddingBottomProperty.native](value: Length) {
|
||||
[paddingBottomProperty.setNative](value: Length) {
|
||||
org.nativescript.widgets.ViewHelper.setPaddingBottom(this.nativeView, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderBottomWidth, 0));
|
||||
}
|
||||
|
||||
get [paddingLeftProperty.native](): Length {
|
||||
[paddingLeftProperty.getDefault](): Length {
|
||||
return { value: this._defaultPaddingLeft, unit: "px" }
|
||||
}
|
||||
set [paddingLeftProperty.native](value: Length) {
|
||||
[paddingLeftProperty.setNative](value: Length) {
|
||||
org.nativescript.widgets.ViewHelper.setPaddingLeft(this.nativeView, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderLeftWidth, 0));
|
||||
}
|
||||
|
||||
get [zIndexProperty.native](): number {
|
||||
[zIndexProperty.getDefault](): number {
|
||||
return org.nativescript.widgets.ViewHelper.getZIndex(this.nativeView);
|
||||
}
|
||||
set [zIndexProperty.native](value: number) {
|
||||
[zIndexProperty.setNative](value: number) {
|
||||
org.nativescript.widgets.ViewHelper.setZIndex(this.nativeView, value);
|
||||
// API >= 21
|
||||
if (this.nativeView.setStateListAnimator) {
|
||||
|
||||
@@ -46,10 +46,10 @@ export class Button extends ButtonBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [whiteSpaceProperty.native](): WhiteSpace {
|
||||
[whiteSpaceProperty.getDefault](): WhiteSpace {
|
||||
return WhiteSpace.NO_WRAP;
|
||||
}
|
||||
set [whiteSpaceProperty.native](value: WhiteSpace) {
|
||||
[whiteSpaceProperty.setNative](value: WhiteSpace) {
|
||||
const nativeView = this.nativeView.titleLabel;
|
||||
switch (value) {
|
||||
case WhiteSpace.NORMAL:
|
||||
@@ -65,106 +65,106 @@ export class Button extends ButtonBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [borderTopWidthProperty.native](): Length {
|
||||
[borderTopWidthProperty.getDefault](): Length {
|
||||
return {
|
||||
value: this.nativeView.contentEdgeInsets.top,
|
||||
unit: "px"
|
||||
};
|
||||
}
|
||||
set [borderTopWidthProperty.native](value: Length) {
|
||||
[borderTopWidthProperty.setNative](value: Length) {
|
||||
let inset = this.nativeView.contentEdgeInsets;
|
||||
let top = layout.toDeviceIndependentPixels(this.effectivePaddingTop + this.effectiveBorderTopWidth);
|
||||
this.nativeView.contentEdgeInsets = { top: top, left: inset.left, bottom: inset.bottom, right: inset.right };
|
||||
}
|
||||
|
||||
get [borderRightWidthProperty.native](): Length {
|
||||
[borderRightWidthProperty.getDefault](): Length {
|
||||
return {
|
||||
value: this.nativeView.contentEdgeInsets.right,
|
||||
unit: "px"
|
||||
};
|
||||
}
|
||||
set [borderRightWidthProperty.native](value: Length) {
|
||||
[borderRightWidthProperty.setNative](value: Length) {
|
||||
let inset = this.nativeView.contentEdgeInsets;
|
||||
let right = layout.toDeviceIndependentPixels(this.effectivePaddingRight + this.effectiveBorderRightWidth);
|
||||
this.nativeView.contentEdgeInsets = { top: inset.top, left: inset.left, bottom: inset.bottom, right: right };
|
||||
}
|
||||
|
||||
get [borderBottomWidthProperty.native](): Length {
|
||||
[borderBottomWidthProperty.getDefault](): Length {
|
||||
return {
|
||||
value: this.nativeView.contentEdgeInsets.bottom,
|
||||
unit: "px"
|
||||
};
|
||||
}
|
||||
set [borderBottomWidthProperty.native](value: Length) {
|
||||
[borderBottomWidthProperty.setNative](value: Length) {
|
||||
let inset = this.nativeView.contentEdgeInsets;
|
||||
let bottom = layout.toDeviceIndependentPixels(this.effectivePaddingBottom + this.effectiveBorderBottomWidth);
|
||||
this.nativeView.contentEdgeInsets = { top: inset.top, left: inset.left, bottom: bottom, right: inset.right };
|
||||
}
|
||||
|
||||
get [borderLeftWidthProperty.native](): Length {
|
||||
[borderLeftWidthProperty.getDefault](): Length {
|
||||
return {
|
||||
value: this.nativeView.contentEdgeInsets.left,
|
||||
unit: "px"
|
||||
};
|
||||
}
|
||||
set [borderLeftWidthProperty.native](value: Length) {
|
||||
[borderLeftWidthProperty.setNative](value: Length) {
|
||||
let inset = this.nativeView.contentEdgeInsets;
|
||||
let left = layout.toDeviceIndependentPixels(this.effectivePaddingLeft + this.effectiveBorderLeftWidth);
|
||||
this.nativeView.contentEdgeInsets = { top: inset.top, left: left, bottom: inset.bottom, right: inset.right };
|
||||
}
|
||||
|
||||
get [paddingTopProperty.native](): Length {
|
||||
[paddingTopProperty.getDefault](): Length {
|
||||
return {
|
||||
value: this.nativeView.contentEdgeInsets.top,
|
||||
unit: "px"
|
||||
};
|
||||
}
|
||||
set [paddingTopProperty.native](value: Length) {
|
||||
[paddingTopProperty.setNative](value: Length) {
|
||||
let inset = this.nativeView.contentEdgeInsets;
|
||||
let top = layout.toDeviceIndependentPixels(this.effectivePaddingTop + this.effectiveBorderTopWidth);
|
||||
this.nativeView.contentEdgeInsets = { top: top, left: inset.left, bottom: inset.bottom, right: inset.right };
|
||||
}
|
||||
|
||||
get [paddingRightProperty.native](): Length {
|
||||
[paddingRightProperty.getDefault](): Length {
|
||||
return {
|
||||
value: this.nativeView.contentEdgeInsets.right,
|
||||
unit: "px"
|
||||
};
|
||||
}
|
||||
set [paddingRightProperty.native](value: Length) {
|
||||
[paddingRightProperty.setNative](value: Length) {
|
||||
let inset = this.nativeView.contentEdgeInsets;
|
||||
let right = layout.toDeviceIndependentPixels(this.effectivePaddingRight + this.effectiveBorderRightWidth);
|
||||
this.nativeView.contentEdgeInsets = { top: inset.top, left: inset.left, bottom: inset.bottom, right: right };
|
||||
}
|
||||
|
||||
get [paddingBottomProperty.native](): Length {
|
||||
[paddingBottomProperty.getDefault](): Length {
|
||||
return {
|
||||
value: this.nativeView.contentEdgeInsets.bottom,
|
||||
unit: "px"
|
||||
};
|
||||
}
|
||||
set [paddingBottomProperty.native](value: Length) {
|
||||
[paddingBottomProperty.setNative](value: Length) {
|
||||
let inset = this.nativeView.contentEdgeInsets;
|
||||
let bottom = layout.toDeviceIndependentPixels(this.effectivePaddingBottom + this.effectiveBorderBottomWidth);
|
||||
this.nativeView.contentEdgeInsets = { top: inset.top, left: inset.left, bottom: bottom, right: inset.right };
|
||||
}
|
||||
|
||||
get [paddingLeftProperty.native](): Length {
|
||||
[paddingLeftProperty.getDefault](): Length {
|
||||
return {
|
||||
value: this.nativeView.contentEdgeInsets.left,
|
||||
unit: "px"
|
||||
};
|
||||
}
|
||||
set [paddingLeftProperty.native](value: Length) {
|
||||
[paddingLeftProperty.setNative](value: Length) {
|
||||
let inset = this.nativeView.contentEdgeInsets;
|
||||
let left = layout.toDeviceIndependentPixels(this.effectivePaddingLeft + this.effectiveBorderLeftWidth);
|
||||
this.nativeView.contentEdgeInsets = { top: inset.top, left: left, bottom: inset.bottom, right: inset.right };
|
||||
}
|
||||
|
||||
get [textAlignmentProperty.native](): TextAlignment {
|
||||
[textAlignmentProperty.getDefault](): TextAlignment {
|
||||
return Button.nativeToJsTextAlignment[this.nativeView.contentHorizontalAlignment];
|
||||
}
|
||||
set [textAlignmentProperty.native](value: TextAlignment) {
|
||||
[textAlignmentProperty.setNative](value: TextAlignment) {
|
||||
this.nativeView.contentHorizontalAlignment = Button.jsToNativeTextAlignment[value];
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,8 @@ export interface CssAnimationPropertyOptions<T, U> {
|
||||
export class Property<T extends ViewBase, U> implements TypedPropertyDescriptor<U> {
|
||||
constructor(options: PropertyOptions<T, U>);
|
||||
|
||||
public readonly native: symbol;
|
||||
public readonly getDefault: symbol;
|
||||
public readonly setNative: symbol;
|
||||
public readonly defaultValue: U;
|
||||
public register(cls: { prototype: T }): void;
|
||||
public nativeValueChange(T, U): void;
|
||||
@@ -64,7 +65,8 @@ export class InheritedProperty<T extends ViewBase, U> extends Property<T, U> {
|
||||
export class CssProperty<T extends Style, U> {
|
||||
constructor(options: CssPropertyOptions<T, U>);
|
||||
|
||||
public readonly native: symbol;
|
||||
public readonly getDefault: symbol;
|
||||
public readonly setNative: symbol;
|
||||
public readonly name: string;
|
||||
public readonly cssName: string;
|
||||
public readonly defaultValue: U;
|
||||
@@ -81,7 +83,6 @@ export class ShorthandProperty<T extends Style, P> {
|
||||
|
||||
public readonly name: string;
|
||||
public readonly cssName: string;
|
||||
public readonly native: symbol;
|
||||
|
||||
public register(cls: { prototype: T }): void;
|
||||
}
|
||||
@@ -89,12 +90,17 @@ export class ShorthandProperty<T extends Style, P> {
|
||||
export class CssAnimationProperty<T extends Style, U> {
|
||||
constructor(options: CssAnimationPropertyOptions<T, U>);
|
||||
|
||||
public readonly getDefault: symbol;
|
||||
public readonly setNative: symbol;
|
||||
|
||||
public readonly name: string;
|
||||
public readonly cssName: string;
|
||||
public readonly native: symbol;
|
||||
|
||||
readonly keyframe: string;
|
||||
|
||||
public readonly defaultValue: U;
|
||||
|
||||
public register(cls: { prototype: T }): void;
|
||||
public isSet(instance: T): boolean;
|
||||
|
||||
|
||||
@@ -44,7 +44,10 @@ export class Property<T extends ViewBase, U> implements TypedPropertyDescriptor<
|
||||
|
||||
public readonly name: string;
|
||||
public readonly key: symbol;
|
||||
public readonly native: symbol;
|
||||
|
||||
public readonly getDefault: symbol;
|
||||
public readonly setNative: symbol;
|
||||
|
||||
public readonly defaultValueKey: symbol;
|
||||
public readonly defaultValue: U;
|
||||
public readonly nativeValueChange: (owner: T, value: U) => void;
|
||||
@@ -61,8 +64,11 @@ export class Property<T extends ViewBase, U> implements TypedPropertyDescriptor<
|
||||
const key = Symbol(name + ":propertyKey");
|
||||
this.key = key;
|
||||
|
||||
const native: symbol = Symbol(name + ":nativeKey");
|
||||
this.native = native;
|
||||
const getDefault: symbol = Symbol(name + ":getDefault");
|
||||
this.getDefault = getDefault;
|
||||
|
||||
const setNative: symbol = Symbol(name + ":setNative");
|
||||
this.setNative = setNative;
|
||||
|
||||
const defaultValueKey = Symbol(name + ":nativeDefaultValue");
|
||||
this.defaultValueKey = defaultValueKey;
|
||||
@@ -95,15 +101,19 @@ export class Property<T extends ViewBase, U> implements TypedPropertyDescriptor<
|
||||
const changed: boolean = equalityComparer ? !equalityComparer(currentValue, unboxedValue) : currentValue !== unboxedValue;
|
||||
|
||||
if (wrapped || changed) {
|
||||
const setNativeValue = this.nativeView && native in this;
|
||||
const setNativeValue = this.nativeView && this[setNative];
|
||||
if (reset) {
|
||||
delete this[key];
|
||||
if (valueChanged) {
|
||||
valueChanged(this, currentValue, unboxedValue);
|
||||
}
|
||||
if (setNativeValue) {
|
||||
this[native] = this[defaultValueKey];
|
||||
delete this[defaultValueKey];
|
||||
if (defaultValueKey in this) {
|
||||
this[setNative](this[defaultValueKey]);
|
||||
delete this[defaultValueKey];
|
||||
} else {
|
||||
this[setNative](defaultValue);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this[key] = unboxedValue;
|
||||
@@ -112,11 +122,11 @@ export class Property<T extends ViewBase, U> implements TypedPropertyDescriptor<
|
||||
}
|
||||
|
||||
if (setNativeValue) {
|
||||
if (!(defaultValueKey in this)) {
|
||||
this[defaultValueKey] = this[native];
|
||||
if (this[getDefault] && !(defaultValueKey in this)) {
|
||||
this[defaultValueKey] = this[getDefault]();
|
||||
}
|
||||
|
||||
this[native] = unboxedValue;
|
||||
this[setNative](unboxedValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +197,8 @@ export class CoercibleProperty<T extends ViewBase, U> extends Property<T, U> imp
|
||||
|
||||
const name = options.name;
|
||||
const key = this.key;
|
||||
const native: symbol = this.native;
|
||||
const getDefault: symbol = this.getDefault;
|
||||
const setNative: symbol = this.setNative;
|
||||
const defaultValueKey = this.defaultValueKey;
|
||||
const defaultValue: U = this.defaultValue;
|
||||
|
||||
@@ -229,7 +240,7 @@ export class CoercibleProperty<T extends ViewBase, U> extends Property<T, U> imp
|
||||
const changed: boolean = equalityComparer ? !equalityComparer(currentValue, unboxedValue) : currentValue !== unboxedValue;
|
||||
|
||||
if (wrapped || changed) {
|
||||
const setNativeValue = this.nativeView && native in this;
|
||||
const setNativeValue = this.nativeView && this[setNative];
|
||||
if (reset) {
|
||||
delete this[key];
|
||||
if (valueChanged) {
|
||||
@@ -237,8 +248,12 @@ export class CoercibleProperty<T extends ViewBase, U> extends Property<T, U> imp
|
||||
}
|
||||
|
||||
if (setNativeValue) {
|
||||
this[native] = this[defaultValueKey];
|
||||
delete this[defaultValueKey];
|
||||
if (defaultValueKey in this) {
|
||||
this[setNative](this[defaultValueKey]);
|
||||
delete this[defaultValueKey];
|
||||
} else {
|
||||
this[setNative](defaultValue);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this[key] = unboxedValue;
|
||||
@@ -247,11 +262,11 @@ export class CoercibleProperty<T extends ViewBase, U> extends Property<T, U> imp
|
||||
}
|
||||
|
||||
if (setNativeValue) {
|
||||
if (!(defaultValueKey in this)) {
|
||||
this[defaultValueKey] = this[native];
|
||||
if (this[getDefault] && !(defaultValueKey in this)) {
|
||||
this[defaultValueKey] = this[getDefault]();
|
||||
}
|
||||
|
||||
this[native] = unboxedValue;
|
||||
this[setNative](unboxedValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +370,8 @@ export class CssProperty<T extends Style, U> implements definitions.CssProperty<
|
||||
protected readonly localValueDescriptor: PropertyDescriptor;
|
||||
|
||||
public readonly key: symbol;
|
||||
public readonly native: symbol;
|
||||
public readonly getDefault: symbol;
|
||||
public readonly setNative: symbol;
|
||||
public readonly sourceKey: symbol;
|
||||
public readonly defaultValueKey: symbol;
|
||||
public readonly defaultValue: U;
|
||||
@@ -373,8 +389,11 @@ export class CssProperty<T extends Style, U> implements definitions.CssProperty<
|
||||
const sourceKey = Symbol(name + ":valueSourceKey");
|
||||
this.sourceKey = sourceKey;
|
||||
|
||||
const native = Symbol(name + ":nativeKey");
|
||||
this.native = native;
|
||||
const getDefault = Symbol(name + ":getDefault");
|
||||
this.getDefault = getDefault;
|
||||
|
||||
const setNative = Symbol(name + ":setNative");
|
||||
this.setNative = setNative;
|
||||
|
||||
const defaultValueKey = Symbol(name + ":nativeDefaultValue");
|
||||
this.defaultValueKey = defaultValueKey;
|
||||
@@ -406,7 +425,7 @@ export class CssProperty<T extends Style, U> implements definitions.CssProperty<
|
||||
|
||||
if (changed) {
|
||||
const view = this.view;
|
||||
const setNativeValue = view.nativeView && native in view;
|
||||
const setNativeValue = view.nativeView && view[setNative];
|
||||
if (reset) {
|
||||
delete this[key];
|
||||
if (valueChanged) {
|
||||
@@ -414,8 +433,12 @@ export class CssProperty<T extends Style, U> implements definitions.CssProperty<
|
||||
}
|
||||
|
||||
if (setNativeValue) {
|
||||
view[native] = this[defaultValueKey];
|
||||
delete this[defaultValueKey];
|
||||
if (defaultValueKey in this) {
|
||||
view[setNative](this[defaultValueKey]);
|
||||
delete this[defaultValueKey];
|
||||
} else {
|
||||
view[setNative](defaultValue);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this[key] = value;
|
||||
@@ -424,11 +447,11 @@ export class CssProperty<T extends Style, U> implements definitions.CssProperty<
|
||||
}
|
||||
|
||||
if (setNativeValue) {
|
||||
if (!(defaultValueKey in this)) {
|
||||
this[defaultValueKey] = view[native];
|
||||
if (view[getDefault] && !(defaultValueKey in this)) {
|
||||
this[defaultValueKey] = view[getDefault]();
|
||||
}
|
||||
|
||||
view[native] = value;
|
||||
view[setNative](value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,7 +494,7 @@ export class CssProperty<T extends Style, U> implements definitions.CssProperty<
|
||||
|
||||
if (changed) {
|
||||
const view = this.view;
|
||||
const setNativeValue = view.nativeView && native in view;
|
||||
const setNativeValue = view.nativeView && view[setNative];
|
||||
if (reset) {
|
||||
delete this[key];
|
||||
if (valueChanged) {
|
||||
@@ -479,8 +502,12 @@ export class CssProperty<T extends Style, U> implements definitions.CssProperty<
|
||||
}
|
||||
|
||||
if (setNativeValue) {
|
||||
view[native] = this[defaultValueKey];
|
||||
delete this[defaultValueKey];
|
||||
if (defaultValueKey in this) {
|
||||
view[setNative](this[defaultValueKey]);
|
||||
delete this[defaultValueKey];
|
||||
} else {
|
||||
view[setNative](defaultValue);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this[key] = value;
|
||||
@@ -489,11 +516,11 @@ export class CssProperty<T extends Style, U> implements definitions.CssProperty<
|
||||
}
|
||||
|
||||
if (setNativeValue) {
|
||||
if (!(defaultValueKey in this)) {
|
||||
this[defaultValueKey] = view[native];
|
||||
if (view[getDefault] && !(defaultValueKey in this)) {
|
||||
this[defaultValueKey] = view[getDefault]();
|
||||
}
|
||||
|
||||
view[native] = value;
|
||||
view[setNative](value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,13 +581,17 @@ export class CssAnimationProperty<T extends Style, U> {
|
||||
public readonly name: string;
|
||||
public readonly cssName: string;
|
||||
|
||||
public readonly native: symbol;
|
||||
public readonly getDefault: symbol;
|
||||
public readonly setNative: symbol;
|
||||
|
||||
public readonly register: (cls: { prototype }) => void;
|
||||
|
||||
public readonly keyframe: string;
|
||||
public readonly defaultValueKey: symbol;
|
||||
public readonly computedValueKey: symbol;
|
||||
|
||||
public readonly defaultValue: U;
|
||||
|
||||
private static properties: { [cssName: string]: CssAnimationProperty<any, any> } = {};
|
||||
|
||||
public _valueConverter?: (value: string) => any;
|
||||
@@ -587,6 +618,8 @@ export class CssAnimationProperty<T extends Style, U> {
|
||||
const defaultValueKey = Symbol(defaultName);
|
||||
this.defaultValueKey = defaultValueKey;
|
||||
|
||||
this.defaultValue = defaultValue;
|
||||
|
||||
const cssValue = Symbol(cssName);
|
||||
const styleValue = Symbol(propertyName);
|
||||
const keyframeValue = Symbol(keyframeName);
|
||||
@@ -594,7 +627,9 @@ export class CssAnimationProperty<T extends Style, U> {
|
||||
this.computedValueKey = computedValue;
|
||||
const computedSource = Symbol("computed-source:" + propertyName);
|
||||
|
||||
const native = this.native = Symbol("native:" + propertyName);
|
||||
// Note the getDefault is unused, CssAnimationProperties are expected to have default JavaScript value.
|
||||
this.getDefault = Symbol(propertyName + ":getDefault");
|
||||
const setNative = this.setNative = Symbol(propertyName + ":setNative");
|
||||
const eventName = propertyName + "Change";
|
||||
|
||||
function descriptor(symbol: symbol, propertySource: ValueSource, enumerable: boolean, configurable: boolean, getsComputed: boolean): PropertyDescriptor {
|
||||
@@ -633,8 +668,8 @@ export class CssAnimationProperty<T extends Style, U> {
|
||||
if (valueChanged) {
|
||||
valueChanged(this, prev, next);
|
||||
}
|
||||
if (this.view.nativeView) {
|
||||
this.view[native] = next;
|
||||
if (this.view.nativeView && this.view[setNative]) {
|
||||
this.view[setNative](next);
|
||||
}
|
||||
if (this.hasListeners(eventName)) {
|
||||
this.notify({ eventName, object: this, propertyName, value });
|
||||
@@ -689,7 +724,8 @@ export class InheritedCssProperty<T extends Style, U> extends CssProperty<T, U>
|
||||
|
||||
const key = this.key;
|
||||
const sourceKey = this.sourceKey;
|
||||
const native = this.native;
|
||||
const getDefault = this.getDefault;
|
||||
const setNative = this.setNative;
|
||||
const defaultValueKey = this.defaultValueKey;
|
||||
|
||||
const eventName = name + "Change";
|
||||
@@ -723,8 +759,7 @@ export class InheritedCssProperty<T extends Style, U> extends CssProperty<T, U>
|
||||
if (style && style[sourceKey] > ValueSource.Default) {
|
||||
newValue = style[name];
|
||||
this[sourceKey] = ValueSource.Inherited;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
newValue = defaultValue;
|
||||
delete this[sourceKey];
|
||||
}
|
||||
@@ -742,7 +777,7 @@ export class InheritedCssProperty<T extends Style, U> extends CssProperty<T, U>
|
||||
|
||||
if (changed) {
|
||||
const view = this.view;
|
||||
const setNativeValue = view.nativeView && native in view;
|
||||
const setNativeValue = view.nativeView && view[setNative];
|
||||
if (reset) {
|
||||
delete this[key];
|
||||
if (valueChanged) {
|
||||
@@ -750,8 +785,12 @@ export class InheritedCssProperty<T extends Style, U> extends CssProperty<T, U>
|
||||
}
|
||||
|
||||
if (setNativeValue) {
|
||||
view[native] = this[defaultValueKey];
|
||||
delete this[defaultValueKey];
|
||||
if (defaultValueKey in this) {
|
||||
view[setNative](this[defaultValueKey]);
|
||||
delete this[defaultValueKey];
|
||||
} else {
|
||||
view[setNative](defaultValue);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this[key] = newValue;
|
||||
@@ -760,11 +799,11 @@ export class InheritedCssProperty<T extends Style, U> extends CssProperty<T, U>
|
||||
}
|
||||
|
||||
if (setNativeValue) {
|
||||
if (!(defaultValueKey in this)) {
|
||||
this[defaultValueKey] = view[native];
|
||||
if (view[getDefault] && !(defaultValueKey in this)) {
|
||||
this[defaultValueKey] = view[getDefault]();
|
||||
}
|
||||
|
||||
view[native] = newValue;
|
||||
view[setNative](newValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -820,7 +859,6 @@ export class ShorthandProperty<T extends Style, P> implements definitions.Shorth
|
||||
protected readonly cssValueDescriptor: PropertyDescriptor;
|
||||
protected readonly localValueDescriptor: PropertyDescriptor;
|
||||
|
||||
public readonly native: symbol;
|
||||
public readonly sourceKey: symbol;
|
||||
|
||||
constructor(options: definitions.ShorthandPropertyOptions<P>) {
|
||||
@@ -920,15 +958,16 @@ export function initNativeView(view: ViewBase): void {
|
||||
continue;
|
||||
}
|
||||
|
||||
const native = property.native;
|
||||
if (native in view) {
|
||||
const setNative = property.setNative;
|
||||
const getDefault = property.getDefault;
|
||||
if (setNative in view) {
|
||||
const defaultValueKey = property.defaultValueKey;
|
||||
if (!(defaultValueKey in view)) {
|
||||
view[defaultValueKey] = view[native];
|
||||
if (view[getDefault] && !(defaultValueKey in view)) {
|
||||
view[defaultValueKey] = view[getDefault]();
|
||||
}
|
||||
|
||||
const value = view[symbol];
|
||||
view[native] = value;
|
||||
view[setNative](value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -940,15 +979,16 @@ export function initNativeView(view: ViewBase): void {
|
||||
continue;
|
||||
}
|
||||
|
||||
const native = property.native;
|
||||
if (native in view) {
|
||||
const defaultValueKey = property.defaultValueKey;
|
||||
if (!(defaultValueKey in style)) {
|
||||
style[defaultValueKey] = view[native];
|
||||
if (view[property.setNative]) {
|
||||
if (view[property.getDefault]) {
|
||||
const defaultValueKey = property.defaultValueKey;
|
||||
if (view[property.getDefault] && !(defaultValueKey in style)) {
|
||||
style[defaultValueKey] = view[property.getDefault]();
|
||||
}
|
||||
}
|
||||
|
||||
const value = style[symbol];
|
||||
view[native] = value;
|
||||
view[property.setNative](value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -961,10 +1001,13 @@ export function resetNativeView(view: ViewBase): void {
|
||||
continue;
|
||||
}
|
||||
|
||||
const native = property.native;
|
||||
if (native in view) {
|
||||
view[native] = view[property.defaultValueKey];
|
||||
delete view[property.defaultValueKey];
|
||||
if (view[property.setNative]) {
|
||||
if (property.defaultValueKey in view) {
|
||||
view[property.setNative](view[property.defaultValueKey]);
|
||||
delete view[property.defaultValueKey];
|
||||
} else {
|
||||
view[property.setNative](property.defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
// This will not call propertyChange!!!
|
||||
@@ -980,10 +1023,13 @@ export function resetNativeView(view: ViewBase): void {
|
||||
continue;
|
||||
}
|
||||
|
||||
const native = property.native;
|
||||
if (native in view) {
|
||||
view[native] = style[property.defaultValueKey];
|
||||
delete style[property.defaultValueKey];
|
||||
if (view[property.setNative]) {
|
||||
if (property.defaultValueKey in style) {
|
||||
view[property.setNative](style[property.defaultValueKey]);
|
||||
delete style[property.defaultValueKey];
|
||||
} else {
|
||||
view[property.setNative](property.defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
// This will not call propertyChange!!!
|
||||
|
||||
@@ -53,8 +53,8 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
|
||||
_currentWidthMeasureSpec: number;
|
||||
_currentHeightMeasureSpec: number;
|
||||
|
||||
_minWidthNative: Length;
|
||||
_minHeightNative: Length;
|
||||
_setMinWidthNative: (value: Length) => void;
|
||||
_setMinHeightNative: (value: Length) => void;
|
||||
|
||||
private _isLayoutValid: boolean;
|
||||
private _cssType: string;
|
||||
|
||||
@@ -290,38 +290,38 @@ export class View extends ViewCommon {
|
||||
return result | (childMeasuredState & layout.MEASURED_STATE_MASK);
|
||||
}
|
||||
|
||||
get [isEnabledProperty.native](): boolean {
|
||||
[isEnabledProperty.getDefault](): boolean {
|
||||
return this.nativeView.isEnabled();
|
||||
}
|
||||
set [isEnabledProperty.native](value: boolean) {
|
||||
[isEnabledProperty.setNative](value: boolean) {
|
||||
this.nativeView.setEnabled(value);
|
||||
}
|
||||
|
||||
get [originXProperty.native](): number {
|
||||
[originXProperty.getDefault](): number {
|
||||
return this.nativeView.getPivotX();
|
||||
}
|
||||
set [originXProperty.native](value: number) {
|
||||
[originXProperty.setNative](value: number) {
|
||||
org.nativescript.widgets.OriginPoint.setX(this.nativeView, value);
|
||||
}
|
||||
|
||||
get [originYProperty.native](): number {
|
||||
[originYProperty.getDefault](): number {
|
||||
return this.nativeView.getPivotY();
|
||||
}
|
||||
set [originYProperty.native](value: number) {
|
||||
[originYProperty.setNative](value: number) {
|
||||
org.nativescript.widgets.OriginPoint.setY(this.nativeView, value);
|
||||
}
|
||||
|
||||
get [automationTextProperty.native](): string {
|
||||
[automationTextProperty.getDefault](): string {
|
||||
return this.nativeView.getContentDescription();
|
||||
}
|
||||
set [automationTextProperty.native](value: string) {
|
||||
[automationTextProperty.setNative](value: string) {
|
||||
this.nativeView.setContentDescription(value);
|
||||
}
|
||||
|
||||
get [isUserInteractionEnabledProperty.native](): boolean {
|
||||
[isUserInteractionEnabledProperty.getDefault](): boolean {
|
||||
return true;
|
||||
}
|
||||
set [isUserInteractionEnabledProperty.native](value: boolean) {
|
||||
[isUserInteractionEnabledProperty.setNative](value: boolean) {
|
||||
if (!value) {
|
||||
initializeDisabledListener();
|
||||
// User interaction is disabled -- we stop it and we do not care whether someone wants to listen for gestures.
|
||||
@@ -331,7 +331,7 @@ export class View extends ViewCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [visibilityProperty.native](): Visibility {
|
||||
[visibilityProperty.getDefault](): Visibility {
|
||||
let nativeVisibility = this.nativeView.getVisibility();
|
||||
switch (nativeVisibility) {
|
||||
case android.view.View.VISIBLE:
|
||||
@@ -344,7 +344,7 @@ export class View extends ViewCommon {
|
||||
throw new Error(`Unsupported android.view.View visibility: ${nativeVisibility}. Currently supported values are android.view.View.VISIBLE, android.view.View.INVISIBLE, android.view.View.GONE.`);
|
||||
}
|
||||
}
|
||||
set [visibilityProperty.native](value: Visibility) {
|
||||
[visibilityProperty.setNative](value: Visibility) {
|
||||
switch (value) {
|
||||
case "visible":
|
||||
this.nativeView.setVisibility(android.view.View.VISIBLE);
|
||||
@@ -360,17 +360,17 @@ export class View extends ViewCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [opacityProperty.native](): number {
|
||||
[opacityProperty.getDefault](): number {
|
||||
return this.nativeView.getAlpha();
|
||||
}
|
||||
set [opacityProperty.native](value: number) {
|
||||
[opacityProperty.setNative](value: number) {
|
||||
this.nativeView.setAlpha(value);
|
||||
}
|
||||
|
||||
get [horizontalAlignmentProperty.native](): HorizontalAlignment {
|
||||
[horizontalAlignmentProperty.getDefault](): HorizontalAlignment {
|
||||
return <HorizontalAlignment>org.nativescript.widgets.ViewHelper.getHorizontalAlignment(this.nativeView);
|
||||
}
|
||||
set [horizontalAlignmentProperty.native](value: HorizontalAlignment) {
|
||||
[horizontalAlignmentProperty.setNative](value: HorizontalAlignment) {
|
||||
const nativeView = this.nativeView;
|
||||
const lp: any = nativeView.getLayoutParams() || new org.nativescript.widgets.CommonLayoutParams();
|
||||
// Set only if params gravity exists.
|
||||
@@ -393,10 +393,10 @@ export class View extends ViewCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [verticalAlignmentProperty.native](): VerticalAlignment {
|
||||
[verticalAlignmentProperty.getDefault](): VerticalAlignment {
|
||||
return <VerticalAlignment>org.nativescript.widgets.ViewHelper.getVerticalAlignment(this.nativeView);
|
||||
}
|
||||
set [verticalAlignmentProperty.native](value: VerticalAlignment) {
|
||||
[verticalAlignmentProperty.setNative](value: VerticalAlignment) {
|
||||
const nativeView = this.nativeView;
|
||||
const lp: any = nativeView.getLayoutParams() || new org.nativescript.widgets.CommonLayoutParams();
|
||||
// Set only if params gravity exists.
|
||||
@@ -419,45 +419,45 @@ export class View extends ViewCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [rotateProperty.native](): number {
|
||||
[rotateProperty.getDefault](): number {
|
||||
return org.nativescript.widgets.ViewHelper.getRotate(this.nativeView);
|
||||
}
|
||||
set [rotateProperty.native](value: number) {
|
||||
[rotateProperty.setNative](value: number) {
|
||||
org.nativescript.widgets.ViewHelper.setRotate(this.nativeView, float(value));
|
||||
}
|
||||
|
||||
get [scaleXProperty.native](): number {
|
||||
[scaleXProperty.getDefault](): number {
|
||||
return org.nativescript.widgets.ViewHelper.getScaleX(this.nativeView);
|
||||
}
|
||||
set [scaleXProperty.native](value: number) {
|
||||
[scaleXProperty.setNative](value: number) {
|
||||
org.nativescript.widgets.ViewHelper.setScaleX(this.nativeView, float(value));
|
||||
}
|
||||
|
||||
get [scaleYProperty.native](): number {
|
||||
[scaleYProperty.getDefault](): number {
|
||||
return org.nativescript.widgets.ViewHelper.getScaleY(this.nativeView);
|
||||
}
|
||||
set [scaleYProperty.native](value: number) {
|
||||
[scaleYProperty.setNative](value: number) {
|
||||
org.nativescript.widgets.ViewHelper.setScaleY(this.nativeView, float(value));
|
||||
}
|
||||
|
||||
get [translateXProperty.native](): Length | number {
|
||||
[translateXProperty.getDefault](): Length | number {
|
||||
return org.nativescript.widgets.ViewHelper.getTranslateX(this.nativeView);
|
||||
}
|
||||
set [translateXProperty.native](value: Length) {
|
||||
[translateXProperty.setNative](value: Length) {
|
||||
org.nativescript.widgets.ViewHelper.setTranslateX(this.nativeView, Length.toDevicePixels(value, 0));
|
||||
}
|
||||
|
||||
get [translateYProperty.native](): Length | number {
|
||||
[translateYProperty.getDefault](): Length | number {
|
||||
return org.nativescript.widgets.ViewHelper.getTranslateY(this.nativeView);
|
||||
}
|
||||
set [translateYProperty.native](value: Length) {
|
||||
[translateYProperty.setNative](value: Length) {
|
||||
org.nativescript.widgets.ViewHelper.setTranslateY(this.nativeView, Length.toDevicePixels(value, 0));
|
||||
}
|
||||
|
||||
get [zIndexProperty.native](): number {
|
||||
[zIndexProperty.getDefault](): number {
|
||||
return org.nativescript.widgets.ViewHelper.getZIndex(this.nativeView);
|
||||
}
|
||||
set [zIndexProperty.native](value: number) {
|
||||
[zIndexProperty.setNative](value: number) {
|
||||
org.nativescript.widgets.ViewHelper.setZIndex(this.nativeView, value);
|
||||
// let nativeView = this.nativeView;
|
||||
// if (nativeView instanceof android.widget.Button) {
|
||||
@@ -465,10 +465,10 @@ export class View extends ViewCommon {
|
||||
// }
|
||||
}
|
||||
|
||||
get [backgroundInternalProperty.native](): android.graphics.drawable.Drawable {
|
||||
[backgroundInternalProperty.getDefault](): android.graphics.drawable.Drawable {
|
||||
return this.nativeView.getBackground();
|
||||
}
|
||||
set [backgroundInternalProperty.native](value: android.graphics.drawable.Drawable | Background) {
|
||||
[backgroundInternalProperty.setNative](value: android.graphics.drawable.Drawable | Background) {
|
||||
if (value instanceof android.graphics.drawable.Drawable) {
|
||||
this.nativeView.setBackground(value);
|
||||
} else {
|
||||
@@ -476,19 +476,19 @@ export class View extends ViewCommon {
|
||||
}
|
||||
}
|
||||
|
||||
set [minWidthProperty.native](value: Length) {
|
||||
[minWidthProperty.setNative](value: Length) {
|
||||
if (this.parent instanceof CustomLayoutView && this.parent.nativeView) {
|
||||
this.parent._setChildMinWidthNative(this);
|
||||
} else {
|
||||
this._minWidthNative = this.minWidth;
|
||||
this._setMinWidthNative(this.minWidth);
|
||||
}
|
||||
}
|
||||
|
||||
set [minHeightProperty.native](value: Length) {
|
||||
[minHeightProperty.setNative](value: Length) {
|
||||
if (this.parent instanceof CustomLayoutView && this.parent.nativeView) {
|
||||
this.parent._setChildMinHeightNative(this);
|
||||
} else {
|
||||
this._minHeightNative = this.minHeight;
|
||||
this._setMinHeightNative(this.minHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -532,11 +532,11 @@ export class CustomLayoutView extends View implements CustomLayoutViewDefinition
|
||||
}
|
||||
|
||||
public _setChildMinWidthNative(child: View): void {
|
||||
child._minWidthNative = child.minWidth;
|
||||
child._setMinWidthNative(child.minWidth);
|
||||
}
|
||||
|
||||
public _setChildMinHeightNative(child: View): void {
|
||||
child._minHeightNative = child.minHeight;
|
||||
child._setMinHeightNative(child.minHeight);
|
||||
}
|
||||
|
||||
public _removeViewFromNativeVisualTree(child: ViewCommon): void {
|
||||
@@ -556,18 +556,19 @@ type NativeSetter = { (view: android.view.View, value: number): void };
|
||||
type NativeGetter = { (view: android.view.View): number };
|
||||
const percentNotSupported = (view: android.view.View, value: number) => { throw new Error("PercentLength is not supported."); };
|
||||
interface NativePercentLengthPropertyOptions {
|
||||
key: string | symbol;
|
||||
getter?: string | symbol;
|
||||
setter: string | symbol;
|
||||
auto?: number;
|
||||
getPixels: NativeGetter;
|
||||
getPixels?: NativeGetter;
|
||||
setPixels: NativeSetter;
|
||||
setPercent?: NativeSetter
|
||||
}
|
||||
|
||||
function createNativePercentLengthProperty(options: NativePercentLengthPropertyOptions) {
|
||||
const { key, auto = 0 } = options;
|
||||
const { getter, setter, auto = 0 } = options;
|
||||
let setPixels, getPixels, setPercent;
|
||||
Object.defineProperty(View.prototype, key, {
|
||||
get: function (this: View): PercentLength {
|
||||
if (getter) {
|
||||
View.prototype[getter] = function(this: View): PercentLength {
|
||||
if (options) {
|
||||
setPixels = options.setPixels;
|
||||
getPixels = options.getPixels;
|
||||
@@ -580,8 +581,10 @@ function createNativePercentLengthProperty(options: NativePercentLengthPropertyO
|
||||
} else {
|
||||
return { value, unit: "px" };
|
||||
}
|
||||
},
|
||||
set: function (this: View, length: PercentLength) {
|
||||
}
|
||||
}
|
||||
if (setter) {
|
||||
View.prototype[setter] = function(this: View, length: PercentLength) {
|
||||
if (options) {
|
||||
setPixels = options.setPixels;
|
||||
getPixels = options.getPixels;
|
||||
@@ -602,39 +605,44 @@ function createNativePercentLengthProperty(options: NativePercentLengthPropertyO
|
||||
throw new Error(`Unsupported PercentLength ${length}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
createNativePercentLengthProperty({
|
||||
key: marginTopProperty.native,
|
||||
getter: marginTopProperty.getDefault,
|
||||
setter: marginTopProperty.setNative,
|
||||
get getPixels() { return org.nativescript.widgets.ViewHelper.getMarginTop },
|
||||
get setPixels() { return org.nativescript.widgets.ViewHelper.setMarginTop },
|
||||
get setPercent() { return org.nativescript.widgets.ViewHelper.setMarginTopPercent }
|
||||
});
|
||||
|
||||
createNativePercentLengthProperty({
|
||||
key: marginRightProperty.native,
|
||||
getter: marginRightProperty.getDefault,
|
||||
setter: marginRightProperty.setNative,
|
||||
get getPixels() { return org.nativescript.widgets.ViewHelper.getMarginRight },
|
||||
get setPixels() { return org.nativescript.widgets.ViewHelper.setMarginRight },
|
||||
get setPercent() { return org.nativescript.widgets.ViewHelper.setMarginRightPercent }
|
||||
});
|
||||
|
||||
createNativePercentLengthProperty({
|
||||
key: marginBottomProperty.native,
|
||||
getter: marginBottomProperty.getDefault,
|
||||
setter: marginBottomProperty.setNative,
|
||||
get getPixels() { return org.nativescript.widgets.ViewHelper.getMarginBottom },
|
||||
get setPixels() { return org.nativescript.widgets.ViewHelper.setMarginBottom },
|
||||
get setPercent() { return org.nativescript.widgets.ViewHelper.setMarginBottomPercent }
|
||||
});
|
||||
|
||||
createNativePercentLengthProperty({
|
||||
key: marginLeftProperty.native,
|
||||
getter: marginLeftProperty.getDefault,
|
||||
setter: marginLeftProperty.setNative,
|
||||
get getPixels() { return org.nativescript.widgets.ViewHelper.getMarginLeft },
|
||||
get setPixels() { return org.nativescript.widgets.ViewHelper.setMarginLeft },
|
||||
get setPercent() { return org.nativescript.widgets.ViewHelper.setMarginLeftPercent }
|
||||
});
|
||||
|
||||
createNativePercentLengthProperty({
|
||||
key: widthProperty.native,
|
||||
getter: widthProperty.getDefault,
|
||||
setter: widthProperty.setNative,
|
||||
auto: -1, //android.view.ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
get getPixels() { return org.nativescript.widgets.ViewHelper.getWidth },
|
||||
get setPixels() { return org.nativescript.widgets.ViewHelper.setWidth },
|
||||
@@ -642,7 +650,8 @@ createNativePercentLengthProperty({
|
||||
});
|
||||
|
||||
createNativePercentLengthProperty({
|
||||
key: heightProperty.native,
|
||||
getter: heightProperty.getDefault,
|
||||
setter: heightProperty.setNative,
|
||||
auto: -1, //android.view.ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
get getPixels() { return org.nativescript.widgets.ViewHelper.getHeight },
|
||||
get setPixels() { return org.nativescript.widgets.ViewHelper.setHeight },
|
||||
@@ -650,13 +659,11 @@ createNativePercentLengthProperty({
|
||||
});
|
||||
|
||||
createNativePercentLengthProperty({
|
||||
key: "_minWidthNative",
|
||||
get getPixels() { return org.nativescript.widgets.ViewHelper.getMinWidth },
|
||||
setter: "_setMinWidthNative",
|
||||
get setPixels() { return org.nativescript.widgets.ViewHelper.setMinWidth }
|
||||
});
|
||||
|
||||
createNativePercentLengthProperty({
|
||||
key: "_minHeightNative",
|
||||
get getPixels() { return org.nativescript.widgets.ViewHelper.getMinHeight },
|
||||
setter: "_setMinHeightNative",
|
||||
get setPixels() { return org.nativescript.widgets.ViewHelper.setMinHeight }
|
||||
});
|
||||
|
||||
4
tns-core-modules/ui/core/view/view.d.ts
vendored
4
tns-core-modules/ui/core/view/view.d.ts
vendored
@@ -503,8 +503,8 @@ export abstract class View extends ViewBase implements ApplyXmlAttributes {
|
||||
_currentWidthMeasureSpec: number;
|
||||
_currentHeightMeasureSpec: number;
|
||||
|
||||
_minWidthNative: Length;
|
||||
_minHeightNative: Length;
|
||||
_setMinWidthNative(value: Length): void;
|
||||
_setMinHeightNative(value: Length): void;
|
||||
//@endprivate
|
||||
|
||||
/**
|
||||
|
||||
@@ -220,13 +220,13 @@ export class View extends ViewCommon {
|
||||
}
|
||||
|
||||
let background = this.style.backgroundInternal;
|
||||
if (!background.isEmpty()) {
|
||||
this[backgroundInternalProperty.native] = background;
|
||||
if (!background.isEmpty() && this[backgroundInternalProperty.setNative]) {
|
||||
this[backgroundInternalProperty.setNative](background);
|
||||
}
|
||||
|
||||
let clipPath = this.style.clipPath;
|
||||
if (clipPath !== "") {
|
||||
this[clipPathProperty.native] = clipPath;
|
||||
if (clipPath !== "" && this[clipPathProperty.setNative]) {
|
||||
this[clipPathProperty.setNative](clipPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,50 +269,50 @@ export class View extends ViewCommon {
|
||||
return this._suspendCATransaction;
|
||||
}
|
||||
|
||||
get [isEnabledProperty.native](): boolean {
|
||||
[isEnabledProperty.getDefault](): boolean {
|
||||
let nativeView = this.nativeView;
|
||||
return nativeView instanceof UIControl ? nativeView.enabled : true;
|
||||
}
|
||||
set [isEnabledProperty.native](value: boolean) {
|
||||
[isEnabledProperty.setNative](value: boolean) {
|
||||
let nativeView = this.nativeView;
|
||||
if (nativeView instanceof UIControl) {
|
||||
nativeView.enabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
get [originXProperty.native](): number {
|
||||
[originXProperty.getDefault](): number {
|
||||
return this.nativeView.layer.anchorPoint.x;
|
||||
}
|
||||
set [originXProperty.native](value: number) {
|
||||
[originXProperty.setNative](value: number) {
|
||||
this.updateOriginPoint(value, this.originY);
|
||||
}
|
||||
|
||||
get [originYProperty.native](): number {
|
||||
[originYProperty.getDefault](): number {
|
||||
return this.nativeView.layer.anchorPoint.y;
|
||||
}
|
||||
set [originYProperty.native](value: number) {
|
||||
[originYProperty.setNative](value: number) {
|
||||
this.updateOriginPoint(this.originX, value);
|
||||
}
|
||||
|
||||
get [automationTextProperty.native](): string {
|
||||
[automationTextProperty.getDefault](): string {
|
||||
return this.nativeView.accessibilityLabel;
|
||||
}
|
||||
set [automationTextProperty.native](value: string) {
|
||||
[automationTextProperty.setNative](value: string) {
|
||||
this.nativeView.accessibilityIdentifier = value;
|
||||
this.nativeView.accessibilityLabel = value;
|
||||
}
|
||||
|
||||
get [isUserInteractionEnabledProperty.native](): boolean {
|
||||
[isUserInteractionEnabledProperty.getDefault](): boolean {
|
||||
return this.nativeView.userInteractionEnabled;
|
||||
}
|
||||
set [isUserInteractionEnabledProperty.native](value: boolean) {
|
||||
[isUserInteractionEnabledProperty.setNative](value: boolean) {
|
||||
this.nativeView.userInteractionEnabled = value;
|
||||
}
|
||||
|
||||
get [visibilityProperty.native](): Visibility {
|
||||
[visibilityProperty.getDefault](): Visibility {
|
||||
return this.nativeView.hidden ? Visibility.COLLAPSE : Visibility.VISIBLE;
|
||||
}
|
||||
set [visibilityProperty.native](value: Visibility) {
|
||||
[visibilityProperty.setNative](value: Visibility) {
|
||||
switch (value) {
|
||||
case Visibility.VISIBLE:
|
||||
this.nativeView.hidden = false;
|
||||
@@ -326,10 +326,10 @@ export class View extends ViewCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [opacityProperty.native](): number {
|
||||
[opacityProperty.getDefault](): number {
|
||||
return this.nativeView.alpha;
|
||||
}
|
||||
set [opacityProperty.native](value: number) {
|
||||
[opacityProperty.setNative](value: number) {
|
||||
let nativeView = this.nativeView;
|
||||
let updateSuspended = this._isPresentationLayerUpdateSuspeneded();
|
||||
if (!updateSuspended) {
|
||||
@@ -341,52 +341,52 @@ export class View extends ViewCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [rotateProperty.native](): number {
|
||||
[rotateProperty.getDefault](): number {
|
||||
return 0;
|
||||
}
|
||||
set [rotateProperty.native](value: number) {
|
||||
[rotateProperty.setNative](value: number) {
|
||||
this.updateNativeTransform();
|
||||
}
|
||||
|
||||
get [scaleXProperty.native](): number {
|
||||
[scaleXProperty.getDefault](): number {
|
||||
return 1;
|
||||
}
|
||||
set [scaleXProperty.native](value: number) {
|
||||
[scaleXProperty.setNative](value: number) {
|
||||
this.updateNativeTransform();
|
||||
}
|
||||
|
||||
get [scaleYProperty.native](): number {
|
||||
[scaleYProperty.getDefault](): number {
|
||||
return 1;
|
||||
}
|
||||
set [scaleYProperty.native](value: number) {
|
||||
[scaleYProperty.setNative](value: number) {
|
||||
this.updateNativeTransform();
|
||||
}
|
||||
|
||||
get [translateXProperty.native](): Length | number {
|
||||
[translateXProperty.getDefault](): Length | number {
|
||||
return 0;
|
||||
}
|
||||
set [translateXProperty.native](value: Length) {
|
||||
[translateXProperty.setNative](value: Length) {
|
||||
this.updateNativeTransform();
|
||||
}
|
||||
|
||||
get [translateYProperty.native](): Length | number {
|
||||
[translateYProperty.getDefault](): Length | number {
|
||||
return 0;
|
||||
}
|
||||
set [translateYProperty.native](value: Length) {
|
||||
[translateYProperty.setNative](value: Length) {
|
||||
this.updateNativeTransform();
|
||||
}
|
||||
|
||||
get [zIndexProperty.native](): number {
|
||||
[zIndexProperty.getDefault](): number {
|
||||
return 0;
|
||||
}
|
||||
set [zIndexProperty.native](value: number) {
|
||||
[zIndexProperty.setNative](value: number) {
|
||||
this.nativeView.layer.zPosition = value;
|
||||
}
|
||||
|
||||
get [backgroundInternalProperty.native](): UIColor {
|
||||
[backgroundInternalProperty.getDefault](): UIColor {
|
||||
return this.nativeView.backgroundColor;
|
||||
}
|
||||
set [backgroundInternalProperty.native](value: UIColor | Background) {
|
||||
[backgroundInternalProperty.setNative](value: UIColor | Background) {
|
||||
let updateSuspended = this._isPresentationLayerUpdateSuspeneded();
|
||||
if (!updateSuspended) {
|
||||
CATransaction.begin();
|
||||
|
||||
@@ -74,37 +74,37 @@ export class DatePicker extends DatePickerBase {
|
||||
this.date = new Date(year, month, day);
|
||||
}
|
||||
|
||||
get [yearProperty.native](): number {
|
||||
[yearProperty.getDefault](): number {
|
||||
return this.android.getYear();
|
||||
}
|
||||
set [yearProperty.native](value: number) {
|
||||
[yearProperty.setNative](value: number) {
|
||||
if (this.android.getYear() !== value) {
|
||||
this.updateNativeDate();
|
||||
}
|
||||
}
|
||||
|
||||
get [monthProperty.native](): number {
|
||||
[monthProperty.getDefault](): number {
|
||||
return this.android.getMonth();
|
||||
}
|
||||
set [monthProperty.native](value: number) {
|
||||
[monthProperty.setNative](value: number) {
|
||||
if (this.android.getMonth() !== (value - 1)) {
|
||||
this.updateNativeDate();
|
||||
}
|
||||
}
|
||||
|
||||
get [dayProperty.native](): number {
|
||||
[dayProperty.getDefault](): number {
|
||||
return this.android.getDayOfMonth();
|
||||
}
|
||||
set [dayProperty.native](value: number) {
|
||||
[dayProperty.setNative](value: number) {
|
||||
if (this.android.getDayOfMonth() !== value) {
|
||||
this.updateNativeDate();
|
||||
}
|
||||
}
|
||||
|
||||
get [dateProperty.native](): Date {
|
||||
[dateProperty.getDefault](): Date {
|
||||
return new Date(this.android.getYear(), this.android.getMonth(), this.android.getDayOfMonth());
|
||||
}
|
||||
set [dateProperty.native](value: Date) {
|
||||
[dateProperty.setNative](value: Date) {
|
||||
if (this.android.getDayOfMonth() !== value.getDay()
|
||||
|| this.android.getMonth() !== value.getMonth()
|
||||
|| this.android.getYear() !== value.getFullYear()) {
|
||||
@@ -112,20 +112,20 @@ export class DatePicker extends DatePickerBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [maxDateProperty.native](): Date {
|
||||
[maxDateProperty.getDefault](): Date {
|
||||
return this.android.getMaxDate();
|
||||
}
|
||||
set [maxDateProperty.native](value: Date) {
|
||||
[maxDateProperty.setNative](value: Date) {
|
||||
let newValue = value.getTime();
|
||||
if (this.android.getMaxDate() !== newValue) {
|
||||
this.android.setMaxDate(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
get [minDateProperty.native](): Date {
|
||||
[minDateProperty.getDefault](): Date {
|
||||
return this.android.getMinDate();
|
||||
}
|
||||
set [minDateProperty.native](value: Date) {
|
||||
[minDateProperty.setNative](value: Date) {
|
||||
let picker = this.android;
|
||||
let newValue = value.getTime();
|
||||
if (picker.getMinDate() !== newValue) {
|
||||
|
||||
@@ -25,40 +25,40 @@ export class DatePicker extends DatePickerBase {
|
||||
return this.nativeView;
|
||||
}
|
||||
|
||||
get [yearProperty.native](): number {
|
||||
[yearProperty.getDefault](): number {
|
||||
return this.nativeView.date.getFullYear();
|
||||
}
|
||||
set [yearProperty.native](value: number) {
|
||||
[yearProperty.setNative](value: number) {
|
||||
let picker = this.nativeView;
|
||||
let comps = ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.date);
|
||||
comps.year = value;
|
||||
this.date = new Date(comps.year, comps.month - 1, comps.day);
|
||||
}
|
||||
|
||||
get [monthProperty.native](): number {
|
||||
[monthProperty.getDefault](): number {
|
||||
return this.nativeView.date.getMonth();
|
||||
}
|
||||
set [monthProperty.native](value: number) {
|
||||
[monthProperty.setNative](value: number) {
|
||||
let picker = this.nativeView;
|
||||
let comps = ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.date);
|
||||
comps.month = value;
|
||||
this.date = new Date(comps.year, comps.month - 1, comps.day);
|
||||
}
|
||||
|
||||
get [dayProperty.native](): number {
|
||||
[dayProperty.getDefault](): number {
|
||||
return this.nativeView.date.getDay();
|
||||
}
|
||||
set [dayProperty.native](value: number) {
|
||||
[dayProperty.setNative](value: number) {
|
||||
let picker = this.nativeView;
|
||||
let comps = ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.date);
|
||||
comps.day = value;
|
||||
this.date = new Date(comps.year, comps.month - 1, comps.day);
|
||||
}
|
||||
|
||||
get [dateProperty.native](): Date {
|
||||
[dateProperty.getDefault](): Date {
|
||||
return this.nativeView.date;
|
||||
}
|
||||
set [dateProperty.native](value: Date) {
|
||||
[dateProperty.setNative](value: Date) {
|
||||
let picker = this.nativeView;
|
||||
let comps = ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.date);
|
||||
comps.year = value.getFullYear();
|
||||
@@ -67,28 +67,28 @@ export class DatePicker extends DatePickerBase {
|
||||
picker.setDateAnimated(ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
|
||||
}
|
||||
|
||||
get [maxDateProperty.native](): Date {
|
||||
[maxDateProperty.getDefault](): Date {
|
||||
return this.nativeView.maximumDate;
|
||||
}
|
||||
set [maxDateProperty.native](value: Date) {
|
||||
[maxDateProperty.setNative](value: Date) {
|
||||
let picker = this.nativeView;
|
||||
let nsDate = NSDate.dateWithTimeIntervalSince1970(value.getTime() / 1000);
|
||||
picker.maximumDate = <any>nsDate;
|
||||
}
|
||||
|
||||
get [minDateProperty.native](): Date {
|
||||
[minDateProperty.getDefault](): Date {
|
||||
return this.nativeView.minimumDate;
|
||||
}
|
||||
set [minDateProperty.native](value: Date) {
|
||||
[minDateProperty.setNative](value: Date) {
|
||||
let picker = this.nativeView;
|
||||
let nsDate = NSDate.dateWithTimeIntervalSince1970(value.getTime() / 1000);
|
||||
picker.minimumDate = <any>nsDate;
|
||||
}
|
||||
|
||||
get [colorProperty.native](): UIColor {
|
||||
[colorProperty.getDefault](): UIColor {
|
||||
return this.nativeView.valueForKey("textColor");
|
||||
}
|
||||
set [colorProperty.native](value: Color | UIColor) {
|
||||
[colorProperty.setNative](value: Color | UIColor) {
|
||||
let picker = this.nativeView;
|
||||
picker.setValueForKey(value instanceof Color ? value.ios : value, "textColor");
|
||||
}
|
||||
|
||||
@@ -192,15 +192,15 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [textProperty.native](): string {
|
||||
[textProperty.getDefault](): string {
|
||||
return this._android.getText();
|
||||
}
|
||||
set [textProperty.native](value: string) {
|
||||
[textProperty.setNative](value: string) {
|
||||
const text = (value === null || value === undefined) ? '' : value.toString();
|
||||
this._android.setText(text, android.widget.TextView.BufferType.EDITABLE);
|
||||
}
|
||||
|
||||
get [keyboardTypeProperty.native](): "datetime" | "phone" | "number" | "url" | "email" | string {
|
||||
[keyboardTypeProperty.getDefault](): "datetime" | "phone" | "number" | "url" | "email" | string {
|
||||
let inputType = this._android.getInputType();
|
||||
switch (inputType) {
|
||||
case android.text.InputType.TYPE_CLASS_DATETIME | android.text.InputType.TYPE_DATETIME_VARIATION_NORMAL:
|
||||
@@ -222,7 +222,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
return inputType.toString();
|
||||
}
|
||||
}
|
||||
set [keyboardTypeProperty.native](value: "datetime" | "phone" | "number" | "url" | "email" | string) {
|
||||
[keyboardTypeProperty.setNative](value: "datetime" | "phone" | "number" | "url" | "email" | string) {
|
||||
let newInputType;
|
||||
switch (value) {
|
||||
case "datetime":
|
||||
@@ -258,7 +258,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
this._setInputType(newInputType);
|
||||
}
|
||||
|
||||
get [returnKeyTypeProperty.native](): "done" | "next" | "go" | "search" | "send" | string {
|
||||
[returnKeyTypeProperty.getDefault](): "done" | "next" | "go" | "search" | "send" | string {
|
||||
let ime = this._android.getImeOptions();
|
||||
switch (ime) {
|
||||
case android.view.inputmethod.EditorInfo.IME_ACTION_DONE:
|
||||
@@ -280,7 +280,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
return ime.toString();
|
||||
}
|
||||
}
|
||||
set [returnKeyTypeProperty.native](value: "done" | "next" | "go" | "search" | "send" | string) {
|
||||
[returnKeyTypeProperty.setNative](value: "done" | "next" | "go" | "search" | "send" | string) {
|
||||
let newImeOptions;
|
||||
switch (value) {
|
||||
case "done":
|
||||
@@ -311,10 +311,10 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
this._android.setImeOptions(newImeOptions);
|
||||
}
|
||||
|
||||
get [editableProperty.native](): boolean {
|
||||
[editableProperty.getDefault](): boolean {
|
||||
return !!this._android.getKeyListener();
|
||||
}
|
||||
set [editableProperty.native](value: boolean) {
|
||||
[editableProperty.setNative](value: boolean) {
|
||||
if (value) {
|
||||
this._android.setKeyListener(this._keyListenerCache);
|
||||
}
|
||||
@@ -323,7 +323,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [autocapitalizationTypeProperty.native](): "none" | "words" | "sentences" | "allCharacters" | string {
|
||||
[autocapitalizationTypeProperty.getDefault](): "none" | "words" | "sentences" | "allCharacters" | string {
|
||||
let inputType = this._android.getInputType();
|
||||
if ((inputType & android.text.InputType.TYPE_TEXT_FLAG_CAP_WORDS) === android.text.InputType.TYPE_TEXT_FLAG_CAP_WORDS) {
|
||||
return "words";
|
||||
@@ -335,7 +335,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
return inputType.toString();
|
||||
}
|
||||
}
|
||||
set [autocapitalizationTypeProperty.native](value: string) {
|
||||
[autocapitalizationTypeProperty.setNative](value: string) {
|
||||
let inputType = this._android.getInputType();
|
||||
inputType = inputType & ~28672; //28672 (0x00070000) 13,14,15bits (111 0000 0000 0000)
|
||||
|
||||
@@ -366,7 +366,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
this._setInputType(inputType);
|
||||
}
|
||||
|
||||
get [autocorrectProperty.native](): boolean {
|
||||
[autocorrectProperty.getDefault](): boolean {
|
||||
let autocorrect = this._android.getInputType();
|
||||
if ((autocorrect & android.text.InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) === android.text.InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) {
|
||||
return true;
|
||||
@@ -374,7 +374,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
|
||||
return false;
|
||||
}
|
||||
set [autocorrectProperty.native](value: boolean) {
|
||||
[autocorrectProperty.setNative](value: boolean) {
|
||||
let inputType = this._android.getInputType();
|
||||
switch (value) {
|
||||
case true:
|
||||
@@ -395,17 +395,17 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
this._setInputType(inputType);
|
||||
}
|
||||
|
||||
get [hintProperty.native](): string {
|
||||
[hintProperty.getDefault](): string {
|
||||
return this._android.getHint();
|
||||
}
|
||||
set [hintProperty.native](value: string) {
|
||||
[hintProperty.setNative](value: string) {
|
||||
this._android.setHint(value + '');
|
||||
}
|
||||
|
||||
get [placeholderColorProperty.native](): android.content.res.ColorStateList {
|
||||
[placeholderColorProperty.getDefault](): android.content.res.ColorStateList {
|
||||
return this._android.getHintTextColors();
|
||||
}
|
||||
set [placeholderColorProperty.native](value: Color | android.content.res.ColorStateList) {
|
||||
[placeholderColorProperty.setNative](value: Color | android.content.res.ColorStateList) {
|
||||
if (value instanceof Color) {
|
||||
this._android.setHintTextColor(value.android);
|
||||
} else {
|
||||
|
||||
@@ -12,7 +12,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
this.nativeView.resignFirstResponder();
|
||||
}
|
||||
|
||||
get [keyboardTypeProperty.native](): "datetime"| "phone" | "number" | "url" | "email" | string {
|
||||
[keyboardTypeProperty.getDefault](): "datetime"| "phone" | "number" | "url" | "email" | string {
|
||||
let keyboardType = this.nativeView.keyboardType;
|
||||
switch (keyboardType) {
|
||||
case UIKeyboardType.NumbersAndPunctuation:
|
||||
@@ -31,7 +31,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
return keyboardType.toString();
|
||||
}
|
||||
}
|
||||
set [keyboardTypeProperty.native](value: "datetime"| "phone" | "number" | "url" | "email" | string) {
|
||||
[keyboardTypeProperty.setNative](value: "datetime"| "phone" | "number" | "url" | "email" | string) {
|
||||
let newKeyboardType: UIKeyboardType;
|
||||
switch (value) {
|
||||
case "datetime":
|
||||
@@ -67,7 +67,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
this.nativeView.keyboardType = newKeyboardType;
|
||||
}
|
||||
|
||||
get [returnKeyTypeProperty.native](): "done" | "next" | "go" | "search" | "send" | string {
|
||||
[returnKeyTypeProperty.getDefault](): "done" | "next" | "go" | "search" | "send" | string {
|
||||
let returnKeyType = this.nativeView.returnKeyType;
|
||||
switch (returnKeyType) {
|
||||
case UIReturnKeyType.Done:
|
||||
@@ -89,7 +89,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
return returnKeyType.toString();
|
||||
}
|
||||
}
|
||||
set [returnKeyTypeProperty.native](value: "done" | "next" | "go" | "search" | "send" | string) {
|
||||
[returnKeyTypeProperty.setNative](value: "done" | "next" | "go" | "search" | "send" | string) {
|
||||
let newValue;
|
||||
switch (value) {
|
||||
case "done":
|
||||
@@ -120,7 +120,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
this.nativeView.returnKeyType = newValue;
|
||||
}
|
||||
|
||||
get [autocapitalizationTypeProperty.native](): "none" | "words" | "sentences" | "allCharacters" {
|
||||
[autocapitalizationTypeProperty.getDefault](): "none" | "words" | "sentences" | "allCharacters" {
|
||||
let autocapitalizationType = this.nativeView.autocapitalizationType;
|
||||
switch (autocapitalizationType) {
|
||||
case UITextAutocapitalizationType.None:
|
||||
@@ -139,7 +139,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
throw new Error("Invalid autocapitalizationType value:" + autocapitalizationType);
|
||||
}
|
||||
}
|
||||
set [autocapitalizationTypeProperty.native](value: "none" | "words" | "sentences" | "allCharacters") {
|
||||
[autocapitalizationTypeProperty.setNative](value: "none" | "words" | "sentences" | "allCharacters") {
|
||||
let newValue: UITextAutocapitalizationType;
|
||||
switch (value) {
|
||||
case "none":
|
||||
@@ -162,7 +162,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
this.nativeView.autocapitalizationType = newValue;
|
||||
}
|
||||
|
||||
get [autocorrectProperty.native](): boolean | number {
|
||||
[autocorrectProperty.getDefault](): boolean | number {
|
||||
let autocorrectionType = this.nativeView.autocorrectionType;
|
||||
switch (autocorrectionType) {
|
||||
case UITextAutocorrectionType.Yes:
|
||||
@@ -173,7 +173,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
return autocorrectionType;
|
||||
}
|
||||
}
|
||||
set [autocorrectProperty.native](value: boolean | number) {
|
||||
[autocorrectProperty.setNative](value: boolean | number) {
|
||||
let newValue: UITextAutocorrectionType;
|
||||
if (typeof value === "number") {
|
||||
newValue = UITextAutocorrectionType.Default;
|
||||
|
||||
@@ -19,10 +19,10 @@ export class HtmlView extends HtmlViewBase {
|
||||
return textView;
|
||||
}
|
||||
|
||||
get [htmlProperty.native](): string {
|
||||
[htmlProperty.getDefault](): string {
|
||||
return "";
|
||||
}
|
||||
set [htmlProperty.native](value: string) {
|
||||
[htmlProperty.setNative](value: string) {
|
||||
// If the data.newValue actually has a <a...> in it; we need to disable autolink mask
|
||||
// it internally disables the coloring, but then the <a> links won't work.. So to support both
|
||||
// styles of links (html and just text based) we have to manually enable/disable the autolink mask
|
||||
|
||||
@@ -48,10 +48,10 @@ export class HtmlView extends HtmlViewBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [htmlProperty.native](): string {
|
||||
[htmlProperty.getDefault](): string {
|
||||
return "";
|
||||
}
|
||||
set [htmlProperty.native](value: string) {
|
||||
[htmlProperty.setNative](value: string) {
|
||||
const htmlString = NSString.stringWithString(value + "");
|
||||
const nsData = htmlString.dataUsingEncoding(NSUnicodeStringEncoding);
|
||||
this._ios.attributedText = NSAttributedString.alloc().initWithDataOptionsDocumentAttributesError(nsData, <any>{ [NSDocumentTypeDocumentAttribute]: NSHTMLTextDocumentType }, null);
|
||||
|
||||
@@ -111,10 +111,10 @@ export class Image extends ImageBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [stretchProperty.native](): "aspectFit" {
|
||||
[stretchProperty.getDefault](): "aspectFit" {
|
||||
return "aspectFit";
|
||||
}
|
||||
set [stretchProperty.native](value: "none" | "aspectFill" | "aspectFit" | "fill") {
|
||||
[stretchProperty.setNative](value: "none" | "aspectFill" | "aspectFit" | "fill") {
|
||||
switch (value) {
|
||||
case "aspectFit":
|
||||
this.android.setScaleType(android.widget.ImageView.ScaleType.FIT_CENTER);
|
||||
@@ -132,10 +132,10 @@ export class Image extends ImageBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [tintColorProperty.native](): Color {
|
||||
[tintColorProperty.getDefault](): Color {
|
||||
return undefined;
|
||||
}
|
||||
set [tintColorProperty.native](value: Color) {
|
||||
[tintColorProperty.setNative](value: Color) {
|
||||
if (value === undefined) {
|
||||
this._android.clearColorFilter();
|
||||
} else {
|
||||
@@ -143,10 +143,10 @@ export class Image extends ImageBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [imageSourceProperty.native](): ImageSource {
|
||||
[imageSourceProperty.getDefault](): ImageSource {
|
||||
return undefined;
|
||||
}
|
||||
set [imageSourceProperty.native](value: ImageSource) {
|
||||
[imageSourceProperty.setNative](value: ImageSource) {
|
||||
if (value && value.android) {
|
||||
let rotation = value.rotationAngle ? value.rotationAngle : 0;
|
||||
this.android.setRotationAngle(rotation);
|
||||
@@ -157,10 +157,10 @@ export class Image extends ImageBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [srcProperty.native](): any {
|
||||
[srcProperty.getDefault](): any {
|
||||
return undefined;
|
||||
}
|
||||
set [srcProperty.native](value: any) {
|
||||
[srcProperty.setNative](value: any) {
|
||||
this._createImageSourceFromSrc();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,10 +123,10 @@ export class Image extends ImageBase {
|
||||
return { width: scaleW, height: scaleH };
|
||||
}
|
||||
|
||||
get [stretchProperty.native](): "aspectFit" {
|
||||
[stretchProperty.getDefault](): "aspectFit" {
|
||||
return "aspectFit";
|
||||
}
|
||||
set [stretchProperty.native](value: "none" | "aspectFill" | "aspectFit" | "fill") {
|
||||
[stretchProperty.setNative](value: "none" | "aspectFill" | "aspectFit" | "fill") {
|
||||
switch (value) {
|
||||
case "aspectFit":
|
||||
this._ios.contentMode = UIViewContentMode.ScaleAspectFit;
|
||||
@@ -144,24 +144,24 @@ export class Image extends ImageBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [tintColorProperty.native](): Color {
|
||||
[tintColorProperty.getDefault](): Color {
|
||||
return undefined;
|
||||
}
|
||||
set [tintColorProperty.native](value: Color) {
|
||||
[tintColorProperty.setNative](value: Color) {
|
||||
this.setTintColor(value);
|
||||
}
|
||||
|
||||
get [imageSourceProperty.native](): ImageSource {
|
||||
[imageSourceProperty.getDefault](): ImageSource {
|
||||
return undefined;
|
||||
}
|
||||
set [imageSourceProperty.native](value: ImageSource) {
|
||||
[imageSourceProperty.setNative](value: ImageSource) {
|
||||
this._setNativeImage(value ? value.ios : null);
|
||||
}
|
||||
|
||||
get [srcProperty.native](): any {
|
||||
[srcProperty.getDefault](): any {
|
||||
return undefined;
|
||||
}
|
||||
set [srcProperty.native](value: any) {
|
||||
[srcProperty.setNative](value: any) {
|
||||
this._createImageSourceFromSrc();
|
||||
}
|
||||
}
|
||||
@@ -93,10 +93,10 @@ export class Label extends TextBase implements LabelDefinition {
|
||||
}
|
||||
}
|
||||
|
||||
get [whiteSpaceProperty.native](): WhiteSpace {
|
||||
[whiteSpaceProperty.getDefault](): WhiteSpace {
|
||||
return WhiteSpace.NO_WRAP;
|
||||
}
|
||||
set [whiteSpaceProperty.native](value: WhiteSpace) {
|
||||
[whiteSpaceProperty.setNative](value: WhiteSpace) {
|
||||
const nativeView = this.nativeView;
|
||||
switch (value) {
|
||||
case WhiteSpace.NORMAL:
|
||||
@@ -112,10 +112,10 @@ export class Label extends TextBase implements LabelDefinition {
|
||||
}
|
||||
}
|
||||
|
||||
get [backgroundInternalProperty.native](): any /* CGColor */ {
|
||||
[backgroundInternalProperty.getDefault](): any /* CGColor */ {
|
||||
return this.nativeView.layer.backgroundColor;
|
||||
}
|
||||
set [backgroundInternalProperty.native](value: Background) {
|
||||
[backgroundInternalProperty.setNative](value: Background) {
|
||||
if (value instanceof Background) {
|
||||
const uiColor = <UIColor>ios.createBackgroundUIColor(this, true);
|
||||
value = uiColor ? uiColor.CGColor : null;
|
||||
@@ -125,10 +125,10 @@ export class Label extends TextBase implements LabelDefinition {
|
||||
this.nativeView.layer.backgroundColor = value;
|
||||
}
|
||||
|
||||
get [borderTopWidthProperty.native](): Length {
|
||||
[borderTopWidthProperty.getDefault](): Length {
|
||||
return zeroLength;
|
||||
}
|
||||
set [borderTopWidthProperty.native](value: Length) {
|
||||
[borderTopWidthProperty.setNative](value: Length) {
|
||||
let nativeView = this.nativeView;
|
||||
let border = nativeView.borderThickness;
|
||||
nativeView.borderThickness = {
|
||||
@@ -139,10 +139,10 @@ export class Label extends TextBase implements LabelDefinition {
|
||||
};
|
||||
}
|
||||
|
||||
get [borderRightWidthProperty.native](): Length {
|
||||
[borderRightWidthProperty.getDefault](): Length {
|
||||
return zeroLength;
|
||||
}
|
||||
set [borderRightWidthProperty.native](value: Length) {
|
||||
[borderRightWidthProperty.setNative](value: Length) {
|
||||
let nativeView = this.nativeView;
|
||||
let border = nativeView.borderThickness;
|
||||
nativeView.borderThickness = {
|
||||
@@ -153,10 +153,10 @@ export class Label extends TextBase implements LabelDefinition {
|
||||
};
|
||||
}
|
||||
|
||||
get [borderBottomWidthProperty.native](): Length {
|
||||
[borderBottomWidthProperty.getDefault](): Length {
|
||||
return zeroLength;
|
||||
}
|
||||
set [borderBottomWidthProperty.native](value: Length) {
|
||||
[borderBottomWidthProperty.setNative](value: Length) {
|
||||
let nativeView = this.nativeView;
|
||||
let border = nativeView.borderThickness;
|
||||
nativeView.borderThickness = {
|
||||
@@ -167,10 +167,10 @@ export class Label extends TextBase implements LabelDefinition {
|
||||
};
|
||||
}
|
||||
|
||||
get [borderLeftWidthProperty.native](): Length {
|
||||
[borderLeftWidthProperty.getDefault](): Length {
|
||||
return zeroLength;
|
||||
}
|
||||
set [borderLeftWidthProperty.native](value: Length) {
|
||||
[borderLeftWidthProperty.setNative](value: Length) {
|
||||
let nativeView = this.nativeView;
|
||||
let border = nativeView.borderThickness;
|
||||
nativeView.borderThickness = {
|
||||
@@ -181,10 +181,10 @@ export class Label extends TextBase implements LabelDefinition {
|
||||
};
|
||||
}
|
||||
|
||||
get [paddingTopProperty.native](): Length {
|
||||
[paddingTopProperty.getDefault](): Length {
|
||||
return zeroLength;
|
||||
}
|
||||
set [paddingTopProperty.native](value: Length) {
|
||||
[paddingTopProperty.setNative](value: Length) {
|
||||
let nativeView = this.nativeView;
|
||||
let padding = nativeView.padding;
|
||||
nativeView.padding = {
|
||||
@@ -195,10 +195,10 @@ export class Label extends TextBase implements LabelDefinition {
|
||||
};
|
||||
}
|
||||
|
||||
get [paddingRightProperty.native](): Length {
|
||||
[paddingRightProperty.getDefault](): Length {
|
||||
return zeroLength;
|
||||
}
|
||||
set [paddingRightProperty.native](value: Length) {
|
||||
[paddingRightProperty.setNative](value: Length) {
|
||||
let nativeView = this.nativeView;
|
||||
let padding = nativeView.padding;
|
||||
nativeView.padding = {
|
||||
@@ -209,10 +209,10 @@ export class Label extends TextBase implements LabelDefinition {
|
||||
};
|
||||
}
|
||||
|
||||
get [paddingBottomProperty.native](): Length {
|
||||
[paddingBottomProperty.getDefault](): Length {
|
||||
return zeroLength;
|
||||
}
|
||||
set [paddingBottomProperty.native](value: Length) {
|
||||
[paddingBottomProperty.setNative](value: Length) {
|
||||
let nativeView = this.nativeView;
|
||||
let padding = nativeView.padding;
|
||||
nativeView.padding = {
|
||||
@@ -223,10 +223,10 @@ export class Label extends TextBase implements LabelDefinition {
|
||||
};
|
||||
}
|
||||
|
||||
get [paddingLeftProperty.native](): Length {
|
||||
[paddingLeftProperty.getDefault](): Length {
|
||||
return zeroLength;
|
||||
}
|
||||
set [paddingLeftProperty.native](value: Length) {
|
||||
[paddingLeftProperty.setNative](value: Length) {
|
||||
let nativeView = this.nativeView;
|
||||
let padding = nativeView.padding;
|
||||
nativeView.padding = {
|
||||
|
||||
@@ -1,44 +1,21 @@
|
||||
import { AbsoluteLayoutBase, View, leftProperty, topProperty, Length, zeroLength } from "./absolute-layout-common";
|
||||
import { AbsoluteLayoutBase, View, leftProperty, topProperty } from "./absolute-layout-common";
|
||||
|
||||
export * from "./absolute-layout-common";
|
||||
|
||||
// define native getter and setter for leftProperty.
|
||||
let leftDescriptor: TypedPropertyDescriptor<Length> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => zeroLength,
|
||||
set: function (this: View, value: Length) {
|
||||
setNativeProperty(this, (lp) => lp.left = this.effectiveLeft);
|
||||
}
|
||||
}
|
||||
|
||||
// define native getter and setter for topProperty.
|
||||
let topDescriptor: TypedPropertyDescriptor<Length> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => zeroLength,
|
||||
set: function (this: View, value: Length) {
|
||||
setNativeProperty(this, (lp) => lp.top = this.effectiveTop);
|
||||
}
|
||||
}
|
||||
|
||||
// register native properties on View type.
|
||||
Object.defineProperties(View.prototype, {
|
||||
[leftProperty.native]: leftDescriptor,
|
||||
[topProperty.native]: topDescriptor
|
||||
});
|
||||
|
||||
function setNativeProperty(view: View, setter: (lp: org.nativescript.widgets.CommonLayoutParams) => void) {
|
||||
if (view instanceof View) {
|
||||
const nativeView: android.view.View = view._nativeView;
|
||||
function makeNativeSetter<T>(setter: (this: View, lp: org.nativescript.widgets.CommonLayoutParams, value: T) => void) {
|
||||
return function(this: View, value: T) {
|
||||
const nativeView: android.view.View = this._nativeView;
|
||||
const lp = nativeView.getLayoutParams() || new org.nativescript.widgets.CommonLayoutParams();
|
||||
if (lp instanceof org.nativescript.widgets.CommonLayoutParams) {
|
||||
setter(lp);
|
||||
setter.call(this, lp, value);
|
||||
nativeView.setLayoutParams(lp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
View.prototype[topProperty.setNative] = makeNativeSetter<number>(function(this: View, lp, value) { lp.top = this.effectiveTop });
|
||||
View.prototype[leftProperty.setNative] = makeNativeSetter<number>(function(this: View, lp, value) { lp.left = this.effectiveLeft });
|
||||
|
||||
export class AbsoluteLayout extends AbsoluteLayoutBase {
|
||||
|
||||
private _layout: org.nativescript.widgets.AbsoluteLayout;
|
||||
|
||||
@@ -2,46 +2,35 @@
|
||||
|
||||
export * from "./dock-layout-common";
|
||||
|
||||
// define native getter and setter for topProperty.
|
||||
let dockDescriptor: TypedPropertyDescriptor<"left" | "top" | "right" | "bottom"> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => "left",
|
||||
set: function (this: View, value: "left" | "top" | "right" | "bottom") {
|
||||
const nativeView: android.view.View = this._nativeView;
|
||||
const lp = nativeView.getLayoutParams() || new org.nativescript.widgets.CommonLayoutParams();
|
||||
if (lp instanceof org.nativescript.widgets.CommonLayoutParams) {
|
||||
switch (value) {
|
||||
case "left":
|
||||
lp.dock = org.nativescript.widgets.Dock.left;
|
||||
break;
|
||||
View.prototype[dockProperty.setNative] = function(this: View, value: "left" | "top" | "right" | "bottom") {
|
||||
const nativeView: android.view.View = this._nativeView;
|
||||
const lp = nativeView.getLayoutParams() || new org.nativescript.widgets.CommonLayoutParams();
|
||||
if (lp instanceof org.nativescript.widgets.CommonLayoutParams) {
|
||||
switch (value) {
|
||||
case "left":
|
||||
lp.dock = org.nativescript.widgets.Dock.left;
|
||||
break;
|
||||
|
||||
case "top":
|
||||
lp.dock = org.nativescript.widgets.Dock.top;
|
||||
break;
|
||||
case "top":
|
||||
lp.dock = org.nativescript.widgets.Dock.top;
|
||||
break;
|
||||
|
||||
case "right":
|
||||
lp.dock = org.nativescript.widgets.Dock.right;
|
||||
break;
|
||||
case "right":
|
||||
lp.dock = org.nativescript.widgets.Dock.right;
|
||||
break;
|
||||
|
||||
case "bottom":
|
||||
lp.dock = org.nativescript.widgets.Dock.bottom;
|
||||
break;
|
||||
case "bottom":
|
||||
lp.dock = org.nativescript.widgets.Dock.bottom;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Error(`Invalid value for dock property: ${value}`);
|
||||
}
|
||||
|
||||
nativeView.setLayoutParams(lp);
|
||||
default:
|
||||
throw new Error(`Invalid value for dock property: ${value}`);
|
||||
}
|
||||
|
||||
nativeView.setLayoutParams(lp);
|
||||
}
|
||||
}
|
||||
|
||||
// register native properties on View type.
|
||||
Object.defineProperties(View.prototype, {
|
||||
[dockProperty.native]: dockDescriptor
|
||||
});
|
||||
|
||||
export class DockLayout extends DockLayoutBase {
|
||||
|
||||
private _layout: org.nativescript.widgets.DockLayout;
|
||||
@@ -59,10 +48,10 @@ export class DockLayout extends DockLayoutBase {
|
||||
return layout;
|
||||
}
|
||||
|
||||
get [stretchLastChildProperty.native](): boolean {
|
||||
[stretchLastChildProperty.getDefault](): boolean {
|
||||
return false;
|
||||
}
|
||||
set [stretchLastChildProperty.native](value: boolean) {
|
||||
[stretchLastChildProperty.setNative](value: boolean) {
|
||||
this._layout.setStretchLastChild(value);
|
||||
}
|
||||
}
|
||||
@@ -12,71 +12,23 @@ import {
|
||||
|
||||
export * from "./flexbox-layout-common";
|
||||
|
||||
const orderDescriptor: TypedPropertyDescriptor<Order> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => orderProperty.defaultValue,
|
||||
set: function (this: View, value: Order) {
|
||||
setLayoutParamsProperty(this, (lp) => lp.order = value);
|
||||
}
|
||||
}
|
||||
|
||||
const flexGrowDescriptor: TypedPropertyDescriptor<FlexGrow> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => flexGrowProperty.defaultValue,
|
||||
set: function (this: View, value: FlexGrow) {
|
||||
setLayoutParamsProperty(this, (lp) => lp.flexGrow = value);
|
||||
}
|
||||
}
|
||||
|
||||
const flexShrinkDescriptor: TypedPropertyDescriptor<FlexShrink> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => flexShrinkProperty.defaultValue,
|
||||
set: function (this: View, value: FlexShrink) {
|
||||
setLayoutParamsProperty(this, (lp) => lp.flexShrink = value);
|
||||
}
|
||||
}
|
||||
|
||||
const flexWrapBeforeDescriptor: TypedPropertyDescriptor<FlexWrapBefore> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => false,
|
||||
set: function (this: View, value: FlexWrapBefore) {
|
||||
setLayoutParamsProperty(this, (lp) => lp.wrapBefore = value);
|
||||
}
|
||||
}
|
||||
|
||||
const alignSelfDescriptor: TypedPropertyDescriptor<AlignSelf> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => AlignSelf.AUTO,
|
||||
set: function (this: View, value: AlignSelf) {
|
||||
setLayoutParamsProperty(this, (lp) => lp.alignSelf = alignSelfMap[value]);
|
||||
}
|
||||
}
|
||||
|
||||
// register native properties on View type.
|
||||
Object.defineProperties(View.prototype, {
|
||||
[orderProperty.native]: orderDescriptor,
|
||||
[flexGrowProperty.native]: flexGrowDescriptor,
|
||||
[flexShrinkProperty.native]: flexShrinkDescriptor,
|
||||
[flexWrapBeforeProperty.native]: flexWrapBeforeDescriptor,
|
||||
[alignSelfProperty.native]: alignSelfDescriptor
|
||||
});
|
||||
|
||||
function setLayoutParamsProperty(view: View, setter: (lp: org.nativescript.widgets.FlexboxLayout.LayoutParams) => void) {
|
||||
const nativeView: android.view.View = view._nativeView;
|
||||
if (nativeView) {
|
||||
let lp = nativeView.getLayoutParams() || new org.nativescript.widgets.FlexboxLayout.LayoutParams();
|
||||
function makeNativeSetter<T>(setter: (lp: org.nativescript.widgets.FlexboxLayout.LayoutParams, value: T) => void) {
|
||||
return function(this: View, value: T) {
|
||||
const nativeView: android.view.View = this._nativeView;
|
||||
const lp = nativeView.getLayoutParams() || new org.nativescript.widgets.FlexboxLayout.LayoutParams();
|
||||
if (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) {
|
||||
setter(lp);
|
||||
setter(lp, value);
|
||||
nativeView.setLayoutParams(lp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
View.prototype[orderProperty.setNative] = makeNativeSetter<Order>((lp, value) => lp.order = value);
|
||||
View.prototype[flexGrowProperty.setNative] = makeNativeSetter<FlexGrow>((lp, value) => lp.flexGrow = value);
|
||||
View.prototype[flexShrinkProperty.setNative] = makeNativeSetter<FlexShrink>((lp, value) => lp.flexShrink = value);
|
||||
View.prototype[flexWrapBeforeProperty.setNative] = makeNativeSetter<FlexWrapBefore>((lp, value) => lp.wrapBefore = value);
|
||||
View.prototype[alignSelfProperty.setNative] = makeNativeSetter<AlignSelf>((lp, value) => lp.alignSelf = alignSelfMap[value]);
|
||||
|
||||
const flexDirectionMap = {
|
||||
[FlexDirection.ROW]: 0, //FlexboxLayoutWidget.FLEX_DIRECTION_ROW,
|
||||
[FlexDirection.ROW_REVERSE]: 1, //FlexboxLayoutWidget.FLEX_DIRECTION_ROW_REVERSE,
|
||||
@@ -139,38 +91,38 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
||||
return layout;
|
||||
}
|
||||
|
||||
get [flexDirectionProperty.native](): FlexDirection {
|
||||
[flexDirectionProperty.getDefault](): FlexDirection {
|
||||
return flexDirectionProperty.defaultValue;
|
||||
}
|
||||
set [flexDirectionProperty.native](flexDirection: FlexDirection) {
|
||||
[flexDirectionProperty.setNative](flexDirection: FlexDirection) {
|
||||
this.android.setFlexDirection(flexDirectionMap[flexDirection]);
|
||||
}
|
||||
|
||||
get [flexWrapProperty.native](): FlexWrap {
|
||||
[flexWrapProperty.getDefault](): FlexWrap {
|
||||
return flexWrapProperty.defaultValue;
|
||||
}
|
||||
set [flexWrapProperty.native](flexWrap: FlexWrap) {
|
||||
[flexWrapProperty.setNative](flexWrap: FlexWrap) {
|
||||
this.android.setFlexWrap(flexWrapMap[flexWrap]);
|
||||
}
|
||||
|
||||
get [justifyContentProperty.native](): JustifyContent {
|
||||
[justifyContentProperty.getDefault](): JustifyContent {
|
||||
return justifyContentProperty.defaultValue;
|
||||
}
|
||||
set [justifyContentProperty.native](justifyContent: JustifyContent) {
|
||||
[justifyContentProperty.setNative](justifyContent: JustifyContent) {
|
||||
this.android.setJustifyContent(justifyContentMap[justifyContent]);
|
||||
}
|
||||
|
||||
get [alignItemsProperty.native](): AlignItems {
|
||||
[alignItemsProperty.getDefault](): AlignItems {
|
||||
return alignItemsProperty.defaultValue;
|
||||
}
|
||||
set [alignItemsProperty.native](alignItems: AlignItems) {
|
||||
[alignItemsProperty.setNative](alignItems: AlignItems) {
|
||||
this.android.setAlignItems(alignItemsMap[alignItems]);
|
||||
}
|
||||
|
||||
get [alignContentProperty.native](): AlignContent {
|
||||
[alignContentProperty.getDefault](): AlignContent {
|
||||
return alignContentProperty.defaultValue;
|
||||
}
|
||||
set [alignContentProperty.native](alignContent: AlignContent) {
|
||||
[alignContentProperty.setNative](alignContent: AlignContent) {
|
||||
this.android.setAlignContent(alignContentMap[alignContent]);
|
||||
}
|
||||
|
||||
@@ -187,7 +139,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
||||
}
|
||||
|
||||
public _setChildMinWidthNative(child: View): void {
|
||||
child._minWidthNative = 0;
|
||||
child._setMinWidthNative(0);
|
||||
const lp = child.nativeView.getLayoutParams();
|
||||
if (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) {
|
||||
lp.minWidth = Length.toDevicePixels(child.minWidth, 0);
|
||||
@@ -196,7 +148,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
||||
}
|
||||
|
||||
public _setChildMinHeightNative(child: View): void {
|
||||
child._minHeightNative = 0;
|
||||
child._setMinHeightNative(0);
|
||||
const lp = child.nativeView.getLayoutParams();
|
||||
if (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) {
|
||||
lp.minHeight = Length.toDevicePixels(child.minHeight, 0);
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import {
|
||||
FlexDirection, FlexWrap, JustifyContent, AlignItems, AlignContent,
|
||||
FlexboxLayoutBase, View, layout,
|
||||
orderProperty, Order as OrderBase,
|
||||
flexGrowProperty, FlexGrow,
|
||||
flexShrinkProperty, FlexShrink,
|
||||
flexWrapBeforeProperty, FlexWrapBefore,
|
||||
alignSelfProperty, AlignSelf,
|
||||
FlexBasisPercent
|
||||
FlexBasisPercent,
|
||||
orderProperty, flexGrowProperty, flexShrinkProperty, flexWrapBeforeProperty, alignSelfProperty
|
||||
} from "./flexbox-layout-common";
|
||||
|
||||
export * from "./flexbox-layout-common";
|
||||
@@ -18,69 +14,17 @@ import UNSPECIFIED = layout.UNSPECIFIED;
|
||||
import MEASURED_SIZE_MASK = layout.MEASURED_SIZE_MASK;
|
||||
import MEASURED_STATE_TOO_SMALL = layout.MEASURED_STATE_TOO_SMALL;
|
||||
|
||||
function childHandler(view) {
|
||||
if (!(view instanceof View)) {
|
||||
throw new Error("Element is not View or its descendant.");
|
||||
}
|
||||
let flexbox = view.parent;
|
||||
function requestFlexboxLayout(this: View, value) {
|
||||
let flexbox = this.parent;
|
||||
if (flexbox instanceof FlexboxLayoutBase) {
|
||||
flexbox.requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
const orderDescriptor: TypedPropertyDescriptor<OrderBase> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => orderProperty.defaultValue,
|
||||
set: function (this: View, value: OrderBase) {
|
||||
childHandler(this);
|
||||
}
|
||||
}
|
||||
|
||||
const flexGrowDescriptor: TypedPropertyDescriptor<FlexGrow> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => flexGrowProperty.defaultValue,
|
||||
set: function (this: View, value: FlexGrow) {
|
||||
childHandler(this);
|
||||
}
|
||||
}
|
||||
|
||||
const flexShrinkDescriptor: TypedPropertyDescriptor<FlexShrink> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => flexShrinkProperty.defaultValue,
|
||||
set: function (this: View, value: FlexShrink) {
|
||||
childHandler(this);
|
||||
}
|
||||
}
|
||||
|
||||
const flexWrapBeforeDescriptor: TypedPropertyDescriptor<FlexWrapBefore> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => false,
|
||||
set: function (this: View, value: FlexWrapBefore) {
|
||||
childHandler(this);
|
||||
}
|
||||
}
|
||||
|
||||
const alignSelfDescriptor: TypedPropertyDescriptor<AlignSelf> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => AlignSelf.AUTO,
|
||||
set: function (this: View, value: AlignSelf) {
|
||||
childHandler(this);
|
||||
}
|
||||
}
|
||||
|
||||
// register native properties on View type.
|
||||
Object.defineProperties(View.prototype, {
|
||||
[orderProperty.native]: orderDescriptor,
|
||||
[flexGrowProperty.native]: flexGrowDescriptor,
|
||||
[flexShrinkProperty.native]: flexShrinkDescriptor,
|
||||
[flexWrapBeforeProperty.native]: flexWrapBeforeDescriptor,
|
||||
[alignSelfProperty.native]: alignSelfDescriptor
|
||||
});
|
||||
View.prototype[orderProperty.setNative] = requestFlexboxLayout;
|
||||
View.prototype[flexGrowProperty.setNative] = requestFlexboxLayout;
|
||||
View.prototype[flexShrinkProperty.setNative] = requestFlexboxLayout;
|
||||
View.prototype[flexWrapBeforeProperty.setNative] = requestFlexboxLayout;
|
||||
View.prototype[alignSelfProperty.setNative] = requestFlexboxLayout;
|
||||
|
||||
const MATCH_PARENT = -1;
|
||||
const WRAP_CONTENT = -2;
|
||||
@@ -289,7 +233,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
||||
|
||||
child._updateEffectiveLayoutValues(this);
|
||||
let lp = child; // child.style;
|
||||
if (FlexboxLayout.getAlignSelf(child) === AlignSelf.STRETCH) {
|
||||
if (FlexboxLayout.getAlignSelf(child) === "stretch") {
|
||||
flexLine._indicesAlignSelfStretch.push(i);
|
||||
}
|
||||
|
||||
@@ -404,7 +348,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
||||
|
||||
child._updateEffectiveLayoutValues(this);
|
||||
const lp = child; // .style;
|
||||
if (FlexboxLayout.getAlignSelf(child) === AlignSelf.STRETCH) {
|
||||
if (FlexboxLayout.getAlignSelf(child) === "stretch") {
|
||||
flexLine._indicesAlignSelfStretch.push(i);
|
||||
}
|
||||
|
||||
@@ -813,7 +757,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
||||
for (let i = 0; i < flexLine.itemCount; i++ , viewIndex++) {
|
||||
let view = this._getReorderedChildAt(viewIndex);
|
||||
let alignSelf = FlexboxLayout.getAlignSelf(view);
|
||||
if (alignSelf !== AlignSelf.AUTO && alignSelf !== AlignSelf.STRETCH) {
|
||||
if (alignSelf !== "auto" && alignSelf !== "stretch") {
|
||||
continue;
|
||||
}
|
||||
switch (flexDirection) {
|
||||
@@ -1104,7 +1048,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
||||
let lp = view; // .style;
|
||||
|
||||
let alignSelf = FlexboxLayout.getAlignSelf(view);
|
||||
if (alignSelf !== AlignSelf.AUTO) {
|
||||
if (alignSelf !== "auto") {
|
||||
alignItems = alignSelf;
|
||||
}
|
||||
|
||||
@@ -1262,7 +1206,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
||||
private _layoutSingleChildVertical(view: View, flexLine: FlexLine, isRtl: boolean, alignItems: AlignItems, left: number, top: number, right: number, bottom: number) {
|
||||
let lp = view; // .style;
|
||||
let alignSelf = FlexboxLayout.getAlignSelf(view);
|
||||
if (alignSelf !== AlignSelf.AUTO) {
|
||||
if (alignSelf !== "auto") {
|
||||
alignItems = alignSelf;
|
||||
}
|
||||
let crossSize = flexLine.crossSize;
|
||||
|
||||
@@ -5,62 +5,21 @@
|
||||
|
||||
export * from "./grid-layout-common";
|
||||
|
||||
function setNativeProperty(view: View, setter: (lp: org.nativescript.widgets.CommonLayoutParams) => void) {
|
||||
const nativeView: android.view.View = view._nativeView;
|
||||
const lp = nativeView.getLayoutParams() || new org.nativescript.widgets.CommonLayoutParams();
|
||||
if (lp instanceof org.nativescript.widgets.CommonLayoutParams) {
|
||||
setter(lp);
|
||||
nativeView.setLayoutParams(lp);
|
||||
function makeNativeSetter<T>(setter: (lp: org.nativescript.widgets.CommonLayoutParams, value: T) => void) {
|
||||
return function(this: View, value: T) {
|
||||
const nativeView: android.view.View = this._nativeView;
|
||||
const lp = nativeView.getLayoutParams() || new org.nativescript.widgets.CommonLayoutParams();
|
||||
if (lp instanceof org.nativescript.widgets.CommonLayoutParams) {
|
||||
setter(lp, value);
|
||||
nativeView.setLayoutParams(lp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// define native getter and setter for rowProperty.
|
||||
let rowDescriptor: TypedPropertyDescriptor<number> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => 0,
|
||||
set: function (this: View, value: number) {
|
||||
setNativeProperty(this, (lp) => lp.row = value);
|
||||
}
|
||||
}
|
||||
|
||||
// define native getter and setter for columnProperty.
|
||||
let colDescriptor: TypedPropertyDescriptor<number> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => 0,
|
||||
set: function (this: View, value: number) {
|
||||
setNativeProperty(this, (lp) => lp.column = value);
|
||||
}
|
||||
}
|
||||
|
||||
// define native getter and setter for rowSpanProperty.
|
||||
let rowSpanDescriptor: TypedPropertyDescriptor<number> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => 1,
|
||||
set: function (this: View, value: number) {
|
||||
setNativeProperty(this, (lp) => lp.rowSpan = value);
|
||||
}
|
||||
}
|
||||
|
||||
// define native getter and setter for columnSpanProperty.
|
||||
let colSpanDescriptor: TypedPropertyDescriptor<number> = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: () => 1,
|
||||
set: function (this: View, value: number) {
|
||||
setNativeProperty(this, (lp) => lp.columnSpan = value);
|
||||
}
|
||||
}
|
||||
|
||||
// register native properties on View type.
|
||||
Object.defineProperties(View.prototype, {
|
||||
[rowProperty.native]: rowDescriptor,
|
||||
[columnProperty.native]: colDescriptor,
|
||||
[rowSpanProperty.native]: rowSpanDescriptor,
|
||||
[columnSpanProperty.native]: colSpanDescriptor
|
||||
});
|
||||
View.prototype[rowProperty.setNative] = makeNativeSetter<number>((lp, value) => lp.row = value);
|
||||
View.prototype[columnProperty.setNative] = makeNativeSetter<number>((lp, value) => lp.column = value);
|
||||
View.prototype[rowSpanProperty.setNative] = makeNativeSetter<number>((lp, value) => lp.rowSpan = value);
|
||||
View.prototype[columnSpanProperty.setNative] = makeNativeSetter<number>((lp, value) => lp.columnSpan = value);
|
||||
|
||||
function createNativeSpec(itemSpec: ItemSpec): org.nativescript.widgets.ItemSpec {
|
||||
switch (itemSpec.gridUnitType) {
|
||||
|
||||
@@ -7,10 +7,10 @@ export * from "./layout-base-common";
|
||||
|
||||
export class LayoutBase extends LayoutBaseCommon {
|
||||
|
||||
get [clipToBoundsProperty.native](): boolean {
|
||||
[clipToBoundsProperty.getDefault](): boolean {
|
||||
return true;
|
||||
}
|
||||
set [clipToBoundsProperty.native](value: boolean) {
|
||||
[clipToBoundsProperty.setNative](value: boolean) {
|
||||
// TODO: Use ClipRectangle if API > 16!
|
||||
|
||||
// We can't implement this without calling setClipChildren(false) on every ancestor up in the visual tree,
|
||||
@@ -25,31 +25,31 @@ export class LayoutBase extends LayoutBaseCommon {
|
||||
console.warn(`clipToBounds with value false is not supported on Android. You can use this.android.getParent().setClipChildren(false) as an alternative`);
|
||||
}
|
||||
|
||||
get [paddingTopProperty.native](): Length {
|
||||
[paddingTopProperty.getDefault](): Length {
|
||||
return { value: this._defaultPaddingTop, unit: "px" }
|
||||
}
|
||||
set [paddingTopProperty.native](value: Length) {
|
||||
[paddingTopProperty.setNative](value: Length) {
|
||||
org.nativescript.widgets.ViewHelper.setPaddingTop(this.nativeView, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderTopWidth, 0));
|
||||
}
|
||||
|
||||
get [paddingRightProperty.native](): Length {
|
||||
[paddingRightProperty.getDefault](): Length {
|
||||
return { value: this._defaultPaddingRight, unit: "px" }
|
||||
}
|
||||
set [paddingRightProperty.native](value: Length) {
|
||||
[paddingRightProperty.setNative](value: Length) {
|
||||
org.nativescript.widgets.ViewHelper.setPaddingRight(this.nativeView, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderRightWidth, 0));
|
||||
}
|
||||
|
||||
get [paddingBottomProperty.native](): Length {
|
||||
[paddingBottomProperty.getDefault](): Length {
|
||||
return { value: this._defaultPaddingBottom, unit: "px" }
|
||||
}
|
||||
set [paddingBottomProperty.native](value: Length) {
|
||||
[paddingBottomProperty.setNative](value: Length) {
|
||||
org.nativescript.widgets.ViewHelper.setPaddingBottom(this.nativeView, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderBottomWidth, 0));
|
||||
}
|
||||
|
||||
get [paddingLeftProperty.native](): Length {
|
||||
[paddingLeftProperty.getDefault](): Length {
|
||||
return { value: this._defaultPaddingLeft, unit: "px" }
|
||||
}
|
||||
set [paddingLeftProperty.native](value: Length) {
|
||||
[paddingLeftProperty.setNative](value: Length) {
|
||||
org.nativescript.widgets.ViewHelper.setPaddingLeft(this.nativeView, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderLeftWidth, 0));
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,10 @@ export * from "./layout-base-common";
|
||||
|
||||
export class LayoutBase extends LayoutBaseCommon {
|
||||
|
||||
get [clipToBoundsProperty.native](): boolean {
|
||||
[clipToBoundsProperty.getDefault](): boolean {
|
||||
return false;
|
||||
}
|
||||
set [clipToBoundsProperty.native](value: boolean) {
|
||||
[clipToBoundsProperty.setNative](value: boolean) {
|
||||
this._setNativeClipToBounds();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ export class StackLayout extends StackLayoutBase {
|
||||
return layout;
|
||||
}
|
||||
|
||||
get [orientationProperty.native](): "horizontal" | "vertical" {
|
||||
[orientationProperty.getDefault](): "horizontal" | "vertical" {
|
||||
return "vertical";
|
||||
}
|
||||
set [orientationProperty.native](value: "horizontal" | "vertical") {
|
||||
[orientationProperty.setNative](value: "horizontal" | "vertical") {
|
||||
this._layout.setOrientation(value === "vertical" ? org.nativescript.widgets.Orientation.vertical : org.nativescript.widgets.Orientation.horizontal)
|
||||
}
|
||||
}
|
||||
@@ -18,24 +18,24 @@ export class WrapLayout extends WrapLayoutBase {
|
||||
return layout;
|
||||
}
|
||||
|
||||
get [orientationProperty.native](): "horizontal" | "vertical" {
|
||||
[orientationProperty.getDefault](): "horizontal" | "vertical" {
|
||||
return "vertical";
|
||||
}
|
||||
set [orientationProperty.native](value: "horizontal" | "vertical") {
|
||||
[orientationProperty.setNative](value: "horizontal" | "vertical") {
|
||||
this._layout.setOrientation(value === "vertical" ? org.nativescript.widgets.Orientation.vertical : org.nativescript.widgets.Orientation.horizontal)
|
||||
}
|
||||
|
||||
get [itemWidthProperty.native](): Length {
|
||||
[itemWidthProperty.getDefault](): Length {
|
||||
return "auto";
|
||||
}
|
||||
set [itemWidthProperty.native](value: Length) {
|
||||
[itemWidthProperty.setNative](value: Length) {
|
||||
this._layout.setItemWidth(Length.toDevicePixels(value, -1));
|
||||
}
|
||||
|
||||
get [itemHeightProperty.native](): Length {
|
||||
[itemHeightProperty.getDefault](): Length {
|
||||
return "auto";
|
||||
}
|
||||
set [itemHeightProperty.native](value: Length) {
|
||||
[itemHeightProperty.setNative](value: Length) {
|
||||
this._layout.setItemHeight(Length.toDevicePixels(value, -1));
|
||||
}
|
||||
}
|
||||
@@ -121,19 +121,19 @@ export class ListPicker extends ListPickerBase {
|
||||
this._android.invalidate();
|
||||
}
|
||||
|
||||
get [selectedIndexProperty.native](): number {
|
||||
[selectedIndexProperty.getDefault](): number {
|
||||
return -1;
|
||||
}
|
||||
set [selectedIndexProperty.native](value: number) {
|
||||
[selectedIndexProperty.setNative](value: number) {
|
||||
if (value >= 0) {
|
||||
this.android.setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
get [itemsProperty.native](): any[] {
|
||||
[itemsProperty.getDefault](): any[] {
|
||||
return null;
|
||||
}
|
||||
set [itemsProperty.native](value: any[] | ItemsSource) {
|
||||
[itemsProperty.setNative](value: any[] | ItemsSource) {
|
||||
let maxValue = value && value.length > 0 ? value.length - 1 : 0;
|
||||
this.android.setMaxValue(maxValue);
|
||||
this._fixNumberPickerRendering();
|
||||
@@ -142,13 +142,13 @@ export class ListPicker extends ListPickerBase {
|
||||
selectedIndexProperty.coerce(this);
|
||||
}
|
||||
|
||||
get [colorProperty.native](): { wheelColor: number, textColor: number } {
|
||||
[colorProperty.getDefault](): { wheelColor: number, textColor: number } {
|
||||
return {
|
||||
wheelColor: this._selectorWheelPaint.getColor(),
|
||||
textColor: this._editText ? this._editText.getTextColors().getDefaultColor() : -1
|
||||
}
|
||||
}
|
||||
set [colorProperty.native](value: { wheelColor: number, textColor: number } | Color) {
|
||||
[colorProperty.setNative](value: { wheelColor: number, textColor: number } | Color) {
|
||||
let color: number;
|
||||
let wheelColor: number;
|
||||
if (value instanceof Color) {
|
||||
|
||||
@@ -32,36 +32,36 @@ export class ListPicker extends ListPickerBase {
|
||||
return this._ios;
|
||||
}
|
||||
|
||||
get [selectedIndexProperty.native](): number {
|
||||
[selectedIndexProperty.getDefault](): number {
|
||||
return -1;
|
||||
}
|
||||
set [selectedIndexProperty.native](value: number) {
|
||||
[selectedIndexProperty.setNative](value: number) {
|
||||
if (value >= 0) {
|
||||
this.ios.selectRowInComponentAnimated(value, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
get [itemsProperty.native](): any[] {
|
||||
[itemsProperty.getDefault](): any[] {
|
||||
return null;
|
||||
}
|
||||
set [itemsProperty.native](value: any[] | ItemsSource) {
|
||||
[itemsProperty.setNative](value: any[] | ItemsSource) {
|
||||
this.ios.reloadAllComponents();
|
||||
|
||||
// Coerce selected index after we have set items to native view.
|
||||
selectedIndexProperty.coerce(this);
|
||||
}
|
||||
|
||||
get [backgroundColorProperty.native](): UIColor {
|
||||
[backgroundColorProperty.getDefault](): UIColor {
|
||||
return this._ios.backgroundColor;
|
||||
}
|
||||
set [backgroundColorProperty.native](value: UIColor | Color) {
|
||||
[backgroundColorProperty.setNative](value: UIColor | Color) {
|
||||
this._ios.backgroundColor = value instanceof Color ? value.ios : value;
|
||||
}
|
||||
|
||||
get [colorProperty.native](): UIColor {
|
||||
[colorProperty.getDefault](): UIColor {
|
||||
return this._ios.tintColor;
|
||||
}
|
||||
set [colorProperty.native](value: UIColor | Color) {
|
||||
[colorProperty.setNative](value: UIColor | Color) {
|
||||
this._ios.tintColor = value instanceof Color ? value.ios : value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,14 +144,14 @@ export class ListView extends ListViewBase {
|
||||
this._realizedTemplates.clear();
|
||||
}
|
||||
|
||||
get [separatorColorProperty.native](): { dividerHeight: number, divider: android.graphics.drawable.Drawable } {
|
||||
[separatorColorProperty.getDefault](): { dividerHeight: number, divider: android.graphics.drawable.Drawable } {
|
||||
let nativeView = this._android;
|
||||
return {
|
||||
dividerHeight: nativeView.getDividerHeight(),
|
||||
divider: nativeView.getDivider()
|
||||
};
|
||||
}
|
||||
set [separatorColorProperty.native](value: Color | { dividerHeight: number, divider: android.graphics.drawable.Drawable }) {
|
||||
[separatorColorProperty.setNative](value: Color | { dividerHeight: number, divider: android.graphics.drawable.Drawable }) {
|
||||
let nativeView = this._android;
|
||||
if (value instanceof Color) {
|
||||
nativeView.setDivider(new android.graphics.drawable.ColorDrawable(value.android));
|
||||
@@ -162,10 +162,10 @@ export class ListView extends ListViewBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [itemTemplatesProperty.native](): KeyedTemplate[] {
|
||||
[itemTemplatesProperty.getDefault](): KeyedTemplate[] {
|
||||
return null;
|
||||
}
|
||||
set [itemTemplatesProperty.native](value: KeyedTemplate[]) {
|
||||
[itemTemplatesProperty.setNative](value: KeyedTemplate[]) {
|
||||
this._itemTemplatesInternal = new Array<KeyedTemplate>(this._defaultTemplate);
|
||||
if (value) {
|
||||
this._itemTemplatesInternal = this._itemTemplatesInternal.concat(value);
|
||||
|
||||
@@ -389,17 +389,17 @@ export class ListView extends ListViewBase {
|
||||
this._map.delete(cell);
|
||||
}
|
||||
|
||||
get [separatorColorProperty.native](): UIColor {
|
||||
[separatorColorProperty.getDefault](): UIColor {
|
||||
return this._ios.separatorColor;
|
||||
}
|
||||
set [separatorColorProperty.native](value: Color | UIColor) {
|
||||
[separatorColorProperty.setNative](value: Color | UIColor) {
|
||||
this._ios.separatorColor = value instanceof Color ? value.ios : value;
|
||||
}
|
||||
|
||||
get [itemTemplatesProperty.native](): KeyedTemplate[] {
|
||||
[itemTemplatesProperty.getDefault](): KeyedTemplate[] {
|
||||
return null;
|
||||
}
|
||||
set [itemTemplatesProperty.native](value: KeyedTemplate[]) {
|
||||
[itemTemplatesProperty.setNative](value: KeyedTemplate[]) {
|
||||
this._itemTemplatesInternal = new Array<KeyedTemplate>(this._defaultTemplate);
|
||||
if (value) {
|
||||
for (let i = 0, length = value.length; i < length; i++) {
|
||||
|
||||
@@ -181,14 +181,14 @@ export class Page extends PageBase {
|
||||
this.actionBar.update();
|
||||
}
|
||||
|
||||
get [actionBarHiddenProperty.native](): boolean {
|
||||
[actionBarHiddenProperty.getDefault](): boolean {
|
||||
return undefined;
|
||||
}
|
||||
set [actionBarHiddenProperty.native](value: boolean) {
|
||||
[actionBarHiddenProperty.setNative](value: boolean) {
|
||||
this.updateActionBar();
|
||||
}
|
||||
|
||||
get [statusBarStyleProperty.native](): { color: number, systemUiVisibility: number } {
|
||||
[statusBarStyleProperty.getDefault](): { color: number, systemUiVisibility: number } {
|
||||
if (device.sdkVersion >= "21") {
|
||||
let window = (<android.app.Activity>this._context).getWindow();
|
||||
let decorView = window.getDecorView();
|
||||
@@ -201,7 +201,7 @@ export class Page extends PageBase {
|
||||
|
||||
return null;
|
||||
}
|
||||
set [statusBarStyleProperty.native](value: "dark" | "light" | { color: number, systemUiVisibility: number }) {
|
||||
[statusBarStyleProperty.setNative](value: "dark" | "light" | { color: number, systemUiVisibility: number }) {
|
||||
if (device.sdkVersion >= "21") {
|
||||
let window = (<android.app.Activity>this._context).getWindow();
|
||||
let decorView = window.getDecorView();
|
||||
@@ -220,7 +220,7 @@ export class Page extends PageBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [androidStatusBarBackgroundProperty.native](): number {
|
||||
[androidStatusBarBackgroundProperty.getDefault](): number {
|
||||
if (device.sdkVersion >= "21") {
|
||||
let window = (<android.app.Activity>this._context).getWindow();
|
||||
return (<any>window).getStatusBarColor();
|
||||
@@ -228,7 +228,7 @@ export class Page extends PageBase {
|
||||
|
||||
return null;
|
||||
}
|
||||
set [androidStatusBarBackgroundProperty.native](value: number | Color) {
|
||||
[androidStatusBarBackgroundProperty.setNative](value: number | Color) {
|
||||
if (device.sdkVersion >= "21") {
|
||||
let window = (<android.app.Activity>this._context).getWindow();
|
||||
let color = value instanceof Color ? value.android : value;
|
||||
|
||||
@@ -584,10 +584,10 @@ export class Page extends PageBase {
|
||||
super._removeViewFromNativeVisualTree(view);
|
||||
}
|
||||
|
||||
get [actionBarHiddenProperty.native](): boolean {
|
||||
[actionBarHiddenProperty.getDefault](): boolean {
|
||||
return undefined;
|
||||
}
|
||||
set [actionBarHiddenProperty.native](value: boolean) {
|
||||
[actionBarHiddenProperty.setNative](value: boolean) {
|
||||
this._updateEnableSwipeBackNavigation(value);
|
||||
if (this.isLoaded) {
|
||||
// Update nav-bar visibility with disabled animations
|
||||
@@ -595,10 +595,10 @@ export class Page extends PageBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [statusBarStyleProperty.native](): UIBarStyle {
|
||||
[statusBarStyleProperty.getDefault](): UIBarStyle {
|
||||
return UIBarStyle.Default;
|
||||
}
|
||||
set [statusBarStyleProperty.native](value: string | UIBarStyle) {
|
||||
[statusBarStyleProperty.setNative](value: string | UIBarStyle) {
|
||||
let frame = this.frame;
|
||||
if (frame) {
|
||||
let navigationBar = (<UINavigationController>frame.ios.controller).navigationBar;
|
||||
|
||||
@@ -23,24 +23,24 @@ export class Progress extends ProgressBase {
|
||||
return this._android;
|
||||
}
|
||||
|
||||
get [valueProperty.native](): number {
|
||||
[valueProperty.getDefault](): number {
|
||||
return 0;
|
||||
}
|
||||
set [valueProperty.native](value: number) {
|
||||
[valueProperty.setNative](value: number) {
|
||||
this._android.setProgress(value);
|
||||
}
|
||||
|
||||
get [maxValueProperty.native](): number {
|
||||
[maxValueProperty.getDefault](): number {
|
||||
return 100;
|
||||
}
|
||||
set [maxValueProperty.native](value: number) {
|
||||
[maxValueProperty.setNative](value: number) {
|
||||
this._android.setMax(value);
|
||||
}
|
||||
|
||||
get [colorProperty.native](): android.graphics.drawable.Drawable {
|
||||
[colorProperty.getDefault](): android.graphics.drawable.Drawable {
|
||||
return null;
|
||||
}
|
||||
set [colorProperty.native](value: Color) {
|
||||
[colorProperty.setNative](value: Color) {
|
||||
let progressDrawable = this._android.getProgressDrawable();
|
||||
if (!progressDrawable) {
|
||||
return;
|
||||
@@ -53,10 +53,10 @@ export class Progress extends ProgressBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [backgroundColorProperty.native](): number {
|
||||
[backgroundColorProperty.getDefault](): number {
|
||||
return null;
|
||||
}
|
||||
set [backgroundColorProperty.native](value: Color) {
|
||||
[backgroundColorProperty.setNative](value: Color) {
|
||||
let progressDrawable = this._android.getProgressDrawable();
|
||||
if (!progressDrawable) {
|
||||
return;
|
||||
@@ -74,10 +74,10 @@ export class Progress extends ProgressBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [backgroundInternalProperty.native](): number {
|
||||
[backgroundInternalProperty.getDefault](): number {
|
||||
return null;
|
||||
}
|
||||
set [backgroundInternalProperty.native](value: Color) {
|
||||
[backgroundInternalProperty.setNative](value: Color) {
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -20,39 +20,39 @@ export class Progress extends ProgressBase {
|
||||
return this._ios;
|
||||
}
|
||||
|
||||
get [valueProperty.native](): number {
|
||||
[valueProperty.getDefault](): number {
|
||||
return 0;
|
||||
}
|
||||
set [valueProperty.native](value: number) {
|
||||
[valueProperty.setNative](value: number) {
|
||||
this._ios.progress = value / this.maxValue;
|
||||
}
|
||||
|
||||
get [maxValueProperty.native](): number {
|
||||
[maxValueProperty.getDefault](): number {
|
||||
return 100;
|
||||
}
|
||||
set [maxValueProperty.native](value: number) {
|
||||
[maxValueProperty.setNative](value: number) {
|
||||
this._ios.progress = this.value / value;
|
||||
}
|
||||
|
||||
get [colorProperty.native](): UIColor {
|
||||
[colorProperty.getDefault](): UIColor {
|
||||
return this._ios.progressTintColor;
|
||||
}
|
||||
set [colorProperty.native](value: Color | UIColor) {
|
||||
[colorProperty.setNative](value: Color | UIColor) {
|
||||
this._ios.progressTintColor = value instanceof Color ? value.ios : value;
|
||||
}
|
||||
|
||||
get [backgroundColorProperty.native](): UIColor {
|
||||
[backgroundColorProperty.getDefault](): UIColor {
|
||||
return this._ios.trackTintColor;
|
||||
}
|
||||
set [backgroundColorProperty.native](value: UIColor | Color) {
|
||||
[backgroundColorProperty.setNative](value: UIColor | Color) {
|
||||
let color = value instanceof Color ? value.ios : value;
|
||||
this._ios.trackTintColor = color;
|
||||
}
|
||||
|
||||
get [backgroundInternalProperty.native](): UIColor {
|
||||
[backgroundInternalProperty.getDefault](): UIColor {
|
||||
return null;
|
||||
}
|
||||
set [backgroundInternalProperty.native](value: Color) {
|
||||
[backgroundInternalProperty.setNative](value: Color) {
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -111,12 +111,12 @@ export class SearchBar extends SearchBarBase {
|
||||
return this._android;
|
||||
}
|
||||
|
||||
get [backgroundColorProperty.native](): number {
|
||||
[backgroundColorProperty.getDefault](): number {
|
||||
// TODO: Why do we get DrawingCacheBackgroundColor but set backgroundColor?????
|
||||
let result = this._android.getDrawingCacheBackgroundColor();
|
||||
return result;
|
||||
}
|
||||
set [backgroundColorProperty.native](value: Color) {
|
||||
[backgroundColorProperty.setNative](value: Color) {
|
||||
let color: number;
|
||||
if (typeof value === "number") {
|
||||
color = value;
|
||||
@@ -129,11 +129,11 @@ export class SearchBar extends SearchBarBase {
|
||||
searchPlate.setBackgroundColor(color);
|
||||
}
|
||||
|
||||
get [colorProperty.native](): number {
|
||||
[colorProperty.getDefault](): number {
|
||||
let textView = this._getTextView();
|
||||
return textView.getCurrentTextColor();
|
||||
}
|
||||
set [colorProperty.native](value: Color) {
|
||||
[colorProperty.setNative](value: Color) {
|
||||
let color: number;
|
||||
if (typeof value === "number") {
|
||||
color = value;
|
||||
@@ -145,10 +145,10 @@ export class SearchBar extends SearchBarBase {
|
||||
textView.setTextColor(color);
|
||||
}
|
||||
|
||||
get [fontSizeProperty.native](): { nativeSize: number } {
|
||||
[fontSizeProperty.getDefault](): { nativeSize: number } {
|
||||
return { nativeSize: this._getTextView().getTextSize() };
|
||||
}
|
||||
set [fontSizeProperty.native](value: number | { nativeSize: number }) {
|
||||
[fontSizeProperty.setNative](value: number | { nativeSize: number }) {
|
||||
if (typeof value === "number") {
|
||||
this._getTextView().setTextSize(value);
|
||||
} else {
|
||||
@@ -156,48 +156,48 @@ export class SearchBar extends SearchBarBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [fontInternalProperty.native](): android.graphics.Typeface {
|
||||
[fontInternalProperty.getDefault](): android.graphics.Typeface {
|
||||
return this._getTextView().getTypeface();
|
||||
}
|
||||
set [fontInternalProperty.native](value: Font | android.graphics.Typeface) {
|
||||
[fontInternalProperty.setNative](value: Font | android.graphics.Typeface) {
|
||||
this._getTextView().setTypeface(value instanceof Font ? value.getAndroidTypeface() : value);
|
||||
}
|
||||
|
||||
get [backgroundInternalProperty.native](): any {
|
||||
[backgroundInternalProperty.getDefault](): any {
|
||||
return null;
|
||||
}
|
||||
set [backgroundInternalProperty.native](value: any) {
|
||||
[backgroundInternalProperty.setNative](value: any) {
|
||||
//
|
||||
}
|
||||
|
||||
get [textProperty.native](): string {
|
||||
[textProperty.getDefault](): string {
|
||||
return "";
|
||||
}
|
||||
set [textProperty.native](value: string) {
|
||||
[textProperty.setNative](value: string) {
|
||||
const text = (value === null || value === undefined) ? '' : value.toString();
|
||||
this._android.setQuery(text, false);
|
||||
}
|
||||
get [hintProperty.native](): string {
|
||||
[hintProperty.getDefault](): string {
|
||||
return "";
|
||||
}
|
||||
set [hintProperty.native](value: string) {
|
||||
[hintProperty.setNative](value: string) {
|
||||
const text = (value === null || value === undefined) ? '' : value.toString();
|
||||
this._android.setQueryHint(text);
|
||||
}
|
||||
get [textFieldBackgroundColorProperty.native](): number {
|
||||
[textFieldBackgroundColorProperty.getDefault](): number {
|
||||
let textView = this._getTextView();
|
||||
return textView.getCurrentTextColor();
|
||||
}
|
||||
set [textFieldBackgroundColorProperty.native](value: Color) {
|
||||
[textFieldBackgroundColorProperty.setNative](value: Color) {
|
||||
let textView = this._getTextView();
|
||||
let color = value instanceof Color ? value.android : value;
|
||||
textView.setBackgroundColor(color);
|
||||
}
|
||||
get [textFieldHintColorProperty.native](): number {
|
||||
[textFieldHintColorProperty.getDefault](): number {
|
||||
let textView = this._getTextView();
|
||||
return textView.getCurrentTextColor();
|
||||
}
|
||||
set [textFieldHintColorProperty.native](value: Color) {
|
||||
[textFieldHintColorProperty.setNative](value: Color) {
|
||||
let textView = this._getTextView();
|
||||
let color = value instanceof Color ? value.android : value;
|
||||
textView.setHintTextColor(color);
|
||||
|
||||
@@ -101,22 +101,22 @@ export class SearchBar extends SearchBarBase {
|
||||
return this.__placeholderLabel;
|
||||
}
|
||||
|
||||
get [backgroundColorProperty.native](): UIColor {
|
||||
[backgroundColorProperty.getDefault](): UIColor {
|
||||
return this._ios.barTintColor;
|
||||
}
|
||||
set [backgroundColorProperty.native](value: UIColor | Color) {
|
||||
[backgroundColorProperty.setNative](value: UIColor | Color) {
|
||||
let color: UIColor = value instanceof Color ? value.ios : value;
|
||||
this._ios.barTintColor = color;
|
||||
}
|
||||
|
||||
get [colorProperty.native](): UIColor {
|
||||
[colorProperty.getDefault](): UIColor {
|
||||
let sf = this._textField;
|
||||
if (sf) {
|
||||
return sf.textColor;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
set [colorProperty.native](value: UIColor | Color) {
|
||||
[colorProperty.setNative](value: UIColor | Color) {
|
||||
let sf = this._textField;
|
||||
let color = value instanceof Color ? value.ios : value;
|
||||
if (sf) {
|
||||
@@ -125,41 +125,41 @@ export class SearchBar extends SearchBarBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [fontInternalProperty.native](): UIFont {
|
||||
[fontInternalProperty.getDefault](): UIFont {
|
||||
let sf = this._textField;
|
||||
return sf ? sf.font : null;
|
||||
}
|
||||
set [fontInternalProperty.native](value: UIFont | Font) {
|
||||
[fontInternalProperty.setNative](value: UIFont | Font) {
|
||||
let sf = this._textField;
|
||||
if (sf) {
|
||||
sf.font = value instanceof Font ? value.getUIFont(sf.font) : value;
|
||||
}
|
||||
}
|
||||
|
||||
get [backgroundInternalProperty.native](): any {
|
||||
[backgroundInternalProperty.getDefault](): any {
|
||||
return null;
|
||||
}
|
||||
set [backgroundInternalProperty.native](value: any) {
|
||||
[backgroundInternalProperty.setNative](value: any) {
|
||||
//
|
||||
}
|
||||
|
||||
get [textProperty.native](): string {
|
||||
[textProperty.getDefault](): string {
|
||||
return '';
|
||||
}
|
||||
set [textProperty.native](value: string) {
|
||||
[textProperty.setNative](value: string) {
|
||||
const text = (value === null || value === undefined) ? '' : value.toString();
|
||||
this._ios.text = text;
|
||||
}
|
||||
|
||||
get [hintProperty.native](): string {
|
||||
[hintProperty.getDefault](): string {
|
||||
return '';
|
||||
}
|
||||
set [hintProperty.native](value: string) {
|
||||
[hintProperty.setNative](value: string) {
|
||||
const text = (value === null || value === undefined) ? '' : value.toString();
|
||||
this._ios.placeholder = text;
|
||||
}
|
||||
|
||||
get [textFieldBackgroundColorProperty.native](): UIColor {
|
||||
[textFieldBackgroundColorProperty.getDefault](): UIColor {
|
||||
const textField = this._textField;
|
||||
if (textField) {
|
||||
return textField.backgroundColor;
|
||||
@@ -167,7 +167,7 @@ export class SearchBar extends SearchBarBase {
|
||||
|
||||
return null;
|
||||
}
|
||||
set [textFieldBackgroundColorProperty.native](value: Color | UIColor) {
|
||||
[textFieldBackgroundColorProperty.setNative](value: Color | UIColor) {
|
||||
const color = value instanceof Color ? value.ios : value
|
||||
const textField = this._textField;
|
||||
if (textField) {
|
||||
@@ -175,7 +175,7 @@ export class SearchBar extends SearchBarBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [textFieldHintColorProperty.native](): UIColor {
|
||||
[textFieldHintColorProperty.getDefault](): UIColor {
|
||||
const placeholderLabel = this._placeholderLabel;
|
||||
if (placeholderLabel) {
|
||||
return placeholderLabel.textColor;
|
||||
@@ -183,7 +183,7 @@ export class SearchBar extends SearchBarBase {
|
||||
|
||||
return null;
|
||||
}
|
||||
set [textFieldHintColorProperty.native](value: Color | UIColor) {
|
||||
[textFieldHintColorProperty.setNative](value: Color | UIColor) {
|
||||
const color = value instanceof Color ? value.ios : value
|
||||
const placeholderLabel = this._placeholderLabel;
|
||||
if (placeholderLabel) {
|
||||
|
||||
@@ -127,18 +127,18 @@ export class SegmentedBarItem extends SegmentedBarItemBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [colorProperty.native](): number {
|
||||
[colorProperty.getDefault](): number {
|
||||
return this._textView.getCurrentTextColor();
|
||||
}
|
||||
set [colorProperty.native](value: Color | number) {
|
||||
[colorProperty.setNative](value: Color | number) {
|
||||
let color = value instanceof Color ? value.android : value;
|
||||
this._textView.setTextColor(color);
|
||||
}
|
||||
|
||||
get [fontSizeProperty.native](): { nativeSize: number } {
|
||||
[fontSizeProperty.getDefault](): { nativeSize: number } {
|
||||
return { nativeSize: this._textView.getTextSize() };
|
||||
}
|
||||
set [fontSizeProperty.native](value: number | { nativeSize: number }) {
|
||||
[fontSizeProperty.setNative](value: number | { nativeSize: number }) {
|
||||
if (typeof value === "number") {
|
||||
this._textView.setTextSize(value);
|
||||
} else {
|
||||
@@ -146,18 +146,18 @@ export class SegmentedBarItem extends SegmentedBarItemBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [fontInternalProperty.native](): android.graphics.Typeface {
|
||||
[fontInternalProperty.getDefault](): android.graphics.Typeface {
|
||||
return this._textView.getTypeface();
|
||||
}
|
||||
set [fontInternalProperty.native](value: Font | android.graphics.Typeface) {
|
||||
[fontInternalProperty.setNative](value: Font | android.graphics.Typeface) {
|
||||
this._textView.setTypeface(value instanceof Font ? value.getAndroidTypeface() : value);
|
||||
}
|
||||
|
||||
get [selectedBackgroundColorProperty.native](): android.graphics.drawable.Drawable.ConstantState {
|
||||
[selectedBackgroundColorProperty.getDefault](): android.graphics.drawable.Drawable.ConstantState {
|
||||
let viewGroup = <android.view.ViewGroup>this._textView.getParent();
|
||||
return viewGroup.getBackground().getConstantState();
|
||||
}
|
||||
set [selectedBackgroundColorProperty.native](value: Color | android.graphics.drawable.Drawable.ConstantState) {
|
||||
[selectedBackgroundColorProperty.setNative](value: Color | android.graphics.drawable.Drawable.ConstantState) {
|
||||
let viewGroup = <android.view.ViewGroup>this._textView.getParent();
|
||||
if (value instanceof Color) {
|
||||
let color = value.android;
|
||||
@@ -234,17 +234,17 @@ export class SegmentedBar extends SegmentedBarBase {
|
||||
this._addingTab = false;
|
||||
}
|
||||
|
||||
get [selectedIndexProperty.native](): number {
|
||||
[selectedIndexProperty.getDefault](): number {
|
||||
return -1;
|
||||
}
|
||||
set [selectedIndexProperty.native](value: number) {
|
||||
[selectedIndexProperty.setNative](value: number) {
|
||||
this._android.setCurrentTab(value);
|
||||
}
|
||||
|
||||
get [itemsProperty.native](): SegmentedBarItem[] {
|
||||
[itemsProperty.getDefault](): SegmentedBarItem[] {
|
||||
return null;
|
||||
}
|
||||
set [itemsProperty.native](value: SegmentedBarItem[]) {
|
||||
[itemsProperty.setNative](value: SegmentedBarItem[]) {
|
||||
this._android.clearAllTabs();
|
||||
|
||||
const newItems = value;
|
||||
|
||||
@@ -36,17 +36,17 @@ export class SegmentedBar extends SegmentedBarBase {
|
||||
return this._ios;
|
||||
}
|
||||
|
||||
get [selectedIndexProperty.native](): number {
|
||||
[selectedIndexProperty.getDefault](): number {
|
||||
return -1;
|
||||
}
|
||||
set [selectedIndexProperty.native](value: number) {
|
||||
[selectedIndexProperty.setNative](value: number) {
|
||||
this._ios.selectedSegmentIndex = value;
|
||||
}
|
||||
|
||||
get [itemsProperty.native](): SegmentedBarItem[] {
|
||||
[itemsProperty.getDefault](): SegmentedBarItem[] {
|
||||
return null;
|
||||
}
|
||||
set [itemsProperty.native](value: SegmentedBarItem[]) {
|
||||
[itemsProperty.setNative](value: SegmentedBarItem[]) {
|
||||
const segmentedControl = this._ios;
|
||||
segmentedControl.removeAllSegments();
|
||||
const newItems = value;
|
||||
@@ -60,18 +60,18 @@ export class SegmentedBar extends SegmentedBarBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [selectedBackgroundColorProperty.native](): UIColor {
|
||||
[selectedBackgroundColorProperty.getDefault](): UIColor {
|
||||
return this._ios.tintColor;
|
||||
}
|
||||
set [selectedBackgroundColorProperty.native](value: UIColor | Color) {
|
||||
[selectedBackgroundColorProperty.setNative](value: UIColor | Color) {
|
||||
let color = value instanceof Color ? value.ios : value;
|
||||
this._ios.tintColor = color;
|
||||
}
|
||||
|
||||
get [colorProperty.native](): UIColor {
|
||||
[colorProperty.getDefault](): UIColor {
|
||||
return null;
|
||||
}
|
||||
set [colorProperty.native](value: Color | UIColor) {
|
||||
[colorProperty.setNative](value: Color | UIColor) {
|
||||
let color = value instanceof Color ? value.ios : value;
|
||||
let bar = this._ios;
|
||||
let currentAttrs = bar.titleTextAttributesForState(UIControlState.Normal);
|
||||
@@ -80,10 +80,10 @@ export class SegmentedBar extends SegmentedBarBase {
|
||||
bar.setTitleTextAttributesForState(attrs, UIControlState.Normal);
|
||||
}
|
||||
|
||||
get [fontInternalProperty.native](): Font {
|
||||
[fontInternalProperty.getDefault](): Font {
|
||||
return null
|
||||
}
|
||||
set [fontInternalProperty.native](value: Font) {
|
||||
[fontInternalProperty.setNative](value: Font) {
|
||||
let font: UIFont = value ? value.getUIFont(UIFont.systemFontOfSize(ios.getter(UIFont, UIFont.labelFontSize))) : null;
|
||||
let bar = this._ios;
|
||||
let currentAttrs = bar.titleTextAttributesForState(UIControlState.Normal);
|
||||
|
||||
@@ -77,29 +77,29 @@ export class Slider extends SliderBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [valueProperty.native](): number {
|
||||
[valueProperty.getDefault](): number {
|
||||
return 0;
|
||||
}
|
||||
set [valueProperty.native](value: number) {
|
||||
[valueProperty.setNative](value: number) {
|
||||
this.setNativeValuesSilently(value - this.minValue, this.maxValue - this.minValue);
|
||||
}
|
||||
get [minValueProperty.native](): number {
|
||||
[minValueProperty.getDefault](): number {
|
||||
return 0;
|
||||
}
|
||||
set [minValueProperty.native](value: number) {
|
||||
[minValueProperty.setNative](value: number) {
|
||||
this.setNativeValuesSilently(this.value - value, this.maxValue - value);
|
||||
}
|
||||
get [maxValueProperty.native](): number {
|
||||
[maxValueProperty.getDefault](): number {
|
||||
return 100;
|
||||
}
|
||||
set [maxValueProperty.native](value: number) {
|
||||
[maxValueProperty.setNative](value: number) {
|
||||
this._android.setMax(value - this.minValue);
|
||||
}
|
||||
|
||||
get [colorProperty.native](): number {
|
||||
[colorProperty.getDefault](): number {
|
||||
return -1;
|
||||
}
|
||||
set [colorProperty.native](value: number | Color) {
|
||||
[colorProperty.setNative](value: number | Color) {
|
||||
if (value instanceof Color) {
|
||||
this._android.getThumb().setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
} else {
|
||||
@@ -107,10 +107,10 @@ export class Slider extends SliderBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [backgroundColorProperty.native](): number {
|
||||
[backgroundColorProperty.getDefault](): number {
|
||||
return -1;
|
||||
}
|
||||
set [backgroundColorProperty.native](value: number | Color) {
|
||||
[backgroundColorProperty.setNative](value: number | Color) {
|
||||
if (value instanceof Color) {
|
||||
this._android.getProgressDrawable().setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
} else {
|
||||
@@ -118,10 +118,10 @@ export class Slider extends SliderBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [backgroundInternalProperty.native](): Background {
|
||||
[backgroundInternalProperty.getDefault](): Background {
|
||||
return null;
|
||||
}
|
||||
set [backgroundInternalProperty.native](value: Background) {
|
||||
[backgroundInternalProperty.setNative](value: Background) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,45 +50,45 @@ export class Slider extends SliderBase {
|
||||
return this._ios;
|
||||
}
|
||||
|
||||
get [valueProperty.native](): number {
|
||||
[valueProperty.getDefault](): number {
|
||||
return 0;
|
||||
}
|
||||
set [valueProperty.native](value: number) {
|
||||
[valueProperty.setNative](value: number) {
|
||||
this._ios.value = value;
|
||||
}
|
||||
get [minValueProperty.native](): number {
|
||||
[minValueProperty.getDefault](): number {
|
||||
return 0;
|
||||
}
|
||||
set [minValueProperty.native](value: number) {
|
||||
[minValueProperty.setNative](value: number) {
|
||||
this._ios.minimumValue = value;
|
||||
}
|
||||
get [maxValueProperty.native](): number {
|
||||
[maxValueProperty.getDefault](): number {
|
||||
return 100;
|
||||
}
|
||||
set [maxValueProperty.native](value: number) {
|
||||
[maxValueProperty.setNative](value: number) {
|
||||
this._ios.maximumValue = value;
|
||||
}
|
||||
|
||||
get [colorProperty.native](): UIColor {
|
||||
[colorProperty.getDefault](): UIColor {
|
||||
return this._ios.thumbTintColor;
|
||||
}
|
||||
set [colorProperty.native](value: UIColor | Color) {
|
||||
[colorProperty.setNative](value: UIColor | Color) {
|
||||
let color = value instanceof Color ? value.ios : value;
|
||||
this._ios.thumbTintColor = color;
|
||||
}
|
||||
|
||||
get [backgroundColorProperty.native](): UIColor {
|
||||
[backgroundColorProperty.getDefault](): UIColor {
|
||||
return this._ios.minimumTrackTintColor;
|
||||
}
|
||||
set [backgroundColorProperty.native](value: UIColor | Color) {
|
||||
[backgroundColorProperty.setNative](value: UIColor | Color) {
|
||||
let color = value instanceof Color ? value.ios : value;
|
||||
this._ios.minimumTrackTintColor = color;
|
||||
}
|
||||
|
||||
get [backgroundInternalProperty.native](): Background {
|
||||
[backgroundInternalProperty.getDefault](): Background {
|
||||
return null;
|
||||
}
|
||||
set [backgroundInternalProperty.native](value: Background) {
|
||||
[backgroundInternalProperty.setNative](value: Background) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,17 +48,17 @@ export class Switch extends SwitchBase {
|
||||
return this._android;
|
||||
}
|
||||
|
||||
get [checkedProperty.native](): boolean {
|
||||
[checkedProperty.getDefault](): boolean {
|
||||
return false;
|
||||
}
|
||||
set [checkedProperty.native](value: boolean) {
|
||||
[checkedProperty.setNative](value: boolean) {
|
||||
this._android.setChecked(value);
|
||||
}
|
||||
|
||||
get [colorProperty.native](): number {
|
||||
[colorProperty.getDefault](): number {
|
||||
return -1;
|
||||
}
|
||||
set [colorProperty.native](value: number | Color) {
|
||||
[colorProperty.setNative](value: number | Color) {
|
||||
if (value instanceof Color) {
|
||||
this._android.getThumbDrawable().setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
} else {
|
||||
@@ -66,10 +66,10 @@ export class Switch extends SwitchBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [backgroundColorProperty.native](): number {
|
||||
[backgroundColorProperty.getDefault](): number {
|
||||
return -1;
|
||||
}
|
||||
set [backgroundColorProperty.native](value: number | Color) {
|
||||
[backgroundColorProperty.setNative](value: number | Color) {
|
||||
if (value instanceof Color) {
|
||||
this._android.getTrackDrawable().setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
} else {
|
||||
@@ -77,10 +77,10 @@ export class Switch extends SwitchBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [backgroundInternalProperty.native](): any {
|
||||
[backgroundInternalProperty.getDefault](): any {
|
||||
return null;
|
||||
}
|
||||
set [backgroundInternalProperty.native](value: any) {
|
||||
[backgroundInternalProperty.setNative](value: any) {
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -62,31 +62,31 @@ export class Switch extends SwitchBase {
|
||||
this.setMeasuredDimension(widthAndState, heightAndState);
|
||||
}
|
||||
|
||||
get [checkedProperty.native](): boolean {
|
||||
[checkedProperty.getDefault](): boolean {
|
||||
return false;
|
||||
}
|
||||
set [checkedProperty.native](value: boolean) {
|
||||
[checkedProperty.setNative](value: boolean) {
|
||||
this._ios.on = value;
|
||||
}
|
||||
|
||||
get [colorProperty.native](): UIColor {
|
||||
[colorProperty.getDefault](): UIColor {
|
||||
return this._ios.thumbTintColor;
|
||||
}
|
||||
set [colorProperty.native](value: UIColor | Color) {
|
||||
[colorProperty.setNative](value: UIColor | Color) {
|
||||
this._ios.thumbTintColor = value instanceof Color ? value.ios : value;
|
||||
}
|
||||
|
||||
get [backgroundColorProperty.native](): UIColor {
|
||||
[backgroundColorProperty.getDefault](): UIColor {
|
||||
return this._ios.onTintColor;
|
||||
}
|
||||
set [backgroundColorProperty.native](value: UIColor | Color) {
|
||||
[backgroundColorProperty.setNative](value: UIColor | Color) {
|
||||
this._ios.onTintColor = value instanceof Color ? value.ios : value;
|
||||
}
|
||||
|
||||
get [backgroundInternalProperty.native](): any {
|
||||
[backgroundInternalProperty.getDefault](): any {
|
||||
return null;
|
||||
}
|
||||
set [backgroundInternalProperty.native](value: any) {
|
||||
[backgroundInternalProperty.setNative](value: any) {
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -214,10 +214,10 @@ export class TabViewItem extends TabViewItemBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [fontSizeProperty.native](): { nativeSize: number } {
|
||||
[fontSizeProperty.getDefault](): { nativeSize: number } {
|
||||
return { nativeSize: this.nativeView.getTextSize() };
|
||||
}
|
||||
set [fontSizeProperty.native](value: number | { nativeSize: number }) {
|
||||
[fontSizeProperty.setNative](value: number | { nativeSize: number }) {
|
||||
if (typeof value === "number") {
|
||||
this.nativeView.setTextSize(value);
|
||||
} else {
|
||||
@@ -225,17 +225,17 @@ export class TabViewItem extends TabViewItemBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [fontInternalProperty.native](): android.graphics.Typeface {
|
||||
[fontInternalProperty.getDefault](): android.graphics.Typeface {
|
||||
return this.nativeView.getTypeface();
|
||||
}
|
||||
set [fontInternalProperty.native](value: Font | android.graphics.Typeface) {
|
||||
[fontInternalProperty.setNative](value: Font | android.graphics.Typeface) {
|
||||
this.nativeView.setTypeface(value instanceof Font ? value.getAndroidTypeface() : value);
|
||||
}
|
||||
|
||||
get [textTransformProperty.native](): TextTransform {
|
||||
[textTransformProperty.getDefault](): TextTransform {
|
||||
return "none";
|
||||
}
|
||||
set [textTransformProperty.native](value: TextTransform) {
|
||||
[textTransformProperty.setNative](value: TextTransform) {
|
||||
const tv = this.nativeView;
|
||||
const result = getTransformedText(this.title, value);
|
||||
tv.setText(result);
|
||||
@@ -348,34 +348,34 @@ export class TabView extends TabViewBase {
|
||||
});
|
||||
}
|
||||
|
||||
get [androidOffscreenTabLimitProperty.native](): number {
|
||||
[androidOffscreenTabLimitProperty.getDefault](): number {
|
||||
return this._viewPager.getOffscreenPageLimit();
|
||||
}
|
||||
set [androidOffscreenTabLimitProperty.native](value: number) {
|
||||
[androidOffscreenTabLimitProperty.setNative](value: number) {
|
||||
this._viewPager.setOffscreenPageLimit(value);
|
||||
}
|
||||
|
||||
get [selectedIndexProperty.native](): number {
|
||||
[selectedIndexProperty.getDefault](): number {
|
||||
return -1;
|
||||
}
|
||||
set [selectedIndexProperty.native](value: number) {
|
||||
[selectedIndexProperty.setNative](value: number) {
|
||||
if (traceEnabled()) {
|
||||
traceWrite("TabView this._viewPager.setCurrentItem(" + value + ", true);", traceCategory);
|
||||
}
|
||||
this._viewPager.setCurrentItem(value, true);
|
||||
}
|
||||
|
||||
get [itemsProperty.native](): TabViewItem[] {
|
||||
[itemsProperty.getDefault](): TabViewItem[] {
|
||||
return null;
|
||||
}
|
||||
set [itemsProperty.native](value: TabViewItem[]) {
|
||||
[itemsProperty.setNative](value: TabViewItem[]) {
|
||||
this.setAdapter(value);
|
||||
}
|
||||
|
||||
get [tabBackgroundColorProperty.native](): android.graphics.drawable.Drawable.ConstantState {
|
||||
[tabBackgroundColorProperty.getDefault](): android.graphics.drawable.Drawable.ConstantState {
|
||||
return this._tabLayout.getBackground().getConstantState();
|
||||
}
|
||||
set [tabBackgroundColorProperty.native](value: android.graphics.drawable.Drawable.ConstantState | Color) {
|
||||
[tabBackgroundColorProperty.setNative](value: android.graphics.drawable.Drawable.ConstantState | Color) {
|
||||
if (value instanceof Color) {
|
||||
this._tabLayout.setBackgroundColor(value.android);
|
||||
} else {
|
||||
@@ -383,26 +383,26 @@ export class TabView extends TabViewBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [tabTextColorProperty.native](): number {
|
||||
[tabTextColorProperty.getDefault](): number {
|
||||
return this._tabLayout.getTabTextColor();
|
||||
}
|
||||
set [tabTextColorProperty.native](value: number | Color) {
|
||||
[tabTextColorProperty.setNative](value: number | Color) {
|
||||
const color = value instanceof Color ? value.android : value;
|
||||
this._tabLayout.setTabTextColor(color);
|
||||
}
|
||||
|
||||
get [selectedTabTextColorProperty.native](): number {
|
||||
[selectedTabTextColorProperty.getDefault](): number {
|
||||
return this._tabLayout.getSelectedTabTextColor();
|
||||
}
|
||||
set [selectedTabTextColorProperty.native](value: number | Color) {
|
||||
[selectedTabTextColorProperty.setNative](value: number | Color) {
|
||||
const color = value instanceof Color ? value.android : value;
|
||||
this._tabLayout.setSelectedTabTextColor(color);
|
||||
}
|
||||
|
||||
get [androidSelectedTabHighlightColorProperty.native](): number {
|
||||
[androidSelectedTabHighlightColorProperty.getDefault](): number {
|
||||
return getDefaultAccentColor(this._context);
|
||||
}
|
||||
set [androidSelectedTabHighlightColorProperty.native](value: number | Color) {
|
||||
[androidSelectedTabHighlightColorProperty.setNative](value: number | Color) {
|
||||
let tabLayout = this._tabLayout;
|
||||
const color = value instanceof Color ? value.android : value;
|
||||
tabLayout.setSelectedIndicatorColors([color]);
|
||||
|
||||
@@ -230,7 +230,7 @@ export class TabView extends TabViewBase {
|
||||
}
|
||||
}
|
||||
|
||||
private setViewControllers(items: Array<TabViewItem>) {
|
||||
private setViewControllers(items: TabViewItem[]) {
|
||||
const length = items ? items.length : 0;
|
||||
if (length === 0) {
|
||||
this._ios.viewControllers = null;
|
||||
@@ -371,10 +371,10 @@ export class TabView extends TabViewBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [selectedIndexProperty.native](): number {
|
||||
[selectedIndexProperty.getDefault](): number {
|
||||
return -1;
|
||||
}
|
||||
set [selectedIndexProperty.native](value: number) {
|
||||
[selectedIndexProperty.setNative](value: number) {
|
||||
if (traceEnabled()) {
|
||||
traceWrite("TabView._onSelectedIndexPropertyChangedSetNativeValue(" + value + ")", traceCategories.Debug);
|
||||
}
|
||||
@@ -384,56 +384,56 @@ export class TabView extends TabViewBase {
|
||||
}
|
||||
}
|
||||
|
||||
get [itemsProperty.native](): TabViewItem[] {
|
||||
[itemsProperty.getDefault](): TabViewItem[] {
|
||||
return null;
|
||||
}
|
||||
set [itemsProperty.native](value: TabViewItem[]) {
|
||||
[itemsProperty.setNative](value: TabViewItem[]) {
|
||||
this.setViewControllers(value);
|
||||
}
|
||||
|
||||
get [tabTextColorProperty.native](): UIColor {
|
||||
[tabTextColorProperty.getDefault](): UIColor {
|
||||
return null;
|
||||
}
|
||||
set [tabTextColorProperty.native](value: UIColor | Color) {
|
||||
[tabTextColorProperty.setNative](value: UIColor | Color) {
|
||||
this._updateIOSTabBarColorsAndFonts();
|
||||
}
|
||||
|
||||
get [tabBackgroundColorProperty.native](): UIColor {
|
||||
[tabBackgroundColorProperty.getDefault](): UIColor {
|
||||
return this._ios.tabBar.barTintColor;
|
||||
}
|
||||
set [tabBackgroundColorProperty.native](value: UIColor | Color) {
|
||||
[tabBackgroundColorProperty.setNative](value: UIColor | Color) {
|
||||
this._ios.tabBar.barTintColor = value instanceof Color ? value.ios : value;
|
||||
}
|
||||
|
||||
get [selectedTabTextColorProperty.native](): UIColor {
|
||||
[selectedTabTextColorProperty.getDefault](): UIColor {
|
||||
return this._ios.tabBar.tintColor;
|
||||
}
|
||||
set [selectedTabTextColorProperty.native](value: UIColor) {
|
||||
[selectedTabTextColorProperty.setNative](value: UIColor) {
|
||||
this._ios.tabBar.tintColor = value instanceof Color ? value.ios : value;
|
||||
this._updateIOSTabBarColorsAndFonts();
|
||||
}
|
||||
|
||||
// TODO: Move this to TabViewItem
|
||||
get [textTransformProperty.native](): TextTransform {
|
||||
[textTransformProperty.getDefault](): TextTransform {
|
||||
return "none";
|
||||
}
|
||||
set [textTransformProperty.native](value: TextTransform) {
|
||||
[textTransformProperty.setNative](value: TextTransform) {
|
||||
this._updateIOSTabBarTextTransform(value);
|
||||
}
|
||||
|
||||
// TODO: Move this to TabViewItem
|
||||
get [fontInternalProperty.native](): Font {
|
||||
[fontInternalProperty.getDefault](): Font {
|
||||
return null;
|
||||
}
|
||||
set [fontInternalProperty.native](value: Font) {
|
||||
[fontInternalProperty.setNative](value: Font) {
|
||||
this._updateIOSTabBarColorsAndFonts();
|
||||
}
|
||||
|
||||
// TODO: Move this to TabViewItem
|
||||
get [iosIconRenderingModeProperty.native](): "automatic" | "alwaysOriginal" | "alwaysTemplate" {
|
||||
[iosIconRenderingModeProperty.getDefault](): "automatic" | "alwaysOriginal" | "alwaysTemplate" {
|
||||
return "automatic";
|
||||
}
|
||||
set [iosIconRenderingModeProperty.native](value: "automatic" | "alwaysOriginal" | "alwaysTemplate") {
|
||||
[iosIconRenderingModeProperty.setNative](value: "automatic" | "alwaysOriginal" | "alwaysTemplate") {
|
||||
this._iconsCache = {};
|
||||
let items = this.items;
|
||||
if (items && items.length) {
|
||||
|
||||
@@ -120,7 +120,7 @@ export abstract class TextBaseCommon extends View implements TextBaseDefinition
|
||||
public _onFormattedTextContentsChanged(data: PropertyChangeData) {
|
||||
if (this._nativeView) {
|
||||
// Notifications from the FormattedString start arriving before the Android view is even created.
|
||||
this[formattedTextProperty.native] = data.value;
|
||||
this[formattedTextProperty.setNative](data.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,10 +62,10 @@ export class TextBase extends TextBaseCommon {
|
||||
this.nativeView.setTransformationMethod(this._defaultTransformationMethod);
|
||||
}
|
||||
|
||||
get [textProperty.native](): string {
|
||||
[textProperty.getDefault](): string {
|
||||
return '';
|
||||
}
|
||||
set [textProperty.native](value: string) {
|
||||
[textProperty.setNative](value: string) {
|
||||
if (this.formattedText) {
|
||||
return;
|
||||
}
|
||||
@@ -73,10 +73,10 @@ export class TextBase extends TextBaseCommon {
|
||||
this._setNativeText();
|
||||
}
|
||||
|
||||
get [formattedTextProperty.native](): FormattedString {
|
||||
[formattedTextProperty.getDefault](): FormattedString {
|
||||
return null;
|
||||
}
|
||||
set [formattedTextProperty.native](value: FormattedString) {
|
||||
[formattedTextProperty.setNative](value: FormattedString) {
|
||||
// Don't change the transformation method if this is secure TextField or we'll lose the hiding characters.
|
||||
if ((<any>this).secure) {
|
||||
return;
|
||||
@@ -86,6 +86,7 @@ export class TextBase extends TextBaseCommon {
|
||||
|
||||
const spannableStringBuilder = createSpannableStringBuilder(value);
|
||||
this.nativeView.setText(<any>spannableStringBuilder);
|
||||
|
||||
textProperty.nativeValueChange(this, (value === null || value === undefined) ? '' : value.toString());
|
||||
|
||||
if (spannableStringBuilder && this.nativeView instanceof android.widget.Button &&
|
||||
@@ -97,11 +98,10 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [textTransformProperty.native](): string {
|
||||
[textTransformProperty.getDefault](): "default" {
|
||||
return "default";
|
||||
}
|
||||
|
||||
set [textTransformProperty.native](value: TextTransform | android.text.method.TransformationMethod) {
|
||||
[textTransformProperty.setNative](value: "default" | TextTransform | android.text.method.TransformationMethod) {
|
||||
// In case of reset.
|
||||
if (value === "default") {
|
||||
this.nativeView.setTransformationMethod(this._defaultTransformationMethod);
|
||||
@@ -114,6 +114,7 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
|
||||
initializeTextTransformation();
|
||||
|
||||
if (typeof value === "string") {
|
||||
this.nativeView.setTransformationMethod(new TextTransformation(this));
|
||||
} else {
|
||||
@@ -121,10 +122,10 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [colorProperty.native](): android.content.res.ColorStateList {
|
||||
[colorProperty.getDefault](): android.content.res.ColorStateList {
|
||||
return this.nativeView.getTextColors();
|
||||
}
|
||||
set [colorProperty.native](value: Color | android.content.res.ColorStateList) {
|
||||
[colorProperty.setNative](value: Color | android.content.res.ColorStateList) {
|
||||
if (!this.formattedText || !(value instanceof Color)) {
|
||||
if (value instanceof Color) {
|
||||
this.nativeView.setTextColor(value.android);
|
||||
@@ -134,10 +135,10 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [fontSizeProperty.native](): { nativeSize: number } {
|
||||
[fontSizeProperty.getDefault](): { nativeSize: number } {
|
||||
return { nativeSize: this.nativeView.getTextSize() };
|
||||
}
|
||||
set [fontSizeProperty.native](value: number | { nativeSize: number }) {
|
||||
[fontSizeProperty.setNative](value: number | { nativeSize: number }) {
|
||||
if (!this.formattedText || (typeof value !== "number")) {
|
||||
if (typeof value === "number") {
|
||||
this.nativeView.setTextSize(value);
|
||||
@@ -147,15 +148,15 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [fontInternalProperty.native](): android.graphics.Typeface {
|
||||
[fontInternalProperty.getDefault](): android.graphics.Typeface {
|
||||
return this.nativeView.getTypeface();
|
||||
}
|
||||
set [fontInternalProperty.native](value: Font | android.graphics.Typeface) {
|
||||
[fontInternalProperty.setNative](value: Font | android.graphics.Typeface) {
|
||||
if (!this.formattedText || !(value instanceof Font)) {
|
||||
this.nativeView.setTypeface(value instanceof Font ? value.getAndroidTypeface() : value);
|
||||
}
|
||||
}
|
||||
get [textAlignmentProperty.native](): TextAlignment {
|
||||
[textAlignmentProperty.getDefault](): TextAlignment {
|
||||
let textAlignmentGravity = this.nativeView.getGravity() & android.view.Gravity.HORIZONTAL_GRAVITY_MASK;
|
||||
switch (textAlignmentGravity) {
|
||||
case android.view.Gravity.CENTER_HORIZONTAL:
|
||||
@@ -167,7 +168,7 @@ export class TextBase extends TextBaseCommon {
|
||||
return "left";
|
||||
}
|
||||
}
|
||||
set [textAlignmentProperty.native](value: TextAlignment) {
|
||||
[textAlignmentProperty.setNative](value: TextAlignment) {
|
||||
let verticalGravity = this.nativeView.getGravity() & android.view.Gravity.VERTICAL_GRAVITY_MASK;
|
||||
switch (value) {
|
||||
case "left":
|
||||
@@ -184,10 +185,10 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [textDecorationProperty.native](): number {
|
||||
[textDecorationProperty.getDefault](): number {
|
||||
return -1;
|
||||
}
|
||||
set [textDecorationProperty.native](value: TextDecoration | number) {
|
||||
[textDecorationProperty.setNative](value: number | TextDecoration) {
|
||||
const isReset = typeof value === "number";
|
||||
if (!this.formattedText || isReset) {
|
||||
value = isReset ? "none" : value;
|
||||
@@ -208,7 +209,6 @@ export class TextBase extends TextBaseCommon {
|
||||
default:
|
||||
throw new Error(`Invalid text decoration value: ${value}. Valid values are: 'none', 'underline', 'line-through', 'underline line-through'.`);
|
||||
}
|
||||
|
||||
this.nativeView.setPaintFlags(flags);
|
||||
} else {
|
||||
this._setNativeText();
|
||||
@@ -217,11 +217,11 @@ export class TextBase extends TextBaseCommon {
|
||||
|
||||
// Overriden in TextField becasue setSingleLine(false) will remove methodTransformation.
|
||||
// and we don't want to allow TextField to be multiline
|
||||
get [whiteSpaceProperty.native](): WhiteSpace {
|
||||
[whiteSpaceProperty.getDefault](): WhiteSpace {
|
||||
return "normal";
|
||||
}
|
||||
|
||||
set [whiteSpaceProperty.native](value: WhiteSpace) {
|
||||
[whiteSpaceProperty.setNative](value: WhiteSpace) {
|
||||
const nativeView = this.nativeView;
|
||||
switch (value) {
|
||||
case "normal":
|
||||
@@ -237,38 +237,38 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [letterSpacingProperty.native](): number {
|
||||
[letterSpacingProperty.getDefault](): number {
|
||||
return org.nativescript.widgets.ViewHelper.getLetterspacing(this.nativeView);
|
||||
}
|
||||
set [letterSpacingProperty.native](value: number) {
|
||||
[letterSpacingProperty.setNative](value: number) {
|
||||
org.nativescript.widgets.ViewHelper.setLetterspacing(this.nativeView, value);
|
||||
}
|
||||
|
||||
get [paddingTopProperty.native](): Length {
|
||||
[paddingTopProperty.getDefault](): Length {
|
||||
return { value: this._defaultPaddingTop, unit: "px" }
|
||||
}
|
||||
set [paddingTopProperty.native](value: Length) {
|
||||
[paddingTopProperty.setNative](value: Length) {
|
||||
org.nativescript.widgets.ViewHelper.setPaddingTop(this.nativeView, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderTopWidth, 0));
|
||||
}
|
||||
|
||||
get [paddingRightProperty.native](): Length {
|
||||
[paddingRightProperty.getDefault](): Length {
|
||||
return { value: this._defaultPaddingRight, unit: "px" }
|
||||
}
|
||||
set [paddingRightProperty.native](value: Length) {
|
||||
[paddingRightProperty.setNative](value: Length) {
|
||||
org.nativescript.widgets.ViewHelper.setPaddingRight(this.nativeView, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderRightWidth, 0));
|
||||
}
|
||||
|
||||
get [paddingBottomProperty.native](): Length {
|
||||
[paddingBottomProperty.getDefault](): Length {
|
||||
return { value: this._defaultPaddingBottom, unit: "px" }
|
||||
}
|
||||
set [paddingBottomProperty.native](value: Length) {
|
||||
[paddingBottomProperty.setNative](value: Length) {
|
||||
org.nativescript.widgets.ViewHelper.setPaddingBottom(this.nativeView, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderBottomWidth, 0));
|
||||
}
|
||||
|
||||
get [paddingLeftProperty.native](): Length {
|
||||
[paddingLeftProperty.getDefault](): Length {
|
||||
return { value: this._defaultPaddingLeft, unit: "px" }
|
||||
}
|
||||
set [paddingLeftProperty.native](value: Length) {
|
||||
[paddingLeftProperty.setNative](value: Length) {
|
||||
org.nativescript.widgets.ViewHelper.setPaddingLeft(this.nativeView, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderLeftWidth, 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ export class TextBase extends TextBaseCommon {
|
||||
|
||||
public nativeView: UITextField | UITextView | UILabel | UIButton;
|
||||
|
||||
get [textProperty.native](): string {
|
||||
[textProperty.getDefault](): string {
|
||||
return '';
|
||||
}
|
||||
set [textProperty.native](value: string) {
|
||||
[textProperty.setNative](value: string) {
|
||||
if (this.formattedText) {
|
||||
return;
|
||||
}
|
||||
@@ -23,16 +23,16 @@ export class TextBase extends TextBaseCommon {
|
||||
this._requestLayoutOnTextChanged();
|
||||
}
|
||||
|
||||
get [formattedTextProperty.native](): FormattedString {
|
||||
[formattedTextProperty.getDefault](): FormattedString {
|
||||
return null;
|
||||
}
|
||||
set [formattedTextProperty.native](value: FormattedString) {
|
||||
[formattedTextProperty.setNative](value: FormattedString) {
|
||||
this._setNativeText();
|
||||
textProperty.nativeValueChange(this, !value ? '' : value.toString());
|
||||
this._requestLayoutOnTextChanged();
|
||||
}
|
||||
|
||||
get [colorProperty.native](): UIColor {
|
||||
[colorProperty.getDefault](): UIColor {
|
||||
let nativeView = this.nativeView;
|
||||
if (nativeView instanceof UIButton) {
|
||||
return nativeView.titleColorForState(UIControlState.Normal);
|
||||
@@ -40,7 +40,7 @@ export class TextBase extends TextBaseCommon {
|
||||
return nativeView.textColor;
|
||||
}
|
||||
}
|
||||
set [colorProperty.native](value: Color | UIColor) {
|
||||
[colorProperty.setNative](value: Color | UIColor) {
|
||||
const color = value instanceof Color ? value.ios : value;
|
||||
if (!this.formattedText) {
|
||||
let nativeView = this.nativeView;
|
||||
@@ -52,12 +52,12 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [fontInternalProperty.native](): UIFont {
|
||||
[fontInternalProperty.getDefault](): UIFont {
|
||||
let nativeView = this.nativeView;
|
||||
nativeView = nativeView instanceof UIButton ? nativeView.titleLabel : nativeView;
|
||||
return nativeView.font;
|
||||
}
|
||||
set [fontInternalProperty.native](value: Font | UIFont) {
|
||||
[fontInternalProperty.setNative](value: Font | UIFont) {
|
||||
if (!this.formattedText) {
|
||||
let nativeView = this.nativeView;
|
||||
nativeView = nativeView instanceof UIButton ? nativeView.titleLabel : nativeView;
|
||||
@@ -66,7 +66,7 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [textAlignmentProperty.native](): TextAlignment {
|
||||
[textAlignmentProperty.getDefault](): TextAlignment {
|
||||
let nativeView = this.nativeView;
|
||||
nativeView = nativeView instanceof UIButton ? nativeView.titleLabel : nativeView;
|
||||
switch (nativeView.textAlignment) {
|
||||
@@ -81,7 +81,7 @@ export class TextBase extends TextBaseCommon {
|
||||
throw new Error(`Unsupported NSTextAlignment: ${nativeView.textAlignment}. Currently supported values are NSTextAlignment.Left, NSTextAlignment.Center, and NSTextAlignment.Right.`);
|
||||
}
|
||||
}
|
||||
set [textAlignmentProperty.native](value: TextAlignment) {
|
||||
[textAlignmentProperty.setNative](value: TextAlignment) {
|
||||
let nativeView = <UITextField | UITextView | UILabel>this.nativeView;
|
||||
switch (value) {
|
||||
case "left":
|
||||
@@ -101,24 +101,24 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
}
|
||||
|
||||
get [textDecorationProperty.native](): TextDecoration {
|
||||
[textDecorationProperty.getDefault](): TextDecoration {
|
||||
return "none";
|
||||
}
|
||||
set [textDecorationProperty.native](value: TextDecoration) {
|
||||
[textDecorationProperty.setNative](value: TextDecoration) {
|
||||
this._setNativeText();
|
||||
}
|
||||
|
||||
get [textTransformProperty.native](): TextTransform {
|
||||
[textTransformProperty.getDefault](): TextTransform {
|
||||
return "none";
|
||||
}
|
||||
set [textTransformProperty.native](value: TextTransform) {
|
||||
[textTransformProperty.setNative](value: TextTransform) {
|
||||
this._setNativeText();
|
||||
}
|
||||
|
||||
get [letterSpacingProperty.native](): number {
|
||||
[letterSpacingProperty.getDefault](): number {
|
||||
return 0;
|
||||
}
|
||||
set [letterSpacingProperty.native](value: number) {
|
||||
[letterSpacingProperty.setNative](value: number) {
|
||||
this._setNativeText();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ export class TextField extends TextFieldBase {
|
||||
this.notify({ eventName: TextField.returnPressEvent, object: this })
|
||||
}
|
||||
|
||||
get [secureProperty.native](): boolean {
|
||||
[secureProperty.getDefault](): boolean {
|
||||
return false;
|
||||
}
|
||||
set [secureProperty.native](value: boolean) {
|
||||
[secureProperty.setNative](value: boolean) {
|
||||
const nativeView = this.nativeView;
|
||||
const currentInputType = nativeView.getInputType();
|
||||
const currentClass = currentInputType & android.text.InputType.TYPE_MASK_CLASS;
|
||||
@@ -49,10 +49,10 @@ export class TextField extends TextFieldBase {
|
||||
nativeView.setInputType(newInputType);
|
||||
}
|
||||
|
||||
get [whiteSpaceProperty.native](): WhiteSpace {
|
||||
[whiteSpaceProperty.getDefault](): WhiteSpace {
|
||||
return "nowrap";
|
||||
}
|
||||
set [whiteSpaceProperty.native](value: WhiteSpace) {
|
||||
[whiteSpaceProperty.setNative](value: WhiteSpace) {
|
||||
// Don't change it otherwise TextField will go to multiline mode.
|
||||
}
|
||||
}
|
||||
@@ -152,10 +152,10 @@ export class TextField extends TextFieldBase {
|
||||
return this._ios;
|
||||
}
|
||||
|
||||
get [hintProperty.native](): string {
|
||||
[hintProperty.getDefault](): string {
|
||||
return this.nativeView.placeholder;
|
||||
}
|
||||
set [hintProperty.native](value: string) {
|
||||
[hintProperty.setNative](value: string) {
|
||||
let stringValue;
|
||||
if (value === null || value === void 0) {
|
||||
stringValue = "";
|
||||
@@ -165,18 +165,18 @@ export class TextField extends TextFieldBase {
|
||||
this.nativeView.placeholder = stringValue;
|
||||
}
|
||||
|
||||
get [secureProperty.native](): boolean {
|
||||
[secureProperty.getDefault](): boolean {
|
||||
return this.nativeView.secureTextEntry;
|
||||
}
|
||||
set [secureProperty.native](value: boolean) {
|
||||
[secureProperty.setNative](value: boolean) {
|
||||
this.nativeView.secureTextEntry = value;
|
||||
}
|
||||
|
||||
get [colorProperty.native](): UIColor {
|
||||
[colorProperty.getDefault](): UIColor {
|
||||
// return this.nativeView.tintColor;
|
||||
return this.nativeView.textColor;
|
||||
}
|
||||
set [colorProperty.native](value: UIColor | Color) {
|
||||
[colorProperty.setNative](value: UIColor | Color) {
|
||||
// NOTE: Do we need this code? We have placeholderColor.
|
||||
// let nativeValue = this.nativeView;
|
||||
// if (this.isShowingHint && value) {
|
||||
@@ -189,10 +189,10 @@ export class TextField extends TextFieldBase {
|
||||
this.nativeView.textColor = color;
|
||||
}
|
||||
|
||||
get [placeholderColorProperty.native](): UIColor {
|
||||
[placeholderColorProperty.getDefault](): UIColor {
|
||||
return null;
|
||||
}
|
||||
set [placeholderColorProperty.native](value: UIColor | Color) {
|
||||
[placeholderColorProperty.setNative](value: UIColor | Color) {
|
||||
let nativeView = this.nativeView;
|
||||
let colorAttibutes = NSMutableDictionary.new<string, any>();
|
||||
colorAttibutes.setValueForKey(value instanceof Color ? value.ios : value, NSForegroundColorAttributeName);
|
||||
@@ -207,31 +207,31 @@ export class TextField extends TextFieldBase {
|
||||
nativeView.attributedPlaceholder = NSAttributedString.alloc().initWithStringAttributes(stringValue, colorAttibutes);
|
||||
}
|
||||
|
||||
get [paddingTopProperty.native](): Length {
|
||||
[paddingTopProperty.getDefault](): Length {
|
||||
return zeroLength;
|
||||
}
|
||||
set [paddingTopProperty.native](value: Length) {
|
||||
[paddingTopProperty.setNative](value: Length) {
|
||||
// Padding is realized via UITextFieldImpl.textRectForBounds method
|
||||
}
|
||||
|
||||
get [paddingRightProperty.native](): Length {
|
||||
[paddingRightProperty.getDefault](): Length {
|
||||
return zeroLength;
|
||||
}
|
||||
set [paddingRightProperty.native](value: Length) {
|
||||
[paddingRightProperty.setNative](value: Length) {
|
||||
// Padding is realized via UITextFieldImpl.textRectForBounds method
|
||||
}
|
||||
|
||||
get [paddingBottomProperty.native](): Length {
|
||||
[paddingBottomProperty.getDefault](): Length {
|
||||
return zeroLength;
|
||||
}
|
||||
set [paddingBottomProperty.native](value: Length) {
|
||||
[paddingBottomProperty.setNative](value: Length) {
|
||||
// Padding is realized via UITextFieldImpl.textRectForBounds method
|
||||
}
|
||||
|
||||
get [paddingLeftProperty.native](): Length {
|
||||
[paddingLeftProperty.getDefault](): Length {
|
||||
return zeroLength;
|
||||
}
|
||||
set [paddingLeftProperty.native](value: Length) {
|
||||
[paddingLeftProperty.setNative](value: Length) {
|
||||
// Padding is realized via UITextFieldImpl.textRectForBounds method
|
||||
}
|
||||
}
|
||||
@@ -146,133 +146,124 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
|
||||
this._setNativeText();
|
||||
}
|
||||
|
||||
get [textProperty.native](): string {
|
||||
[textProperty.getDefault](): string {
|
||||
return "";
|
||||
}
|
||||
set [textProperty.native](value: string) {
|
||||
[textProperty.setNative](value: string) {
|
||||
this._refreshHintState(this.hint, value);
|
||||
}
|
||||
|
||||
get [hintProperty.native](): string {
|
||||
[hintProperty.getDefault](): string {
|
||||
return "";
|
||||
}
|
||||
set [hintProperty.native](value: string) {
|
||||
[hintProperty.setNative](value: string) {
|
||||
this._refreshHintState(value, this.text);
|
||||
}
|
||||
|
||||
get [editableProperty.native](): boolean {
|
||||
[editableProperty.getDefault](): boolean {
|
||||
return this.nativeView.editable;
|
||||
}
|
||||
set [editableProperty.native](value: boolean) {
|
||||
[editableProperty.setNative](value: boolean) {
|
||||
this.nativeView.editable = value;
|
||||
}
|
||||
|
||||
get [colorProperty.native](): UIColor {
|
||||
return null;
|
||||
}
|
||||
set [colorProperty.native](color: Color) {
|
||||
[colorProperty.setNative](color: Color) {
|
||||
this._refreshColor();
|
||||
|
||||
}
|
||||
|
||||
get [placeholderColorProperty.native](): Color {
|
||||
return null;
|
||||
}
|
||||
set [placeholderColorProperty.native](value: Color) {
|
||||
[placeholderColorProperty.setNative](value: Color) {
|
||||
this._refreshColor();
|
||||
}
|
||||
|
||||
get [borderTopWidthProperty.native](): Length {
|
||||
[borderTopWidthProperty.getDefault](): Length {
|
||||
return {
|
||||
value: this.nativeView.textContainerInset.top,
|
||||
unit: "px"
|
||||
};
|
||||
}
|
||||
set [borderTopWidthProperty.native](value: Length) {
|
||||
[borderTopWidthProperty.setNative](value: Length) {
|
||||
let inset = this.nativeView.textContainerInset;
|
||||
let top = layout.toDeviceIndependentPixels(this.effectivePaddingTop + this.effectiveBorderTopWidth);
|
||||
this.nativeView.textContainerInset = { top: top, left: inset.left, bottom: inset.bottom, right: inset.right };
|
||||
}
|
||||
|
||||
get [borderRightWidthProperty.native](): Length {
|
||||
[borderRightWidthProperty.getDefault](): Length {
|
||||
return {
|
||||
value: this.nativeView.textContainerInset.right,
|
||||
unit: "px"
|
||||
};
|
||||
}
|
||||
set [borderRightWidthProperty.native](value: Length) {
|
||||
[borderRightWidthProperty.setNative](value: Length) {
|
||||
let inset = this.nativeView.textContainerInset;
|
||||
let right = layout.toDeviceIndependentPixels(this.effectivePaddingRight + this.effectiveBorderRightWidth);
|
||||
this.nativeView.textContainerInset = { top: inset.top, left: inset.left, bottom: inset.bottom, right: right };
|
||||
}
|
||||
|
||||
get [borderBottomWidthProperty.native](): Length {
|
||||
[borderBottomWidthProperty.getDefault](): Length {
|
||||
return {
|
||||
value: this.nativeView.textContainerInset.bottom,
|
||||
unit: "px"
|
||||
};
|
||||
}
|
||||
set [borderBottomWidthProperty.native](value: Length) {
|
||||
[borderBottomWidthProperty.setNative](value: Length) {
|
||||
let inset = this.nativeView.textContainerInset;
|
||||
let bottom = layout.toDeviceIndependentPixels(this.effectivePaddingBottom + this.effectiveBorderBottomWidth);
|
||||
this.nativeView.textContainerInset = { top: inset.top, left: inset.left, bottom: bottom, right: inset.right };
|
||||
}
|
||||
|
||||
get [borderLeftWidthProperty.native](): Length {
|
||||
[borderLeftWidthProperty.getDefault](): Length {
|
||||
return {
|
||||
value: this.nativeView.textContainerInset.left,
|
||||
unit: "px"
|
||||
};
|
||||
}
|
||||
set [borderLeftWidthProperty.native](value: Length) {
|
||||
[borderLeftWidthProperty.setNative](value: Length) {
|
||||
let inset = this.nativeView.textContainerInset;
|
||||
let left = layout.toDeviceIndependentPixels(this.effectivePaddingLeft + this.effectiveBorderLeftWidth);
|
||||
this.nativeView.textContainerInset = { top: inset.top, left: left, bottom: inset.bottom, right: inset.right };
|
||||
}
|
||||
|
||||
get [paddingTopProperty.native](): Length {
|
||||
[paddingTopProperty.getDefault](): Length {
|
||||
return {
|
||||
value: this.nativeView.textContainerInset.top,
|
||||
unit: "px"
|
||||
};
|
||||
}
|
||||
set [paddingTopProperty.native](value: Length) {
|
||||
[paddingTopProperty.setNative](value: Length) {
|
||||
let inset = this.nativeView.textContainerInset;
|
||||
let top = layout.toDeviceIndependentPixels(this.effectivePaddingTop + this.effectiveBorderTopWidth);
|
||||
this.nativeView.textContainerInset = { top: top, left: inset.left, bottom: inset.bottom, right: inset.right };
|
||||
}
|
||||
|
||||
get [paddingRightProperty.native](): Length {
|
||||
[paddingRightProperty.getDefault](): Length {
|
||||
return {
|
||||
value: this.nativeView.textContainerInset.right,
|
||||
unit: "px"
|
||||
};
|
||||
}
|
||||
set [paddingRightProperty.native](value: Length) {
|
||||
[paddingRightProperty.setNative](value: Length) {
|
||||
let inset = this.nativeView.textContainerInset;
|
||||
let right = layout.toDeviceIndependentPixels(this.effectivePaddingRight + this.effectiveBorderRightWidth);
|
||||
this.nativeView.textContainerInset = { top: inset.top, left: inset.left, bottom: inset.bottom, right: right };
|
||||
}
|
||||
|
||||
get [paddingBottomProperty.native](): Length {
|
||||
[paddingBottomProperty.getDefault](): Length {
|
||||
return {
|
||||
value: this.nativeView.textContainerInset.bottom,
|
||||
unit: "px"
|
||||
};
|
||||
}
|
||||
set [paddingBottomProperty.native](value: Length) {
|
||||
[paddingBottomProperty.setNative](value: Length) {
|
||||
let inset = this.nativeView.textContainerInset;
|
||||
let bottom = layout.toDeviceIndependentPixels(this.effectivePaddingBottom + this.effectiveBorderBottomWidth);
|
||||
this.nativeView.textContainerInset = { top: inset.top, left: inset.left, bottom: bottom, right: inset.right };
|
||||
}
|
||||
|
||||
get [paddingLeftProperty.native](): Length {
|
||||
[paddingLeftProperty.getDefault](): Length {
|
||||
return {
|
||||
value: this.nativeView.textContainerInset.left,
|
||||
unit: "px"
|
||||
};
|
||||
}
|
||||
set [paddingLeftProperty.native](value: Length) {
|
||||
[paddingLeftProperty.setNative](value: Length) {
|
||||
let inset = this.nativeView.textContainerInset;
|
||||
let left = layout.toDeviceIndependentPixels(this.effectivePaddingLeft + this.effectiveBorderLeftWidth);
|
||||
this.nativeView.textContainerInset = { top: inset.top, left: left, bottom: inset.bottom, right: inset.right };
|
||||
|
||||
@@ -77,25 +77,25 @@ export class TimePicker extends TimePickerBase {
|
||||
this._setNativeValueSilently(this.hour, this.minute);
|
||||
}
|
||||
|
||||
get [timeProperty.native](): Date {
|
||||
[timeProperty.getDefault](): Date {
|
||||
let nativeView = this._android;
|
||||
return new Date(0, 0, 0, nativeView.getCurrentHour().intValue(), nativeView.getCurrentMinute().intValue());
|
||||
}
|
||||
set [timeProperty.native](value: Date) {
|
||||
[timeProperty.setNative](value: Date) {
|
||||
this._setNativeValueSilently(this.hour, this.minute);
|
||||
}
|
||||
|
||||
get [minuteProperty.native](): number {
|
||||
[minuteProperty.getDefault](): number {
|
||||
return this._android.getCurrentMinute().intValue();
|
||||
}
|
||||
set [minuteProperty.native](value: number) {
|
||||
[minuteProperty.setNative](value: number) {
|
||||
this._setNativeValueSilently(this.hour, value);
|
||||
}
|
||||
|
||||
get [hourProperty.native](): number {
|
||||
[hourProperty.getDefault](): number {
|
||||
return this._android.getCurrentHour().intValue()
|
||||
}
|
||||
set [hourProperty.native](value: number) {
|
||||
[hourProperty.setNative](value: number) {
|
||||
this._setNativeValueSilently(value, this.minute);
|
||||
}
|
||||
}
|
||||
@@ -44,66 +44,66 @@ export class TimePicker extends TimePickerBase {
|
||||
return this._ios;
|
||||
}
|
||||
|
||||
get [timeProperty.native](): Date {
|
||||
[timeProperty.getDefault](): Date {
|
||||
return this.nativeView.date;
|
||||
}
|
||||
set [timeProperty.native](value: Date) {
|
||||
[timeProperty.setNative](value: Date) {
|
||||
this.nativeView.date = getDate(this.hour, this.minute);
|
||||
}
|
||||
|
||||
get [minuteProperty.native](): number {
|
||||
[minuteProperty.getDefault](): number {
|
||||
return this.nativeView.date.getMinutes();
|
||||
}
|
||||
set [minuteProperty.native](value: number) {
|
||||
[minuteProperty.setNative](value: number) {
|
||||
this.nativeView.date = getDate(this.hour, value);
|
||||
}
|
||||
|
||||
get [hourProperty.native](): number {
|
||||
[hourProperty.getDefault](): number {
|
||||
return this.nativeView.date.getHours();
|
||||
}
|
||||
set [hourProperty.native](value: number) {
|
||||
[hourProperty.setNative](value: number) {
|
||||
this.nativeView.date = getDate(value, this.minute);
|
||||
}
|
||||
|
||||
get [minHourProperty.native](): number {
|
||||
[minHourProperty.getDefault](): number {
|
||||
return this.nativeView.minimumDate ? this.nativeView.minimumDate.getHours() : 0;
|
||||
}
|
||||
set [minHourProperty.native](value: number) {
|
||||
[minHourProperty.setNative](value: number) {
|
||||
this.nativeView.minimumDate = getDate(value, this.minute);
|
||||
}
|
||||
|
||||
get [maxHourProperty.native](): number {
|
||||
[maxHourProperty.getDefault](): number {
|
||||
return this.nativeView.maximumDate ? this.nativeView.maximumDate.getHours() : 24;
|
||||
}
|
||||
set [maxHourProperty.native](value: number) {
|
||||
[maxHourProperty.setNative](value: number) {
|
||||
this.nativeView.maximumDate = getDate(value, this.minute);
|
||||
}
|
||||
|
||||
get [minMinuteProperty.native](): number {
|
||||
[minMinuteProperty.getDefault](): number {
|
||||
return this.nativeView.minimumDate ? this.nativeView.minimumDate.getMinutes() : 0;
|
||||
}
|
||||
set [minMinuteProperty.native](value: number) {
|
||||
[minMinuteProperty.setNative](value: number) {
|
||||
this.nativeView.minimumDate = getDate(this.hour, value);
|
||||
}
|
||||
|
||||
get [maxMinuteProperty.native](): number {
|
||||
[maxMinuteProperty.getDefault](): number {
|
||||
return this.nativeView.maximumDate ? this.nativeView.maximumDate.getMinutes() : 60;
|
||||
}
|
||||
set [maxMinuteProperty.native](value: number) {
|
||||
[maxMinuteProperty.setNative](value: number) {
|
||||
this.nativeView.maximumDate = getDate(this.hour, value);
|
||||
}
|
||||
|
||||
get [timeProperty.native](): number {
|
||||
[timeProperty.getDefault](): number {
|
||||
return this.nativeView.minuteInterval;
|
||||
}
|
||||
set [timeProperty.native](value: number) {
|
||||
[timeProperty.setNative](value: number) {
|
||||
this.nativeView.minuteInterval = value;
|
||||
}
|
||||
|
||||
get [colorProperty.native](): UIColor {
|
||||
[colorProperty.getDefault](): UIColor {
|
||||
return this.nativeView.valueForKey("textColor");
|
||||
}
|
||||
set [colorProperty.native](value: Color | UIColor) {
|
||||
[colorProperty.setNative](value: Color | UIColor) {
|
||||
const color = value instanceof Color ? value.ios : value;
|
||||
this.nativeView.setValueForKey(color, "textColor");
|
||||
}
|
||||
|
||||
@@ -69,10 +69,10 @@ export abstract class WebViewBase extends View implements WebViewDefinition {
|
||||
|
||||
abstract reload(): void;
|
||||
|
||||
get [srcProperty.native](): string {
|
||||
[srcProperty.getDefault](): string {
|
||||
return "";
|
||||
}
|
||||
set [srcProperty.native](src: string) {
|
||||
[srcProperty.setNative](src: string) {
|
||||
this.stopLoading();
|
||||
|
||||
if (isFileOrResourcePath(src)) {
|
||||
|
||||
Reference in New Issue
Block a user