Skip to content

Commit 3f658e0

Browse files
committed
test: vue demo app
1 parent 921f9f5 commit 3f658e0

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

demo-vue/app/examples/Tabs.vue

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<NavigationButton text="Back" android.systemIcon="ic_menu_back" @tap="onNavigationButtonTap" />
55
</ActionBar>
66

7-
<MDTabs selectedIndex="1">
7+
<MDTabs ref="tabs" unloadOnTabChange="false">
88
<!-- The bottom tab UI is created via MDTabStrip (the containier) and MDTabStripItem (for each tab)-->
99
<MDTabStrip>
1010
<MDTabStripItem>
@@ -29,22 +29,18 @@
2929
</MDTabContentItem>
3030
<MDTabContentItem>
3131
<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>
3833
</GridLayout>
3934
</MDTabContentItem>
35+
4036
</MDTabs>
4137
</Page>
4238
</template>
4339

4440
<script lang="ts">
4541
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';
4844
4945
import Vue from 'vue';
5046
@@ -54,24 +50,46 @@ export default Vue.extend({
5450
name: 'Tabs',
5551
data() {
5652
return {
57-
title: title
53+
title: title,
54+
addThirdItem:false
5855
};
5956
},
6057
methods: {
6158
onNavigationButtonTap() {
6259
frameModule.Frame.topmost().goBack();
6360
},
61+
6462
onLoaded(name) {
6563
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)
6685
}
6786
}
6887
});
6988
</script>
7089

7190
<style>
7291
73-
MDTabs {
74-
/* color: gold; */
92+
/* MDTabs {
7593
}
7694
7795
MDTabContentItem.special {
@@ -96,6 +114,6 @@ MDTabStripItem.nested Label {
96114
97115
MDTabStripItem.nested:active Label {
98116
color: yellowgreen;
99-
}
117+
} */
100118
101119
</style>

0 commit comments

Comments
 (0)