From db9fa7ead31116d9011adcdc2ddf200954024880 Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Sun, 12 Jun 2016 03:07:08 +0200 Subject: [PATCH] fix(item): improve open/close logic, update demos --- demos/item-sliding/index.ts | 89 +++++++++++- demos/item-sliding/main.html | 149 ++++++--------------- src/components/item/item-sliding.scss | 8 +- src/components/item/item-sliding.ts | 28 +++- src/components/item/test/sliding/main.html | 16 +-- src/components/menu/menu.ts | 2 +- 6 files changed, 162 insertions(+), 130 deletions(-) diff --git a/demos/item-sliding/index.ts b/demos/item-sliding/index.ts index c40e1274f75..1f8a6143dff 100644 --- a/demos/item-sliding/index.ts +++ b/demos/item-sliding/index.ts @@ -1,10 +1,95 @@ import {Component} from '@angular/core'; -import {ionicBootstrap} from 'ionic-angular'; +import {ionicBootstrap, ItemSliding, Toast, NavController} from 'ionic-angular'; @Component({ templateUrl: 'main.html' }) -class ApiDemoApp {} +class InitialPage { + chats: any[]; + logins: any[]; + + constructor(private nav: NavController) { + this.chats = [ + { + img: './avatar-cher.png', + name: 'Cher', + message: 'Ugh. As if.', + time: '9:38 pm' + }, { + img: './avatar-dionne.png', + name: 'Dionne', + message: 'Mr. Hall was way harsh.', + time: '8:59 pm' + }, { + img: './avatar-murray.png', + name: 'Murray', + message: 'Excuse me, "Ms. Dione."', + time: 'Wed' + }]; + + this.logins = [ + { + icon: 'logo-twitter', + name: 'Twitter', + username: 'admin', + }, { + icon: 'logo-github', + name: 'GitHub', + username: 'admin37', + }, { + icon: 'logo-instagram', + name: 'Instagram', + username: 'imanadmin', + }, { + icon: 'logo-codepen', + name: 'Codepen', + username: 'administrator', + }]; + } + + more(item: ItemSliding) { + console.log('More'); + item.close(); + } + + delete(item: ItemSliding) { + console.log('Delete'); + item.close(); + } + + mute(item: ItemSliding) { + console.log('Mute'); + item.close(); + } + + archive(item: ItemSliding) { + console.log('Archive'); + item.close(); + } + + download(item: ItemSliding) { + item.setClass('downloading', true); + setTimeout(() => { + const toast = Toast.create({ + message: 'Item was downloaded!' + }); + this.nav.present(toast); + item.setClass('downloading', false); + item.close(); + + // Wait 2s to close toast + setTimeout(() => toast.dismiss(), 2000); + }, 1500); + } +} + + +@Component({ + template: '' +}) +class ApiDemoApp { + root = InitialPage; +} ionicBootstrap(ApiDemoApp); diff --git a/demos/item-sliding/main.html b/demos/item-sliding/main.html index 75912f3bf65..ab8513fc413 100644 --- a/demos/item-sliding/main.html +++ b/demos/item-sliding/main.html @@ -8,83 +8,37 @@ Chats - + - + -

Cher

-

Ugh. As if.

+

{{chat.name}}

+

{{chat.message}}

- 9:38 pm + {{chat.time}}
- - - - - -
- - - - - -

Dionne

-

Mr. Hall was way harsh.

- - 8:59 pm - -
- - - -
- - - - - -

Murray

-

Excuse me, "Ms. Dione."

- - Wed - -
- - - -
@@ -95,66 +49,26 @@

Murray

Logins - + - -

Twitter

-

admin

+ +

{{login.name}}

+

{{login.username}}

- - - - -
- - - - -

GitHub

-

admin37

-
- - - - -
- - - - -

Instagram

-

imanadmin

-
- - + -
- - - - -

Codepen

-

administrator

-
- - -
@@ -164,6 +78,19 @@

Codepen