more animations + remove confirm for main entry card
This commit is contained in:
1 parent
ff76e3900b
commit
05e4505fdb
2 files changed
+78
-27
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
<div class="movie-card" @fadeInOut>
|
<div class="movie-card" [@fadeInOut]="direction">
|
||||||
<div class="card-head">
|
<div class="card-head">
|
||||||
<img class="card-img" [src]="postPath" alt="Movie Poster">
|
<img class="card-img" [src]="postPath" alt="Movie Poster">
|
||||||
|
|
||||||
@@ -35,8 +35,8 @@
|
|||||||
</a>
|
</a>
|
||||||
<div class="card-info">
|
<div class="card-info">
|
||||||
<span class="Year">{{releaseYear}}</span>
|
<span class="Year">{{releaseYear}}</span>
|
||||||
<i class="card-dot"></i>
|
<i class="card-dot" *ngIf="runtime"></i>
|
||||||
<span class="duration">{{runtime}} min</span>
|
<span class="duration" *ngIf="runtime">{{runtime}} min</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
import { UserCollectionsModalComponent } from '../../modals/list-selection-modal/user-collections-modal.component';
|
import { UserCollectionsModalComponent } from '../../modals/list-selection-modal/user-collections-modal.component';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import {
|
import { trigger, transition, style, animate } from '@angular/animations';
|
||||||
trigger,
|
|
||||||
transition,
|
|
||||||
style,
|
|
||||||
animate,
|
|
||||||
state,
|
|
||||||
} from '@angular/animations';
|
|
||||||
import { Entry } from '../../../models/entry.model';
|
import { Entry } from '../../../models/entry.model';
|
||||||
import { LibraryService } from '../../../../core/services/library.service';
|
import { LibraryService } from '../../../../core/services/library.service';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { ConfirmModalComponent } from '../../modals/confirm-modal/confirm-modal.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-main-card',
|
selector: 'app-main-card',
|
||||||
@@ -18,16 +13,37 @@ import { Router } from '@angular/router';
|
|||||||
styleUrls: ['./main-card.component.css'],
|
styleUrls: ['./main-card.component.css'],
|
||||||
animations: [
|
animations: [
|
||||||
trigger('fadeInOut', [
|
trigger('fadeInOut', [
|
||||||
transition(':enter', [
|
transition('void => topToBottom', [
|
||||||
style({ opacity: 0, transform: 'translateY(-50px)' }),
|
style({ opacity: 0, transform: 'translateY(-50%)' }),
|
||||||
animate(
|
animate(
|
||||||
'300ms ease-out',
|
'300ms ease-out',
|
||||||
style({ opacity: 1, transform: 'translateY(0)' })
|
style({ opacity: 1, transform: 'translateY(0)' })
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
transition(':leave', [
|
transition('void => bottomToTop', [
|
||||||
|
style({ opacity: 0, transform: 'translateY(50%)' }),
|
||||||
animate(
|
animate(
|
||||||
'300ms ease-in',
|
'400ms ease-out',
|
||||||
|
style({ opacity: 1, transform: 'translateY(0)' })
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
transition('void => leftToRight', [
|
||||||
|
style({ opacity: 0, transform: 'translateX(-50%)' }),
|
||||||
|
animate(
|
||||||
|
'500ms ease-out',
|
||||||
|
style({ opacity: 1, transform: 'translateX(0)' })
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
transition('void => rightToLeft', [
|
||||||
|
style({ opacity: 0, transform: 'translateX(50%)' }),
|
||||||
|
animate(
|
||||||
|
'500ms ease-out',
|
||||||
|
style({ opacity: 1, transform: 'translateX(0)' })
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
transition('* => void', [
|
||||||
|
animate(
|
||||||
|
'400ms ease-in',
|
||||||
style({ opacity: 0, transform: 'translateY(-50px)' })
|
style({ opacity: 0, transform: 'translateY(-50px)' })
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
@@ -38,6 +54,8 @@ export class MainCardComponent implements OnInit {
|
|||||||
@Output() removedEvent = new EventEmitter();
|
@Output() removedEvent = new EventEmitter();
|
||||||
@Input() entry!: Entry;
|
@Input() entry!: Entry;
|
||||||
|
|
||||||
|
direction = 'topToBottom';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private libraryService: LibraryService,
|
private libraryService: LibraryService,
|
||||||
public dialog: MatDialog,
|
public dialog: MatDialog,
|
||||||
@@ -54,6 +72,17 @@ export class MainCardComponent implements OnInit {
|
|||||||
},
|
},
|
||||||
error: (error) => {},
|
error: (error) => {},
|
||||||
});
|
});
|
||||||
|
this.setRandomDirection();
|
||||||
|
}
|
||||||
|
|
||||||
|
setRandomDirection() {
|
||||||
|
const directions = [
|
||||||
|
'topToBottom',
|
||||||
|
'bottomToTop',
|
||||||
|
'leftToRight',
|
||||||
|
'rightToLeft',
|
||||||
|
];
|
||||||
|
this.direction = directions[Math.floor(Math.random() * directions.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
get releaseYear(): number {
|
get releaseYear(): number {
|
||||||
@@ -72,6 +101,7 @@ export class MainCardComponent implements OnInit {
|
|||||||
console.log(`Entry added to library`, entry);
|
console.log(`Entry added to library`, entry);
|
||||||
entry.isInLibrary = true;
|
entry.isInLibrary = true;
|
||||||
this.entry = entry;
|
this.entry = entry;
|
||||||
|
this.libraryService.refrechEntries();
|
||||||
obs.unsubscribe();
|
obs.unsubscribe();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -82,20 +112,36 @@ export class MainCardComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeEntry(id: number) {
|
removeEntry(id: number) {
|
||||||
console.log('Deleting Entry From Library.');
|
const dialogRef = this.dialog.open(ConfirmModalComponent, {
|
||||||
this.libraryService.deleteEntry(id).subscribe({
|
width: '400px',
|
||||||
next: (response) => {
|
data: {
|
||||||
console.log('Entry successfully deleted.', response);
|
title: 'Confirmation',
|
||||||
// ? emit to dynamic entry list
|
message: `Are you sure you want to remove ${this.entry.title} from the library?`,
|
||||||
this.entry.id = 0;
|
type: 'danger',
|
||||||
this.entry.isInLibrary = false;
|
|
||||||
this.removedEvent.emit(this.entry.id);
|
|
||||||
// todo entry removed notification
|
|
||||||
},
|
|
||||||
error: (error) => {
|
|
||||||
console.error('Error deleting entry:', error);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
dialogRef.afterClosed().subscribe((result) => {
|
||||||
|
if (result) {
|
||||||
|
console.log(result);
|
||||||
|
if (result.confirmed != true) return;
|
||||||
|
|
||||||
|
this.libraryService.deleteEntry(id).subscribe({
|
||||||
|
next: (response) => {
|
||||||
|
console.log('Entry successfully deleted.', response);
|
||||||
|
// ? emit to dynamic entry list
|
||||||
|
this.entry.id = 0;
|
||||||
|
this.entry.isInLibrary = false;
|
||||||
|
this.removedEvent.emit(this.entry.id);
|
||||||
|
// todo entry removed notification
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
// TODO show notification
|
||||||
|
console.error('Error deleting entry:', error);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
showAddToListModal() {
|
showAddToListModal() {
|
||||||
@@ -117,6 +163,11 @@ export class MainCardComponent implements OnInit {
|
|||||||
cardClick() {
|
cardClick() {
|
||||||
if (this.entry.isInLibrary)
|
if (this.entry.isInLibrary)
|
||||||
this.router.navigate([`/entries/${this.entry.id}`]);
|
this.router.navigate([`/entries/${this.entry.id}`]);
|
||||||
|
else
|
||||||
|
window.open(
|
||||||
|
'https://www.themoviedb.org/movie/' + this.entry.entryId.tmdb_id,
|
||||||
|
'_blank'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTmdbLink() {
|
getTmdbLink() {
|
||||||
@@ -136,7 +187,7 @@ export class MainCardComponent implements OnInit {
|
|||||||
if (this.entry.poster_path == null)
|
if (this.entry.poster_path == null)
|
||||||
return 'assets/images/default/default-poster.png';
|
return 'assets/images/default/default-poster.png';
|
||||||
|
|
||||||
return `https://image.tmdb.org/t/p/w154` + this.entry.poster_path;
|
return `https://image.tmdb.org/t/p/w300` + this.entry.poster_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
get runtime() {
|
get runtime() {
|
||||||
|
|||||||
Reference in new issue
Block a user