4
4
<NavigationButton text =" Back" android.systemIcon =" ic_menu_back" @tap =" onNavigationButtonTap" />
5
5
</ActionBar >
6
6
7
- <MDTabs selectedIndex = " 1 " >
7
+ <MDTabs ref = " tabs " unloadOnTabChange = " false " >
8
8
<!-- The bottom tab UI is created via MDTabStrip (the containier) and MDTabStripItem (for each tab)-->
9
9
<MDTabStrip >
10
10
<MDTabStripItem >
29
29
</MDTabContentItem >
30
30
<MDTabContentItem >
31
31
<GridLayout backgroundColor =" green" @loaded =" onLoaded('green')" >
32
- <Label text =" Account Page" class =" h2 text-center" ></Label >
33
- </GridLayout >
34
- </MDTabContentItem >
35
- <MDTabContentItem >
36
- <GridLayout backgroundColor =" yellow" @loaded =" onLoaded('yellow')" >
37
- <Label text =" Search Page" class =" h2 text-center" ></Label >
32
+ <Label text =" Account Page" class =" h2 text-center" @tap =" addPage" ></Label >
38
33
</GridLayout >
39
34
</MDTabContentItem >
35
+
40
36
</MDTabs >
41
37
</Page >
42
38
</template >
43
39
44
40
<script lang="ts">
45
41
import * as frameModule from ' @nativescript/core/ui/frame' ;
46
- import { Tabs } from ' @nativescript-community/ui-material-tabs' ;
47
- import { EventData } from ' @nativescript/core' ;
42
+ import { TabContentItem , Tabs } from ' @nativescript-community/ui-material-tabs' ;
43
+ import { Color , EventData , GridLayout , Label , StackLayout } from ' @nativescript/core' ;
48
44
49
45
import Vue from ' vue' ;
50
46
@@ -54,24 +50,46 @@ export default Vue.extend({
54
50
name: ' Tabs' ,
55
51
data() {
56
52
return {
57
- title: title
53
+ title: title ,
54
+ addThirdItem:false
58
55
};
59
56
},
60
57
methods: {
61
58
onNavigationButtonTap() {
62
59
frameModule .Frame .topmost ().goBack ();
63
60
},
61
+
64
62
onLoaded(name ) {
65
63
console .log (' onTabLoaded' , name )
64
+ },
65
+ createContent(index : number ) {
66
+ const label = new Label ();
67
+ label .text = ` ${index === 0 ? " Home" : (index === 1 ? " Account" : " Search" )} ` ;
68
+ label .className = " h2 text-center" ;
69
+ const stack = new GridLayout ();
70
+ stack .backgroundColor = " yellow" ;
71
+ stack .addChild (label );
72
+
73
+ return stack ;
74
+ },
75
+ addPage() {
76
+ console .log (' addPage' )
77
+ this .addThirdItem = true ;
78
+
79
+ const items = this .$refs .tabs .nativeView .items .slice (0 );
80
+ const item: TabContentItem = new TabContentItem ();
81
+ // The createContent is a custom method that returns a StackLayout with a Label as a chils
82
+ item .content = this .createContent (index );
83
+ items .push (item );
84
+ this .$refs .tabs .nativeView .items = items .slice (0 )
66
85
}
67
86
}
68
87
});
69
88
</script >
70
89
71
90
<style >
72
91
73
- MDTabs {
74
- /* color: gold; */
92
+ /* MDTabs {
75
93
}
76
94
77
95
MDTabContentItem.special {
@@ -96,6 +114,6 @@ MDTabStripItem.nested Label {
96
114
97
115
MDTabStripItem.nested:active Label {
98
116
color: yellowgreen;
99
- }
117
+ } */
100
118
101
119
</style >
0 commit comments