Skip to content

Commit b29b570

Browse files
committed
docs: improve & extend the Tabs examples
1 parent 6e500f3 commit b29b570

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

app/ns-ui-widgets-category/tabs/properties/properties-page.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ exports.onTabsLoaded = (args) => {
3030
tabs.swipeEnabled = true;
3131
tabs.offscreenTabLimit = 1;
3232
tabs.tabsPosition = "top";
33-
33+
3434
/*
3535
Using the nativeView property (correspnding to tabs.ios or tabs.android depending on the used platform)
3636
*/
@@ -45,13 +45,13 @@ function createTabStrip() {
4545

4646
// An array of TabStripItem
4747
const tabStripItems = [];
48-
for (let index = 0; index < 3; index++) {
48+
for (let index = 0; index < 5; index++) {
4949
// Each item is of type TabStripItem
5050
const item = new TabStripItem();
5151
/*
5252
Using TabStripItem title property
5353
*/
54-
item.title = `${index === 0 ? "Home" : (index === 1 ? "Account" : "Search")}`;
54+
item.title = `Tab ${index + 1}`;
5555
/*
5656
Using TabStripItem title property
5757
*/
@@ -66,7 +66,7 @@ function createTabStrip() {
6666
function createTabsContentArray() {
6767
// array of TabContentItem
6868
const arr = [];
69-
for (let index = 0; index < 3; index++) {
69+
for (let index = 0; index < 5; index++) {
7070
// item is of type TabContentItem
7171
const item = new TabContentItem();
7272
// The createContent is a custom method that returns a StackLayout with a Label as a chils
@@ -79,12 +79,17 @@ function createTabsContentArray() {
7979

8080
function createContent(index) {
8181
const label = new Label();
82-
label.text = `${index === 0 ? "Home" : (index === 1 ? "Account" : "Search")}`;
82+
label.text = `Content ${index + 1}`;
8383
label.className = "h2 text-center";
8484
label.color = new Color("red");
85+
label.id = "label";
8586
const stack = new StackLayout();
8687
stack.verticalAlignment = "middle";
8788
stack.addChild(label);
8889

90+
stack.on("loaded", (args) => {
91+
console.log(`Loaded [${(args.object).getViewById("label").text}] - testing offscreenTabLimit property)`)
92+
});
93+
8994
return stack;
9095
}

app/ns-ui-widgets-category/tabs/properties/properties-ts-page.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,12 @@ function createTabStrip() {
3838
const tabStrip: TabStrip = new TabStrip();
3939
tabStrip.iosIconRenderingMode = "automatic"; // iOS only (automatic is the default value)
4040
const tabStripItems: Array<TabStripItem> = [];
41-
for (let index = 0; index < 3; index++) {
41+
for (let index = 0; index < 5; index++) {
4242
const item: TabStripItem = new TabStripItem();
4343
/*
4444
Using TabStripItem title property
4545
*/
46-
item.title = `Tab ${index === 0
47-
? "res://baseline_home_black_24pt"
48-
: (index === 1
49-
? "res://baseline_account_balance_black_24pt"
50-
: "res://baseline_search_black_24pt")}`;
46+
item.title = `Tab ${index + 1}`;
5147
/*
5248
Using TabStripItem title property
5349
*/
@@ -65,7 +61,7 @@ function createTabStrip() {
6561

6662
function createTabsContentArray() {
6763
const arr: Array<TabContentItem> = [];
68-
for (let index = 0; index < 3; index++) {
64+
for (let index = 0; index < 5; index++) {
6965
const item: TabContentItem = new TabContentItem();
7066
// The createContent is a custom method that returns a StackLayout with a Label as a chils
7167
item.view = createContent(index);
@@ -77,12 +73,21 @@ function createTabsContentArray() {
7773

7874
function createContent(index: number) {
7975
const label = new Label();
80-
label.text = `${index === 0 ? "Home" : (index === 1 ? "Account" : "Search")}`;
76+
label.text = `Content ${index + 1}`;
8177
label.className = "h2 text-center";
8278
label.color = new Color("red");
79+
label.id = "label";
8380
const stack = new StackLayout();
8481
stack.verticalAlignment = "middle";
8582
stack.addChild(label);
8683

84+
stack.on("loaded", (args) => {
85+
console.log(`Loaded [${(<any>args.object).getViewById("label").text}]`)
86+
})
87+
88+
stack.on("unloaded", (args) => {
89+
console.log(`UNLOADED [${(<any>args.object).getViewById("label").text}]`)
90+
})
91+
8792
return stack;
8893
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
"id": "org.nativescript.nativescriptsdkexamplesjs",
2424
"tns-android": {
2525
"version": "6.0.0-rc-2019-07-04-174325-01"
26+
},
27+
"tns-ios": {
28+
"version": "6.0.0-rc-2019-07-04-095546-01"
2629
}
2730
},
2831
"dependencies": {

0 commit comments

Comments
 (0)