Create a single NS app for cuteness.io, gallery-app and ui-tests-app in apps/

Move all other apps to https://github.com/NativeScript/tns-apps-graveyard
This commit is contained in:
Rossen Hristov
2016-07-05 18:09:57 +03:00
parent c2867e7a1c
commit a18d5e7622
484 changed files with 756 additions and 5501 deletions

View File

@@ -0,0 +1,80 @@
import pageModule = require("ui/page");
import buttonModule = require("ui/button");
import textFieldModule = require("ui/text-field");
import stackLayoutModule = require("ui/layouts/stack-layout");
import observableModule = require("data/observable");
export function createPage() {
var page = new pageModule.Page();
var stack = new stackLayoutModule.StackLayout();
var sourceOneWay = new observableModule.Observable();
var sourceTwoWay = new observableModule.Observable();
var targetOneWay = new textFieldModule.TextField();
var targetTwoWay = new textFieldModule.TextField();
var buttonOneWay = new buttonModule.Button();
var buttonTwoWay = new buttonModule.Button();
var buttonSetText = new buttonModule.Button();
targetOneWay.id = "textFieldOneWay";
targetTwoWay.id = "textFieldTwoWay";
buttonOneWay.id = "buttonOneWay";
buttonTwoWay.id = "buttonTwoWay";
targetOneWay.automationText = "textFieldOneWay";
targetTwoWay.automationText = "textFieldTwoWay";
buttonOneWay.automationText = "buttonOneWay";
buttonTwoWay.automationText = "buttonTwoWay";
buttonSetText.id = "buttonSetText";
buttonSetText.automationText = "buttonSetText";
buttonSetText.text = "SetText";
buttonSetText.on(buttonModule.Button.tapEvent, function () {
targetOneWay.text = "Test";
targetTwoWay.text = "Test";
});
stack.addChild(buttonSetText);
// OneWay Binding
var bindingOptionOneWay = {
sourceProperty: "textSource",
targetProperty: "text",
twoWay: false
};
targetOneWay.bind(bindingOptionOneWay, sourceOneWay);
sourceOneWay.set("textSource", "OneWay");
buttonOneWay.on(buttonModule.Button.loadedEvent, function () {
buttonOneWay.text = sourceOneWay.get("textSource");
});
buttonOneWay.on(buttonModule.Button.tapEvent, function () {
buttonOneWay.text = sourceOneWay.get("textSource");
});
stack.addChild(targetOneWay);
stack.addChild(buttonOneWay);
// TwoWay Binding
var bindingOptionTwoWay = {
sourceProperty: "textSource",
targetProperty: "text",
twoWay: true
};
targetTwoWay.bind(bindingOptionTwoWay, sourceTwoWay);
sourceTwoWay.set("textSource", "TwoWay");
buttonTwoWay.on(buttonModule.Button.loadedEvent, function () {
buttonTwoWay.text = sourceTwoWay.get("textSource");
});
buttonTwoWay.on(buttonModule.Button.tapEvent, function () {
buttonTwoWay.text = sourceTwoWay.get("textSource");
});
stack.addChild(targetTwoWay);
stack.addChild(buttonTwoWay);
page.content = stack;
return page;
}

View File

@@ -0,0 +1,42 @@
import buttonModule = require("ui/button");
import stackLayoutModule = require("ui/layouts/stack-layout");
import textFieldModule = require("ui/text-field");
import observable = require("data/observable");
export function stack0Loaded(args: observable.EventData) {
var source = new observable.Observable();
var stack0 = <stackLayoutModule.StackLayout>args.object;
var target = stack0.getViewById<textFieldModule.TextField>("tf");
var button = stack0.getViewById<textFieldModule.TextField>("btn");
var bindingOptions = {
sourceProperty: "textSource",
targetProperty: "text"// ,
// twoWay: true
};
target.bind(bindingOptions, source);
source.set("textSource", "Text");
button.on(buttonModule.Button.tapEvent, function () {
button.text = source.get("textSource");
});
}
export function stack1Loaded(args: observable.EventData) {
var stack1 = <stackLayoutModule.StackLayout>args.object;
stack1.bindingContext = { text: "Label" };
}
export function stack2Loaded(args: observable.EventData) {
var stack2 = <stackLayoutModule.StackLayout>args.object;
stack2.bindingContext = {
myProperty: "Button",
myFunction: () => {
console.log("### onTap event ###");
}
};
}
export function stack3Loaded(args: observable.EventData) {
var stack3 = <stackLayoutModule.StackLayout>args.object;
stack3.bindingContext = { myItems: [{ text: "Label1" }, { text: "Label2" }] };
}

View File

@@ -0,0 +1,21 @@
<Page>
<StackLayout>
<StackLayout loaded="stack0Loaded" orientation="horizontal">
<TextField id="tf" automationText="tf" text="{{ textSource }}" width="150" />
<Button id="btn" automationText="btn" width="150" />
</StackLayout>
<StackLayout loaded="stack1Loaded">
<Label id="label" automationText="label" text="{{ text }}" />
</StackLayout>
<StackLayout loaded="stack2Loaded">
<Button id="button" automationText="button" text="{{ myProperty }}" tap="{{ myFunction }}" />
</StackLayout>
<StackLayout loaded="stack3Loaded">
<ListView id="listView" automationText="listView" items="{{ myItems }}">
<ListView.itemTemplate>
<Label id="item" automationText="item" text="{{ text }}" />
</ListView.itemTemplate>
</ListView>
</StackLayout>
</StackLayout>
</Page>