Skip to content

Commit bb14c23

Browse files
committed
feat: support for frame elements
1 parent af728bd commit bb14c23

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"set-value": "^2.0.0",
7777
"tns-core-modules": "^3.4.0",
7878
"util-inspect": "^0.1.8",
79-
"vue": "^2.5.13"
79+
"vue": "^2.5.16"
8080
},
8181
"jest": {
8282
"verbose": true,

platform/nativescript/element-registry.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,11 @@ registerElement(
270270
skipAddToDom: true
271271
}
272272
)
273+
274+
registerElement('Frame', () => require('tns-core-modules/ui/frame').Frame, {
275+
insertChild(parentNode, childNode, atIndex) {
276+
if (childNode.tagName === 'page') {
277+
parentNode.nativeView.navigate({ create: () => childNode.nativeView })
278+
}
279+
}
280+
})

platform/nativescript/renderer/utils.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ export function isContentView(view) {
1515
}
1616

1717
export function insertChild(parentNode, childNode, atIndex = -1) {
18+
if (typeof parentNode.meta.insertChild === 'function') {
19+
return parentNode.meta.insertChild(parentNode, childNode, atIndex)
20+
}
21+
1822
if (!parentNode || childNode.meta.skipAddToDom) {
1923
return
2024
}
@@ -51,6 +55,10 @@ export function insertChild(parentNode, childNode, atIndex = -1) {
5155
}
5256

5357
export function removeChild(parentNode, childNode) {
58+
if (typeof parentNode.meta.removeChild === 'function') {
59+
return parentNode.meta.removeChild(parentNode, childNode)
60+
}
61+
5462
if (!parentNode || childNode.meta.skipAddToDom) {
5563
return
5664
}

samples/app/app-with-frames.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const Vue = require('./nativescript-vue')
2+
3+
Vue.config.silent = false
4+
Vue.config.debug = true
5+
6+
new Vue({
7+
data() {
8+
return {
9+
a: true
10+
}
11+
},
12+
template: `
13+
<GridLayout rows="*, *">
14+
<Frame row="0">
15+
<Page v-if="a">
16+
<StackLayout>
17+
<Label text="Hello Frame"/>
18+
<Button text="go to other Frame" @tap="a = false"/>
19+
</StackLayout>
20+
</Page>
21+
<Page v-else>
22+
<StackLayout>
23+
<Label text="Hello other frame"/>
24+
<Button text="go to prev Frame" @tap="a = true"/>
25+
</StackLayout>
26+
</Page>
27+
</Frame>
28+
<Frame row="1">
29+
<Page v-if="!a" actionBarHidden="true">
30+
<StackLayout>
31+
<Label text="Hello Frame"/>
32+
<Button text="go to other Frame" @tap="a = true"/>
33+
</StackLayout>
34+
</Page>
35+
<Page v-else actionBarHidden="true">
36+
<StackLayout>
37+
<Label text="Hello other frame"/>
38+
<Button text="go to prev Frame" @tap="a = false"/>
39+
</StackLayout>
40+
</Page>
41+
</Frame>
42+
</GridLayout>
43+
`
44+
}).$start()

0 commit comments

Comments
 (0)