Skip to content

Commit

Permalink
add readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
luanbatistadev committed May 9, 2022
1 parent a4eb9c8 commit 917057b
Show file tree
Hide file tree
Showing 24 changed files with 174 additions and 27 deletions.
62 changes: 52 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,58 @@
# pokedart
<samp>

A new Flutter project.
# <p align='center'>PokeDart by Luan Batista</p>
# <p align='center'>Web, Desktop && Mobile: IOS | Android</p>

## Getting Started
## <p align='center'>Flutter</p>
- ### The pokedart project was made for a company test, but it is much more than that. In it I learn one more skill, Mobx and I also develop my code in Flutter and Dart! Hope you like it!

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:
## <p align='center'>Mobile Version: Android | IOS</p>

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
<p align="center">
<img width=250 src="assets/screenshots/video-demo.gif"/>
<img width=250 src="assets/screenshots/shot1.jpg" />
<img width=250 src="assets/screenshots/shot2.jpg" />
<img width=250 src="assets/screenshots/shot3.jpg" />
<img width=250 src="assets/screenshots/shot4.jpg" />
<img width=250 src="assets/screenshots/shot5.jpg" />
<img width=250 src="assets/screenshots/shot6.jpg" />

</p>

## <p align='center'>Web && Desktop</p>
<p align="center"><img src="assets/screenshots/video-web.gif"/></p>



## <p align='center'>@luanbatistadev</p>

<p align="center">
<a href="https://github.com/luanbatistadev">
<img align="center" alt="Luan Batista | GitHub" width="45px" src="assets\images\github ico.png" />
</a>
<a href="https://twitter.com/luanbatistadev">
<img align="center" alt="Luan Batista | Twitter" width="45px" src="assets\images\twitter ico.png" />
</a>
<a href="https://br.linkedin.com/in/luan-rafael-batista-ramos-4379941a8">
<img align="center" alt="Luan Batista | LinkedIn" width="45px" src="assets\images\linkedin ico.ico" />
</a>
<a href="https://www.twitch.tv/luangamegg">
<img align="center" alt="Luan Batista | Twitch" width="45px" src="assets\images\twitch ico.png" />
</a>
</p>

<br>

<samp>

<h2 align="center">
Open Source
</h2>
<p align="center">
<sub>Copyright © 2022-present, Luan Batista.</sub>
</p>
<p align="center">PokeDart <a href="/LICENSE">is MIT licensed 💖</a></p>

</samp>
Binary file added assets/images/github ico.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/linkedin ico.ico
Binary file not shown.
Binary file added assets/images/photo1.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/photo2.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/photo3.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/photo4.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/twitch ico.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/twitter ico.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/shot1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/shot2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/shot3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/shot4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/shot5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/shot6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/video-demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/video-web.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 33 additions & 8 deletions lib/screens/favorite_page/favorite_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:pokedart/components/constants/constants.dart';
import 'package:pokedart/screens/favorite_page/components/pokemon_tile.dart';
import 'package:pokedart/stores/pokemon_stores.dart';

Expand Down Expand Up @@ -64,14 +65,38 @@ class _FavoriteScreenState extends State<FavoriteScreen> {

Widget _buildBody() {
return Observer(
builder: (context) => SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return PokemonTile(pokemon: _pokemonApiStore.pokemons[index]);
},
childCount: _pokemonApiStore.pokemons.length,
),
),
builder: (context) {
if (_pokemonApiStore.isLoading) {
return SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.all(8.0).copyWith(top: 300),
child: const Center(
child: CircularProgressIndicator(
color: kRedColor,
),
),
),
);
} else if (_pokemonApiStore.pokemons.isEmpty) {
return SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.all(8.0).copyWith(top: 300),
child: const Center(
child: Text('Nenhum Pokemon Favoritado!'),
),
),
);
} else {
return SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return PokemonTile(pokemon: _pokemonApiStore.pokemons[index]);
},
childCount: _pokemonApiStore.pokemons.length,
),
);
}
},
);
}
}
4 changes: 2 additions & 2 deletions lib/screens/home_page/home_screen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:pokedart/components/constants/constants.dart';
import 'package:pokedart/screens/home_page/components/logo.dart';
import 'package:pokedart/screens/home_page/components/search.dart';

