-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathtab-item-binding.component.ts
56 lines (46 loc) · 1.31 KB
/
tab-item-binding.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Component } from "@angular/core";
import { isAndroid } from "platform";
function getIconSource(icon: string): string {
const iconPrefix = isAndroid ? "res://" : "res://tabIcons/";
return iconPrefix + icon;
}
const notSelected = {
title: "Not Selected",
textTransform: "lowercase",
iconSource: getIconSource("home")
};
const selected = {
title: "Selected",
textTransform: "uppercase",
iconSource: getIconSource("browse")
};
@Component({
template: `
<ActionBar title="Tab Item Binding"></ActionBar>
<TabView (selectedIndexChange)="onIndexChange($event)">
<GridLayout *tabItem="items[0]">
<Label text="First Tab"></Label>
</GridLayout>
<GridLayout *tabItem="items[1]">
<Label text="Second Tab"></Label>
</GridLayout>
<GridLayout *tabItem="items[2]">
<Label text="Third Tab"></Label>
</GridLayout>
</TabView>
`
})
export class TabItemBindingComponent {
public items = [
notSelected,
notSelected,
notSelected
];
onIndexChange(args): void {
const selectedIndex = args.object.selectedIndex;
for (let i = 0; i < this.items.length; i++) {
this.items[i] = notSelected;
}
this.items[selectedIndex] = selected;
}
}