Merge pull request #3342 from NativeScript/fixes

Fixes
This commit is contained in:
Rossen Hristov
2016-12-21 17:08:59 +02:00
committed by GitHub
9 changed files with 138 additions and 31 deletions

View File

@@ -1557,7 +1557,7 @@ function isNonNegativeFiniteNumberConverter(value: string): number {
}
function parseBorderColor(value: string): { top: Color, right: Color, bottom: Color, left: Color } {
let result: { top: Color, right: Color, bottom: Color, left: Color };
let result: { top: Color, right: Color, bottom: Color, left: Color } = { top: undefined, right: undefined, bottom: undefined, left: undefined };
if (value.indexOf("rgb") === 0) {
result.top = result.right = result.bottom = result.left = new Color(value);
return result;
@@ -1599,8 +1599,9 @@ function parseBorderColor(value: string): { top: Color, right: Color, bottom: Co
result.left = arr3;
}
else {
throw new Error("Expected 1, 2, 3 or 4 parameters. Actual: " + value);
throw new Error(`Expected 1, 2, 3 or 4 parameters. Actual: ${value}`);
}
return result;
}
// Border Color properties.

View File

@@ -4,7 +4,6 @@ import {
ViewCommon, layout, isEnabledProperty, originXProperty, originYProperty, automationTextProperty, isUserInteractionEnabledProperty, visibilityProperty, opacityProperty, minWidthProperty, minHeightProperty,
widthProperty, heightProperty, marginLeftProperty, marginTopProperty,
marginRightProperty, marginBottomProperty, horizontalAlignmentProperty, verticalAlignmentProperty,
paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty,
rotateProperty, scaleXProperty, scaleYProperty,
translateXProperty, translateYProperty, zIndexProperty, backgroundInternalProperty,
Background, GestureTypes, GestureEventData, applyNativeSetters, Property,
@@ -584,30 +583,6 @@ createNativePercentLengthProperty({
setPercent: ViewHelper.setMarginLeftPercent
});
createNativePercentLengthProperty({
key: paddingTopProperty.native,
getPixels: ViewHelper.getPaddingTop,
setPixels: ViewHelper.setPaddingTop
});
createNativePercentLengthProperty({
key: paddingRightProperty.native,
getPixels: ViewHelper.getPaddingRight,
setPixels: ViewHelper.setPaddingRight
});
createNativePercentLengthProperty({
key: paddingBottomProperty.native,
getPixels: ViewHelper.getPaddingBottom,
setPixels: ViewHelper.setPaddingBottom
});
createNativePercentLengthProperty({
key: paddingLeftProperty.native,
getPixels: ViewHelper.getPaddingLeft,
setPixels: ViewHelper.setPaddingLeft
});
createNativePercentLengthProperty({
key: widthProperty.native,
auto: android.view.ViewGroup.LayoutParams.MATCH_PARENT,

View File

@@ -1,4 +1,7 @@
import { LayoutBaseCommon, clipToBoundsProperty } from "./layout-base-common";
import {
LayoutBaseCommon, clipToBoundsProperty,
paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, Length, layout
} from "./layout-base-common";
export * from "./layout-base-common";
@@ -21,4 +24,37 @@ export class LayoutBase extends LayoutBaseCommon {
// http://stackoverflow.com/questions/25044085/when-drawing-outside-the-view-clip-bounds-with-android-how-do-i-prevent-underli
console.warn(`clipToBounds with value false is not supported on Android. You can use this.android.getParent().setClipChildren(false) as an alternative`);
}
//PaddingTop
get [paddingTopProperty.native](): Length {
return { value: org.nativescript.widgets.ViewHelper.getPaddingTop(this.nativeView), unit: "px" };
}
set [paddingTopProperty.native](value: Length) {
org.nativescript.widgets.ViewHelper.setPaddingTop(this.nativeView, Length.toDevicePixels(value, 0) + this.style.effectiveBorderTopWidth);
}
//PaddingRight
get [paddingRightProperty.native](): Length {
return { value: org.nativescript.widgets.ViewHelper.getPaddingRight(this.nativeView), unit: "px" };
}
set [paddingRightProperty.native](value: Length) {
org.nativescript.widgets.ViewHelper.setPaddingRight(this.nativeView, Length.toDevicePixels(value, 0) + this.style.effectiveBorderRightWidth);
}
//PaddingBottom
get [paddingBottomProperty.native](): Length {
return { value: org.nativescript.widgets.ViewHelper.getPaddingBottom(this.nativeView), unit: "px" };
}
set [paddingBottomProperty.native](value: Length) {
org.nativescript.widgets.ViewHelper.setPaddingBottom(this.nativeView, Length.toDevicePixels(value, 0) + this.style.effectiveBorderBottomWidth);
}
//PaddingLeft
get [paddingLeftProperty.native](): Length {
return { value: org.nativescript.widgets.ViewHelper.getPaddingLeft(this.nativeView), unit: "px" };
}
set [paddingLeftProperty.native](value: Length) {
org.nativescript.widgets.ViewHelper.setPaddingLeft(this.nativeView, Length.toDevicePixels(value, 0) + this.style.effectiveBorderLeftWidth);
}
}

View File

@@ -1,7 +1,8 @@
import {
TextBaseCommon, textProperty, formattedTextProperty, textAlignmentProperty, textDecorationProperty,
textTransformProperty, letterSpacingProperty, colorProperty, fontInternalProperty, whiteSpaceProperty,
Font, Color, FormattedString, TextDecoration, TextAlignment, TextTransform, WhiteSpace
Font, Color, FormattedString, TextDecoration, TextAlignment, TextTransform, WhiteSpace,
paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, Length, layout
} from "./text-base-common";
export * from "./text-base-common";
@@ -187,6 +188,38 @@ export class TextBase extends TextBaseCommon {
set [letterSpacingProperty.native](value: number) {
org.nativescript.widgets.ViewHelper.setLetterspacing(this._nativeView, value);
}
//PaddingTop
get [paddingTopProperty.native](): Length {
return { value: org.nativescript.widgets.ViewHelper.getPaddingTop(this.nativeView), unit: "px" };
}
set [paddingTopProperty.native](value: Length) {
org.nativescript.widgets.ViewHelper.setPaddingTop(this.nativeView, Length.toDevicePixels(value, 0) + this.style.effectiveBorderTopWidth);
}
//PaddingRight
get [paddingRightProperty.native](): Length {
return { value: org.nativescript.widgets.ViewHelper.getPaddingRight(this.nativeView), unit: "px" };
}
set [paddingRightProperty.native](value: Length) {
org.nativescript.widgets.ViewHelper.setPaddingRight(this.nativeView, Length.toDevicePixels(value, 0) + this.style.effectiveBorderRightWidth);
}
//PaddingBottom
get [paddingBottomProperty.native](): Length {
return { value: org.nativescript.widgets.ViewHelper.getPaddingBottom(this.nativeView), unit: "px" };
}
set [paddingBottomProperty.native](value: Length) {
org.nativescript.widgets.ViewHelper.setPaddingBottom(this.nativeView, Length.toDevicePixels(value, 0) + this.style.effectiveBorderBottomWidth);
}
//PaddingLeft
get [paddingLeftProperty.native](): Length {
return { value: org.nativescript.widgets.ViewHelper.getPaddingLeft(this.nativeView), unit: "px" };
}
set [paddingLeftProperty.native](value: Length) {
org.nativescript.widgets.ViewHelper.setPaddingLeft(this.nativeView, Length.toDevicePixels(value, 0) + this.style.effectiveBorderLeftWidth);
}
}
@Interfaces([android.text.method.TransformationMethod])