-
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
16 changed files
with
437 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'package:get/get_connect.dart'; | ||
|
||
class RestClient extends GetConnect { | ||
RestClient() { | ||
httpClient.baseUrl = 'https://api.themoviedb.org/3'; | ||
} | ||
} |
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,81 @@ | ||
import 'package:app_filmes/application/ui/filmes_app_icons_icons.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
class MovieCard extends StatelessWidget { | ||
const MovieCard({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SizedBox( | ||
height: 280, | ||
width: 158, | ||
child: Stack( | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.all(10), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Material( | ||
elevation: 2, | ||
borderRadius: BorderRadius.circular(20), | ||
child: ClipRRect( | ||
clipBehavior: Clip.antiAlias, | ||
borderRadius: BorderRadius.circular(20), | ||
child: Image.network( | ||
'https://br.web.img3.acsta.net/pictures/15/09/29/12/57/543717.jpg', | ||
width: 148, | ||
height: 184, | ||
fit: BoxFit.cover, | ||
), | ||
), | ||
), | ||
const SizedBox(height: 20), | ||
const Text( | ||
'Cristiano Ronaldo', | ||
overflow: TextOverflow.ellipsis, | ||
maxLines: 2, | ||
style: TextStyle( | ||
fontSize: 12, | ||
fontWeight: FontWeight.w600, | ||
), | ||
), | ||
const Text( | ||
'2015', | ||
overflow: TextOverflow.ellipsis, | ||
maxLines: 2, | ||
style: TextStyle( | ||
fontSize: 11, | ||
color: Colors.grey, | ||
fontWeight: FontWeight.bold, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
Positioned( | ||
bottom: 80, | ||
right: -8, | ||
child: Material( | ||
elevation: 5, | ||
shape: const CircleBorder(), | ||
clipBehavior: Clip.antiAlias, | ||
child: SizedBox( | ||
height: 30, | ||
child: IconButton( | ||
iconSize: 13, | ||
icon: const Icon( | ||
FilmesAppIcons.heart, | ||
color: Colors.grey, | ||
), | ||
onPressed: () {}, | ||
), | ||
), | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
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,30 @@ | ||
import 'dart:convert'; | ||
|
||
class GenreModel { | ||
GenreModel({ | ||
required this.id, | ||
required this.name, | ||
}); | ||
|
||
final int id; | ||
final String name; | ||
|
||
Map<String, dynamic> toMap() { | ||
return { | ||
'id': id, | ||
'name': name, | ||
}; | ||
} | ||
|
||
factory GenreModel.fromMap(Map<String, dynamic> map) { | ||
return GenreModel( | ||
id: map['id'] ?? 0, | ||
name: map['name'] ?? '', | ||
); | ||
} | ||
|
||
String toJson() => json.encode(toMap()); | ||
|
||
factory GenreModel.fromJson(String source) => | ||
GenreModel.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,28 @@ | ||
import 'package:app_filmes/modules/movies/movies_controller.dart'; | ||
import 'package:get/get.dart'; | ||
|
||
import 'package:app_filmes/repositories/genres/genres_repository.dart'; | ||
import 'package:app_filmes/repositories/genres/genres_repository_impl.dart'; | ||
import 'package:app_filmes/services/genres/genres_service.dart'; | ||
import 'package:app_filmes/services/genres/genres_service_impl.dart'; | ||
|
||
class MoviesBindings implements Bindings { | ||
@override | ||
void dependencies() { | ||
Get.lazyPut<GenresRepository>( | ||
() => GenresRepositoryImpl( | ||
restClient: Get.find(), | ||
), | ||
); | ||
Get.lazyPut<GenresService>( | ||
() => GenresServiceImpl( | ||
genreRepository: Get.find(), | ||
), | ||
); | ||
Get.lazyPut( | ||
() => MoviesController( | ||
genresService: Get.find(), | ||
), | ||
); | ||
} | ||
} |
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,37 @@ | ||
import 'package:get/get.dart'; | ||
|
||
import 'package:app_filmes/application/ui/messages/messages_mixin.dart'; | ||
import 'package:app_filmes/models/genre_model.dart'; | ||
import 'package:app_filmes/services/genres/genres_service.dart'; | ||
|
||
class MoviesController extends GetxController with MessagesMixin { | ||
final GenresService _genresService; | ||
final _message = Rxn<MessageModel>(); | ||
final genres = <GenreModel>[].obs; | ||
|
||
MoviesController({ | ||
required GenresService genresService, | ||
}) : _genresService = genresService; | ||
|
||
@override | ||
void onInit() { | ||
super.onInit(); | ||
messageListener(_message); | ||
} | ||
|
||
@override | ||
void onReady() async { | ||
super.onReady(); | ||
try { | ||
final genres = await _genresService.getGenres(); | ||
this.genres.assignAll(genres); | ||
} catch (e) { | ||
_message( | ||
MessageModel.error( | ||
title: 'Erro', | ||
message: 'Erro ao buscar Categorias', | ||
), | ||
); | ||
} | ||
} | ||
} |
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,16 +1,28 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
|
||
import 'package:get/get.dart'; | ||
|
||
import 'widgets/movies_filters.dart'; | ||
import 'widgets/movies_group.dart'; | ||
import 'widgets/movies_header.dart'; | ||
|
||
class MoviesPage extends StatelessWidget { | ||
|
||
const MoviesPage({ Key? key }) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Movies'), | ||
return SizedBox( | ||
width: Get.width, | ||
height: Get.height, | ||
child: ListView( | ||
children: const [ | ||
MoviesHeader(), | ||
MoviesFilters(), | ||
MoviesGroup(title: 'Mais Populares'), | ||
MoviesGroup(title: 'Top Filmes'), | ||
], | ||
), | ||
body: Container(), | ||
); | ||
} | ||
} |
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,47 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:app_filmes/models/genre_model.dart'; | ||
import 'package:app_filmes/application/ui/theme_extension.dart'; | ||
|
||
class FilterTag extends StatelessWidget { | ||
final GenreModel model; | ||
final bool selected; | ||
final VoidCallback onPressed; | ||
|
||
const FilterTag({ | ||
Key? key, | ||
required this.model, | ||
this.selected = false, | ||
required this.onPressed, | ||
}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return InkWell( | ||
onTap: onPressed, | ||
child: Container( | ||
margin: const EdgeInsets.all(5), | ||
padding: const EdgeInsets.all(5), | ||
height: 20, | ||
constraints: const BoxConstraints( | ||
minWidth: 100, | ||
minHeight: 30, | ||
), | ||
decoration: BoxDecoration( | ||
color: selected ? context.themeRed : Colors.black, | ||
borderRadius: BorderRadius.circular(30), | ||
), | ||
child: Align( | ||
alignment: Alignment.center, | ||
child: Text( | ||
model.name, | ||
style: const TextStyle( | ||
color: Colors.white, | ||
fontSize: 14, | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
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,33 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:get/get.dart'; | ||
|
||
import 'package:app_filmes/modules/movies/movies_controller.dart'; | ||
import 'filter_tag.dart'; | ||
|
||
class MoviesFilters extends GetView<MoviesController> { | ||
const MoviesFilters({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Padding( | ||
padding: const EdgeInsets.only(top: 8), | ||
child: SingleChildScrollView( | ||
scrollDirection: Axis.horizontal, | ||
child: Obx(() { | ||
return Row( | ||
children: controller.genres | ||
.map( | ||
(g) => FilterTag( | ||
model: g, | ||
onPressed: () {}, | ||
selected: false, | ||
), | ||
) | ||
.toList(), | ||
); | ||
}), | ||
), | ||
); | ||
} | ||
} |
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,39 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:app_filmes/application/ui/widgets/movie_card.dart'; | ||
|
||
class MoviesGroup extends StatelessWidget { | ||
const MoviesGroup({Key? key, required this.title}) : super(key: key); | ||
final String title; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Padding( | ||
padding: const EdgeInsets.all(8), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
const SizedBox(height: 20), | ||
Text( | ||
title, | ||
style: const TextStyle( | ||
fontSize: 24, | ||
fontWeight: FontWeight.bold, | ||
), | ||
), | ||
SizedBox( | ||
height: 280, | ||
child: ListView.builder( | ||
shrinkWrap: true, | ||
scrollDirection: Axis.horizontal, | ||
itemCount: 10, | ||
itemBuilder: (context, index) { | ||
return const MovieCard(); | ||
} | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.