-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release: 1.0.0
- Loading branch information
Showing
18 changed files
with
1,822 additions
and
154 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,49 @@ | ||
class PopularMovie { | ||
final String title; | ||
final String posterPath; | ||
final String releaseDate; | ||
final bool adult; | ||
final String backdropPath; | ||
final List<int> genreIds; | ||
final String originalLanguage; | ||
final String originalTitle; | ||
final String overview; | ||
final double popularity; | ||
final bool video; | ||
final double voteAverage; | ||
final int voteCount; | ||
|
||
PopularMovie({ | ||
required this.title, | ||
required this.posterPath, | ||
required this.releaseDate, | ||
this.adult = false, | ||
this.backdropPath = "", | ||
this.genreIds = const [], | ||
this.originalLanguage = "", | ||
this.originalTitle = "", | ||
this.overview = "", | ||
this.popularity = 0.0, | ||
this.video = false, | ||
this.voteAverage = 0.0, | ||
this.voteCount = 0, | ||
}); | ||
|
||
factory PopularMovie.fromJson(Map<String, dynamic> json) { | ||
return PopularMovie( | ||
title: json['title'] ?? '', | ||
posterPath: json['poster_path'] ?? '', | ||
releaseDate: json['release_date'] ?? '', | ||
adult: json['adult'] ?? false, | ||
backdropPath: json['backdrop_path'] ?? '', | ||
genreIds: List<int>.from(json['genre_ids'] ?? []), | ||
originalLanguage: json['original_language'] ?? '', | ||
originalTitle: json['original_title'] ?? '', | ||
overview: json['overview'] ?? '', | ||
popularity: json['popularity']?.toDouble() ?? 0.0, | ||
video: json['video'] ?? false, | ||
voteAverage: json['vote_average']?.toDouble() ?? 0.0, | ||
voteCount: json['vote_count'] ?? 0, | ||
); | ||
} | ||
} |
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,46 @@ | ||
class PopularSeries { | ||
final String originalName; | ||
final String posterPath; | ||
final String firstAirDate; | ||
final bool adult; | ||
final String backdropPath; | ||
final List<int> genreIds; | ||
final List<String> originCountry; | ||
final String originalLanguage; | ||
final String overview; | ||
final double popularity; | ||
final double voteAverage; | ||
final int voteCount; | ||
|
||
PopularSeries({ | ||
required this.originalName, | ||
required this.posterPath, | ||
required this.firstAirDate, | ||
this.adult = false, | ||
this.backdropPath = "", | ||
this.genreIds = const [], | ||
this.originCountry = const [], | ||
this.originalLanguage = "", | ||
this.overview = "", | ||
this.popularity = 0.0, | ||
this.voteAverage = 0.0, | ||
this.voteCount = 0, | ||
}); | ||
|
||
factory PopularSeries.fromJson(Map<String, dynamic> json) { | ||
return PopularSeries( | ||
originalName: json['original_name'] ?? '', | ||
posterPath: json['poster_path'] ?? '', | ||
firstAirDate: json['first_air_date'] ?? '', | ||
adult: json['adult'] ?? false, | ||
backdropPath: json['backdrop_path'] ?? '', | ||
genreIds: List<int>.from(json['genre_ids'] ?? []), | ||
originCountry: List<String>.from(json['origin_country'] ?? []), | ||
originalLanguage: json['original_language'] ?? '', | ||
overview: json['overview'] ?? '', | ||
popularity: json['popularity']?.toDouble() ?? 0.0, | ||
voteAverage: json['vote_average']?.toDouble() ?? 0.0, | ||
voteCount: json['vote_count'] ?? 0, | ||
); | ||
} | ||
} |
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,40 @@ | ||
import 'dart:convert'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:dart_plus_app/classes/popular_movies.dart'; | ||
import 'package:dart_plus_app/classes/popular_series.dart'; | ||
|
||
class LocalDataService { | ||
Future<List<dynamic>> fetchData() async { | ||
try { | ||
final String moviesResponse = | ||
await rootBundle.loadString('lib/data/mock/popularMovies.json'); | ||
final String seriesResponse = | ||
await rootBundle.loadString('lib/data/mock/popularTvSeries.json'); | ||
print("Movies Data: $moviesResponse"); | ||
print("Series Data: $seriesResponse"); | ||
|
||
final moviesData = jsonDecode(moviesResponse); | ||
final seriesData = jsonDecode(seriesResponse); | ||
print("Parsed Movies Data: $moviesData"); | ||
print("Parsed Series Data: $seriesData"); | ||
|
||
List<dynamic> items = []; | ||
if (moviesData != null && moviesData['results'] is List) { | ||
items.addAll((moviesData['results'] as List) | ||
.map((item) => PopularMovie.fromJson(item)) | ||
.toList()); | ||
} | ||
if (seriesData != null && seriesData['results'] is List) { | ||
items.addAll((seriesData['results'] as List) | ||
.map((item) => PopularSeries.fromJson(item)) | ||
.toList()); | ||
} | ||
|
||
print("Loaded items: $items"); | ||
return items; | ||
} catch (e) { | ||
print('Erro ao carregar dados: $e'); | ||
return []; | ||
} | ||
} | ||
} |
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,84 @@ | ||
import 'dart:convert'; | ||
import 'package:dart_plus_app/data/mock/fetch/localdataservice.dart'; | ||
import 'package:dart_plus_app/widgets/grid_view_vertical.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:dart_plus_app/classes/popular_movies.dart'; | ||
import 'package:dart_plus_app/classes/popular_series.dart'; | ||
|
||
void main() { | ||
runApp(const MyApp()); | ||
} | ||
|
||
class MyApp extends StatelessWidget { | ||
const MyApp({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const MaterialApp( | ||
home: ContentDisplayScreen(), | ||
); | ||
} | ||
} | ||
|
||
class ContentDisplayScreen extends StatefulWidget { | ||
const ContentDisplayScreen({super.key}); | ||
|
||
@override | ||
State<ContentDisplayScreen> createState() => _ContentDisplayScreenState(); | ||
} | ||
|
||
class _ContentDisplayScreenState extends State<ContentDisplayScreen> { | ||
List<dynamic> items = []; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
fetchData(); | ||
} | ||
|
||
void fetchData() async { | ||
var data = await LocalDataService().fetchData(); | ||
setState(() { | ||
items = data; | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar(title: const Text("Popular Media")), | ||
body: WidgetGridViewVertical(mediaItems: items), | ||
); | ||
} | ||
} | ||
|
||
List<Widget> processMetadata(String jsonString) { | ||
Map<String, dynamic> data = jsonDecode(jsonString); | ||
List<Widget> widgets = []; | ||
|
||
List<dynamic> items = []; | ||
items.addAll((data['popularMovies'] as List) | ||
.map((item) => PopularMovie.fromJson(item)) | ||
.toList()); | ||
items.addAll((data['popularTvSeries'] as List) | ||
.map((item) => PopularSeries.fromJson(item)) | ||
.toList()); | ||
items.addAll((data['trending'] as List) | ||
.map((item) => PopularMovie.fromJson(item)) | ||
.toList()); | ||
|
||
for (var item in items) { | ||
widgets.add(ListTile( | ||
title: Text(item.title ?? item.originalName, | ||
style: const TextStyle(fontWeight: FontWeight.bold)), | ||
subtitle: Text(item.overview), | ||
leading: Image.network( | ||
'https://image.tmdb.org/t/p/w500${item.posterPath}', | ||
width: 50, | ||
height: 100, | ||
fit: BoxFit.cover), | ||
isThreeLine: true, | ||
)); | ||
} | ||
return widgets; | ||
} |
Oops, something went wrong.