| @@ -36,7 +36,7 @@ | |||||
| </section> | </section> | ||||
| <ion-fab vertical="bottom" horizontal="start" slot="fixed"> | <ion-fab vertical="bottom" horizontal="start" slot="fixed"> | ||||
| <ion-fab-button class="share-button"> | |||||
| <ion-fab-button class="share-button" (click)="share()"> | |||||
| <ion-icon name="share-social-outline"></ion-icon> | <ion-icon name="share-social-outline"></ion-icon> | ||||
| </ion-fab-button> | </ion-fab-button> | ||||
| </ion-fab> | </ion-fab> | ||||
| @@ -4,6 +4,7 @@ import { Location } from '@angular/common'; | |||||
| import { DomSanitizer } from '@angular/platform-browser'; | import { DomSanitizer } from '@angular/platform-browser'; | ||||
| import { NewsService, IMAGE_BASE_URL } from '../services/news.service'; | import { NewsService, IMAGE_BASE_URL } from '../services/news.service'; | ||||
| import { ToastService } from '../services/toast.service'; | import { ToastService } from '../services/toast.service'; | ||||
| import { SocialSharing } from '@ionic-native/social-sharing/ngx'; | |||||
| @Component({ | @Component({ | ||||
| selector: 'app-home-details', | selector: 'app-home-details', | ||||
| @@ -20,7 +21,8 @@ export class HomeDetailsPage implements OnInit { | |||||
| private location: Location, | private location: Location, | ||||
| private dom:DomSanitizer, | private dom:DomSanitizer, | ||||
| private newsService: NewsService, | private newsService: NewsService, | ||||
| private toastService: ToastService | |||||
| private toastService: ToastService, | |||||
| private socialSharing: SocialSharing | |||||
| ) { } | ) { } | ||||
| getUrl(url) { | getUrl(url) { | ||||
| @@ -31,6 +33,10 @@ export class HomeDetailsPage implements OnInit { | |||||
| return this.dom.bypassSecurityTrustHtml(htmlTextWithStyle += '<style type="text/css">p{ margin: 0px 0px 10px 0px; }</style>'); | return this.dom.bypassSecurityTrustHtml(htmlTextWithStyle += '<style type="text/css">p{ margin: 0px 0px 10px 0px; }</style>'); | ||||
| } | } | ||||
| share() { | |||||
| this.socialSharing.share(this.newsDetails.title, '', IMAGE_BASE_URL + this.newsDetails.image_path + this.newsDetails.image_file_name, this.newsDetails.hls_url ? this.newsDetails.hls_url : ''); | |||||
| } | |||||
| ngOnInit() { | ngOnInit() { | ||||
| let alias_title = this.route.snapshot.paramMap.get('alias_title'); | let alias_title = this.route.snapshot.paramMap.get('alias_title'); | ||||
| let type = this.route.snapshot.paramMap.get('type'); | let type = this.route.snapshot.paramMap.get('type'); | ||||
| @@ -6,7 +6,7 @@ | |||||
| </div> | </div> | ||||
| <header> {{ currentMatch.Teams[currentMatch.Matchdetail.Team_Home].Name_Short }} v/s {{ currentMatch.Teams[currentMatch.Matchdetail.Team_Away].Name_Short }} <br> | <header> {{ currentMatch.Teams[currentMatch.Matchdetail.Team_Home].Name_Short }} v/s {{ currentMatch.Teams[currentMatch.Matchdetail.Team_Away].Name_Short }} <br> | ||||
| <span> {{ currentMatch.Matchdetail.Venue.Name }} </span> </header> | <span> {{ currentMatch.Matchdetail.Venue.Name }} </span> </header> | ||||
| <div class="action"> | |||||
| <div class="action" (click)="shareMatchDetails()"> | |||||
| <button> <ion-icon name="share-social"></ion-icon> </button> | <button> <ion-icon name="share-social"></ion-icon> </button> | ||||
| </div> | </div> | ||||
| </section> | </section> | ||||
| @@ -4,7 +4,7 @@ import { ActivatedRoute } from '@angular/router'; | |||||
| import { MatchService } from '../services/match.service'; | import { MatchService } from '../services/match.service'; | ||||
| import { ToastService } from '../services/toast.service'; | import { ToastService } from '../services/toast.service'; | ||||
| import { RawMatchData } from '../live/live.page'; | import { RawMatchData } from '../live/live.page'; | ||||
| import { SocialSharing } from '@ionic-native/social-sharing/ngx'; | |||||
| interface RawCommentaryForBall { | interface RawCommentaryForBall { | ||||
| Over: string; | Over: string; | ||||
| @@ -69,9 +69,25 @@ export class MatchDetailsPage implements OnInit { | |||||
| private location: Location, | private location: Location, | ||||
| private route: ActivatedRoute, | private route: ActivatedRoute, | ||||
| private matchService: MatchService, | private matchService: MatchService, | ||||
| private toastService: ToastService | |||||
| private toastService: ToastService, | |||||
| private socialSharing: SocialSharing | |||||
| ) { } | ) { } | ||||
| shareMatchDetails() { | |||||
| console.log("Sharing match details..."); | |||||
| let message: string; | |||||
| if (this.currentMatch.Innings) { | |||||
| this.currentMatch.Innings.forEach(inning => { | |||||
| message = this.currentMatch.Teams[inning.Battingteam].Name_Short + ' ' + inning.Total + '/' + inning.Wickets + '(' + inning.Overs + ')' + '\n'; | |||||
| }); | |||||
| } else { | |||||
| message = 'Match to start on, ' + this.currentMatch.Matchdetail.Match.Date + ' @' + this.currentMatch.Matchdetail.Match.Time + '\n' + this.currentMatch.Teams[this.currentMatch.Matchdetail.Team_Home].Name_Short + ' v/s ' + this.currentMatch.Teams[this.currentMatch.Matchdetail.Team_Away].Name_Short; | |||||
| } | |||||
| this.socialSharing.share(message); | |||||
| } | |||||
| ngOnInit() { | ngOnInit() { | ||||
| let match_id = JSON.parse(this.route.snapshot.paramMap.get('match_id')); | let match_id = JSON.parse(this.route.snapshot.paramMap.get('match_id')); | ||||