Skip to content

Commit

Permalink
swipe to delete
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmenkus committed Mar 2, 2020
1 parent fc27032 commit 8e8db32
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
13 changes: 10 additions & 3 deletions src/app/contacts/contacts.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@
<ion-icon color="dark" name="add-circle-outline"></ion-icon>
</ion-button>
<ion-list *ngIf="!none">
<ion-item *ngFor="let account of socialAccounts" href="{{account.url}}">
<ion-label>{{account.user}}</ion-label>
</ion-item>
<ion-item-sliding *ngFor="let account of socialAccounts">
<ion-item>
<ion-label>{{account.user}}</ion-label>
</ion-item>
<ion-item-options side="end">
<ion-item-option color="danger" (click)="deleteAccount(account)">
<ion-icon color="dark" name="trash"></ion-icon>
</ion-item-option>
</ion-item-options>
</ion-item-sliding>
</ion-list>
</ion-card>
<ion-card *ngIf="adding">
Expand Down
4 changes: 4 additions & 0 deletions src/app/contacts/contacts.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export class ContactsPage implements OnInit {
this.adding = true;
}

deleteAccount(account: backend.socialAccount) {
this.firebase.deleteSocialAccount(this.type, account);
}

addSMAccount() {
this.firebase.addSocialAccount(this.type, new backend.socialAccount(this.id,this.username,this.url));
this.adding = false;
Expand Down
15 changes: 11 additions & 4 deletions src/app/home/home.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,18 @@
<ion-avatar>
<ion-img src = "{{contact.photo}}"></ion-img>
</ion-avatar>
</ion-col>
</ion-col>
<ion-col id ="user-info">
<ion-item lines="none">
<ion-title>{{contact.name}}</ion-title>
</ion-item>
<ion-item-sliding>
<ion-item lines="none">
<ion-title>{{contact.name}}</ion-title>
</ion-item>
<ion-item-options side="end">
<ion-item-option color="danger" (click)="deleteContact(contact)">
<ion-icon color="dark" name="trash"></ion-icon>
</ion-item-option>
</ion-item-options>
</ion-item-sliding>
</ion-col>
</ion-row>
</ion-grid>
Expand Down
4 changes: 4 additions & 0 deletions src/app/home/home.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export class HomePage {
});
}

deleteContact(cont: backend.contact) {
this.firebase.deleteFromUserContacts(cont);
}

goToUserContact( cont: backend.contact ) {
this.router.navigate(['user-contact', {contact: JSON.stringify(cont)}]);
}
Expand Down

0 comments on commit 8e8db32

Please sign in to comment.