mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
Fix the last several errors
This commit is contained in:
@ -9,9 +9,11 @@ export function onLoaded(args: { eventName: string, object: any }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function onAddRowColumn(args: { eventName: string, object: any }) {
|
export function onAddRowColumn(args: { eventName: string, object: any }) {
|
||||||
|
|
||||||
var layout = <GridLayout>args.object.parent.parent;
|
var layout = <GridLayout>args.object.parent.parent;
|
||||||
var row = new ItemSpec(1, GridUnitType.AUTO);
|
var row = new ItemSpec(1, GridUnitType.AUTO);
|
||||||
var column = new ItemSpec(1, GridUnitType.AUTO);
|
var column = new ItemSpec(1, GridUnitType.AUTO);
|
||||||
|
|
||||||
layout.addRow(row);
|
layout.addRow(row);
|
||||||
layout.addColumn(column);
|
layout.addColumn(column);
|
||||||
|
|
||||||
|
@ -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 {
|
export class ViewModel extends Observable {
|
||||||
|
|
||||||
@ -42,32 +42,34 @@ export class ViewModel extends Observable {
|
|||||||
|
|
||||||
public onAlignments(args: { eventName: string, object: any }): void {
|
public onAlignments(args: { eventName: string, object: any }): void {
|
||||||
var view: View = <View>args.object;
|
var view: View = <View>args.object;
|
||||||
if (view.horizontalAlignment === HorizontalAlignment.STRETCH) {
|
|
||||||
view.horizontalAlignment = HorizontalAlignment.LEFT;
|
if (view.horizontalAlignment === "stretch") {
|
||||||
view.verticalAlignment = VerticalAlignment.TOP;
|
view.horizontalAlignment = "left";
|
||||||
} else if (view.horizontalAlignment === HorizontalAlignment.LEFT) {
|
view.verticalAlignment = "top";
|
||||||
view.horizontalAlignment = HorizontalAlignment.CENTER;
|
} else if (view.horizontalAlignment === "left") {
|
||||||
view.verticalAlignment = VerticalAlignment.MIDDLE;
|
view.horizontalAlignment = "center";
|
||||||
} else if (view.horizontalAlignment === HorizontalAlignment.CENTER) {
|
view.verticalAlignment = "middle";
|
||||||
view.horizontalAlignment = HorizontalAlignment.RIGHT;
|
} else if (view.horizontalAlignment === "center") {
|
||||||
view.verticalAlignment = VerticalAlignment.BOTTOM;
|
view.horizontalAlignment = "right";
|
||||||
|
view.verticalAlignment = "bottom";
|
||||||
} else {
|
} else {
|
||||||
view.horizontalAlignment = HorizontalAlignment.STRETCH;
|
view.horizontalAlignment = "stretch";
|
||||||
view.verticalAlignment = VerticalAlignment.STRETCH;
|
view.verticalAlignment = "stretch";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public onCollapse(args: { eventName: string, object: any }): void {
|
public onCollapse(args: { eventName: string, object: any }): void {
|
||||||
var view: View = <View>args.object;
|
var view: View = <View>args.object;
|
||||||
view.visibility = Visibility.COLLAPSE;
|
view.visibility = "collapse";
|
||||||
}
|
}
|
||||||
|
|
||||||
public onVisibile(args: { eventName: string, object: any }): void {
|
public onVisibile(args: { eventName: string, object: any }): void {
|
||||||
var view: View = <View>args.object;
|
var view: View = <View>args.object;
|
||||||
|
|
||||||
var layout = <LayoutBase>view.parent;
|
var layout = <LayoutBase>view.parent;
|
||||||
|
|
||||||
var child = <View>layout.getViewById("collapse");
|
var child = layout.getViewById<View>("collapse");
|
||||||
child.visibility = Visibility.VISIBLE;
|
child.visibility = "visible";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Layout properties
|
// Layout properties
|
||||||
|
@ -9,9 +9,11 @@ export function onLoaded(args: { eventName: string, object: any }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function onAddRowColumn(args: { eventName: string, object: any }) {
|
export function onAddRowColumn(args: { eventName: string, object: any }) {
|
||||||
|
|
||||||
var layout = <GridLayout>args.object.parent.parent;
|
var layout = <GridLayout>args.object.parent.parent;
|
||||||
var row = new ItemSpec(1, GridUnitType.AUTO);
|
var row = new ItemSpec(1, "auto");
|
||||||
var column = new ItemSpec(1, GridUnitType.AUTO);
|
var column = new ItemSpec(1, "auto");
|
||||||
|
|
||||||
layout.addRow(row);
|
layout.addRow(row);
|
||||||
layout.addColumn(column);
|
layout.addColumn(column);
|
||||||
|
|
||||||
|
@ -42,24 +42,24 @@ export class ViewModel extends Observable {
|
|||||||
|
|
||||||
public onAlignments(args: { eventName: string, object: any }): void {
|
public onAlignments(args: { eventName: string, object: any }): void {
|
||||||
var view: View = <View>args.object;
|
var view: View = <View>args.object;
|
||||||
if (view.horizontalAlignment === HorizontalAlignment.STRETCH) {
|
if (view.horizontalAlignment === "stretch") {
|
||||||
view.horizontalAlignment = HorizontalAlignment.LEFT;
|
view.horizontalAlignment = "left";
|
||||||
view.verticalAlignment = VerticalAlignment.TOP;
|
view.verticalAlignment = "top";
|
||||||
} else if (view.horizontalAlignment === HorizontalAlignment.LEFT) {
|
} else if (view.horizontalAlignment === "left") {
|
||||||
view.horizontalAlignment = HorizontalAlignment.CENTER;
|
view.horizontalAlignment = "center";
|
||||||
view.verticalAlignment = VerticalAlignment.MIDDLE;
|
view.verticalAlignment = "middle";
|
||||||
} else if (view.horizontalAlignment === HorizontalAlignment.CENTER) {
|
} else if (view.horizontalAlignment === "center") {
|
||||||
view.horizontalAlignment = HorizontalAlignment.RIGHT;
|
view.horizontalAlignment = "right";
|
||||||
view.verticalAlignment = VerticalAlignment.BOTTOM;
|
view.verticalAlignment = "bottom";
|
||||||
} else {
|
} else {
|
||||||
view.horizontalAlignment = HorizontalAlignment.STRETCH;
|
view.horizontalAlignment = "stretch";
|
||||||
view.verticalAlignment = VerticalAlignment.STRETCH;
|
view.verticalAlignment = "stretch";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public onCollapse(args: { eventName: string, object: any }): void {
|
public onCollapse(args: { eventName: string, object: any }): void {
|
||||||
var view: View = <View>args.object;
|
var view: View = <View>args.object;
|
||||||
view.visibility = Visibility.COLLAPSE;
|
view.visibility = "collapse";
|
||||||
}
|
}
|
||||||
|
|
||||||
public onVisibile(args: { eventName: string, object: any }): void {
|
public onVisibile(args: { eventName: string, object: any }): void {
|
||||||
@ -67,7 +67,7 @@ export class ViewModel extends Observable {
|
|||||||
var layout = <LayoutBase>view.parent;
|
var layout = <LayoutBase>view.parent;
|
||||||
|
|
||||||
var child = <View>layout.getViewById("collapse");
|
var child = <View>layout.getViewById("collapse");
|
||||||
child.visibility = Visibility.VISIBLE;
|
child.visibility = "visible";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Layout properties
|
// Layout properties
|
||||||
|
@ -7,7 +7,7 @@ import { TextView } from "ui/text-view";
|
|||||||
var view: View;
|
var view: View;
|
||||||
export function navigatingTo(args: EventData) {
|
export function navigatingTo(args: EventData) {
|
||||||
var page = <Page>args.object;
|
var page = <Page>args.object;
|
||||||
view = <View>page.getViewById("target");
|
view = page.getViewById<View>("target");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function onPan(data: PanGestureEventData) {
|
export function onPan(data: PanGestureEventData) {
|
||||||
|
@ -7,7 +7,9 @@ let iconModes = ["automatic", "alwaysOriginal", "alwaysTemplate", undefined];
|
|||||||
export function onChangeRenderingMode(args: EventData){
|
export function onChangeRenderingMode(args: EventData){
|
||||||
let button = (<Button>args.object);
|
let button = (<Button>args.object);
|
||||||
let tabView = button.page.getViewById<TabView>("tab-view");
|
let tabView = button.page.getViewById<TabView>("tab-view");
|
||||||
|
|
||||||
tabView.iosIconRenderingMode = <"automatic" | "alwaysOriginal" | "alwaysTemplate">iconModes[(iconModes.indexOf(tabView.iosIconRenderingMode) + 1) % iconModes.length];
|
tabView.iosIconRenderingMode = <"automatic" | "alwaysOriginal" | "alwaysTemplate">iconModes[(iconModes.indexOf(tabView.iosIconRenderingMode) + 1) % iconModes.length];
|
||||||
|
|
||||||
for(let i = 0, length = tabView.items.length; i < length; i++){
|
for(let i = 0, length = tabView.items.length; i < length; i++){
|
||||||
(<Button>tabView.items[i].view).text = "" + tabView.iosIconRenderingMode;
|
(<Button>tabView.items[i].view).text = "" + tabView.iosIconRenderingMode;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
"time-grunt": "1.3.0",
|
"time-grunt": "1.3.0",
|
||||||
"tslint": "^3.15.1",
|
"tslint": "^3.15.1",
|
||||||
"typedoc": "0.4.5",
|
"typedoc": "0.4.5",
|
||||||
"typescript": "~2.0.10"
|
"typescript": "^2.0.10"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"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",
|
"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",
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import * as style from "ui/styling/style";
|
import * as style from "ui/styling/style";
|
||||||
import {PropertyMetadata, PropertyMetadataSettings} from "ui/core/dependency-observable";
|
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 view from "ui/core/view";
|
||||||
import * as buttonModule from "ui/button";
|
import * as buttonModule from "ui/button";
|
||||||
import * as pages from "ui/page";
|
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).
|
// 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;
|
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 {
|
// export class MyTextViewStyler implements style.Styler {
|
||||||
public static setFontFamilyProperty(view: view.View, newValue: any) {
|
// public static setFontFamilyProperty(view: view.View, newValue: any) {
|
||||||
if (view.android) {
|
// if (view.android) {
|
||||||
(<android.widget.TextView>view.android).setTypeface(android.graphics.Typeface.create(newValue, android.graphics.Typeface.NORMAL));
|
// (<android.widget.TextView>view.android).setTypeface(android.graphics.Typeface.create(newValue, android.graphics.Typeface.NORMAL));
|
||||||
}
|
// }
|
||||||
else if (view.ios) {
|
// else if (view.ios) {
|
||||||
var fontSize = (<UIButton>view._nativeView).titleLabel.font.pointSize;
|
// var fontSize = (<UIButton>view._nativeView).titleLabel.font.pointSize;
|
||||||
(<UIButton>view._nativeView).titleLabel.font = UIFont.fontWithNameSize(newValue, fontSize);
|
// (<UIButton>view._nativeView).titleLabel.font = UIFont.fontWithNameSize(newValue, fontSize);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static resetFontFamilyProperty(view: view.View, nativeValue: any) {
|
// public static resetFontFamilyProperty(view: view.View, nativeValue: any) {
|
||||||
if (view.android) {
|
// if (view.android) {
|
||||||
(<android.widget.TextView>view.android).setTypeface(android.graphics.Typeface.create(nativeValue, android.graphics.Typeface.NORMAL));
|
// (<android.widget.TextView>view.android).setTypeface(android.graphics.Typeface.create(nativeValue, android.graphics.Typeface.NORMAL));
|
||||||
}
|
// }
|
||||||
else if (view.ios) {
|
// else if (view.ios) {
|
||||||
var fontSize = (<UIButton>view._nativeView).titleLabel.font.pointSize;
|
// var fontSize = (<UIButton>view._nativeView).titleLabel.font.pointSize;
|
||||||
(<UIButton>view._nativeView).titleLabel.font = UIFont.fontWithNameSize(nativeValue, fontSize);;
|
// (<UIButton>view._nativeView).titleLabel.font = UIFont.fontWithNameSize(nativeValue, fontSize);;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static getNativeFontFamilyValue = function (view: view.View): any {
|
// public static getNativeFontFamilyValue = function (view: view.View): any {
|
||||||
if (view.android) {
|
// if (view.android) {
|
||||||
return (<android.widget.TextView>view.android).getTypeface();
|
// return (<android.widget.TextView>view.android).getTypeface();
|
||||||
}
|
// }
|
||||||
else if (view.ios) {
|
// else if (view.ios) {
|
||||||
return (<UIButton>view._nativeView).titleLabel.font.fontName;
|
// return (<UIButton>view._nativeView).titleLabel.font.fontName;
|
||||||
}
|
// }
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static registerHandlers() {
|
// public static registerHandlers() {
|
||||||
style.registerHandler(fontFamilyProperty, new style.StylePropertyChangedHandler(
|
// style.registerHandler(fontFamilyProperty, new style.StylePropertyChangedHandler(
|
||||||
MyTextViewStyler.setFontFamilyProperty,
|
// MyTextViewStyler.setFontFamilyProperty,
|
||||||
MyTextViewStyler.resetFontFamilyProperty,
|
// MyTextViewStyler.resetFontFamilyProperty,
|
||||||
MyTextViewStyler.getNativeFontFamilyValue), "MyButton");
|
// MyTextViewStyler.getNativeFontFamilyValue), "MyButton");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
//export class MyStyle extends styles.Style {
|
//export class MyStyle extends styles.Style {
|
||||||
// get fontFamily(): string {
|
// get fontFamily(): string {
|
||||||
@ -75,7 +74,7 @@ export class MyButton extends buttonModule.Button {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MyTextViewStyler.registerHandlers();
|
// MyTextViewStyler.registerHandlers();
|
||||||
|
|
||||||
export function createPage() {
|
export function createPage() {
|
||||||
var stackLayout = new stackLayoutDef.StackLayout();
|
var stackLayout = new stackLayoutDef.StackLayout();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import * as stack from "ui/layouts/stack-layout";
|
import * as stack from "ui/layouts/stack-layout";
|
||||||
import * as style from "ui/styling/style";
|
import * as style from "ui/styling/style";
|
||||||
|
import {unsetValue} from "ui/core/view";
|
||||||
|
|
||||||
export function buttonTap(args) {
|
export function buttonTap(args) {
|
||||||
var stackLayout = <stack.StackLayout>args.object.parent;
|
var stackLayout = <stack.StackLayout>args.object.parent;
|
||||||
|
@ -23,7 +23,7 @@ export function createPage() {
|
|||||||
return page;
|
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();
|
var btn = new btns.Button();
|
||||||
btn.text = text;
|
btn.text = text;
|
||||||
btn.horizontalAlignment = text;
|
btn.horizontalAlignment = text;
|
||||||
|
@ -17,7 +17,7 @@ export function createPage() {
|
|||||||
|
|
||||||
var btn2 = new buttonModule.Button();
|
var btn2 = new buttonModule.Button();
|
||||||
btn2.horizontalAlignment = "center";
|
btn2.horizontalAlignment = "center";
|
||||||
btn2.verticalAlignment = "center";
|
btn2.verticalAlignment = "middle";
|
||||||
btn2.text = "center, center";
|
btn2.text = "center, center";
|
||||||
|
|
||||||
var btn3 = new buttonModule.Button();
|
var btn3 = new buttonModule.Button();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import * as pages from "ui/page";
|
import * as pages from "ui/page";
|
||||||
import * as buttons from "ui/button";
|
import * as buttons from "ui/button";
|
||||||
|
import { VerticalAlignment } from "ui/core/view";
|
||||||
|
|
||||||
export function createPage() {
|
export function createPage() {
|
||||||
var page = new pages.Page();
|
var page = new pages.Page();
|
||||||
@ -9,7 +10,7 @@ export function createPage() {
|
|||||||
btn.height = 60;
|
btn.height = 60;
|
||||||
btn.text = "test";
|
btn.text = "test";
|
||||||
|
|
||||||
var vAligns = ["stretch", "top", "center", "bottom"];
|
var vAligns: VerticalAlignment[] = ["stretch", "top", "middle", "bottom"];
|
||||||
//var hAligns = ["stretch", "left", "center", "right"];
|
//var hAligns = ["stretch", "left", "center", "right"];
|
||||||
var count = 0;
|
var count = 0;
|
||||||
btn.on(buttons.Button.tapEvent, function () {
|
btn.on(buttons.Button.tapEvent, function () {
|
||||||
|
@ -308,7 +308,7 @@ export function test_AnimationCurveInKeyframes() {
|
|||||||
TKUnit.assertEqual(animation.keyframes[0].curve, enums.AnimationCurve.linear);
|
TKUnit.assertEqual(animation.keyframes[0].curve, enums.AnimationCurve.linear);
|
||||||
TKUnit.assertEqual(animation.keyframes[1].curve, undefined);
|
TKUnit.assertEqual(animation.keyframes[1].curve, undefined);
|
||||||
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[1].curve, enums.AnimationCurve.linear);
|
||||||
TKUnit.assertEqual(realAnimation.animations[2].curve, enums.AnimationCurve.easeIn);
|
TKUnit.assertEqual(realAnimation.animations[2].curve, enums.AnimationCurve.easeIn);
|
||||||
}
|
}
|
@ -28,7 +28,6 @@ export var test_Bindable_Members = function () {
|
|||||||
var obj = new bindable.Bindable();
|
var obj = new bindable.Bindable();
|
||||||
TKUnit.assert(types.isDefined(obj.bind), "Bindable.bind not defined");
|
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.unbind), "Bindable.unbind not defined");
|
||||||
TKUnit.assert(types.isDefined(obj._updateTwoWayBinding), "Bindable.updateTwoWayBinding not defined");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_Bindable_Bind_ToTarget_OneWay = function () {
|
export var test_Bindable_Bind_ToTarget_OneWay = function () {
|
||||||
@ -155,7 +154,6 @@ export var test_bindingContext_ValueSource_IsInherited = function () {
|
|||||||
var context = {};
|
var context = {};
|
||||||
views[0].bindingContext = context;
|
views[0].bindingContext = context;
|
||||||
TKUnit.assert(views[1].bindingContext === context, "bindingContext not inherited.");
|
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);
|
helper.do_PageTest_WithButton(test);
|
||||||
|
@ -235,7 +235,7 @@ var _testNativeBackgroundColorFromLocal = function (views: Array<viewModule.View
|
|||||||
TKUnit.assert(actualResult === expectedBackgroundColorHex, "Actual: " + actualResult + "; Expected: " + expectedBackgroundColorHex);
|
TKUnit.assert(actualResult === expectedBackgroundColorHex, "Actual: " + actualResult + "; Expected: " + expectedBackgroundColorHex);
|
||||||
}
|
}
|
||||||
|
|
||||||
var expectedTextAlignment = enums.TextAlignment.right;
|
var expectedTextAlignment: "right" = "right";
|
||||||
export var testLocalTextAlignmentFromCss = function () {
|
export var testLocalTextAlignmentFromCss = function () {
|
||||||
helper.buildUIAndRunTest(_createButtonFunc(), function (views: Array<viewModule.View>) {
|
helper.buildUIAndRunTest(_createButtonFunc(), function (views: Array<viewModule.View>) {
|
||||||
var view = <buttonModule.Button>views[0];
|
var view = <buttonModule.Button>views[0];
|
||||||
|
@ -101,7 +101,7 @@ export function percent_support_children_test(test: testModule.UITest<LayoutBase
|
|||||||
TKUnit.assertEqual(bounds.bottom, 120, "TopLeft layout BOTTOM incorrect");
|
TKUnit.assertEqual(bounds.bottom, 120, "TopLeft layout BOTTOM incorrect");
|
||||||
|
|
||||||
btn.horizontalAlignment = "center";
|
btn.horizontalAlignment = "center";
|
||||||
btn.verticalAlignment = "center";
|
btn.verticalAlignment = "middle";
|
||||||
test.waitUntilTestElementLayoutIsValid();
|
test.waitUntilTestElementLayoutIsValid();
|
||||||
|
|
||||||
bounds = btn._getCurrentLayoutBounds();
|
bounds = btn._getCurrentLayoutBounds();
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
} from "ui/layouts/flexbox-layout";
|
} from "ui/layouts/flexbox-layout";
|
||||||
// << flexbox-layout-require
|
// << flexbox-layout-require
|
||||||
|
|
||||||
import {View, unsetValue} from "ui/core/view";
|
import {View, unsetValue, Length} from "ui/core/view";
|
||||||
import {Label} from "ui/label";
|
import {Label} from "ui/label";
|
||||||
import * as TKUnit from "../../TKUnit";
|
import * as TKUnit from "../../TKUnit";
|
||||||
import * as helper from "../helper";
|
import * as helper from "../helper";
|
||||||
@ -494,8 +494,8 @@ export const testJustifyContent_flexStart_withParentPadding = test(
|
|||||||
({root, flexbox, text1, text2, text3}) => {
|
({root, flexbox, text1, text2, text3}) => {
|
||||||
isRightOf(text2, text1);
|
isRightOf(text2, text1);
|
||||||
isRightOf(text3, text2);
|
isRightOf(text3, text2);
|
||||||
equal(left(text1), dipToDp(flexbox.style.paddingLeft.value), `Expected ${text1}.left to equal ${flexbox}.paddingLeft`);
|
equal(left(text1), Length.toDevicePixels(flexbox.style.paddingLeft, 0), `Expected ${text1}.left to equal ${flexbox}.paddingLeft`);
|
||||||
equal(top(text1), dipToDp(flexbox.style.paddingTop.value), `Expected ${text1}.top to equal ${flexbox}.paddingTop`);
|
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}) => {
|
({root, flexbox, text1, text2, text3}) => {
|
||||||
isLeftOf(text2, text3);
|
isLeftOf(text2, text3);
|
||||||
isLeftOf(text1, text2);
|
isLeftOf(text1, text2);
|
||||||
closeEnough(width(flexbox) - right(text3), dipToDp(flexbox.style.paddingRight.value));
|
closeEnough(width(flexbox) - right(text3), Length.toDevicePixels(flexbox.style.paddingRight, 0));
|
||||||
closeEnough(top(text3), dipToDp(flexbox.style.paddingTop.value));
|
closeEnough(top(text3), Length.toDevicePixels(flexbox.style.paddingTop, 0));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -544,10 +544,10 @@ export const testJustifyContent_center_withParentPadding = test(
|
|||||||
({root, flexbox, text1, text2, text3}) => {
|
({root, flexbox, text1, text2, text3}) => {
|
||||||
isRightOf(text2, text1);
|
isRightOf(text2, text1);
|
||||||
isRightOf(text3, text2);
|
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;
|
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 <= 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) - dipToDp(flexbox.style.paddingRight.value) && width(flexbox) - right(text3) - dipToDp(flexbox.style.paddingRight.value) <= 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(text1, text3);
|
||||||
isAbove(text2, 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);
|
isLeftOf(text2, text3);
|
||||||
|
|
||||||
let { bounds1, bounds2 } = comparableBounds(text3, flexbox);
|
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,
|
({flexbox}) => flexbox.alignItems = AlignItems.FLEX_END,
|
||||||
({root, flexbox, text1, text2, text3}) => {
|
({root, flexbox, text1, text2, text3}) => {
|
||||||
isRightOf(text2, text1);
|
isRightOf(text2, text1);
|
||||||
closeEnough(bottom(text1), height(flexbox) - dipToDp(flexbox.style.paddingBottom.value));
|
closeEnough(bottom(text1), height(flexbox) - Length.toDevicePixels(flexbox.style.paddingBottom, 0));
|
||||||
closeEnough(bottom(text2), height(flexbox) - dipToDp(flexbox.style.paddingBottom.value));
|
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}) => {
|
({root, flexbox, text1, text2, text3}) => {
|
||||||
isBelow(text2, text1);
|
isBelow(text2, text1);
|
||||||
closeEnough(right(text1), width(flexbox) - dipToDp(flexbox.style.paddingRight.value));
|
closeEnough(right(text1), width(flexbox) - Length.toDevicePixels(flexbox.style.paddingRight, 0));
|
||||||
closeEnough(right(text2), width(flexbox) - dipToDp(flexbox.style.paddingRight.value));
|
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}) => {
|
({flexbox, text1, text2, text3}) => {
|
||||||
isBelow(text2, text1);
|
isBelow(text2, text1);
|
||||||
isRightOf(text3, text2);
|
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}) => {
|
({flexbox, text1, text2, text3}) => {
|
||||||
isRightOf(text2, text1);
|
isRightOf(text2, text1);
|
||||||
isBelow(text3, text2);
|
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}) => {
|
({flexbox, text1, text2, text3}) => {
|
||||||
isBelow(text2, text1);
|
isBelow(text2, text1);
|
||||||
isRightOf(text3, text2);
|
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);
|
isRightOf(text2, text1);
|
||||||
isBelow(text3, text2);
|
isBelow(text3, text2);
|
||||||
// dips anyone?
|
// 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));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ export class StackLayoutTest extends testModule.UITest<StackLayout> {
|
|||||||
TKUnit.assertEqual(bounds.bottom, 120, "TopLeft layout BOTTOM incorrect");
|
TKUnit.assertEqual(bounds.bottom, 120, "TopLeft layout BOTTOM incorrect");
|
||||||
|
|
||||||
btn.horizontalAlignment = "center";
|
btn.horizontalAlignment = "center";
|
||||||
btn.verticalAlignment = "center";
|
btn.verticalAlignment = "middle";
|
||||||
this.waitUntilTestElementLayoutIsValid();
|
this.waitUntilTestElementLayoutIsValid();
|
||||||
|
|
||||||
bounds = btn._getCurrentLayoutBounds();
|
bounds = btn._getCurrentLayoutBounds();
|
||||||
@ -264,7 +264,7 @@ export class StackLayoutTest extends testModule.UITest<StackLayout> {
|
|||||||
TKUnit.assertEqual(bounds.bottom, 120, "TopLeft layout BOTTOM incorrect");
|
TKUnit.assertEqual(bounds.bottom, 120, "TopLeft layout BOTTOM incorrect");
|
||||||
|
|
||||||
btn.horizontalAlignment = "center";
|
btn.horizontalAlignment = "center";
|
||||||
btn.verticalAlignment = "center";
|
btn.verticalAlignment = "middle";
|
||||||
this.waitUntilTestElementLayoutIsValid();
|
this.waitUntilTestElementLayoutIsValid();
|
||||||
|
|
||||||
bounds = btn._getCurrentLayoutBounds();
|
bounds = btn._getCurrentLayoutBounds();
|
||||||
|
@ -289,7 +289,7 @@ export class WrapLayoutTest extends testModule.UITest<wrapLayoutModule.WrapLayou
|
|||||||
TKUnit.assertEqual(bounds.bottom, 120, "TopLeft layout BOTTOM incorrect");
|
TKUnit.assertEqual(bounds.bottom, 120, "TopLeft layout BOTTOM incorrect");
|
||||||
|
|
||||||
btn.horizontalAlignment = "center";
|
btn.horizontalAlignment = "center";
|
||||||
btn.verticalAlignment = "center";
|
btn.verticalAlignment = "middle";
|
||||||
this.waitUntilTestElementLayoutIsValid();
|
this.waitUntilTestElementLayoutIsValid();
|
||||||
|
|
||||||
bounds = btn._getCurrentLayoutBounds();
|
bounds = btn._getCurrentLayoutBounds();
|
||||||
|
@ -57,7 +57,6 @@ export class ListViewTest extends testModule.UITest<listViewModule.ListView> {
|
|||||||
var listView = new listViewModule.ListView();
|
var listView = new listViewModule.ListView();
|
||||||
// << article-create-listview
|
// << article-create-listview
|
||||||
|
|
||||||
TKUnit.assertEqual(listView.isScrolling, false, "Default listView.isScrolling");
|
|
||||||
TKUnit.assert(types.isUndefined(listView.items), "Default listView.items should be undefined");
|
TKUnit.assert(types.isUndefined(listView.items), "Default listView.items should be undefined");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.");
|
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() {
|
export function test_setInlineStyle_setsLocalValues() {
|
||||||
var testButton = new buttonModule.Button();
|
var testButton = new buttonModule.Button();
|
||||||
testButton.text = "Test";
|
testButton.text = "Test";
|
||||||
@ -647,7 +617,7 @@ export function test_setInlineStyle_setsLocalValues() {
|
|||||||
|
|
||||||
helper.buildUIAndRunTest(stack, function (views: Array<viewModule.View>) {
|
helper.buildUIAndRunTest(stack, function (views: Array<viewModule.View>) {
|
||||||
(<any>testButton)._applyInlineStyle("color: red;");
|
(<any>testButton)._applyInlineStyle("color: red;");
|
||||||
helper.assertViewColor(testButton, "#FF0000", dependencyObservableModule.ValueSource.Local);
|
helper.assertViewColor(testButton, "#FF0000");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,8 +642,8 @@ export var testIsVisible = function () {
|
|||||||
TKUnit.assertEqual(lbl.visibility, "collapse");
|
TKUnit.assertEqual(lbl.visibility, "collapse");
|
||||||
TKUnit.assertEqual(lbl.isCollapsed, true);
|
TKUnit.assertEqual(lbl.isCollapsed, true);
|
||||||
|
|
||||||
lbl.visibility = "collapsed";
|
lbl.visibility = "collapse";
|
||||||
TKUnit.assertEqual(lbl.visibility, "collapsed");
|
TKUnit.assertEqual(lbl.visibility, "collapse");
|
||||||
TKUnit.assertEqual(lbl.isCollapsed, true);
|
TKUnit.assertEqual(lbl.isCollapsed, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,12 @@ import * as types from "utils/types";
|
|||||||
import * as fs from "file-system";
|
import * as fs from "file-system";
|
||||||
import * as observable from "data/observable";
|
import * as observable from "data/observable";
|
||||||
import * as stackLayoutModule from "ui/layouts/stack-layout";
|
import * as stackLayoutModule from "ui/layouts/stack-layout";
|
||||||
import {Label} from "ui/label";
|
import { Label } from "ui/label";
|
||||||
import {Page} from "ui/page";
|
import { Page } from "ui/page";
|
||||||
import {Button} from "ui/button";
|
import { Button } from "ui/button";
|
||||||
import {TabView} from "ui/tab-view";
|
import { TabView } from "ui/tab-view";
|
||||||
import {Observable} from "data/observable";
|
import { Observable } from "data/observable";
|
||||||
import {TemplateView} from "./template-builder-tests/template-view";
|
import { TemplateView } from "./template-builder-tests/template-view";
|
||||||
import * as myCustomControlWithoutXml from "./mymodule/MyControl";
|
import * as myCustomControlWithoutXml from "./mymodule/MyControl";
|
||||||
import * as listViewModule from "ui/list-view";
|
import * as listViewModule from "ui/list-view";
|
||||||
import * as helper from "../ui/helper";
|
import * as helper from "../ui/helper";
|
||||||
@ -25,6 +25,7 @@ import * as platform from "platform";
|
|||||||
import * as gesturesModule from "ui/gestures";
|
import * as gesturesModule from "ui/gestures";
|
||||||
import * as segmentedBar from "ui/segmented-bar";
|
import * as segmentedBar from "ui/segmented-bar";
|
||||||
import { Source } from "utils/debug";
|
import { Source } from "utils/debug";
|
||||||
|
import { PercentLength } from "ui/core/view";
|
||||||
|
|
||||||
export function test_load_IsDefined() {
|
export function test_load_IsDefined() {
|
||||||
TKUnit.assertTrue(types.isFunction(builder.load), "ui/builder should have load method!");
|
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() {
|
export function test_parse_ShouldParseNumberProperties() {
|
||||||
var p = <Page>builder.parse("<Page width='100' />");
|
var p = <Page>builder.parse("<Page width='100' />");
|
||||||
TKUnit.assertEqual(p.width.value, 100);
|
TKUnit.assertTrue(PercentLength.equals(p.width, 100));
|
||||||
TKUnit.assertEqual(p.width.unit, "dip");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function test_parse_ShouldParseBooleanProperties() {
|
export function test_parse_ShouldParseBooleanProperties() {
|
||||||
@ -451,7 +451,7 @@ export function test_parse_ShouldParseSubProperties() {
|
|||||||
p.bindingContext = obj;
|
p.bindingContext = obj;
|
||||||
var sw = <switchModule.Switch>p.content;
|
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() {
|
export function test_parse_ShouldParseBindingToSpecialProperty() {
|
||||||
|
@ -965,17 +965,17 @@ function updateChildLayoutParams(child: ViewCommon, parent: ViewCommon, density:
|
|||||||
let parentWidthMeasureSize = layout.getMeasureSpecSize(parentWidthMeasureSpec);
|
let parentWidthMeasureSize = layout.getMeasureSpecSize(parentWidthMeasureSpec);
|
||||||
let parentWidthMeasureMode = layout.getMeasureSpecMode(parentWidthMeasureSpec);
|
let parentWidthMeasureMode = layout.getMeasureSpecMode(parentWidthMeasureSpec);
|
||||||
let parentAvailableWidth = parentWidthMeasureMode === layout.UNSPECIFIED ? -1 : parentWidthMeasureSize;
|
let parentAvailableWidth = parentWidthMeasureMode === layout.UNSPECIFIED ? -1 : parentWidthMeasureSize;
|
||||||
style.effectiveWidth = PercentLength.toDevicePixels(style.width, parentAvailableWidth)
|
style.effectiveWidth = PercentLength.toDevicePixels(style.width, -2, parentAvailableWidth)
|
||||||
style.effectiveMarginLeft = PercentLength.toDevicePixels(style.marginLeft, parentAvailableWidth);
|
style.effectiveMarginLeft = PercentLength.toDevicePixels(style.marginLeft, 0, parentAvailableWidth);
|
||||||
style.effectiveMarginRight = PercentLength.toDevicePixels(style.marginRight, parentAvailableWidth);
|
style.effectiveMarginRight = PercentLength.toDevicePixels(style.marginRight, 0, parentAvailableWidth);
|
||||||
|
|
||||||
let parentHeightMeasureSpec = parent._currentHeightMeasureSpec;
|
let parentHeightMeasureSpec = parent._currentHeightMeasureSpec;
|
||||||
let parentHeightMeasureSize = layout.getMeasureSpecSize(parentHeightMeasureSpec);
|
let parentHeightMeasureSize = layout.getMeasureSpecSize(parentHeightMeasureSpec);
|
||||||
let parentHeightMeasureMode = layout.getMeasureSpecMode(parentHeightMeasureSpec);
|
let parentHeightMeasureMode = layout.getMeasureSpecMode(parentHeightMeasureSpec);
|
||||||
let parentAvailableHeight = parentHeightMeasureMode === layout.UNSPECIFIED ? -1 : parentHeightMeasureSize;
|
let parentAvailableHeight = parentHeightMeasureMode === layout.UNSPECIFIED ? -1 : parentHeightMeasureSize;
|
||||||
style.effectiveHeight = PercentLength.toDevicePixels(style.height, parentAvailableHeight);
|
style.effectiveHeight = PercentLength.toDevicePixels(style.height, -2, parentAvailableHeight);
|
||||||
style.effectiveMarginTop = PercentLength.toDevicePixels(style.marginTop, parentAvailableHeight);
|
style.effectiveMarginTop = PercentLength.toDevicePixels(style.marginTop, 0, parentAvailableHeight);
|
||||||
style.effectiveMarginBottom = PercentLength.toDevicePixels(style.marginBottom, parentAvailableHeight);
|
style.effectiveMarginBottom = PercentLength.toDevicePixels(style.marginBottom, 0, parentAvailableHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
function equalsCommon(a: Length, b: Length): boolean;
|
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 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 | {
|
export type Length = "auto" | number | {
|
||||||
|
29
tns-core-modules/ui/core/view.d.ts
vendored
29
tns-core-modules/ui/core/view.d.ts
vendored
@ -102,6 +102,12 @@ declare module "ui/core/view" {
|
|||||||
export namespace Length {
|
export namespace Length {
|
||||||
export function parse(text: string): Length;
|
export function parse(text: string): Length;
|
||||||
export function equals(a: Length, b: Length): boolean;
|
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 | {
|
export type PercentLength = "auto" | number | {
|
||||||
@ -111,6 +117,13 @@ declare module "ui/core/view" {
|
|||||||
export namespace PercentLength {
|
export namespace PercentLength {
|
||||||
export function parse(text: string): PercentLength;
|
export function parse(text: string): PercentLength;
|
||||||
export function equals(a: PercentLength, b: PercentLength): boolean;
|
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;
|
// _onStylePropertyChanged(property: dependencyObservable.Property): void;
|
||||||
//@endprivate
|
//@endprivate
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * __Obsolete:__ There is a new property system that does not rely on _getValue.
|
* __Obsolete:__ There is a new property system that does not rely on _getValue.
|
||||||
// */
|
*/
|
||||||
// public _getValue(property: any): never;
|
public _getValue(property: any): never;
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * __Obsolete:__ There is a new property system that does not rely on _setValue.
|
* __Obsolete:__ There is a new property system that does not rely on _setValue.
|
||||||
// */
|
*/
|
||||||
// public _setValue(property: any, value: any): never;
|
public _setValue(property: any, value: any): never;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
2
tns-core-modules/ui/definitions.d.ts
vendored
2
tns-core-modules/ui/definitions.d.ts
vendored
@ -93,7 +93,7 @@ declare module "ui/core/view-base" {
|
|||||||
public onLoaded(): void;
|
public onLoaded(): void;
|
||||||
public onUnloaded(): void;
|
public onUnloaded(): void;
|
||||||
|
|
||||||
public bind(options: BindingOptions, source: Object): void;
|
public bind(options: BindingOptions, source?: Object): void;
|
||||||
public unbind(property: string): void;
|
public unbind(property: string): void;
|
||||||
|
|
||||||
public requestLayout(): void;
|
public requestLayout(): void;
|
||||||
|
Reference in New Issue
Block a user