Expand All @@ -7,9 +8,8 @@ class HomePage extends StatelessWidget {

@override
Widget build(BuildContext context) {
const _kBackgroundColor = Color.fromARGB(255, 253, 26, 87);
return Scaffold(
backgroundColor: _kBackgroundColor,
backgroundColor: kRedColor,
body: SingleChildScrollView(
child: Column(
children: const [
Expand Down
4 changes: 1 addition & 3 deletions lib/screens/pokemon_page/pokemon_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:pokedart/components/constants/constants.dart';
Expand Down Expand Up @@ -40,7 +38,7 @@ class _PokemonPageState extends State<PokemonPage> {
? widget.pokemon
: _pokemonApiStore.pokemon,
maxExtent: MediaQuery.of(context).size.height /
(Platform.isAndroid ? 4 : 3.2),
(4.3.clamp(3.2, 4.3)),
),
),
SliverToBoxAdapter(
Expand Down
14 changes: 13 additions & 1 deletion lib/screens/result_page/result_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:pokedart/components/constants/constants.dart';
import 'package:pokedart/screens/favorite_page/components/pokemon_tile.dart';
import 'package:pokedart/stores/pokemon_stores.dart';

Expand Down Expand Up @@ -85,7 +86,18 @@ class _ResultPageState extends State<ResultPage> {
Widget _buildBody() {
return Observer(
builder: (context) {
if (_pokemonApiStore.pokemons.isEmpty) {
if (_pokemonApiStore.isLoading) {
return SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.all(8.0).copyWith(top: 300),
child: const Center(
child: CircularProgressIndicator(
color: kRedColor,
),
),
),
);
} else if (_pokemonApiStore.pokemons.isEmpty) {
return SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.all(8.0).copyWith(top: 300),
Expand Down
45 changes: 45 additions & 0 deletions lib/services/pokemon_services.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'dart:convert';

import 'package:http/http.dart' as http;
import 'package:pokedart/models/evolution.dart';
import 'package:pokedart/models/pokemon.dart';

Future<List<Pokemon>> fetchPokemonsFromApi() async {
final response = await http.get(
Uri.parse(
'https://pokeapi.co/api/v2/pokemon-species?limit=100000&offset=0',
),
);
final Map<String,dynamic> json = jsonDecode(response.body) as Map<String,dynamic>;
final pokemonsJson = json['results'] as List;
final pokemons = pokemonsJson.map((e) => Pokemon.fromJson(e as Map<String, dynamic>)).toList();
return pokemons;
}

Future<Pokemon> fetchDataPokemon(String name) async {
EvolutionChain evolutionChain = EvolutionChain();
final response =
await http.get(Uri.parse('https://pokeapi.co/api/v2/pokemon/$name'));
final json = jsonDecode(response.body);
final pokemonsJson = json as Map<String, dynamic>;
final pokemon = Pokemon.fromJson(pokemonsJson);

final responseEvolution = await http
.get(Uri.parse('https://pokeapi.co/api/v2/pokemon-species/$name'));
if (responseEvolution.statusCode == 200) {
final Map<String,dynamic> jsonEvolution = jsonDecode(responseEvolution.body) as Map<String,dynamic>;
final evolutionJson =
jsonEvolution['evolution_chain'] as Map<String, dynamic>;
evolutionChain = EvolutionChain.fromJson(evolutionJson);
}

final responseAbilities = await http.get(Uri.parse(evolutionChain.url!));
if (responseAbilities.statusCode == 200) {
final jsonAbilities = jsonDecode(responseAbilities.body);
final evolutionJson = jsonAbilities as Map<String, dynamic>;
final evolution = Evolution.fromJson(evolutionJson);
return pokemon.copyWith(evolution: evolution);
} else {
return pokemon;
}
}
12 changes: 10 additions & 2 deletions lib/stores/pokemon_stores.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ abstract class _PokeApiStoreBase with Store {
@observable
List<String> historyList = [];

@observable
bool isLoading = false;

@action
Future<void> getHistoryList() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
Expand Down Expand Up @@ -56,6 +59,7 @@ abstract class _PokeApiStoreBase with Store {

@action
Future<void> getFavorite(String name) async {
isLoading = true;
final prefs = await SharedPreferences.getInstance();
final favorite = prefs.getStringList('pokemons');
if (favorite != null) {
Expand All @@ -65,6 +69,7 @@ abstract class _PokeApiStoreBase with Store {
}
}
}
isLoading = false;
}

@action
Expand Down Expand Up @@ -95,14 +100,15 @@ abstract class _PokeApiStoreBase with Store {
}

@action
Future<void> fetchPokemons() async {
Future<void> fetchPokemons() async {
final List<Pokemon> pokemons = await fetchPokemonsFromApi();

this.pokemons = pokemons;
}

@action
Future<void> searchPokemon(String name) async {
isLoading = true;
await fetchPokemons();
final List<Pokemon> pokemons = this
.pokemons
Expand All @@ -115,13 +121,15 @@ abstract class _PokeApiStoreBase with Store {
.toList();

this.pokemons = pokemons;
isLoading = false;
}

@action
Future<void> fetchDataListPokemon() async {
final List<Pokemon> pokemons = this.pokemons;

for (var i = 0; i < pokemons.length; i++) {
final Pokemon pokemon = await fetchDataPokemon(pokemons[i].name!) ;
final Pokemon pokemon = await fetchDataPokemon(pokemons[i].name!);

pokemons[i] = pokemon;
this.pokemons = pokemons;
Expand Down
19 changes: 18 additions & 1 deletion lib/stores/pokemon_stores.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 917057b

Please sign in to comment.