import { Component } from '@angular/core' ; import { ActionSheet , ActionSheetController , NavController } from 'ionic-angular' ; import { InAppBrowser } from 'ionic-native' ; import { ConferenceData } from '../../providers/conference-data' ; import { SessionDetailPage } from '../session-detail/session-detail' ; import { SpeakerDetailPage } from '../speaker-detail/speaker-detail' ; @ Component ( { templateUrl : 'build/pages/speaker-list/speaker-list.html' } ) export class SpeakerListPage { actionSheet : ActionSheet ; speakers = [ ] ; constructor ( public actionSheetCtrl , public navCtrl , confData ) { confData . getSpeakers ( ) . then ( speakers => { this . speakers = speakers ; } ) ; } goToSessionDetail ( session ) { this . navCtrl . push ( SessionDetailPage , session ) ; } goToSpeakerDetail ( speakerName ) { this . navCtrl . push ( SpeakerDetailPage , speakerName ) ; } goToSpeakerTwitter ( speaker ) { new InAppBrowser ( `https://twitter.com/${ speaker . twitter }` , '_system' ) ; } openSpeakerShare ( speaker ) { let actionSheet = this . actionSheetCtrl . create ( { title : 'Share ' + speaker . name , buttons : [ { text : 'Copy Link' , handler : ( ) => { console . log ( 'Copy link clicked on https://twitter.com/' + speaker . twitter ) ; if ( window [ 'cordova' ] && window [ 'cordova' ] . plugins . clipboard ) { window [ 'cordova' ] . plugins . clipboard . copy ( 'https://twitter.com/' + speaker . twitter ) ; } } } , { text : 'Share via ...' , handler : ( ) => { console . log ( 'Share via clicked' ) ; } } , { text : 'Cancel' , role : 'cancel' , handler : ( ) => { console . log ( 'Cancel clicked' ) ; } } ] } ) ; actionSheet . present ( ) ; } openContact ( speaker ) { let actionSheet = this . actionSheetCtrl . create ( { title : 'Contact with ' + speaker . name , buttons : [ { text : `Email ( ${ speaker . email } )` , icon : 'mail' , handler : ( ) => { window . open ( 'mailto:' + speaker . email ) ; } } , { text : `Call ( ${ speaker . phone } )` , icon : 'call' , handler : ( ) => { window . open ( 'tel:' + speaker . phone ) ; } } ] } ) ; actionSheet . present ( ) ; } }