-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
30 changed files
with
887 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,98 @@ | ||
import 'package:app_filmes/application/ui/filmes_app_icons_icons.dart'; | ||
import 'package:app_filmes/models/movie_model.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:get/get.dart'; | ||
import 'package:intl/intl.dart'; | ||
|
||
import 'package:app_filmes/application/ui/filmes_app_icons_icons.dart'; | ||
import 'package:app_filmes/application/ui/theme_extension.dart'; | ||
import 'package:app_filmes/models/movie_model.dart'; | ||
|
||
class MovieCard extends StatelessWidget { | ||
MovieCard({ | ||
Key? key, | ||
required this.movie, | ||
required this.favoriteCallback, | ||
}) : super(key: key); | ||
|
||
final MovieModel movie; | ||
final dateFormat = DateFormat('dd/MM/y'); | ||
MovieCard({Key? key, required this.movie}) : super(key: key); | ||
final VoidCallback favoriteCallback; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
padding: const EdgeInsets.all(10), | ||
height: 305, | ||
width: 170, | ||
child: Stack( | ||
children: [ | ||
Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Material( | ||
elevation: 2, | ||
borderRadius: BorderRadius.circular(15), | ||
child: ClipRRect( | ||
return InkWell( | ||
onTap: () { | ||
Get.toNamed( | ||
'/movie/detail', | ||
arguments: movie.id, | ||
); | ||
}, | ||
child: Container( | ||
padding: const EdgeInsets.all(10), | ||
height: 305, | ||
width: 170, | ||
child: Stack( | ||
children: [ | ||
Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Material( | ||
elevation: 2, | ||
borderRadius: BorderRadius.circular(15), | ||
clipBehavior: Clip.antiAlias, | ||
child: Image.network( | ||
movie.posterPath, | ||
height: 190, | ||
width: 165, | ||
fit: BoxFit.cover, | ||
child: ClipRRect( | ||
borderRadius: BorderRadius.circular(15), | ||
clipBehavior: Clip.antiAlias, | ||
child: Image.network( | ||
'https://image.tmdb.org/t/p/w200${movie.posterPath}', | ||
height: 190, | ||
width: 165, | ||
fit: BoxFit.cover, | ||
), | ||
), | ||
), | ||
), | ||
SizedBox(height: 20), | ||
Text( | ||
movie.title, | ||
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600), | ||
overflow: TextOverflow.ellipsis, | ||
maxLines: 2, | ||
), | ||
Text( | ||
dateFormat.format(DateTime.parse(movie.releaseDate)), | ||
style: TextStyle( | ||
fontSize: 11, | ||
fontWeight: FontWeight.w300, | ||
color: Colors.grey, | ||
const SizedBox(height: 20), | ||
Text( | ||
movie.title, | ||
style: const TextStyle( | ||
fontSize: 12, fontWeight: FontWeight.w600), | ||
overflow: TextOverflow.ellipsis, | ||
maxLines: 2, | ||
), | ||
), | ||
], | ||
), | ||
Positioned( | ||
bottom: 65, | ||
right: -4, | ||
child: Material( | ||
elevation: 5, | ||
shape: CircleBorder(), | ||
clipBehavior: Clip.antiAlias, | ||
child: SizedBox( | ||
height: 40, | ||
child: IconButton( | ||
iconSize: 18, | ||
icon: Icon( | ||
FilmesAppIcons.heartEmpty, | ||
Text( | ||
dateFormat.format(DateTime.parse(movie.releaseDate)), | ||
style: const TextStyle( | ||
fontSize: 11, | ||
fontWeight: FontWeight.w300, | ||
color: Colors.grey, | ||
), | ||
onPressed: () {}, | ||
), | ||
], | ||
), | ||
Positioned( | ||
bottom: 65, | ||
right: -4, | ||
child: Material( | ||
elevation: 5, | ||
shape: const CircleBorder(), | ||
clipBehavior: Clip.antiAlias, | ||
child: SizedBox( | ||
height: 40, | ||
child: IconButton( | ||
iconSize: 18, | ||
icon: Icon( | ||
movie.favorite | ||
? FilmesAppIcons.heart | ||
: FilmesAppIcons.heartEmpty, | ||
color: movie.favorite ? context.themeRed : Colors.grey, | ||
), | ||
onPressed: favoriteCallback, | ||
), | ||
), | ||
), | ||
), | ||
), | ||
], | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} | ||
} |
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,34 @@ | ||
import 'dart:convert'; | ||
|
||
class CastModel { | ||
CastModel({ | ||
required this.name, | ||
required this.image, | ||
required this.character, | ||
}); | ||
|
||
final String name; | ||
final String image; | ||
final String character; | ||
|
||
Map<String, dynamic> toMap() { | ||
return { | ||
'original_name': name, | ||
'profile_path': image, | ||
'character': character, | ||
}; | ||
} | ||
|
||
factory CastModel.fromMap(Map<String, dynamic> map) { | ||
return CastModel( | ||
name: map['original_name'] ?? '', | ||
image: 'https://image.tmdb.org/t/p/w200${map['profile_path']}', | ||
character: map['character'] ?? '', | ||
); | ||
} | ||
|
||
String toJson() => json.encode(toMap()); | ||
|
||
factory CastModel.fromJson(String source) => | ||
CastModel.fromMap(json.decode(source)); | ||
} |
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,75 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:app_filmes/models/genre_model.dart'; | ||
import 'cast_model.dart'; | ||
|
||
class MovieDetailModel { | ||
final String title; | ||
final double stars; | ||
final List<GenreModel> genres; | ||
final List<String> urlImages; | ||
final DateTime releaseDate; | ||
final String overview; | ||
final List<String> productionCompanies; | ||
final String originalLanguage; | ||
final List<CastModel> cast; | ||
|
||
MovieDetailModel({ | ||
required this.title, | ||
required this.stars, | ||
required this.genres, | ||
required this.urlImages, | ||
required this.releaseDate, | ||
required this.overview, | ||
required this.productionCompanies, | ||
required this.originalLanguage, | ||
required this.cast, | ||
}); | ||
|
||
Map<String, dynamic> toMap() { | ||
return { | ||
'title': title, | ||
'vote_average': stars, | ||
'genres': genres.map((x) => x.toMap()).toList(), | ||
'urlImages': urlImages, | ||
'release_date': releaseDate.millisecondsSinceEpoch, | ||
'overview': overview, | ||
'production_companies': productionCompanies, | ||
'original_language': originalLanguage, | ||
'cast': cast.map((x) => x.toMap()).toList(), | ||
}; | ||
} | ||
|
||
factory MovieDetailModel.fromMap(Map<String, dynamic> map) { | ||
var urlImagesPoster = map['images']['posters']; | ||
var urlImages = urlImagesPoster | ||
?.map<String>((images) => | ||
'https://image.tmdb.org/t/p/w200${images['file_path']}') | ||
.toList() ?? | ||
const []; | ||
|
||
return MovieDetailModel( | ||
title: map['title'] ?? '', | ||
stars: map['vote_average'] ?? 0.0, | ||
genres: List<GenreModel>.from(map['genres']?.map( | ||
(x) => GenreModel.fromMap(x), | ||
) ?? | ||
const []), | ||
urlImages: urlImages, | ||
releaseDate: DateTime.parse(map['release_date']), | ||
overview: map['overview'] ?? '', | ||
productionCompanies: List<dynamic>.from( | ||
map['production_companies'] ?? const [], | ||
).map<String>((production) => production['name']).toList(), | ||
originalLanguage: map['original_language'] ?? '', | ||
cast: List<CastModel>.from( | ||
map['credits']['cast']?.map((x) => CastModel.fromMap(x)) ?? const [], | ||
), | ||
); | ||
} | ||
|
||
String toJson() => json.encode(toMap()); | ||
|
||
factory MovieDetailModel.fromJson(String source) => | ||
MovieDetailModel.fromMap(json.decode(source)); | ||
} |
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,15 @@ | ||
import 'package:get/get.dart'; | ||
|
||
import 'favorites_controller.dart'; | ||
|
||
class FavoritesBindings implements Bindings { | ||
@override | ||
void dependencies() { | ||
Get.put( | ||
FavoritesController( | ||
authService: Get.find(), | ||
moviesService: Get.find(), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.