replaced listview with collectionview

This commit is contained in:
vishnuraghavb 2021-03-01 00:19:36 +05:30
parent a8302d4d2e
commit 10094f4894
2 changed files with 31 additions and 19 deletions

View file

@ -41,7 +41,14 @@
:text="`${currentComponent}` | L" :text="`${currentComponent}` | L"
col="1" col="1"
/> />
<!-- <MDButton v-if="recipes.length" class="er" :text="layout== 1 ? icon.l1 : layout==2 ? icon.l2 : icon.l3" variant="text" col="2" @tap="switchLayout" /> --> <MDButton
v-if="recipes.length"
class="er mdr"
:text="layout == 1 ? icon.l1 : layout == 2 ? icon.l2 : icon.l3"
variant="text"
col="2"
@tap="switchLayout"
/>
<MDButton <MDButton
v-if="recipes.length && !selectMode" v-if="recipes.length && !selectMode"
class="er" class="er"
@ -61,14 +68,14 @@
</GridLayout> </GridLayout>
</ActionBar> </ActionBar>
<AbsoluteLayout> <AbsoluteLayout>
<ListView <CollectionView
width="100%" width="100%"
height="100%" height="100%"
for="recipe in filteredRecipes" for="recipe in filteredRecipes"
@loaded="listViewLoad" ref="listview"
:itemTemplateSelector="getLayout" :itemTemplateSelector="getLayout"
> >
<v-template key="one"> <v-template name="one">
<GridLayout class="recipeContainer" :class="isFirstItem(recipe.id)"> <GridLayout class="recipeContainer" :class="isFirstItem(recipe.id)">
<GridLayout <GridLayout
class="recipeItem layout1 mdr" class="recipeItem layout1 mdr"
@ -152,8 +159,7 @@
</GridLayout> </GridLayout>
</GridLayout> </GridLayout>
</v-template> </v-template>
<v-template name="two">
<!-- <v-template key="two">
<GridLayout class="recipeContainer" :class="isFirstItem(recipe.id)"> <GridLayout class="recipeContainer" :class="isFirstItem(recipe.id)">
<GridLayout <GridLayout
class="recipeItem layout2 mdr" class="recipeItem layout2 mdr"
@ -218,7 +224,7 @@
</GridLayout> </GridLayout>
</GridLayout> </GridLayout>
</v-template> </v-template>
<v-template key="three"> <v-template name="three">
<GridLayout class="recipeContainer" :class="isFirstItem(recipe.id)"> <GridLayout class="recipeContainer" :class="isFirstItem(recipe.id)">
<GridLayout <GridLayout
class="recipeItem layout1 mdr" class="recipeItem layout1 mdr"
@ -257,8 +263,8 @@
</StackLayout> </StackLayout>
</GridLayout> </GridLayout>
</GridLayout> </GridLayout>
</v-template> --> </v-template>
</ListView> </CollectionView>
<GridLayout rows="*, auto, *, 88" columns="*" class="emptyStateContainer"> <GridLayout rows="*, auto, *, 88" columns="*" class="emptyStateContainer">
<StackLayout <StackLayout
row="1" row="1"
@ -499,10 +505,11 @@ export default {
e.setDivider(null); e.setDivider(null);
e.setDividerHeight(1); e.setDividerHeight(1);
}, },
// switchLayout() { switchLayout() {
// if ( this.layout == 2 ) this.layout = 1 if (this.layout == 3) this.layout = 1;
// else this.layout++ else this.layout++;
// }, this.$refs.listview.refresh();
},
getLayout() { getLayout() {
switch (this.layout) { switch (this.layout) {
case 1: case 1:
@ -739,17 +746,20 @@ export default {
// DATA HANDLERS // DATA HANDLERS
addToSelection(args, id) { addToSelection(args, id) {
// console.log(args, id);
this.showFAB = false; this.showFAB = false;
if (!this.selectMode) this.hijackLocalBackEvent(); if (!this.selectMode) this.hijackLocalBackEvent();
this.selectMode = true; this.selectMode = true;
this.$emit("selectModeOn", false); this.$emit("selectModeOn", false);
let item = args.object; let item = args.object;
if (item.className === "selected") { console.log(item.className);
item.className = ""; let classes = item.className;
if (classes.includes("selected")) {
item.className = classes.replace(/selected/g, "");
this.selection.splice(this.selection.indexOf(id), 1); this.selection.splice(this.selection.indexOf(id), 1);
this.recipeList.splice(this.selection.indexOf(id), 1); this.recipeList.splice(this.selection.indexOf(id), 1);
} else { } else {
item.className = "selected"; item.className = classes + " selected";
this.selection.push(id); this.selection.push(id);
this.recipeList.push(item); this.recipeList.push(item);
} }
@ -759,7 +769,9 @@ export default {
this.selectMode = false; this.selectMode = false;
this.$emit("selectModeOn", true); this.$emit("selectModeOn", true);
this.selection = []; this.selection = [];
this.recipeList.forEach((e) => (e.className = "")); this.recipeList.forEach((e) => {
e.className = e.className.replace(/selected/g, "");
});
this.releaseLocalBackEvent(); this.releaseLocalBackEvent();
this.showFAB = true; this.showFAB = true;
}, },

View file

@ -15,8 +15,8 @@
android { android {
defaultConfig { defaultConfig {
versionCode 6 versionCode 7
versionName '1.3.0' versionName '1.3.1'
applicationId 'com.vishnuraghav.enrecipes' applicationId 'com.vishnuraghav.enrecipes'
minSdkVersion 21 minSdkVersion 21
generatedDensities = [] generatedDensities = []