-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathhome.component.ts
More file actions
86 lines (78 loc) · 2.04 KB
/
home.component.ts
File metadata and controls
86 lines (78 loc) · 2.04 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { Component, NgZone, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { RouterExtensions, NativeScriptCommonModule } from '@nativescript/angular';
import { Page, TabView } from '@nativescript/core';
@Component({
moduleId: module.id,
selector: 'demo-home',
templateUrl: './home.component.html',
imports: [NativeScriptCommonModule],
standalone: true,
})
export class HomeComponent implements OnInit {
tabItems: { [key: string]: { index: number; title?: string; iconSource?: string; textTransform?: string } } = {};
private _tabs = ['start'];
private _hasInitTab: { start?: boolean } = {};
private _tabView: TabView;
constructor(
private _ngZone: NgZone,
// vcRef: ViewContainerRef,
private _activeRoute: ActivatedRoute,
private _page: Page,
private _ngRouter: Router,
private _router: RouterExtensions,
) {
this._initMenu();
}
ngOnInit() {
this._viewTab(0);
}
onIndexChanged(e) {
if (e && e.object) {
this._tabView = <TabView>e.object;
}
}
loadedTabView(args) {
//
}
private _viewTab(index: number) {
let route;
switch (index) {
case 0:
if (!this._hasInitTab.start) {
this._hasInitTab.start = true;
route = { outlets: { startTab: ['start'] } };
}
break;
}
console.log('tab index changed:', index);
this._ngZone.run(() => {
if (route) {
this._router.navigate([route], {
animated: false,
relativeTo: this._activeRoute,
});
}
});
}
private _initMenu(profilePic?: string) {
for (let i = 0; i < this._tabs.length; i++) {
const tab = this._tabs[i];
// console.log('================')
// console.log(tab)
// console.log(i);
// console.log(tab);
let title = '';
switch (tab) {
case 'start':
title = 'Start Tab';
break;
}
this.tabItems[tab] = {
index: i,
title,
textTransform: 'capitalize',
};
}
}
}