Start to add entries
BIN
assets/sprites/dex/bulbasaur.png
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
assets/sprites/dex/charizard.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
assets/sprites/dex/charmander.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
assets/sprites/dex/charmeleon.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
assets/sprites/dex/ivysaur.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
assets/sprites/dex/venusaur.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
assets/sprites/gen1/bulbasaur.png
Normal file
After Width: | Height: | Size: 364 B |
BIN
assets/sprites/gen1/charizard.png
Normal file
After Width: | Height: | Size: 615 B |
BIN
assets/sprites/gen1/charmander.png
Normal file
After Width: | Height: | Size: 378 B |
BIN
assets/sprites/gen1/charmeleon.png
Normal file
After Width: | Height: | Size: 460 B |
BIN
assets/sprites/gen1/ivysaur.png
Normal file
After Width: | Height: | Size: 429 B |
BIN
assets/sprites/gen1/venusaur.png
Normal file
After Width: | Height: | Size: 650 B |
151
lib/MainApp.dart
Normal file
|
@ -0,0 +1,151 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:libacflutter/Constants.dart';
|
||||
import 'package:pokedex/Session.dart';
|
||||
import 'package:pokedex/pokemon.dart';
|
||||
|
||||
class MainApp extends StatefulWidget {
|
||||
@override
|
||||
_MainAppState createState() => _MainAppState();
|
||||
}
|
||||
|
||||
class _MainAppState extends State<MainApp> {
|
||||
void toggleTheme() {
|
||||
setState(() {
|
||||
SessionData.darkMode = !SessionData.darkMode;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'PokeDex',
|
||||
theme: SessionData.darkMode ? ThemeData.dark() : ThemeData.light(),
|
||||
routes: {
|
||||
"/": (context) => Home(toggleTheme: toggleTheme),
|
||||
"/dex": (context) => DexEntry(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Home extends StatefulWidget {
|
||||
final VoidCallback toggleTheme;
|
||||
|
||||
Home({required this.toggleTheme});
|
||||
|
||||
@override
|
||||
_HomeState createState() => _HomeState();
|
||||
}
|
||||
|
||||
class _HomeState extends State<Home> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('PokeDex'),
|
||||
backgroundColor:
|
||||
SessionData.darkMode
|
||||
? LibACFlutterConstants.TITLEBAR_COLOR
|
||||
: Colors.cyan,
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: widget.toggleTheme,
|
||||
icon:
|
||||
SessionData.darkMode
|
||||
? Icon(Icons.sunny)
|
||||
: Icon(Icons.mode_night),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: GridView.builder(
|
||||
itemBuilder: (builder, index) {
|
||||
return Card(
|
||||
elevation: 50,
|
||||
color: Color.fromARGB(255, 194, 94, 0),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, "/dex", arguments: index);
|
||||
},
|
||||
child: SizedBox(
|
||||
width: 300,
|
||||
height: 300,
|
||||
child: Column(
|
||||
children: [
|
||||
Image.asset(
|
||||
Pokemon.values[index].toDexPath(),
|
||||
width: 198,
|
||||
height: 198,
|
||||
),
|
||||
Text(
|
||||
Pokemon.values[index].name,
|
||||
style: TextStyle(fontSize: 32, color: Colors.black),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: Pokemon.values.length,
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 4,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DexEntry extends StatefulWidget {
|
||||
@override
|
||||
_DexEntryState createState() => _DexEntryState();
|
||||
}
|
||||
|
||||
class _DexEntryState extends State<DexEntry> {
|
||||
Pokemon _pkmn = Pokemon.Bulbasaur;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
int index = ModalRoute.of(context)!.settings.arguments as int;
|
||||
_pkmn = Pokemon.values[index];
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(_pkmn.name),
|
||||
backgroundColor:
|
||||
SessionData.darkMode
|
||||
? LibACFlutterConstants.TITLEBAR_COLOR
|
||||
: Colors.cyan,
|
||||
),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Column(
|
||||
children: [
|
||||
Image.asset(_pkmn.toDexPath()),
|
||||
Text("ID: ${_pkmn.id}", style: TextStyle(fontSize: 24)),
|
||||
Row(
|
||||
children: [
|
||||
Text("Type: ", style: TextStyle(fontSize: 24)),
|
||||
_pkmn.getTypeWidgets(),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 24),
|
||||
if (_pkmn.hasEvolutions)
|
||||
Row(
|
||||
children: [
|
||||
Text("Evolutions: ", style: TextStyle(fontSize: 24)),
|
||||
_pkmn.getEvolutions(0),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
3
lib/Session.dart
Normal file
|
@ -0,0 +1,3 @@
|
|||
class SessionData {
|
||||
static bool darkMode = false;
|
||||
}
|
120
lib/main.dart
|
@ -1,122 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:pokedex/MainApp.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: ThemeData(
|
||||
// This is the theme of your application.
|
||||
//
|
||||
// TRY THIS: Try running your application with "flutter run". You'll see
|
||||
// the application has a purple toolbar. Then, without quitting the app,
|
||||
// try changing the seedColor in the colorScheme below to Colors.green
|
||||
// and then invoke "hot reload" (save your changes or press the "hot
|
||||
// reload" button in a Flutter-supported IDE, or press "r" if you used
|
||||
// the command line to start the app).
|
||||
//
|
||||
// Notice that the counter didn't reset back to zero; the application
|
||||
// state is not lost during the reload. To reset the state, use hot
|
||||
// restart instead.
|
||||
//
|
||||
// This works for code too, not just values: Most code changes can be
|
||||
// tested with just a hot reload.
|
||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
||||
),
|
||||
home: const MyHomePage(title: 'Flutter Demo Home Page'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
const MyHomePage({super.key, required this.title});
|
||||
|
||||
// This widget is the home page of your application. It is stateful, meaning
|
||||
// that it has a State object (defined below) that contains fields that affect
|
||||
// how it looks.
|
||||
|
||||
// This class is the configuration for the state. It holds the values (in this
|
||||
// case the title) provided by the parent (in this case the App widget) and
|
||||
// used by the build method of the State. Fields in a Widget subclass are
|
||||
// always marked "final".
|
||||
|
||||
final String title;
|
||||
|
||||
@override
|
||||
State<MyHomePage> createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
int _counter = 0;
|
||||
|
||||
void _incrementCounter() {
|
||||
setState(() {
|
||||
// This call to setState tells the Flutter framework that something has
|
||||
// changed in this State, which causes it to rerun the build method below
|
||||
// so that the display can reflect the updated values. If we changed
|
||||
// _counter without calling setState(), then the build method would not be
|
||||
// called again, and so nothing would appear to happen.
|
||||
_counter++;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// This method is rerun every time setState is called, for instance as done
|
||||
// by the _incrementCounter method above.
|
||||
//
|
||||
// The Flutter framework has been optimized to make rerunning build methods
|
||||
// fast, so that you can just rebuild anything that needs updating rather
|
||||
// than having to individually change instances of widgets.
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
// TRY THIS: Try changing the color here to a specific color (to
|
||||
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
|
||||
// change color while the other colors stay the same.
|
||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
// Here we take the value from the MyHomePage object that was created by
|
||||
// the App.build method, and use it to set our appbar title.
|
||||
title: Text(widget.title),
|
||||
),
|
||||
body: Center(
|
||||
// Center is a layout widget. It takes a single child and positions it
|
||||
// in the middle of the parent.
|
||||
child: Column(
|
||||
// Column is also a layout widget. It takes a list of children and
|
||||
// arranges them vertically. By default, it sizes itself to fit its
|
||||
// children horizontally, and tries to be as tall as its parent.
|
||||
//
|
||||
// Column has various properties to control how it sizes itself and
|
||||
// how it positions its children. Here we use mainAxisAlignment to
|
||||
// center the children vertically; the main axis here is the vertical
|
||||
// axis because Columns are vertical (the cross axis would be
|
||||
// horizontal).
|
||||
//
|
||||
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
|
||||
// action in the IDE, or press "p" in the console), to see the
|
||||
// wireframe for each widget.
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const Text('You have pushed the button this many times:'),
|
||||
Text(
|
||||
'$_counter',
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: _incrementCounter,
|
||||
tooltip: 'Increment',
|
||||
child: const Icon(Icons.add),
|
||||
), // This trailing comma makes auto-formatting nicer for build methods.
|
||||
);
|
||||
}
|
||||
runApp(MainApp());
|
||||
}
|
||||
|
|
202
lib/pokemon.dart
Normal file
|
@ -0,0 +1,202 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
enum Generation {
|
||||
One,
|
||||
Two,
|
||||
Three,
|
||||
Four,
|
||||
Five,
|
||||
Six,
|
||||
Seven,
|
||||
Eight,
|
||||
Nine;
|
||||
|
||||
toSpritePath() {
|
||||
switch (this) {
|
||||
case Generation.One:
|
||||
return 'assets/sprites/gen1';
|
||||
case Generation.Two:
|
||||
return 'assets/sprites/gen2';
|
||||
case Generation.Three:
|
||||
return 'assets/sprites/gen3';
|
||||
case Generation.Four:
|
||||
return 'assets/sprites/gen4';
|
||||
case Generation.Five:
|
||||
return 'assets/sprites/gen5';
|
||||
case Generation.Six:
|
||||
return 'assets/sprites/gen6';
|
||||
case Generation.Seven:
|
||||
return 'assets/sprites/gen7';
|
||||
case Generation.Eight:
|
||||
return 'assets/sprites/gen8';
|
||||
case Generation.Nine:
|
||||
return 'assets/sprites/gen9';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum Type {
|
||||
Normal(Color.fromARGB(255, 192, 192, 192), Colors.black),
|
||||
Fire(Color.fromARGB(255, 255, 0, 0), Colors.black),
|
||||
Water(Color.fromARGB(255, 0, 174, 255), Colors.black),
|
||||
Electric(Color(0xffFFD700), Colors.black),
|
||||
Grass(Color.fromARGB(255, 0, 255, 0), Colors.black),
|
||||
Ice(Color.fromARGB(255, 0, 255, 255), Colors.black),
|
||||
Fighting(Color.fromARGB(255, 255, 0, 0), Colors.black),
|
||||
Poison(Color.fromARGB(255, 128, 0, 128), Colors.black),
|
||||
Ground(Color.fromARGB(255, 128, 126, 0), Colors.black),
|
||||
Flying(Color.fromARGB(255, 128, 128, 255), Colors.black),
|
||||
Psychic(Color.fromARGB(255, 255, 0, 255), Colors.black),
|
||||
Bug(Color.fromARGB(255, 128, 128, 0), Colors.black),
|
||||
Rock(Color.fromARGB(255, 128, 128, 128), Colors.black),
|
||||
Ghost(Color.fromARGB(255, 128, 0, 128), Colors.black),
|
||||
Dragon(Color.fromARGB(255, 85, 0, 102), Colors.black),
|
||||
Dark(Color.fromARGB(255, 51, 51, 51), Colors.black),
|
||||
Steel(Color.fromARGB(255, 192, 192, 192), Colors.black),
|
||||
Fairy(Color.fromARGB(255, 255, 102, 255), Colors.black);
|
||||
|
||||
final Color backgroundColor;
|
||||
final Color textColor;
|
||||
const Type(this.backgroundColor, this.textColor);
|
||||
}
|
||||
|
||||
class Evolution {
|
||||
final int to;
|
||||
final int level;
|
||||
const Evolution(this.to, this.level);
|
||||
}
|
||||
|
||||
enum LearnType { TM, HM }
|
||||
|
||||
enum Move {
|
||||
Growl(LearnType.TM, Type.Normal, "Growl", 0, 100, 40),
|
||||
Tackle(LearnType.TM, Type.Normal, "Tackle", 40, 100, 35),
|
||||
VineWhip(LearnType.TM, Type.Grass, "Vine Whip", 45, 100, 25),
|
||||
RazorLeaf(LearnType.TM, Type.Grass, "Razor Leaf", 55, 95, 25),
|
||||
SolarBeam(LearnType.TM, Type.Grass, "Solar Beam", 120, 100, 10),
|
||||
PoisonPowder(LearnType.TM, Type.Poison, "Poison Powder", 0, 75, 35),
|
||||
SleepPowder(LearnType.TM, Type.Grass, "Sleep Powder", 0, 75, 15),
|
||||
TakeDown(LearnType.TM, Type.Normal, "Take Down", 90, 85, 20),
|
||||
DoubleEdge(LearnType.TM, Type.Normal, "Double-Edge", 120, 100, 15),
|
||||
LeechSeed(LearnType.TM, Type.Grass, "Leech Seed", 0, 90, 10),
|
||||
Growth(LearnType.TM, Type.Normal, "Growth", 0, 0, 20),
|
||||
PoisonSting(LearnType.TM, Type.Poison, "Poison Sting", 15, 100, 35),
|
||||
StringShot(LearnType.TM, Type.Bug, "String Shot", 0, 95, 40),
|
||||
BugBite(LearnType.TM, Type.Bug, "Bug Bite", 60, 100, 20),
|
||||
Confusion(LearnType.TM, Type.Psychic, "Confusion", 50, 100, 25);
|
||||
|
||||
final LearnType type;
|
||||
final Type moveType;
|
||||
final String moveName;
|
||||
final int power;
|
||||
final int accuracy;
|
||||
final int pp;
|
||||
const Move(
|
||||
this.type,
|
||||
this.moveType,
|
||||
this.moveName,
|
||||
this.power,
|
||||
this.accuracy,
|
||||
this.pp,
|
||||
);
|
||||
}
|
||||
|
||||
enum Pokemon {
|
||||
Bulbasaur(1, Generation.One, [Type.Grass, Type.Poison], Evolution(2, 16)),
|
||||
Ivysaur(2, Generation.One, [Type.Grass, Type.Poison], Evolution(3, 32)),
|
||||
Venusaur(3, Generation.One, [Type.Grass, Type.Poison], null),
|
||||
Charmander(4, Generation.One, [Type.Fire], Evolution(5, 16)),
|
||||
Charmeleon(5, Generation.One, [Type.Fire], Evolution(6, 36)),
|
||||
Charizard(6, Generation.One, [Type.Fire, Type.Flying], null);
|
||||
|
||||
final int id;
|
||||
final Generation generation;
|
||||
final List<Type> types;
|
||||
final Evolution? evolution;
|
||||
bool get hasEvolutions => evolution != null;
|
||||
const Pokemon(this.id, this.generation, this.types, this.evolution);
|
||||
|
||||
String toSpritePath() {
|
||||
return '${generation.toSpritePath()}/${name.toLowerCase()}.png';
|
||||
}
|
||||
|
||||
String toDexPath() {
|
||||
return 'assets/sprites/dex/${name.toLowerCase()}.png';
|
||||
}
|
||||
|
||||
String toSpriteShinyPath() {
|
||||
return '${generation.toSpritePath()}/${name.toLowerCase()}_shiny.png';
|
||||
}
|
||||
|
||||
Widget getTypeWidgets() {
|
||||
List<Widget> widgets = [];
|
||||
for (Type type in types) {
|
||||
widgets.add(
|
||||
ElevatedButton(
|
||||
onPressed: () {},
|
||||
style: ButtonStyle(
|
||||
backgroundColor: WidgetStatePropertyAll(type.backgroundColor),
|
||||
foregroundColor: WidgetStatePropertyAll(type.textColor),
|
||||
),
|
||||
child: Text(type.name, style: TextStyle(fontSize: 24)),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Row(children: widgets);
|
||||
}
|
||||
|
||||
Widget getEvolutions(int subID) {
|
||||
if (!hasEvolutions) return Row(children: []);
|
||||
|
||||
Pokemon ev = Pokemon.values.where((x) => x.id == evolution!.to).first;
|
||||
|
||||
List<Widget> sprites = [];
|
||||
|
||||
if (subID == 0) {
|
||||
sprites.add(
|
||||
Column(
|
||||
children: [
|
||||
Image.asset(toDexPath(), width: 96, height: 96),
|
||||
getTypeWidgets(),
|
||||
],
|
||||
),
|
||||
);
|
||||
sprites.add(
|
||||
Column(
|
||||
children: [
|
||||
Icon(Icons.arrow_forward, size: 48),
|
||||
Text("Level ${evolution!.level}", style: TextStyle(fontSize: 24)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
sprites.add(
|
||||
Column(
|
||||
children: [
|
||||
Image.asset(ev.toDexPath(), width: 96, height: 96),
|
||||
ev.getTypeWidgets(),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (ev.hasEvolutions) {
|
||||
sprites.add(
|
||||
Column(
|
||||
children: [
|
||||
Icon(Icons.arrow_forward, size: 48),
|
||||
Text(
|
||||
"Level ${ev.evolution!.level}",
|
||||
style: TextStyle(fontSize: 24),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
//sprites.add(Icon(Icons.arrow_forward, size: 48));
|
||||
sprites.add(ev.getEvolutions(subID + 1));
|
||||
}
|
||||
|
||||
return Row(children: sprites);
|
||||
}
|
||||
}
|
19
pubspec.yaml
|
@ -2,7 +2,7 @@ name: pokedex
|
|||
description: "A PokeDex!"
|
||||
# The following line prevents the package from being accidentally published to
|
||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||
|
||||
# The following defines the version and build number for your application.
|
||||
# A version number is three numbers separated by dots, like 1.2.43
|
||||
|
@ -57,16 +57,25 @@ dev_dependencies:
|
|||
|
||||
# The following section is specific to Flutter packages.
|
||||
flutter:
|
||||
|
||||
# The following line ensures that the Material Icons font is
|
||||
# included with your application, so that you can use the icons in
|
||||
# the material Icons class.
|
||||
uses-material-design: true
|
||||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
assets:
|
||||
- assets/sprites/gen1/bulbasaur.png
|
||||
- assets/sprites/dex/bulbasaur.png
|
||||
- assets/sprites/dex/ivysaur.png
|
||||
- assets/sprites/gen1/ivysaur.png
|
||||
- assets/sprites/dex/venusaur.png
|
||||
- assets/sprites/gen1/venusaur.png
|
||||
- assets/sprites/dex/charmander.png
|
||||
- assets/sprites/gen1/charmander.png
|
||||
- assets/sprites/dex/charmeleon.png
|
||||
- assets/sprites/gen1/charmeleon.png
|
||||
- assets/sprites/dex/charizard.png
|
||||
- assets/sprites/gen1/charizard.png
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/to/resolution-aware-images
|
||||
|
|