-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathHome.vue
More file actions
71 lines (67 loc) · 1.87 KB
/
Home.vue
File metadata and controls
71 lines (67 loc) · 1.87 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
<template>
<Page>
<ActionBar title="NativeFlix" />
<ListView
height="100%"
separatorColor="transparent"
:items="flicks"
@itemTap="onFlickTap">
<template #default="{ item }">
<GridLayout
height="280"
borderRadius="10"
class="bg-secondary"
rows="*, auto, auto"
columns="*"
margin="5 10"
padding="0">
<Image
row="0"
margin="0"
stretch="aspectFill"
:src="item.image" />
<Label
row="1"
margin="10 10 0 10"
fontWeight="700"
class="text-primary"
fontSize="18"
:text="item.title" />
<Label
row="2"
margin="0 10 10 10"
class="text-secondary"
fontSize="14"
textWrap="true"
:text="item.description" />
</GridLayout>
</template>
</ListView>
</Page>
</template>
<script lang="ts">
import { defineComponent } from "nativescript-vue";
import FlickService from '../services/FlickService';
import Details from './Details.vue';
import type { FlickModel } from '../models/Flick';
const flickService = new FlickService();
export default defineComponent({
data() {
return {
flicks: flickService.getFlicks() as FlickModel[]
}
},
methods: {
onFlickTap(args: { item?: FlickModel; index?: number }) {
const item = args.item || (typeof args.index === 'number' ? this.flicks[args.index] : undefined);
if (!item) {
return;
}
const id = item.id;
this.$navigateTo(Details, {
props: { id }
});
}
}
});
</script>