Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

home.page.ts 4.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import { Component, OnInit, ViewChild } from '@angular/core';
  2. import { IonSlides } from '@ionic/angular';
  3. import { Router } from '@angular/router';
  4. export type INews = {
  5. id: string | number,
  6. image: string,
  7. heading: string,
  8. description: string,
  9. type: 'VIDEO' | 'ARTICLE',
  10. likes: number,
  11. isBookmarked: boolean,
  12. isLiked: boolean,
  13. comments: Array<{
  14. user: string,
  15. comment: string,
  16. likes: number,
  17. isLiked: boolean
  18. }>,
  19. };
  20. @Component({
  21. selector: 'app-home',
  22. templateUrl: './home.page.html',
  23. styleUrls: ['./home.page.scss'],
  24. })
  25. export class HomePage implements OnInit {
  26. @ViewChild('slides') slides: IonSlides;
  27. selectedTab: string = 'news';
  28. selectedArticle: number = null;
  29. slideOpts = {
  30. slidesPerView: 1.5,
  31. spaceBetween: 15,
  32. initialSlide: 1,
  33. centeredSlides: true
  34. };
  35. newsData: Array<INews> = [];
  36. constructor(
  37. private router: Router
  38. ) { }
  39. ngOnInit() {
  40. this.newsData = [{
  41. id: 0,
  42. image: 'https://www.ak4tsay1.com/wp-content/uploads/2020/02/Kings-XI-Punjab-KXIP-Strengths-and-Weakness-for-IPL-2020-800x445.jpg',
  43. heading: 'KL Rahul scores fastest 100',
  44. description: `Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste ab qui, incidunt illo dolore laboriosam sapiente deserunt officiis ullam. Explicabo accusantium quia tempore totam repellat amet debitis adipisci deserunt iste.`,
  45. type: 'ARTICLE',
  46. isLiked: false,
  47. isBookmarked: false,
  48. likes: 308,
  49. comments: []
  50. }, {
  51. id: 1,
  52. image: 'https://s3.india.com/wp-content/uploads/2020/10/Mayank-Agarwal-celebrates-Kings-XI-Punjabs-win-over-Mumbai-Indians-in-match-37-of-Dream11-IPL-2020-in-Dubai%C2%A9KXIP-Twitter.jpg',
  53. heading: 'KXIP beat MI by 3 Wickets',
  54. description: `Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste ab qui, incidunt illo dolore laboriosam sapiente deserunt officiis ullam.
  55. Explicabo accusantium quia tempore totam repellat amet debitis adipisci deserunt iste.
  56. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste ab qui, incidunt illo dolore laboriosam sapiente deserunt officiis u
  57. santium quia tempore totam repellat amet debitis adipisci deserunt iste.
  58. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste ab qui, incidunt illo dolore laboriosam sapiente deserunt officiis u
  59. santium quia tempore totam repellat amet debitis adipisci deserunt iste.`,
  60. type: 'VIDEO',
  61. likes: 10,
  62. isLiked: false,
  63. isBookmarked: false,
  64. comments: [{
  65. user: 'kxipFan',
  66. comment: 'Yay!',
  67. likes: 2,
  68. isLiked: true,
  69. }, {
  70. user: 'SehwagFan',
  71. comment: 'finally!',
  72. likes: 5,
  73. isLiked: false,
  74. }]
  75. }, {
  76. id: 2,
  77. image: 'https://www.ak4tsay1.com/wp-content/uploads/2020/02/Kings-XI-Punjab-KXIP-Strengths-and-Weakness-for-IPL-2020-800x445.jpg',
  78. heading: 'KL Rahul scores fastest 100',
  79. description: `Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste ab qui, incidunt illo dolore laboriosam sapiente deserunt officiis ullam. Explicabo accusantium quia tempore totam repellat amet debitis adipisci deserunt iste.`,
  80. type: 'ARTICLE',
  81. isLiked: false,
  82. isBookmarked: false,
  83. likes: 308,
  84. comments: []
  85. }, {
  86. id: 3,
  87. image: 'https://www.ak4tsay1.com/wp-content/uploads/2020/02/Kings-XI-Punjab-KXIP-Strengths-and-Weakness-for-IPL-2020-800x445.jpg',
  88. heading: 'KL Rahul scores fastest 100',
  89. description: `Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste ab qui, incidunt illo dolore laboriosam sapiente deserunt officiis ullam. Explicabo accusantium quia tempore totam repellat amet debitis adipisci deserunt iste.`,
  90. type: 'ARTICLE',
  91. isLiked: false,
  92. isBookmarked: false,
  93. likes: 308,
  94. comments: []
  95. }];
  96. }
  97. ngAfterViewInit() {
  98. this.selectedArticle = 0;
  99. }
  100. getIndex(e: any) {
  101. console.log(this.slides);
  102. }
  103. showNewsDetails(news: any) {
  104. this.router.navigate(['/home-details', { news: JSON.stringify(news) }])
  105. }
  106. }