Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

119 wiersze
3.0 KiB

  1. import { Component, OnInit, ViewChild } from '@angular/core';
  2. import { Location } from '@angular/common';
  3. import { ActivatedRoute } from '@angular/router';
  4. import * as faker from 'faker';
  5. import { IonContent } from '@ionic/angular';
  6. type IPlayer = {
  7. name: string,
  8. image: string,
  9. jersey: number,
  10. isCaptain?: boolean,
  11. isKeeper?: boolean,
  12. isTopScorer?: boolean,
  13. role: string,
  14. };
  15. type ITeam = {
  16. name: string,
  17. image: string,
  18. players: Array<IPlayer>
  19. };
  20. @Component({
  21. selector: 'app-match-details',
  22. templateUrl: './match-details.page.html',
  23. styleUrls: ['./match-details.page.scss'],
  24. })
  25. export class MatchDetailsPage implements OnInit {
  26. @ViewChild(IonContent, { static: false }) content: IonContent;
  27. isPlayerSelected: boolean = false;
  28. isHomeTeamSelected: boolean = true;
  29. selectedSegment: 'MATCH' | 'SCORE' = 'MATCH';
  30. selectedRoster: 'LIVE' | 'HOME' | 'AWAY' = 'LIVE';
  31. roles = ['BOWLER', 'BATSMAN'];
  32. matchData: {
  33. home: ITeam,
  34. away: ITeam,
  35. };
  36. matchStats: {
  37. stadium: string,
  38. homeTeam: any,
  39. awayTeam: any
  40. };
  41. constructor(
  42. private location: Location,
  43. private route: ActivatedRoute,
  44. ) { }
  45. scrollToPlayerDetails() {
  46. let details: any = document.querySelector('.player-details');
  47. this.content.scrollToPoint(0, (details.offsetTop - 200), 1000);
  48. }
  49. ngOnInit() {
  50. this.matchStats = JSON.parse(this.route.snapshot.paramMap.get('matchStats'));
  51. this.matchData = {
  52. home : {
  53. name: 'KXIP',
  54. image: 'assets/home-team/KXIP.svg',
  55. players: []
  56. },
  57. away: {
  58. name: 'MI',
  59. image: 'assets/logos/mi.svg',
  60. players: []
  61. }
  62. };
  63. for (let i = 1; i < 12; i += 1) {
  64. this.matchData.home.players.push({
  65. name: faker.name.findName(),
  66. image: 'assets/home-team/roster/' + i.toString() + '.png',
  67. jersey: Math.ceil(Math.random() * (99 - 1)),
  68. isCaptain: i == 3? true : false,
  69. isKeeper: i === 5? true : false,
  70. role: this.roles[Math.floor(Math.random() * (2 - 0))],
  71. isTopScorer: i === 3? true : false
  72. });
  73. this.matchData.away.players.push({
  74. name: faker.name.findName(),
  75. image: 'assets/mi-roster/' + i.toString() + '.png',
  76. jersey: Math.ceil(Math.random() * (99 - 1)),
  77. isCaptain: i == 5? true : false,
  78. isKeeper: i === 4? true : false,
  79. role: this.roles[Math.floor(Math.random() * (2 - 0))]
  80. });
  81. }
  82. }
  83. back() {
  84. this.location.back();
  85. }
  86. selectPlayerDetails() {
  87. this.isPlayerSelected = true;
  88. setTimeout(() => {
  89. this.scrollToPlayerDetails();
  90. }, 100);
  91. }
  92. limitDecimals(value: number) {
  93. return value.toPrecision(2);
  94. }
  95. }