Fix the last several errors

This commit is contained in:
PanayotCankov
2016-12-20 13:24:32 +02:00
parent 6122c44126
commit d10ca1da03
26 changed files with 147 additions and 158 deletions

View File

@ -9,9 +9,11 @@ export function onLoaded(args: { eventName: string, object: any }) {
}
export function onAddRowColumn(args: { eventName: string, object: any }) {
var layout = <GridLayout>args.object.parent.parent;
var row = new ItemSpec(1, GridUnitType.AUTO);
var column = new ItemSpec(1, GridUnitType.AUTO);
layout.addRow(row);
layout.addColumn(column);

View File

@ -1,4 +1,4 @@
import { LayoutBase, View, Observable, HorizontalAlignment, VerticalAlignment, Visibility} from "ui/layouts/layout-base";
import { LayoutBase, View, Observable, HorizontalAlignment, VerticalAlignment, Visibility} from "ui/layouts/layout-base";
export class ViewModel extends Observable {
@ -42,32 +42,34 @@ export class ViewModel extends Observable {
public onAlignments(args: { eventName: string, object: any }): void {
var view: View = <View>args.object;
if (view.horizontalAlignment === HorizontalAlignment.STRETCH) {
view.horizontalAlignment = HorizontalAlignment.LEFT;
view.verticalAlignment = VerticalAlignment.TOP;
} else if (view.horizontalAlignment === HorizontalAlignment.LEFT) {
view.horizontalAlignment = HorizontalAlignment.CENTER;
view.verticalAlignment = VerticalAlignment.MIDDLE;
} else if (view.horizontalAlignment === HorizontalAlignment.CENTER) {
view.horizontalAlignment = HorizontalAlignment.RIGHT;
view.verticalAlignment = VerticalAlignment.BOTTOM;
if (view.horizontalAlignment === "stretch") {
view.horizontalAlignment = "left";
view.verticalAlignment = "top";
} else if (view.horizontalAlignment === "left") {
view.horizontalAlignment = "center";
view.verticalAlignment = "middle";
} else if (view.horizontalAlignment === "center") {
view.horizontalAlignment = "right";
view.verticalAlignment = "bottom";
} else {
view.horizontalAlignment = HorizontalAlignment.STRETCH;
view.verticalAlignment = VerticalAlignment.STRETCH;
view.horizontalAlignment = "stretch";
view.verticalAlignment = "stretch";
}
}
public onCollapse(args: { eventName: string, object: any }): void {
var view: View = <View>args.object;
view.visibility = Visibility.COLLAPSE;
view.visibility = "collapse";
}
public onVisibile(args: { eventName: string, object: any }): void {
var view: View = <View>args.object;
var layout = <LayoutBase>view.parent;
var child = <View>layout.getViewById("collapse");
child.visibility = Visibility.VISIBLE;
var child = layout.getViewById<View>("collapse");
child.visibility = "visible";
}
// Layout properties

View File

@ -9,9 +9,11 @@ export function onLoaded(args: { eventName: string, object: any }) {
}
export function onAddRowColumn(args: { eventName: string, object: any }) {
var layout = <GridLayout>args.object.parent.parent;
var row = new ItemSpec(1, GridUnitType.AUTO);
var column = new ItemSpec(1, GridUnitType.AUTO);
var row = new ItemSpec(1, "auto");
var column = new ItemSpec(1, "auto");
layout.addRow(row);
layout.addColumn(column);

View File

@ -42,24 +42,24 @@ export class ViewModel extends Observable {
public onAlignments(args: { eventName: string, object: any }): void {
var view: View = <View>args.object;
if (view.horizontalAlignment === HorizontalAlignment.STRETCH) {
view.horizontalAlignment = HorizontalAlignment.LEFT;
view.verticalAlignment = VerticalAlignment.TOP;
} else if (view.horizontalAlignment === HorizontalAlignment.LEFT) {
view.horizontalAlignment = HorizontalAlignment.CENTER;
view.verticalAlignment = VerticalAlignment.MIDDLE;
} else if (view.horizontalAlignment === HorizontalAlignment.CENTER) {
view.horizontalAlignment = HorizontalAlignment.RIGHT;
view.verticalAlignment = VerticalAlignment.BOTTOM;
if (view.horizontalAlignment === "stretch") {
view.horizontalAlignment = "left";
view.verticalAlignment = "top";
} else if (view.horizontalAlignment === "left") {
view.horizontalAlignment = "center";
view.verticalAlignment = "middle";
} else if (view.horizontalAlignment === "center") {
view.horizontalAlignment = "right";
view.verticalAlignment = "bottom";
} else {
view.horizontalAlignment = HorizontalAlignment.STRETCH;
view.verticalAlignment = VerticalAlignment.STRETCH;
view.horizontalAlignment = "stretch";
view.verticalAlignment = "stretch";
}
}
public onCollapse(args: { eventName: string, object: any }): void {
var view: View = <View>args.object;
view.visibility = Visibility.COLLAPSE;
view.visibility = "collapse";
}
public onVisibile(args: { eventName: string, object: any }): void {
@ -67,7 +67,7 @@ export class ViewModel extends Observable {
var layout = <LayoutBase>view.parent;
var child = <View>layout.getViewById("collapse");
child.visibility = Visibility.VISIBLE;
child.visibility = "visible";
}
// Layout properties

View File

@ -7,7 +7,7 @@ import { TextView } from "ui/text-view";
var view: View;
export function navigatingTo(args: EventData) {
var page = <Page>args.object;
view = <View>page.getViewById("target");
view = page.getViewById<View>("target");
}
export function onPan(data: PanGestureEventData) {

View File

@ -7,7 +7,9 @@ let iconModes = ["automatic", "alwaysOriginal", "alwaysTemplate", undefined];
export function onChangeRenderingMode(args: EventData){
let button = (<Button>args.object);
let tabView = button.page.getViewById<TabView>("tab-view");
tabView.iosIconRenderingMode = <"automatic" | "alwaysOriginal" | "alwaysTemplate">iconModes[(iconModes.indexOf(tabView.iosIconRenderingMode) + 1) % iconModes.length];
for(let i = 0, length = tabView.items.length; i < length; i++){
(<Button>tabView.items[i].view).text = "" + tabView.iosIconRenderingMode;
}

View File

@ -31,7 +31,7 @@
"time-grunt": "1.3.0",
"tslint": "^3.15.1",
"typedoc": "0.4.5",
"typescript": "~2.0.10"
"typescript": "^2.0.10"
},
"scripts": {
"setup": "npm run dev-link-tns-platform-declarations && npm run dev-link-tns-core-modules && npm run dev-link-tests && npm run dev-link-apps",

View File

@ -1,6 +1,5 @@
import * as style from "ui/styling/style";
import {PropertyMetadata, PropertyMetadataSettings} from "ui/core/dependency-observable";
import * as styleProperty from "ui/styling/style-property";
import * as view from "ui/core/view";
import * as buttonModule from "ui/button";
import * as pages from "ui/page";
@ -10,46 +9,46 @@ import {isAndroid} from "platform";
// on Android we explicitly set propertySettings to None because android will invalidate its layout (skip unnecessary native call).
let AffectsLayout = isAndroid ? PropertyMetadataSettings.None : PropertyMetadataSettings.AffectsLayout;
export var fontFamilyProperty = new styleProperty.Property("fontFamily", "font-family", new PropertyMetadata(undefined, AffectsLayout));
// export var fontFamilyProperty = new styleProperty.Property("fontFamily", "font-family", new PropertyMetadata(undefined, AffectsLayout));
export class MyTextViewStyler implements style.Styler {
public static setFontFamilyProperty(view: view.View, newValue: any) {
if (view.android) {
(<android.widget.TextView>view.android).setTypeface(android.graphics.Typeface.create(newValue, android.graphics.Typeface.NORMAL));
}
else if (view.ios) {
var fontSize = (<UIButton>view._nativeView).titleLabel.font.pointSize;
(<UIButton>view._nativeView).titleLabel.font = UIFont.fontWithNameSize(newValue, fontSize);
}
}
// export class MyTextViewStyler implements style.Styler {
// public static setFontFamilyProperty(view: view.View, newValue: any) {
// if (view.android) {
// (<android.widget.TextView>view.android).setTypeface(android.graphics.Typeface.create(newValue, android.graphics.Typeface.NORMAL));
// }
// else if (view.ios) {
// var fontSize = (<UIButton>view._nativeView).titleLabel.font.pointSize;
// (<UIButton>view._nativeView).titleLabel.font = UIFont.fontWithNameSize(newValue, fontSize);
// }
// }
public static resetFontFamilyProperty(view: view.View, nativeValue: any) {
if (view.android) {
(<android.widget.TextView>view.android).setTypeface(android.graphics.Typeface.create(nativeValue, android.graphics.Typeface.NORMAL));
}
else if (view.ios) {
var fontSize = (<UIButton>view._nativeView).titleLabel.font.pointSize;
(<UIButton>view._nativeView).titleLabel.font = UIFont.fontWithNameSize(nativeValue, fontSize);;
}
}
// public static resetFontFamilyProperty(view: view.View, nativeValue: any) {
// if (view.android) {
// (<android.widget.TextView>view.android).setTypeface(android.graphics.Typeface.create(nativeValue, android.graphics.Typeface.NORMAL));
// }
// else if (view.ios) {
// var fontSize = (<UIButton>view._nativeView).titleLabel.font.pointSize;
// (<UIButton>view._nativeView).titleLabel.font = UIFont.fontWithNameSize(nativeValue, fontSize);;
// }
// }
public static getNativeFontFamilyValue = function (view: view.View): any {
if (view.android) {
return (<android.widget.TextView>view.android).getTypeface();
}
else if (view.ios) {
return (<UIButton>view._nativeView).titleLabel.font.fontName;
}
return null;
}
// public static getNativeFontFamilyValue = function (view: view.View): any {
// if (view.android) {
// return (<android.widget.TextView>view.android).getTypeface();
// }
// else if (view.ios) {
// return (<UIButton>view._nativeView).titleLabel.font.fontName;
// }
// return null;
// }
public static registerHandlers() {
style.registerHandler(fontFamilyProperty, new style.StylePropertyChangedHandler(
MyTextViewStyler.setFontFamilyProperty,
MyTextViewStyler.resetFontFamilyProperty,
MyTextViewStyler.getNativeFontFamilyValue), "MyButton");
}
}
// public static registerHandlers() {
// style.registerHandler(fontFamilyProperty, new style.StylePropertyChangedHandler(
// MyTextViewStyler.setFontFamilyProperty,
// MyTextViewStyler.resetFontFamilyProperty,
// MyTextViewStyler.getNativeFontFamilyValue), "MyButton");
// }
// }
//export class MyStyle extends styles.Style {
// get fontFamily(): string {
@ -75,7 +74,7 @@ export class MyButton extends buttonModule.Button {
}
MyTextViewStyler.registerHandlers();
// MyTextViewStyler.registerHandlers();
export function createPage() {
var stackLayout = new stackLayoutDef.StackLayout();

View File

@ -1,5 +1,6 @@
import * as stack from "ui/layouts/stack-layout";
import * as style from "ui/styling/style";
import {unsetValue} from "ui/core/view";
export function buttonTap(args) {
var stackLayout = <stack.StackLayout>args.object.parent;

View File

@ -23,7 +23,7 @@ export function createPage() {
return page;
}
function addButton(layout: layout.StackLayout, text: "left" | "center" | "middle" | "right" | "stretch") {
function addButton(layout: layout.StackLayout, text: "left" | "center" | "right" | "stretch") {
var btn = new btns.Button();
btn.text = text;
btn.horizontalAlignment = text;

View File

@ -17,7 +17,7 @@ export function createPage() {
var btn2 = new buttonModule.Button();
btn2.horizontalAlignment = "center";
btn2.verticalAlignment = "center";
btn2.verticalAlignment = "middle";
btn2.text = "center, center";
var btn3 = new buttonModule.Button();

View File

@ -1,5 +1,6 @@
import * as pages from "ui/page";
import * as buttons from "ui/button";
import { VerticalAlignment } from "ui/core/view";
export function createPage() {
var page = new pages.Page();
@ -9,7 +10,7 @@ export function createPage() {
btn.height = 60;
btn.text = "test";
var vAligns = ["stretch", "top", "center", "bottom"];
var vAligns: VerticalAlignment[] = ["stretch", "top", "middle", "bottom"];
//var hAligns = ["stretch", "left", "center", "right"];
var count = 0;
btn.on(buttons.Button.tapEvent, function () {

View File

@ -308,7 +308,7 @@ export function test_AnimationCurveInKeyframes() {
TKUnit.assertEqual(animation.keyframes[0].curve, enums.AnimationCurve.linear);
TKUnit.assertEqual(animation.keyframes[1].curve, undefined);
TKUnit.assertEqual(animation.keyframes[1].curve, undefined);
let realAnimation = keyframeAnimation.KeyframeAnimation.keyframeAnimationFromInfo(animation, 2);
let realAnimation = keyframeAnimation.KeyframeAnimation.keyframeAnimationFromInfo(animation);
TKUnit.assertEqual(realAnimation.animations[1].curve, enums.AnimationCurve.linear);
TKUnit.assertEqual(realAnimation.animations[2].curve, enums.AnimationCurve.easeIn);
}

View File

@ -28,7 +28,6 @@ export var test_Bindable_Members = function () {
var obj = new bindable.Bindable();
TKUnit.assert(types.isDefined(obj.bind), "Bindable.bind not defined");
TKUnit.assert(types.isDefined(obj.unbind), "Bindable.unbind not defined");
TKUnit.assert(types.isDefined(obj._updateTwoWayBinding), "Bindable.updateTwoWayBinding not defined");
}
export var test_Bindable_Bind_ToTarget_OneWay = function () {
@ -155,7 +154,6 @@ export var test_bindingContext_ValueSource_IsInherited = function () {
var context = {};
views[0].bindingContext = context;
TKUnit.assert(views[1].bindingContext === context, "bindingContext not inherited.");
TKUnit.assert(views[1]._getValueSource(bindable.Bindable.bindingContextProperty) === dependencyObservableModule.ValueSource.Inherited, "bindingContext should be propagated as Inherited.");
}
helper.do_PageTest_WithButton(test);

View File

@ -235,7 +235,7 @@ var _testNativeBackgroundColorFromLocal = function (views: Array<viewModule.View
TKUnit.assert(actualResult === expectedBackgroundColorHex, "Actual: " + actualResult + "; Expected: " + expectedBackgroundColorHex);
}
var expectedTextAlignment = enums.TextAlignment.right;
var expectedTextAlignment: "right" = "right";
export var testLocalTextAlignmentFromCss = function () {
helper.buildUIAndRunTest(_createButtonFunc(), function (views: Array<viewModule.View>) {
var view = <buttonModule.Button>views[0];

View File

@ -101,7 +101,7 @@ export function percent_support_children_test(test: testModule.UITest<LayoutBase
TKUnit.assertEqual(bounds.bottom, 120, "TopLeft layout BOTTOM incorrect");
btn.horizontalAlignment = "center";
btn.verticalAlignment = "center";
btn.verticalAlignment = "middle";
test.waitUntilTestElementLayoutIsValid();
bounds = btn._getCurrentLayoutBounds();

View File

@ -10,7 +10,7 @@ import {
} from "ui/layouts/flexbox-layout";
// << flexbox-layout-require
import {View, unsetValue} from "ui/core/view";
import {View, unsetValue, Length} from "ui/core/view";
import {Label} from "ui/label";
import * as TKUnit from "../../TKUnit";
import * as helper from "../helper";
@ -494,8 +494,8 @@ export const testJustifyContent_flexStart_withParentPadding = test(
({root, flexbox, text1, text2, text3}) => {
isRightOf(text2, text1);
isRightOf(text3, text2);
equal(left(text1), dipToDp(flexbox.style.paddingLeft.value), `Expected ${text1}.left to equal ${flexbox}.paddingLeft`);
equal(top(text1), dipToDp(flexbox.style.paddingTop.value), `Expected ${text1}.top to equal ${flexbox}.paddingTop`);
equal(left(text1), Length.toDevicePixels(flexbox.style.paddingLeft, 0), `Expected ${text1}.left to equal ${flexbox}.paddingLeft`);
equal(top(text1), Length.toDevicePixels(flexbox.style.paddingTop, 0), `Expected ${text1}.top to equal ${flexbox}.paddingTop`);
}
);
@ -516,8 +516,8 @@ export const testJustifyContent_flexEnd_withParentPadding = test(
({root, flexbox, text1, text2, text3}) => {
isLeftOf(text2, text3);
isLeftOf(text1, text2);
closeEnough(width(flexbox) - right(text3), dipToDp(flexbox.style.paddingRight.value));
closeEnough(top(text3), dipToDp(flexbox.style.paddingTop.value));
closeEnough(width(flexbox) - right(text3), Length.toDevicePixels(flexbox.style.paddingRight, 0));
closeEnough(top(text3), Length.toDevicePixels(flexbox.style.paddingTop, 0));
}
);
@ -544,10 +544,10 @@ export const testJustifyContent_center_withParentPadding = test(
({root, flexbox, text1, text2, text3}) => {
isRightOf(text2, text1);
isRightOf(text3, text2);
let space = width(flexbox) - width(text1) - width(text2) - width(text3) - dipToDp(flexbox.style.paddingLeft.value) - dipToDp(flexbox.style.paddingRight.value);
let space = width(flexbox) - width(text1) - width(text2) - width(text3) - Length.toDevicePixels(flexbox.style.paddingLeft, 0) - Length.toDevicePixels(flexbox.style.paddingRight, 0);
space = space / 2;
check(space - 1 <= left(text1) - dipToDp(flexbox.style.paddingLeft.value) && left(text1) - dipToDp(flexbox.style.paddingLeft.value) <= space + 1);
check(space - 1 <= width(flexbox) - right(text3) - dipToDp(flexbox.style.paddingRight.value) && width(flexbox) - right(text3) - dipToDp(flexbox.style.paddingRight.value) <= space + 1);
check(space - 1 <= left(text1) - Length.toDevicePixels(flexbox.style.paddingLeft, 0) && left(text1) - Length.toDevicePixels(flexbox.style.paddingLeft, 0) <= space + 1);
check(space - 1 <= width(flexbox) - right(text3) - Length.toDevicePixels(flexbox.style.paddingRight, 0) && width(flexbox) - right(text3) - Length.toDevicePixels(flexbox.style.paddingRight, 0) <= space + 1);
}
);
@ -870,7 +870,7 @@ export const testAlignContent_flexEnd_parentPadding = test(
isAbove(text1, text3);
isAbove(text2, text3);
closeEnough(bottom(text3), height(flexbox) - dipToDp(flexbox.style.paddingBottom.value));
closeEnough(bottom(text3), height(flexbox) - Length.toDevicePixels(flexbox.style.paddingBottom, 0));
}
);
@ -886,7 +886,7 @@ export const testAlignContent_flexEnd_parentPadding_column = test(
isLeftOf(text2, text3);
let { bounds1, bounds2 } = comparableBounds(text3, flexbox);
closeEnough(bounds1.right, bounds2.right - dipToDp(flexbox.style.paddingRight.value));
closeEnough(bounds1.right, bounds2.right - Length.toDevicePixels(flexbox.style.paddingRight, 0));
}
);
@ -1249,8 +1249,8 @@ export const testAlignItems_flexEnd_parentPadding = test(
({flexbox}) => flexbox.alignItems = AlignItems.FLEX_END,
({root, flexbox, text1, text2, text3}) => {
isRightOf(text2, text1);
closeEnough(bottom(text1), height(flexbox) - dipToDp(flexbox.style.paddingBottom.value));
closeEnough(bottom(text2), height(flexbox) - dipToDp(flexbox.style.paddingBottom.value));
closeEnough(bottom(text1), height(flexbox) - Length.toDevicePixels(flexbox.style.paddingBottom, 0));
closeEnough(bottom(text2), height(flexbox) - Length.toDevicePixels(flexbox.style.paddingBottom, 0));
}
);
@ -1262,8 +1262,8 @@ export const testAlignItems_flexEnd_parentPadding_column = test(
},
({root, flexbox, text1, text2, text3}) => {
isBelow(text2, text1);
closeEnough(right(text1), width(flexbox) - dipToDp(flexbox.style.paddingRight.value));
closeEnough(right(text2), width(flexbox) - dipToDp(flexbox.style.paddingRight.value));
closeEnough(right(text1), width(flexbox) - Length.toDevicePixels(flexbox.style.paddingRight, 0));
closeEnough(right(text2), width(flexbox) - Length.toDevicePixels(flexbox.style.paddingRight, 0));
}
);
@ -1808,7 +1808,7 @@ export const testWrap_parentPadding_horizontal = test(
({flexbox, text1, text2, text3}) => {
isBelow(text2, text1);
isRightOf(text3, text2);
closeEnough(height(flexbox), dipToDp(flexbox.style.paddingTop.value) + dipToDp(flexbox.style.paddingBottom.value) + height(text1) + height(text2));
closeEnough(height(flexbox), Length.toDevicePixels(flexbox.style.paddingTop, 0) + Length.toDevicePixels(flexbox.style.paddingBottom, 0) + height(text1) + height(text2));
}
);
@ -1826,7 +1826,7 @@ export const testWrap_parentPadding_vertical = test(
({flexbox, text1, text2, text3}) => {
isRightOf(text2, text1);
isBelow(text3, text2);
closeEnough(width(flexbox), dipToDp(flexbox.style.paddingLeft.value) + dipToDp(flexbox.style.paddingRight.value) + width(text1) + width(text2));
closeEnough(width(flexbox), Length.toDevicePixels(flexbox.style.paddingLeft, 0) + Length.toDevicePixels(flexbox.style.paddingRight, 0) + width(text1) + width(text2));
}
);
@ -1844,7 +1844,7 @@ export const testWrap_childMargin_horizontal = test(
({flexbox, text1, text2, text3}) => {
isBelow(text2, text1);
isRightOf(text3, text2);
closeEnough(height(flexbox), height(text1) + height(text2) + dipToDp(text2.style.marginTop.value) + dipToDp(text2.style.marginBottom.value));
closeEnough(height(flexbox), height(text1) + height(text2) + Length.toDevicePixels(text2.style.marginTop, 0) + Length.toDevicePixels(text2.style.marginBottom, 0));
}
);
@ -1907,7 +1907,7 @@ export const testWrap_childMargin_vertical = test(
isRightOf(text2, text1);
isBelow(text3, text2);
// dips anyone?
closeEnough(width(flexbox), width(text1) + width(text2) + dipToDp(text2.marginLeft.value) + dipToDp(text2.marginRight.value));
closeEnough(width(flexbox), width(text1) + width(text2) + Length.toDevicePixels(text2.marginLeft, 0) + Length.toDevicePixels(text2.marginRight, 0));
}
);

View File

@ -219,7 +219,7 @@ export class StackLayoutTest extends testModule.UITest<StackLayout> {
TKUnit.assertEqual(bounds.bottom, 120, "TopLeft layout BOTTOM incorrect");
btn.horizontalAlignment = "center";
btn.verticalAlignment = "center";
btn.verticalAlignment = "middle";
this.waitUntilTestElementLayoutIsValid();
bounds = btn._getCurrentLayoutBounds();
@ -264,7 +264,7 @@ export class StackLayoutTest extends testModule.UITest<StackLayout> {
TKUnit.assertEqual(bounds.bottom, 120, "TopLeft layout BOTTOM incorrect");
btn.horizontalAlignment = "center";
btn.verticalAlignment = "center";
btn.verticalAlignment = "middle";
this.waitUntilTestElementLayoutIsValid();
bounds = btn._getCurrentLayoutBounds();

View File

@ -289,7 +289,7 @@ export class WrapLayoutTest extends testModule.UITest<wrapLayoutModule.WrapLayou
TKUnit.assertEqual(bounds.bottom, 120, "TopLeft layout BOTTOM incorrect");
btn.horizontalAlignment = "center";
btn.verticalAlignment = "center";
btn.verticalAlignment = "middle";
this.waitUntilTestElementLayoutIsValid();
bounds = btn._getCurrentLayoutBounds();

View File

@ -57,7 +57,6 @@ export class ListViewTest extends testModule.UITest<listViewModule.ListView> {
var listView = new listViewModule.ListView();
// << article-create-listview
TKUnit.assertEqual(listView.isScrolling, false, "Default listView.isScrolling");
TKUnit.assert(types.isUndefined(listView.items), "Default listView.items should be undefined");
}

View File

@ -609,36 +609,6 @@ function testButtonPressedStateIsRed(btn: buttonModule.Button) {
TKUnit.assert(btn.style.color === undefined, "Color should not have a value after returned to normal state.");
}
export function test_styling_converters_are_defined() {
TKUnit.assert(types.isDefined(styling.converters), "converters module is not defined");
TKUnit.assert(types.isFunction(styling.converters.colorConverter), "colorConverter function is not defined");
TKUnit.assert(types.isFunction(styling.converters.fontSizeConverter), "fontSizeConverter function is not defined");
TKUnit.assert(types.isFunction(styling.converters.textAlignConverter), "textAlignConverter function is not defined");
}
export function test_styling_properties_are_defined() {
TKUnit.assert(types.isDefined(styling.properties), "properties module is not defined");
TKUnit.assert(types.isDefined(styling.properties.backgroundColorProperty), "backgroundColorProperty property is not defined");
TKUnit.assert(types.isDefined(styling.properties.colorProperty), "colorProperty property is not defined");
TKUnit.assert(types.isDefined(styling.properties.fontSizeProperty), "fontSizeProperty property is not defined");
TKUnit.assert(types.isDefined(styling.properties.textAlignmentProperty), "textAlignmentProperty property is not defined");
TKUnit.assert(types.isFunction(styling.properties.eachInheritableProperty), "properties.eachInheritableProperty function is not defined");
TKUnit.assert(types.isFunction(styling.properties.eachProperty), "properties.eachProperty function is not defined");
TKUnit.assert(types.isFunction(styling.properties.getPropertyByCssName), "properties.getPropertyByCssName function is not defined");
TKUnit.assert(types.isFunction(styling.properties.getPropertyByName), "properties.getPropertyByName function is not defined");
}
export function test_styling_stylers_are_defined() {
TKUnit.assert(types.isFunction(styleModule.registerHandler), "registerHandler function is not defined");
TKUnit.assert(types.isFunction(styleModule.StylePropertyChangedHandler), "StylePropertyChangedHandler class is not defined");
}
export function test_styling_classes_are_defined() {
TKUnit.assert(types.isFunction(styling.Style), "Style class is not defined");
TKUnit.assert(types.isFunction(styling.Property), "Property class is not defined");
}
export function test_setInlineStyle_setsLocalValues() {
var testButton = new buttonModule.Button();
testButton.text = "Test";
@ -647,7 +617,7 @@ export function test_setInlineStyle_setsLocalValues() {
helper.buildUIAndRunTest(stack, function (views: Array<viewModule.View>) {
(<any>testButton)._applyInlineStyle("color: red;");
helper.assertViewColor(testButton, "#FF0000", dependencyObservableModule.ValueSource.Local);
helper.assertViewColor(testButton, "#FF0000");
});
}

View File

@ -642,8 +642,8 @@ export var testIsVisible = function () {
TKUnit.assertEqual(lbl.visibility, "collapse");
TKUnit.assertEqual(lbl.isCollapsed, true);
lbl.visibility = "collapsed";
TKUnit.assertEqual(lbl.visibility, "collapsed");
lbl.visibility = "collapse";
TKUnit.assertEqual(lbl.visibility, "collapse");
TKUnit.assertEqual(lbl.isCollapsed, true);
});
}

View File

@ -25,6 +25,7 @@ import * as platform from "platform";
import * as gesturesModule from "ui/gestures";
import * as segmentedBar from "ui/segmented-bar";
import { Source } from "utils/debug";
import { PercentLength } from "ui/core/view";
export function test_load_IsDefined() {
TKUnit.assertTrue(types.isFunction(builder.load), "ui/builder should have load method!");
@ -307,8 +308,7 @@ export function test_parse_ShouldSetCanvasAttachedProperties() {
export function test_parse_ShouldParseNumberProperties() {
var p = <Page>builder.parse("<Page width='100' />");
TKUnit.assertEqual(p.width.value, 100);
TKUnit.assertEqual(p.width.unit, "dip");
TKUnit.assertTrue(PercentLength.equals(p.width, 100));
};
export function test_parse_ShouldParseBooleanProperties() {
@ -451,7 +451,7 @@ export function test_parse_ShouldParseSubProperties() {
p.bindingContext = obj;
var sw = <switchModule.Switch>p.content;
TKUnit.assert(sw.visibility === "collapsed", "Expected result: collapsed; Actual result: " + sw.visibility + "; type: " + typeof (sw.visibility));
TKUnit.assert(sw.visibility === "collapse", "Expected result: collapsed; Actual result: " + sw.visibility + "; type: " + typeof (sw.visibility));
};
export function test_parse_ShouldParseBindingToSpecialProperty() {

View File

@ -965,17 +965,17 @@ function updateChildLayoutParams(child: ViewCommon, parent: ViewCommon, density:
let parentWidthMeasureSize = layout.getMeasureSpecSize(parentWidthMeasureSpec);
let parentWidthMeasureMode = layout.getMeasureSpecMode(parentWidthMeasureSpec);
let parentAvailableWidth = parentWidthMeasureMode === layout.UNSPECIFIED ? -1 : parentWidthMeasureSize;
style.effectiveWidth = PercentLength.toDevicePixels(style.width, parentAvailableWidth)
style.effectiveMarginLeft = PercentLength.toDevicePixels(style.marginLeft, parentAvailableWidth);
style.effectiveMarginRight = PercentLength.toDevicePixels(style.marginRight, parentAvailableWidth);
style.effectiveWidth = PercentLength.toDevicePixels(style.width, -2, parentAvailableWidth)
style.effectiveMarginLeft = PercentLength.toDevicePixels(style.marginLeft, 0, parentAvailableWidth);
style.effectiveMarginRight = PercentLength.toDevicePixels(style.marginRight, 0, parentAvailableWidth);
let parentHeightMeasureSpec = parent._currentHeightMeasureSpec;
let parentHeightMeasureSize = layout.getMeasureSpecSize(parentHeightMeasureSpec);
let parentHeightMeasureMode = layout.getMeasureSpecMode(parentHeightMeasureSpec);
let parentAvailableHeight = parentHeightMeasureMode === layout.UNSPECIFIED ? -1 : parentHeightMeasureSize;
style.effectiveHeight = PercentLength.toDevicePixels(style.height, parentAvailableHeight);
style.effectiveMarginTop = PercentLength.toDevicePixels(style.marginTop, parentAvailableHeight);
style.effectiveMarginBottom = PercentLength.toDevicePixels(style.marginBottom, parentAvailableHeight);
style.effectiveHeight = PercentLength.toDevicePixels(style.height, -2, parentAvailableHeight);
style.effectiveMarginTop = PercentLength.toDevicePixels(style.marginTop, 0, parentAvailableHeight);
style.effectiveMarginBottom = PercentLength.toDevicePixels(style.marginBottom, 0, parentAvailableHeight);
}
function equalsCommon(a: Length, b: Length): boolean;
@ -1066,7 +1066,7 @@ export namespace PercentLength {
}
}
export const equals: { (a: PercentLength, b: PercentLength): boolean } = equalsCommon;
export const toDevicePixels: { (length: PercentLength, parentAvailableWidth: number): number } = toDevicePixelsCommon;
export const toDevicePixels: { (length: PercentLength, auto: number, parentAvailableWidth: number): number } = toDevicePixelsCommon;
}
export type Length = "auto" | number | {

View File

@ -102,6 +102,12 @@ declare module "ui/core/view" {
export namespace Length {
export function parse(text: string): Length;
export function equals(a: Length, b: Length): boolean;
/**
* Converts Length unit to device pixels.
* @param length The PercentLength to convert.
* @param auto Value to use for conversion of "auto".
*/
export function toDevicePixels(length: PercentLength, auto: number): number;
}
export type PercentLength = "auto" | number | {
@ -111,6 +117,13 @@ declare module "ui/core/view" {
export namespace PercentLength {
export function parse(text: string): PercentLength;
export function equals(a: PercentLength, b: PercentLength): boolean;
/**
* Converts PercentLength unit to device pixels.
* @param length The PercentLength to convert.
* @param auto Value to use for conversion of "auto".
* @param parentAvailableWidth Value to use as base when converting percent unit.
*/
export function toDevicePixels(length: PercentLength, auto: number, parentAvailableWidth: number): number;
}
/**
@ -604,15 +617,15 @@ declare module "ui/core/view" {
// _onStylePropertyChanged(property: dependencyObservable.Property): void;
//@endprivate
// /**
// * __Obsolete:__ There is a new property system that does not rely on _getValue.
// */
// public _getValue(property: any): never;
/**
* __Obsolete:__ There is a new property system that does not rely on _getValue.
*/
public _getValue(property: any): never;
// /**
// * __Obsolete:__ There is a new property system that does not rely on _setValue.
// */
// public _setValue(property: any, value: any): never;
/**
* __Obsolete:__ There is a new property system that does not rely on _setValue.
*/
public _setValue(property: any, value: any): never;
}
/**

View File

@ -93,7 +93,7 @@ declare module "ui/core/view-base" {
public onLoaded(): void;
public onUnloaded(): void;
public bind(options: BindingOptions, source: Object): void;
public bind(options: BindingOptions, source?: Object): void;
public unbind(property: string): void;
public requestLayout(): void;