|
| 1 | +<template> |
| 2 | + <Page> |
| 3 | + <StackLayout> |
| 4 | + <Label :text="currentSection" height="60" width="100%" backgroundColor="red" /> |
| 5 | + <CollectionView width="100%" height="100%" colWidth="50%" ref="listView" :items="itemList" @itemTap="onItemTap" itemIdGenerator="index" :spanSize="index => (index % 5 === 0 ? 2 : 1)"> |
| 6 | + <v-template if="$index % 5 === 0"> |
| 7 | + <Label fontSize="17" :text="item.title" verticalAlignment="center" height="30" /> |
| 8 | + </v-template> |
| 9 | + <v-template> |
| 10 | + <GridLayout columns="16,auto,*,auto,16" rows="12,auto,*,auto" rippleColor="red" backgroundColor="white" height="80"> |
| 11 | + <Label |
| 12 | + v-show="!!item.leftIcon" |
| 13 | + col="1" |
| 14 | + row="0" |
| 15 | + rowSpan="5" |
| 16 | + fontSize="24" |
| 17 | + marginRight="16" |
| 18 | + textAlignment="left" |
| 19 | + :text="item.leftIcon" |
| 20 | + horizontalAlignment="left" |
| 21 | + verticalAlignment="center" |
| 22 | + color="gray" |
| 23 | + class="mdi" |
| 24 | + /> |
| 25 | + <Image |
| 26 | + v-show="item.avatar" |
| 27 | + backgroundColor="gray" |
| 28 | + col="1" |
| 29 | + row="1" |
| 30 | + rowSpan="3" |
| 31 | + width="40" |
| 32 | + height="40" |
| 33 | + stretch="aspectFill" |
| 34 | + marginRight="16" |
| 35 | + :src="item.avatar" |
| 36 | + verticalAlignment="center" |
| 37 | + borderRadius="20" |
| 38 | + android:roundAsCircle="true" |
| 39 | + /> |
| 40 | + |
| 41 | + <StackLayout col="2" row="1" rowSpan="2" verticalAlignment="center"> |
| 42 | + <Label col="2" row="1" :fontSize="10" v-show="!!item.overText" :text="item.overText | uppercase" verticalAlignment="center" color="gray" /> |
| 43 | + <Label :fontSize="17" :text="item.title" textWrap="true" verticalTextAlignment="top" maxLines="2" lineBreak="end" /> |
| 44 | + <Label v-show="!!item.subtitle" :fontSize="14" :text="item.subtitle" verticalTextAlignment="top" color="gray" maxLines="2" lineBreak="end" /> |
| 45 | + </StackLayout> |
| 46 | + |
| 47 | + <Label col="3" row="1" fontSize="10" v-show="!!item.date" :text="item.date" verticalAlignment="top" /> |
| 48 | + <GridLayout col="3" row="1" rowSpan="2" verticalAlignment="center"> |
| 49 | + <Label v-show="!!item.rightIcon" class="mdi" :fontSize="24" textAlignment="right" color="gray" :text="item.rightIcon" verticalAlignment="center" /> |
| 50 | + <Button variant="flat" v-show="!!item.rightButton" class="icon-themed-btn" :text="item.rightButton" verticalAlignment="center" @tap="$emit('rightTap')" /> |
| 51 | + </GridLayout> |
| 52 | + |
| 53 | + <AbsoluteLayout row="3" colSpan="5" marginTop="12" marginLeft="20" backgroundColor="gray" height="1" verticalAlignment="bottom" /> |
| 54 | + </GridLayout> |
| 55 | + </v-template> |
| 56 | + </CollectionView> |
| 57 | + </StackLayout> |
| 58 | + </Page> |
| 59 | +</template> |
| 60 | + |
| 61 | +<script lang="ts"> |
| 62 | +const DetailsPage = { |
| 63 | + template: ` |
| 64 | + <Page> |
| 65 | + <ActionBar class="action-bar" title="Details Page"> |
| 66 | + <ActionItem text="Action"></ActionItem> |
| 67 | + </ActionBar> |
| 68 | + <StackLayout> |
| 69 | + <Label :text="'Details ' + Math.random()" /> |
| 70 | + <Button text="another" @tap="openDetails" /> |
| 71 | + <Button text="back" @tap="goBack" /> |
| 72 | + </StackLayout> |
| 73 | + </Page> |
| 74 | + `, |
| 75 | +
|
| 76 | + methods: { |
| 77 | + openDetails() { |
| 78 | + this.$navigateTo(DetailsPage); |
| 79 | + }, |
| 80 | + goBack() { |
| 81 | + this.$navigateBack(); |
| 82 | + } |
| 83 | + } |
| 84 | +}; |
| 85 | +
|
| 86 | +export default { |
| 87 | + data() { |
| 88 | + const items = []; |
| 89 | + for (let loop = 0; loop < 1000; loop++) { |
| 90 | + items.push({ |
| 91 | + // width: loop % 5 === 0 ? '100%' : '50%', |
| 92 | + index: loop, |
| 93 | + leftIcon: 'mdi-magnify', |
| 94 | + title: 'title ' + loop.toString(), |
| 95 | + subtitle: 'subtitle ' + loop.toString() |
| 96 | + // visible: loop % 10 !== 0 |
| 97 | + }); |
| 98 | + } |
| 99 | + return { |
| 100 | + currentSection: 0, |
| 101 | + itemList: items |
| 102 | + }; |
| 103 | + }, |
| 104 | + methods: { |
| 105 | + onItemTap({ index, item }) { |
| 106 | + console.log(`Tapped on ${index} ${item.title}`); |
| 107 | + this.$navigateTo(DetailsPage); |
| 108 | + }, |
| 109 | + logEvent(e) { |
| 110 | + console.log('logEvent', e.eventName, e.extraData); |
| 111 | + } |
| 112 | + // onDisplayEvent(e) { |
| 113 | + // console.log('onDisplayEvent', e.eventName, e.index); |
| 114 | + // if (e.index % 5 === 0 && this.currentSection !== e.index) { |
| 115 | + // // this.currentSection = e.index; |
| 116 | + // } |
| 117 | + // } |
| 118 | + // itemIdGenerator(item, i) { |
| 119 | + // return item.index; |
| 120 | + // } |
| 121 | + } |
| 122 | +}; |
| 123 | +</script> |
| 124 | + |
| 125 | +<style scoped> |
| 126 | +ActionBar { |
| 127 | + background-color: #53ba82; |
| 128 | + color: #ffffff; |
| 129 | +} |
| 130 | +
|
| 131 | +.message { |
| 132 | + vertical-align: center; |
| 133 | + text-align: center; |
| 134 | + font-size: 20; |
| 135 | + color: #333333; |
| 136 | +} |
| 137 | +</style> |
0 commit comments