I am creating a grocery list app that has a food food name on each row. The left column displays items that are not needed and the right column displays items that are needed. Currently I can change the state by clicking on each column. However, I'd like to toggle between these two functions so that switching the state works by clicking on the column like it does now, or just the row.
The HTML:
<ion-row id="test" (press)="delete(list)">
<ion-col class="offFoods" [ngClass]="{'grey-out': list.state == 'on'}" (tap)="additem(list)">
{{list.foodname}}
</ion-col>
<ion-col class="onFoods" [ngClass]="{'grey-out': list.state == 'off'}" (tap)="unlist(list)">
{{list.foodname}}
</ion-col>
</ion-row>
The TS for these functions:
additem(list) {
var listkey = this.listKey;
var customlistData = {
category: list.category,
foodname: list.foodname,
state: "on",
};
var user = firebase.auth().currentUser;
var uid = user.uid;
var foodid = list.$key;//Must click Banana
if(this.plt.is('ios')) {
this.taptic.selection();
}
if (this.plt.is('android')) {
this.vibration.vibrate(75);
}
return firebase.database().ref('userlists' + '/' + listkey + '/' + 'list' + '/' + foodid).set(customlistData);
}
unlist(list) {
var listkey = this.listKey;
var customlistData = {
category: list.category,
foodname: list.foodname,
state: "off",
};
var user = firebase.auth().currentUser;
var uid = user.uid;
var foodid = list.$key;//Must click Banana
if(this.plt.is('ios')) {
this.taptic.selection();
}
if (this.plt.is('android')) {
this.vibration.vibrate(75);
}
return firebase.database().ref('userlists' + '/' + listkey + '/' + 'list' + '/' + foodid).set(customlistData);
}