-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83e0db4
commit 6fc2f98
Showing
18 changed files
with
164 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/app/modules/shared/components/media-people/media-people.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<article class="mb-4"> | ||
<h4 class="mb-3 text-center" translate="home.actors"></h4> | ||
<p-carousel dir="ltr" [value]="people" [showIndicators]="false" [numVisible]="3.5" [numScroll]="2" [responsiveOptions]="responsiveOptions"> | ||
<ng-template let-person pTemplate="person"> | ||
<a class="text-center d-inline-block"> | ||
<img class="rounded-4" priority width="200" height="300" [ngSrc]="'https://image.tmdb.org/t/p/w200'+person.profile_path" [alt]="person.name"> | ||
<p class="mb-0 mt-1">{{person.name}}</p> | ||
</a> | ||
</ng-template> | ||
</p-carousel> | ||
</article> |
21 changes: 21 additions & 0 deletions
21
src/app/modules/shared/components/media-people/media-people.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
:host ::ng-deep { | ||
.p-ripple { | ||
color: white; | ||
border-radius: 50%; | ||
background-color: var(--ripple-bgc); | ||
&.p-disabled { | ||
opacity: 0; | ||
} | ||
} | ||
} | ||
a { | ||
width: 280px; | ||
height: 183px; | ||
background-size: cover; | ||
background-position: center; | ||
@media screen and (max-width: 767px) { | ||
& { | ||
width: 100%; | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/app/modules/shared/components/media-people/media-people.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { MediaPeopleComponent } from './media-people.component'; | ||
|
||
describe('MediaPeopleComponent', () => { | ||
let component: MediaPeopleComponent; | ||
let fixture: ComponentFixture<MediaPeopleComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [MediaPeopleComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(MediaPeopleComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
src/app/modules/shared/components/media-people/media-people.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { IResponsiveOption } from '../../interfaces/iresponsive-option'; | ||
import { IPerson } from '../../interfaces/iperson'; | ||
|
||
@Component({ | ||
selector: 'app-media-people', | ||
templateUrl: './media-people.component.html', | ||
styleUrl: './media-people.component.scss' | ||
}) | ||
export class MediaPeopleComponent { | ||
constructor() { | ||
this.responsiveOptions = [ | ||
{ breakpoint: '1199px', numVisible: 2.7, numScroll: 2 }, | ||
{ breakpoint: '991px', numVisible: 2, numScroll: 2 }, | ||
{ breakpoint: '767px', numVisible: 1, numScroll: 1 } | ||
]; | ||
} | ||
responsiveOptions: IResponsiveOption[]; | ||
@Input({required: true}) people!: IPerson[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface IGenre { | ||
id: number, | ||
name: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
export interface IGenre { | ||
id: number, | ||
name: string | ||
} | ||
import { IGenre } from "./igenre"; | ||
|
||
export interface IGenres { | ||
genres: IGenre[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { IPerson } from "./iperson" | ||
|
||
export interface IPeople { | ||
page: number, | ||
results: IPerson[], | ||
total_pages: number, | ||
total_results: number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { IMedia } from "./imedia"; | ||
|
||
export interface IPerson { | ||
id: number, | ||
name: string, | ||
adult: boolean, | ||
gender: number, | ||
media_type: string, | ||
popularity: number, | ||
known_for: IMedia[], | ||
profile_path: string, | ||
original_name: string, | ||
known_for_department: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,67 @@ | ||
import { Component } from '@angular/core'; | ||
import { MediaService } from '../../modules/shared/services/media.service'; | ||
import { IMedia } from '../../modules/shared/interfaces/imedia'; | ||
import { SharedModule } from '../../modules/shared/shared.module'; | ||
import { IGenre } from '../../modules/shared/interfaces/igenres'; | ||
import { TranslateService } from '@ngx-translate/core'; | ||
import { IMedia } from '../../modules/shared/interfaces/imedia'; | ||
import { IGenre } from '../../modules/shared/interfaces/igenre'; | ||
import { IPerson } from '../../modules/shared/interfaces/iperson'; | ||
|
||
@Component({ | ||
selector: 'app-home', | ||
standalone: true, | ||
imports: [SharedModule], | ||
templateUrl: './home.component.html', | ||
styleUrl: './home.component.scss' | ||
styleUrl: './home.component.scss', | ||
}) | ||
export class HomeComponent { | ||
constructor(private translate: TranslateService, private http: MediaService){ | ||
constructor(private translate: TranslateService, private http: MediaService) { | ||
translate.onLangChange.subscribe({ | ||
next: () => { | ||
if(this.translate.currentLang === "ar"){ | ||
this.getGenres('movie' ,'ar') | ||
this.getGenres('tv' ,'ar') | ||
} else{ | ||
this.getGenres('movie' ,'en') | ||
this.getGenres('tv' ,'en') | ||
if (this.translate.currentLang === 'ar') { | ||
this.getGenres('movie', 'ar'); | ||
this.getGenres('tv', 'ar'); | ||
} else { | ||
this.getGenres('movie', 'en'); | ||
this.getGenres('tv', 'en'); | ||
} | ||
} | ||
}) | ||
this.getMedia('movie', 'upcoming') | ||
this.getMedia('movie', 'popular') | ||
this.getMedia('movie', 'top_rated') | ||
this.getMedia('tv', 'top_rated') | ||
}, | ||
}); | ||
this.getPeople(); | ||
this.getMedia('movie', 'upcoming'); | ||
this.getMedia('movie', 'popular'); | ||
this.getMedia('movie', 'top_rated'); | ||
this.getMedia('tv', 'top_rated'); | ||
} | ||
releaseMovies!: IMedia[]; | ||
popularMovies!: IMedia[]; | ||
movieGenres!: IGenre[]; | ||
tvGenres!: IGenre[]; | ||
people!: IPerson[]; | ||
movies!: IMedia[]; | ||
series!: IMedia[]; | ||
getPeople(): void { | ||
this.http.getPeople().subscribe({ | ||
next: (data) => this.people = data.results, | ||
}); | ||
} | ||
getMedia(media: string, type: string): void { | ||
this.http.getMedia(media, type).subscribe({ | ||
next: data => { | ||
if(type === 'upcoming'){ | ||
this.releaseMovies = data.results | ||
} else if(type === 'popular'){ | ||
this.popularMovies = data.results | ||
} else if(media === 'movie' && type === 'top_rated'){ | ||
this.movies = data.results | ||
} else if(media === 'tv' && type === 'top_rated'){ | ||
this.series = data.results | ||
} | ||
} | ||
}) | ||
next: (data) => { | ||
if (type === 'upcoming') this.releaseMovies = data.results; | ||
else if (type === 'popular') this.popularMovies = data.results; | ||
else if (media === 'movie' && type === 'top_rated') | ||
this.movies = data.results; | ||
else if (media === 'tv' && type === 'top_rated') | ||
this.series = data.results; | ||
}, | ||
}); | ||
} | ||
getGenres(media: string, language: string): void { | ||
this.http.getGenres(media, language).subscribe({ | ||
next: data => { | ||
if(media === 'movie'){ | ||
this.movieGenres = data.genres | ||
} else if(media === 'tv'){ | ||
this.tvGenres = data.genres | ||
} | ||
} | ||
}) | ||
next: (data) => { | ||
if (media === 'movie') this.movieGenres = data.genres; | ||
else if (media === 'tv') this.tvGenres = data.genres; | ||
}, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters