refactor(demos): make each actionSheet section a module

This commit is contained in:
Drew Rygh
2015-11-04 16:23:05 -06:00
parent 3003c73890
commit 19ce43a182
4 changed files with 6 additions and 6 deletions

View File

@ -0,0 +1,77 @@
import {Platform, Page, ActionSheet} from 'ionic/ionic';
import {forwardRef} from 'angular2/angular2';
import {AndroidAttribute} from '../../helpers';
@Page({
templateUrl: 'action-sheets/basic/basic.html',
directives: [forwardRef(() => AndroidAttribute)]
})
export class BasicPage {
constructor(actionSheet: ActionSheet, platform: Platform) {
this.actionSheet = actionSheet;
this.platform = platform;
}
openMenu() {
if (this.platform.is('android')) {
var androidSheet = {
buttons: [
{ text: 'Share', icon: 'share' },
{ text: 'Play', icon: 'arrow-dropright-circle'},
{ text: 'Favorite', icon: 'ion-md-heart-outline'}
],
destructiveText: 'Delete',
titleText: 'Albums',
cancelText: 'Cancel',
cancel: function() {
console.log('Canceled');
},
destructiveButtonClicked: () => {
console.log('Destructive clicked');
},
buttonClicked: function(index) {
console.log('Button clicked', index);
if (index == 1) { return false; }
return true;
}
};
}
this.actionSheet.open(androidSheet || {
buttons: [
{ text: 'Share'},
{ text: 'Play'},
{ text: 'Favorite'}
],
destructiveText: 'Delete',
titleText: 'Albums',
cancelText: 'Cancel',
cancel: function() {
console.log('Canceled');
},
destructiveButtonClicked: () => {
console.log('Destructive clicked');
},
buttonClicked: function(index) {
console.log('Button clicked', index);
if (index == 1) { return false; }
return true;
}
}).then(actionSheetRef => {
console.log(actionSheetRef);
this.actionSheetRef = actionSheetRef;
});
}
onPageWillLeave() {
let actionSheet = this.actionSheet.get();
if (actionSheet) {
actionSheet.close();
}
}
}