From 746b53cdc6750a3e5e3a81f303a9e64cd88adde5 Mon Sep 17 00:00:00 2001 From: kj1352 Date: Wed, 14 Apr 2021 08:48:37 +0530 Subject: [PATCH] Match details social sharing --- src/app/home-details/home-details.page.html | 2 +- src/app/home-details/home-details.page.ts | 8 +++++++- src/app/match-details/match-details.page.html | 2 +- src/app/match-details/match-details.page.ts | 20 +++++++++++++++++-- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/app/home-details/home-details.page.html b/src/app/home-details/home-details.page.html index b7ca7fe..49fa3fc 100644 --- a/src/app/home-details/home-details.page.html +++ b/src/app/home-details/home-details.page.html @@ -36,7 +36,7 @@ - diff --git a/src/app/home-details/home-details.page.ts b/src/app/home-details/home-details.page.ts index 53ccb45..6c3db96 100644 --- a/src/app/home-details/home-details.page.ts +++ b/src/app/home-details/home-details.page.ts @@ -4,6 +4,7 @@ import { Location } from '@angular/common'; import { DomSanitizer } from '@angular/platform-browser'; import { NewsService, IMAGE_BASE_URL } from '../services/news.service'; import { ToastService } from '../services/toast.service'; +import { SocialSharing } from '@ionic-native/social-sharing/ngx'; @Component({ selector: 'app-home-details', @@ -20,7 +21,8 @@ export class HomeDetailsPage implements OnInit { private location: Location, private dom:DomSanitizer, private newsService: NewsService, - private toastService: ToastService + private toastService: ToastService, + private socialSharing: SocialSharing ) { } getUrl(url) { @@ -31,6 +33,10 @@ export class HomeDetailsPage implements OnInit { return this.dom.bypassSecurityTrustHtml(htmlTextWithStyle += ''); } + 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() { let alias_title = this.route.snapshot.paramMap.get('alias_title'); let type = this.route.snapshot.paramMap.get('type'); diff --git a/src/app/match-details/match-details.page.html b/src/app/match-details/match-details.page.html index 0b5f321..438b02d 100644 --- a/src/app/match-details/match-details.page.html +++ b/src/app/match-details/match-details.page.html @@ -6,7 +6,7 @@
{{ currentMatch.Teams[currentMatch.Matchdetail.Team_Home].Name_Short }} v/s {{ currentMatch.Teams[currentMatch.Matchdetail.Team_Away].Name_Short }}
{{ currentMatch.Matchdetail.Venue.Name }}
-
+
diff --git a/src/app/match-details/match-details.page.ts b/src/app/match-details/match-details.page.ts index ebd6f57..e09ca38 100644 --- a/src/app/match-details/match-details.page.ts +++ b/src/app/match-details/match-details.page.ts @@ -4,7 +4,7 @@ import { ActivatedRoute } from '@angular/router'; import { MatchService } from '../services/match.service'; import { ToastService } from '../services/toast.service'; import { RawMatchData } from '../live/live.page'; - +import { SocialSharing } from '@ionic-native/social-sharing/ngx'; interface RawCommentaryForBall { Over: string; @@ -69,9 +69,25 @@ export class MatchDetailsPage implements OnInit { private location: Location, private route: ActivatedRoute, 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() { let match_id = JSON.parse(this.route.snapshot.paramMap.get('match_id'));