mirrored_repositories/unicornpopcorn-app/lib/src/pages
class Peliculas {
  List<Pelicula> items = new List();
  Peliculas();
  Peliculas.fromJsonList(List<dynamic> jsonList) {
    if (jsonList == null) return;
    for (var item in jsonList) {
      final pelicula = new Pelicula.fromJsonMap(item);
      items.add(pelicula);
    }
  }
}

class Pelicula {
  String uniqueId;
  double popularity;
  int id;
  bool video;
  int voteCount;
  double voteAverage;
  String title;
  String releaseDate;
  String originalLanguage;
  String originalTitle;
  List<int> genreIds;
  String backdropPath;
  bool adult;
  String overview;
  String posterPath;

  Pelicula({
    this.popularity,
    this.id,
    this.video,
    this.voteCount,
    this.voteAverage,
    this.title,
    this.releaseDate,
    this.originalLanguage,
    this.originalTitle,
    this.genreIds,
    this.backdropPath,
    this.adult,
    this.overview,
    this.posterPath,
  });

  Pelicula.fromJsonMap(Map<String, dynamic> json) {
    id = json['id'];
    video = json['video'];
    voteCount = json['vote_count'];
    voteAverage = json['vote_average'] / 1;
    title = json['title'];
    releaseDate = json['release_date'];
    originalLanguage = json['original_language'];
    originalTitle = json['original_title'];
    genreIds = json['genre_ids'].cast<int>();
    backdropPath = json['backdrop_path'];
    adult = json['adult'];
    overview = json['overview'];
    posterPath = json['poster_path'];
    popularity = json['popularity'] / 1;
  }

  getPosterImg() {
    if (posterPath == null) {
      return 'https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fstatic.popcornopolis.com%2Fmedia%2Fcatalog%2Fproduct%2Fcache%2F1%2Fimage%2F650x%2F7b8fef0172c2eb72dd8fd366c999954c%2Fu%2Fn%2Funicornpopcorn_logo.jpg&f=1&nofb=1';
    } else {
      return 'https://image.tmdb.org/t/p/w500/$posterPath';
    }
  }

  getBackgroundImg() {
    if (posterPath == null) {
      return 'https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fstatic.popcornopolis.com%2Fmedia%2Fcatalog%2Fproduct%2Fcache%2F1%2Fimage%2F650x%2F7b8fef0172c2eb72dd8fd366c999954c%2Fu%2Fn%2Funicornpopcorn_logo.jpg&f=1&nofb=1';
    } else {
      return 'https://image.tmdb.org/t/p/w500/$backdropPath';
    }
  }
}
