Skip to content

Commit f3f874a

Browse files
committed
docs: BottomNavigation events
1 parent febd1fb commit f3f874a

File tree

5 files changed

+114
-0
lines changed

5 files changed

+114
-0
lines changed

app/ng-ui-widgets-category/bottom-navigation/bottom-navigation-examples.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Link } from "../../link";
44
let menuLinks = [
55
new Link("Events", "/bottom-navigation/events"),
66
new Link("Usage", "/bottom-navigation/usage"),
7+
new Link("Properties", "/bottom-navigation/properties"),
78
new Link("Theming", "/bottom-navigation/theming")
89
];
910

app/ng-ui-widgets-category/bottom-navigation/bottom-navigation-examples.module.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { BottomNavigationExamplesComponent } from "./bottom-navigation-examples.
88
import { UsageComponent } from "./usage/usage.component";
99
import { ThemingComponent } from "./theming/theming.component";
1010
import { EventsComponent } from "./events/events.component";
11+
import { PropertiesComponent } from "./properties/properties.component";
12+
1113
export const routerConfig = [
1214
{
1315
path: "",
@@ -27,6 +29,11 @@ export const routerConfig = [
2729
path: "events",
2830
component: EventsComponent,
2931
data: { title: "Events" }
32+
},
33+
{
34+
path: "properties",
35+
component: PropertiesComponent,
36+
data: { title: "Properties" }
3037
}
3138
];
3239
@NgModule({
@@ -42,6 +49,7 @@ export const routerConfig = [
4249
BottomNavigationExamplesComponent,
4350
EventsComponent,
4451
UsageComponent,
52+
PropertiesComponent,
4553
ThemingComponent
4654
]
4755
})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
- `items: Array<TabContentItem>;` - Gets or sets the items of the BottomNavigation.
3+
4+
- `tabStrip: TabStrip;` - Gets or sets the tab strip of the BottomNavigation.
5+
6+
- `selectedIndex: number;` - Gets or sets the selectedIndex of the BottomNavigation.
7+
8+
- `android: any` /* android.view.View */; - Gets the native [android widget](http://developer.android.com/reference/android/support/v4/view/ViewPager.html) that represents the user interface for this component. Valid only when running on Android OS.
9+
10+
- `ios: any` /* UITabBarController */; - Gets the native iOS [UITabBarController](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITabBarController_Class/) that represents the user interface for this component. Valid only when running on iOS.
11+
12+
<snippet id='bottom-navigation-properties-ng'/>
13+
<snippet id='bottom-navigation-properties-ng-html'>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<!-- >> bottom-navigation-properties-ng-html -->
2+
<BottomNavigation (loaded)="onBottomNavLoaded($event)"></BottomNavigation>
3+
<!-- << bottom-navigation-properties-ng-html -->
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// >> bottom-navigation-properties-ng
2+
import { Component } from "@angular/core";
3+
import { Label } from "tns-core-modules/ui/label";
4+
import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout";
5+
import { Color } from "tns-core-modules/color/color";
6+
import { EventData } from "tns-core-modules/data/observable";
7+
import { BottomNavigation, TabStrip, TabStripItem, TabContentItem } from "tns-core-modules/ui/bottom-navigation";
8+
9+
@Component({
10+
moduleId: module.id,
11+
templateUrl: "./properties.component.html"
12+
})
13+
export class PropertiesComponent {
14+
onBottomNavLoaded(args: EventData) {
15+
const bottomNav = args.object as BottomNavigation;
16+
17+
/*
18+
Using the items property to assign array of TabContentItem componentns
19+
Note: The number of TabContentItem components should be equal to the number of TabStripItem components
20+
*/
21+
const tabContentItemsArray: Array<TabContentItem> = this.createTabsContentArray();
22+
bottomNav.items = tabContentItemsArray;
23+
24+
/*
25+
Using the tabStrip property to createa a TabStrip with multiple TabStripItems (tabs)
26+
Note: The number of TabStripItem components should be equal to the number of TabContentItem components
27+
*/
28+
const tabStrip = this.createTabStrip();
29+
bottomNav.tabStrip = tabStrip;
30+
31+
/*
32+
Using the selectedIndex property
33+
*/
34+
bottomNav.selectedIndex = 1;
35+
36+
console.log(bottomNav.nativeView); // === bottomNav.android | bottomNav.ios
37+
}
38+
39+
createTabStrip() {
40+
const tabStrip: TabStrip = new TabStrip();
41+
tabStrip.iosIconRenderingMode = "automatic"; // iOS only (automatic is the default value)
42+
const tabStripItems: Array<TabStripItem> = [];
43+
for (let index = 0; index < 3; index++) {
44+
const item: TabStripItem = new TabStripItem();
45+
/*
46+
Using TabStripItem title property
47+
*/
48+
item.title = `Tab ${index}`;
49+
/*
50+
Using TabStripItem title property
51+
*/
52+
item.iconSource = index === 0
53+
? "res://baseline_home_black_24pt"
54+
: (index === 1
55+
? "res://baseline_account_balance_black_24pt"
56+
: "res://baseline_search_black_24pt");
57+
tabStripItems.push(item);
58+
}
59+
tabStrip.items = tabStripItems;
60+
61+
return tabStrip;
62+
}
63+
64+
createTabsContentArray() {
65+
const arr: Array<TabContentItem> = [];
66+
for (let index = 0; index < 3; index++) {
67+
const item: TabContentItem = new TabContentItem();
68+
// The createContent is a custom method that returns a StackLayout with a Label as a chils
69+
item.view = this.createContent(index);
70+
arr.push(item);
71+
}
72+
73+
return arr;
74+
}
75+
// >> (hide)
76+
createContent(index: number) {
77+
const label = new Label();
78+
label.text = `${index === 0 ? "Home" : (index === 1 ? "Account" : "Search")}`;
79+
label.className = "h2 text-center";
80+
label.color = new Color("red");
81+
const stack = new StackLayout();
82+
stack.verticalAlignment = "middle";
83+
stack.addChild(label);
84+
85+
return stack;
86+
}
87+
// << (hide)
88+
}
89+
// << bottom-navigation-properties-ng

0 commit comments

Comments
 (0)