Skip to content

Commit 1eaa724

Browse files
committed
Merge branch 'master' into MisterBrownRSA-master
2 parents 7ea61fd + c0b7eaa commit 1eaa724

File tree

11 files changed

+131
-24
lines changed

11 files changed

+131
-24
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ and these awesome backers:
6363
- Robert M. Svendsen
6464
- Andy Drexler
6565
- ChiwalahSoftware
66+
- Nayir Chami
6667

6768
If you'd like to join them, please consider [becoming a backer / sponsor on Patreon](https://www.patreon.com/rigor789).
6869

platform/nativescript/runtime/components/android.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
functional: true,
66
render(h, { children }) {
77
if (isAndroid) {
8-
return children[0]
8+
return children
99
}
1010
}
1111
}

platform/nativescript/runtime/components/ios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
functional: true,
66
render(h, { children }) {
77
if (isIOS) {
8-
return children[0]
8+
return children
99
}
1010
}
1111
}

platform/nativescript/runtime/components/list-view.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ export default {
8282
const oldVnode = args.view && args.view[VUE_VIEW]
8383

8484
args.view = this.$templates.patchTemplate(name, context, oldVnode)
85+
},
86+
refresh() {
87+
this.$refs.listView.nativeView.refresh()
8588
}
8689
}
8790
}

platform/nativescript/runtime/components/v-template.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ export class VueKeyedTemplate /* implements KeyedTemplate */ {
101101
}
102102

103103
createView() {
104-
const vnode = this._scopedFn(deepProxy({}))
105-
const nativeView = patch(null, vnode).nativeView
106-
nativeView[VUE_VIEW] = vnode
107-
return nativeView
104+
// we are returning null because we don't have the data here
105+
// the view will be created in the `patchTemplate` method above.
106+
// see https://github.com/nativescript-vue/nativescript-vue/issues/229#issuecomment-390330474
107+
return null
108108
}
109109
}

platform/nativescript/runtime/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import platformComponents from './components/index'
1111
import platformDirectives from './directives/index'
1212

1313
import { mustUseProp, isReservedTag, isUnknownElement } from '../util/index'
14-
import { ensurePage } from '../util'
1514

1615
export const VUE_VM_REF = '__vue_vm_ref__'
1716

@@ -56,7 +55,7 @@ Vue.prototype.$mount = function(el, hydrating) {
5655
return mountComponent(this, el, hydrating)
5756
}
5857

59-
Vue.prototype.$start = function({ getRootView }) {
58+
Vue.prototype.$start = function() {
6059
let self = this
6160
const AppConstructor = Vue.extend(this.$options)
6261

@@ -67,10 +66,7 @@ Vue.prototype.$start = function({ getRootView }) {
6766
}
6867

6968
self.$mount()
70-
args.root =
71-
typeof getRootView === 'function'
72-
? getRootView(self)
73-
: ensurePage(self.$el, self)
69+
args.root = self.$el.nativeView
7470
})
7571

7672
run()

platform/nativescript/util/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export function isPage(el) {
3434
return el && el.tagName === 'page'
3535
}
3636

37+
/** @deprecated */
3738
export function ensurePage(el, vm) {
3839
if (!isPage(el)) {
3940
const page = new (getViewClass('page'))()

samples/app/127.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const Vue = require('./nativescript-vue')
2+
3+
Vue.config.silent = false
4+
5+
new Vue({
6+
data: {
7+
foo: false
8+
},
9+
template: `
10+
<Frame>
11+
<Page>
12+
<ActionBar title="Issue #127" />
13+
14+
<StackLayout>
15+
<Label v-if="foo" text="Enable" @tap="foo = false"/>
16+
<Label v-if="!foo" text="Disable" @tap="foo = true"/>
17+
</StackLayout>
18+
</Page>
19+
</Frame>
20+
`,
21+
created() {
22+
console.log(Vue.compile(this.$options.template).render.toString())
23+
}
24+
}).$start()

samples/app/229.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const Vue = require('./nativescript-vue')
2+
3+
Vue.config.silent = false
4+
5+
new Vue({
6+
data: {
7+
items: [{ color: 'red' }, { color: 'blue' }]
8+
},
9+
template: `
10+
<Frame>
11+
<Page>
12+
<ActionBar title="Issue #229" />
13+
14+
<GridLayout>
15+
<ListView for="item in items" class="list-group">
16+
<v-template>
17+
<Label :backgroundColor="item.color" :text="item.color" padding="50" />
18+
</v-template>
19+
</ListView>
20+
</GridLayout>
21+
</Page>
22+
</Frame>
23+
`
24+
}).$start()

samples/app/231.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const Vue = require('./nativescript-vue')
2+
3+
Vue.config.silent = false
4+
5+
const ImageCard = {
6+
props: {
7+
src: {
8+
type: String,
9+
required: true
10+
}
11+
},
12+
template: '<Image :src="src" stretch="aspectFit" />'
13+
}
14+
const url = 'https://api.giphy.com/v1/gifs/search'
15+
const key = 'ZboEpjHv00FzK6SI7l33H7wutWlMldQs'
16+
const filter = 'limit=25&offset=0&rating=G&lang=fr'
17+
18+
new Vue({
19+
components: {
20+
ImageCard
21+
},
22+
template: `
23+
<Frame>
24+
<Page class="page">
25+
<ActionBar class="action-bar" title="Poket Gif" />
26+
27+
<StackLayout class="layout">
28+
<SearchBar hint="Chercher un gif" ref="search" v-model="q" @submit="search" />
29+
30+
<ListView for="img in imgs" height="100%">
31+
<v-template>
32+
<ImageCard :src="img.images.downsized.url" />
33+
</v-template>
34+
</ListView>
35+
</StackLayout>
36+
</Page>
37+
</Frame>
38+
`,
39+
40+
data() {
41+
return {
42+
imgs: [],
43+
surprise: false,
44+
q: ''
45+
}
46+
},
47+
48+
methods: {
49+
search() {
50+
this.$refs.search.nativeView.dismissSoftInput()
51+
fetch(`${url}?api_key=${key}&q=${this.q}&${filter}`)
52+
.then(response => response.json())
53+
.then(json => (this.imgs = json.data))
54+
}
55+
}
56+
}).$start()

samples/app/app-with-android-ios.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@ const Vue = require('./nativescript-vue')
22

33
new Vue({
44
template: `
5-
<Page>
6-
<StackLayout>
7-
<Label android:text="hi android" ios:text="hi ios..." />
8-
9-
<android>
10-
<Label text="hello android" />
11-
</android>
12-
<ios>
13-
<Label text="hello ios" />
14-
</ios>
15-
</StackLayout>
16-
</Page>
5+
<Page>
6+
<StackLayout>
7+
<Label android:text="hi android" ios:text="hi ios..." />
8+
9+
<android>
10+
<Label text="hello android" />
11+
<Label text="hello android 2" />
12+
</android>
13+
<ios>
14+
<Label text="hello ios" />
15+
<Label text="hello ios 2" />
16+
</ios>
17+
</StackLayout>
18+
</Page>
1719
`
1820
}).$start({
1921
getRootView(self) {

0 commit comments

Comments
 (0)