XML examples added

This commit is contained in:
Vladimir Enchev
2015-03-09 08:41:23 +02:00
parent 63f9509432
commit 2bdf2136e7
5 changed files with 66 additions and 19 deletions

View File

@@ -14,6 +14,16 @@ import absoluteLayoutModule = require("ui/layouts/absolute-layout");
// ```
// </snippet>
// ### Declaring a AbsoluteLayout.
//```XML
// <Page>
// <AbsoluteLayout>
// <Label text="This is Label 1" left="30" top="70" />
// </AbsoluteLayout>
// </Page>
//```
// </snippet>
export var testAll = function () {
// <snippet module="ui/layouts/absolute-layout" title="absolute-layout">
// ## Creating and populating a AbsoluteLayout with children
@@ -50,7 +60,7 @@ export var testAll = function () {
TKUnit.assertEqual(actualValue.top, 10 * density, "ActualTop");
TKUnit.assertEqual(width, 100 * density, "ActualWidth");
TKUnit.assertEqual(height, 100 * density, "Actualheight");
});
});
}
export function test_padding() {
@@ -75,5 +85,5 @@ export function test_padding() {
layoutHelper.assertMeasure(btn, 100, 100);
layoutHelper.assertLayout(btn, 25, 35, 100, 100);
});
});
}

View File

@@ -11,6 +11,20 @@ import navHelper = require("../ui/helper");
import dockModule = require("ui/layouts/dock-layout");
// ```
// ### Declaring a DockLayout.
//```XML
//<Page>
// <DockLayout stretchLastChild="true" >
// <Button dock="left" text = "left" style ="background-color: red; margin: 5;"/ >/ >
// <Button dock="top" text = "top" style ="background-color: lightblue; margin: 5;"/ >
// <Button dock="right" text = "right" style ="background-color: lightgreen; margin: 5;"/ >
// <Button dock="bottom" text = "bottom" style ="background-color: lightpink; margin: 5;"/ >
// <Button text="fill" style ="background-color: wheat; margin: 5;"/ >
// < / DockLayout >
//< / Page>
//```
// </snippet>
// Other frequently used modules when working with a DockLayout include:
// ``` JavaScript
import enums = require("ui/enums");

View File

@@ -505,6 +505,18 @@ export var test_codesnippets = function () {
var gridLayout = new layout.GridLayout();
// ```
// ### Create grid layout with an xml declaration
// ``` XML
// <GridLayout columns="80, *, auto" rows="auto, *" >
// <Button col="0" />
// <Button col="1" />
// <Button col="2" />
//// by default column and row are set to 0
// <Button row="1" colSpan="3" />
// </GridLayout>
// ```
// </snippet>
// ### Add views to grid layout
// ``` JavaScript
var btn1 = new button.Button();
@@ -557,16 +569,4 @@ export var test_codesnippets = function () {
gridLayout.addRow(firstRow);
gridLayout.addRow(secondRow);
// ```
// ### Create same grid layout with an xml declaration
// ``` XML
// <GridLayout columns="80, *, auto" rows="auto, *" >
// <Button col="0" />
// <Button col="1" />
// <Button col="2" />
//// by default column and row are set to 0
// <Button row="1" colSpan="3" />
// </GridLayout>
// ```
// </snippet>
};

View File

@@ -46,7 +46,7 @@ export function setUpModule() {
newPage.content = tmp;
return newPage;
};
navHelper.navigate(pageFactory);
}
@@ -142,7 +142,7 @@ export function test_StackLayout_DesiredSize_Vertical() {
}, ASYNC);
TKUnit.assertEqual(rootLayout.getMeasuredWidth(), Math.max(btn1.getMeasuredWidth(), btn2.getMeasuredWidth()), "Layout getMeasuredWidth should be Max of children getMeasuredWidth");
TKUnit.assertEqual(rootLayout.getMeasuredHeight(),(btn1.getMeasuredHeight() + btn2.getMeasuredHeight()), "Layout getMeasuredHeight should be Sum of children getMeasuredHeight");
TKUnit.assertEqual(rootLayout.getMeasuredHeight(), (btn1.getMeasuredHeight() + btn2.getMeasuredHeight()), "Layout getMeasuredHeight should be Sum of children getMeasuredHeight");
}
export function test_StackLayout_DesiredSize_Horizontal() {
@@ -155,7 +155,7 @@ export function test_StackLayout_DesiredSize_Horizontal() {
return btn2.arranged;
}, ASYNC);
TKUnit.assertEqual(rootLayout.getMeasuredWidth(),(btn1.getMeasuredWidth() + btn2.getMeasuredWidth()), "Layout getMeasuredWidth should be Sum of children getMeasuredWidth");
TKUnit.assertEqual(rootLayout.getMeasuredWidth(), (btn1.getMeasuredWidth() + btn2.getMeasuredWidth()), "Layout getMeasuredWidth should be Sum of children getMeasuredWidth");
TKUnit.assertEqual(rootLayout.getMeasuredHeight(), Math.max(btn1.getMeasuredHeight(), btn2.getMeasuredHeight()), "Layout getMeasuredHeight should be Max of children getMeasuredHeight");
}
@@ -178,8 +178,8 @@ export function test_StackLayout_Padding_Vertical() {
helper.assertMeasure(btn1, 260, 50);
helper.assertMeasure(btn1, 260, 50);
helper.assertLayout(btn1, 10, 20, 260, 50, "btn1");
helper.assertLayout(btn2, 10, 70, 260, 50, "btn2");
helper.assertLayout(btn1, 10, 20, 260, 50, "btn1");
helper.assertLayout(btn2, 10, 70, 260, 50, "btn2");
}
export function test_StackLayout_Padding_Horizontal() {
@@ -213,6 +213,16 @@ export function test_codesnippets() {
var stackLayout = new layout.StackLayout();
// ```
// ### Declaring a StackLayout.
//```XML
// <Page>
// <StackLayout orientation="horizontal">
// <Label text="This is Label 1" />
// </StackLayout>
// </Page>
//```
// </snippet>
// ### Add child view to layout
// ``` JavaScript
var btn = new button.Button();

View File

@@ -26,6 +26,19 @@ var _createWrapLayoutFunc = function (childCount: number, childWidth?: number, c
// ```
// </snippet>
// ### Declaring a WrapLayout.
//```XML
// <Page>
// <WrapLayout>
// <Label text="This is Label 1" />
// <Label text="This is Label 2" />
// <Label text="This is Label 3" />
// <Label text="This is Label 4" />
// </WrapLayout>
// </Page>
//```
// </snippet>
wrapLayout.width = 200;
wrapLayout.height = 200;