diff --git a/assets/sprites/flareon.png b/assets/sprites/flareon.png new file mode 100644 index 0000000..b930c09 Binary files /dev/null and b/assets/sprites/flareon.png differ diff --git a/assets/sprites/jolteon.png b/assets/sprites/jolteon.png new file mode 100644 index 0000000..8c479d9 Binary files /dev/null and b/assets/sprites/jolteon.png differ diff --git a/lib/Consts.dart b/lib/Consts.dart index 7ff11b3..d7b706f 100644 --- a/lib/Consts.dart +++ b/lib/Consts.dart @@ -1,7 +1,7 @@ import 'dart:io'; class Constants { - static const VERSION = "1.0.032325+1552"; + static const VERSION = "1.0.032325+1814"; static bool get isMobile => Platform.isAndroid || Platform.isIOS; } diff --git a/lib/MainApp.dart b/lib/MainApp.dart index 74ac0a2..14fd5b8 100644 --- a/lib/MainApp.dart +++ b/lib/MainApp.dart @@ -5,6 +5,8 @@ import 'package:pokedex/Session.dart'; import 'package:pokedex/pokemon.dart'; class MainApp extends StatefulWidget { + const MainApp({super.key}); + @override _MainAppState createState() => _MainAppState(); } @@ -32,7 +34,7 @@ class _MainAppState extends State { class Home extends StatefulWidget { final VoidCallback toggleTheme; - Home({required this.toggleTheme}); + const Home({super.key, required this.toggleTheme}); @override _HomeState createState() => _HomeState(); @@ -128,6 +130,8 @@ class _HomeState extends State { } class DexEntry extends StatefulWidget { + const DexEntry({super.key}); + @override _DexEntryState createState() => _DexEntryState(); } @@ -184,11 +188,18 @@ class _DexEntryState extends State { SizedBox(height: 32), if (_pkmn.hasEvolutions) if (Constants.isMobile) - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: _pkmn.getEvolutions(0), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: _pkmn.getEvolutions(0), + ), ), - if (!Constants.isMobile) Row(children: _pkmn.getEvolutions(0)), + if (!Constants.isMobile) + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row(children: _pkmn.getEvolutions(0)), + ), ], ), ), diff --git a/lib/pokemon.dart b/lib/pokemon.dart index 19714c5..898ea92 100644 --- a/lib/pokemon.dart +++ b/lib/pokemon.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:pokedex/Consts.dart'; enum Generation { @@ -84,6 +83,8 @@ enum EvolutionCondition { abstract class Evolution { const Evolution(); String printEvolution(); + + Widget getEvolution(); } class SingleEvolution extends Evolution { @@ -91,7 +92,7 @@ class SingleEvolution extends Evolution { final int level; final List? condition; - const SingleEvolution(this.to, this.level, {this.condition = null}); + const SingleEvolution(this.to, this.level, {this.condition}); @override String printEvolution() { @@ -110,12 +111,47 @@ class SingleEvolution extends Evolution { } return sRet; } + + @override + Widget getEvolution() { + Pokemon pkmn = Pokemon.values.where((x) => x.id == to).first; + + var arrow = Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon( + Constants.isMobile ? Icons.arrow_downward : Icons.arrow_forward, + size: 48, + ), + Text(printEvolution(), style: TextStyle(fontSize: 24)), + ], + ); + + Column col = Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Image.asset( + pkmn.toDexPath(), + width: Constants.isMobile ? 64 : 128, + height: Constants.isMobile ? 64 : 128, + ), + pkmn.getTypeWidgets(), + ], + ); + + Column rw = Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [arrow, col], + ); + + return rw; + } } class BranchedEvolution extends Evolution { final List alternates; final List levels; - final Map?> conditions; + final List> conditions; const BranchedEvolution(this.alternates, this.levels, this.conditions); @@ -123,6 +159,78 @@ class BranchedEvolution extends Evolution { String printEvolution() { return ""; } + + String _prntEV(List conds, int level) { + String sRet = ""; + if (level != -1) { + sRet += "Level ${level}"; + } + for (var condition in conds) { + sRet += condition.name; + } + return sRet; + } + + @override + Widget getEvolution() { + // This is a branched evolution. So first, we print the arrows, and conditions. + Row arrowRow; + List arrows = []; + + List pkmnRow = []; + Row rowPkmn; + + for (var pkmn in alternates) { + int index = alternates.indexOf(pkmn); + Pokemon _pkmn = Pokemon.values.where((x) => x.id == pkmn).first; + + arrows.add( + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon( + Constants.isMobile ? Icons.arrow_downward : Icons.arrow_forward, + size: 48, + ), + Text( + _prntEV(conditions[index], levels[index]), + style: TextStyle(fontSize: 24), + ), + //Text(printEvolution(), style: TextStyle(fontSize: 24)), + ], + ), + ); + + pkmnRow.add( + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Image.asset( + _pkmn.toDexPath(), + width: Constants.isMobile ? 64 : 128, + height: Constants.isMobile ? 64 : 128, + ), + _pkmn.getTypeWidgets(), + ], + ), + ); + } + + arrowRow = Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: arrows, + ); + + rowPkmn = Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: pkmnRow, + ); + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [arrowRow, rowPkmn], + ); + } } enum LearnType { TM, HM } @@ -487,11 +595,15 @@ enum Pokemon { "Eevee", Generation.One, [Type.Normal], - BranchedEvolution([134], [-1], { - 134: [EvolutionCondition.WaterStone], - }), + BranchedEvolution([134, 135, 136], [-1, -1, -1], [ + [EvolutionCondition.WaterStone], + [EvolutionCondition.ThunderStone], + [EvolutionCondition.FireStone], + ]), ), - Vaporeon(134, "Vaporeon", Generation.One, [Type.Water], null); + Vaporeon(134, "Vaporeon", Generation.One, [Type.Water], null), + Jolteon(135, "Jolteon", Generation.One, [Type.Electric], null), + Flareon(136, "Flareon", Generation.One, [Type.Fire], null); final int id; final String properName; @@ -539,29 +651,39 @@ enum Pokemon { String printName({var proper = false}) { String sRet; - if (!proper) + if (!proper) { sRet = name.replaceAll("_", " "); - else + } else { sRet = properName; + } - if (sRet.endsWith("F")) sRet = sRet.substring(0, sRet.length - 1) + "♀"; - if (sRet.endsWith("M")) sRet = sRet.substring(0, sRet.length - 1) + "♂"; + if (sRet.endsWith("F")) sRet = "${sRet.substring(0, sRet.length - 1)}♀"; + if (sRet.endsWith("M")) sRet = "${sRet.substring(0, sRet.length - 1)}♂"; return sRet; } List getEvolutions(int subID) { + print("SUBID ${subID}"); if (!hasEvolutions) return []; - Pokemon ev = Pokemon.Abra; + List Evs = []; - if (evolution is SingleEvolution) - ev = - Pokemon.values - .where((x) => x.id == (evolution! as SingleEvolution).to) - .first; - else { + print("Processing evolutions for ${properName}"); + + if (evolution is SingleEvolution) { + print("Single Evolution identified"); + Evs.add( + Pokemon.values + .where((x) => x.id == (evolution! as SingleEvolution).to) + .first, + ); + } else { + print("Branching Evolution identified"); // Handle branched evolutions. Refactor below to accomodate a list of pokemon. + for (var ev in (evolution! as BranchedEvolution).alternates) { + Evs.add(Pokemon.values.where((x) => x.id == ev).first); + } } List sprites = []; @@ -569,64 +691,29 @@ enum Pokemon { if (subID == 0) { sprites.add(Text("Evolutions: ", style: TextStyle(fontSize: 24))); sprites.add( - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Image.asset( - toDexPath(), - width: Constants.isMobile ? 64 : 128, - height: Constants.isMobile ? 64 : 128, - ), - getTypeWidgets(), - ], - ), - ); - sprites.add( - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Icon( - Constants.isMobile ? Icons.arrow_downward : Icons.arrow_forward, - size: 48, - ), - Text(evolution!.printEvolution(), style: TextStyle(fontSize: 24)), - ], + Image.asset( + toDexPath(), + width: Constants.isMobile ? 64 : 128, + height: Constants.isMobile ? 64 : 128, ), ); + sprites.add(getTypeWidgets()); + sprites.add(evolution!.getEvolution()); + print("Main page EV."); + } else { + sprites.add(evolution!.getEvolution()); + } + + List afterEvs = []; + for (var ev in Evs) { + afterEvs.addAll(ev.getEvolutions(subID + 1)); + print("Processing evolution: ${ev.properName}"); } sprites.add( - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Constants.isMobile - ? Image.asset(ev.toDexPath(), width: 64, height: 64) - : Image.asset(ev.toDexPath(), width: 128, height: 128), - ev.getTypeWidgets(), - ], - ), + Row(crossAxisAlignment: CrossAxisAlignment.start, children: afterEvs), ); - if (ev.hasEvolutions) { - sprites.add( - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Icon( - Constants.isMobile ? Icons.arrow_downward : Icons.arrow_forward, - size: 48, - ), - Text( - ev.evolution!.printEvolution(), - style: TextStyle(fontSize: 24), - ), - ], - ), - ); - //sprites.add(Icon(Icons.arrow_forward, size: 48)); - sprites.addAll(ev.getEvolutions(subID + 1)); - } - return sprites; } } diff --git a/pubspec.yaml b/pubspec.yaml index e56d457..be64121 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.032325+1552 +version: 1.0.032325+1814 environment: sdk: ^3.7.0 @@ -199,6 +199,8 @@ flutter: - assets/sprites/ditto.png - assets/sprites/eevee.png - assets/sprites/vaporeon.png + - assets/sprites/jolteon.png + - assets/sprites/flareon.png # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/to/resolution-aware-images