Fix android UX

This commit is contained in:
zontreck 2025-03-22 19:56:49 -07:00
parent c62a39edcb
commit 2ade0cca22
2 changed files with 37 additions and 29 deletions

View file

@ -94,16 +94,16 @@ class _HomeState extends State<Home> {
children: [ children: [
Image.asset( Image.asset(
Pokemon.values[index].toDexPath(), Pokemon.values[index].toDexPath(),
width: 198, width: 64,
height: 198, height: 64,
), ),
Text( Text(
Pokemon.values[index].name, Pokemon.values[index].name,
style: TextStyle(fontSize: 32, color: Colors.black), style: TextStyle(fontSize: 16, color: Colors.black),
), ),
Text( Text(
"#${Pokemon.values[index].id}", "#${Pokemon.values[index].id}",
style: TextStyle(fontSize: 24, color: Colors.black), style: TextStyle(fontSize: 16, color: Colors.black),
), ),
], ],
), ),
@ -113,7 +113,7 @@ class _HomeState extends State<Home> {
}, },
itemCount: Pokemon.values.length, itemCount: Pokemon.values.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4, crossAxisCount: 3,
), ),
), ),
), ),
@ -148,25 +148,27 @@ class _DexEntryState extends State<DexEntry> {
), ),
body: Padding( body: Padding(
padding: EdgeInsets.all(8), padding: EdgeInsets.all(8),
child: Column( child: SingleChildScrollView(
children: [ child: Column(
Image.asset(_pkmn.toDexPath()), crossAxisAlignment: CrossAxisAlignment.start,
Text("ID: ${_pkmn.id}", style: TextStyle(fontSize: 24)), children: [
Row( Center(child: Image.asset(_pkmn.toDexPath())),
children: [ Text("ID: ${_pkmn.id}", style: TextStyle(fontSize: 24)),
Text("Type: ", style: TextStyle(fontSize: 24)),
_pkmn.getTypeWidgets(),
],
),
SizedBox(height: 24),
if (_pkmn.hasEvolutions)
Row( Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text("Evolutions: ", style: TextStyle(fontSize: 24)), Text("Type: ", style: TextStyle(fontSize: 24)),
_pkmn.getEvolutions(0), _pkmn.getTypeWidgets(),
], ],
), ),
], SizedBox(height: 32),
if (_pkmn.hasEvolutions)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: _pkmn.getEvolutions(0),
),
],
),
), ),
), ),
); );

View file

@ -145,15 +145,16 @@ enum Pokemon {
backgroundColor: WidgetStatePropertyAll(type.backgroundColor), backgroundColor: WidgetStatePropertyAll(type.backgroundColor),
foregroundColor: WidgetStatePropertyAll(type.textColor), foregroundColor: WidgetStatePropertyAll(type.textColor),
), ),
child: Text(type.name, style: TextStyle(fontSize: 24)),
child: Text(type.name, style: TextStyle(fontSize: 16)),
), ),
); );
} }
return Row(children: widgets); return Row(children: widgets);
} }
Widget getEvolutions(int subID) { List<Widget> getEvolutions(int subID) {
if (!hasEvolutions) return Row(children: []); if (!hasEvolutions) return [];
Pokemon ev = Pokemon.values.where((x) => x.id == evolution!.to).first; Pokemon ev = Pokemon.values.where((x) => x.id == evolution!.to).first;
@ -162,16 +163,19 @@ enum Pokemon {
if (subID == 0) { if (subID == 0) {
sprites.add( sprites.add(
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Image.asset(toDexPath(), width: 96, height: 96), Text("Evolutions: ", style: TextStyle(fontSize: 24)),
Image.asset(toDexPath(), width: 64, height: 64),
getTypeWidgets(), getTypeWidgets(),
], ],
), ),
); );
sprites.add( sprites.add(
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Icon(Icons.arrow_forward, size: 48), Icon(Icons.arrow_downward, size: 48),
Text("Level ${evolution!.level}", style: TextStyle(fontSize: 24)), Text("Level ${evolution!.level}", style: TextStyle(fontSize: 24)),
], ],
), ),
@ -180,8 +184,9 @@ enum Pokemon {
sprites.add( sprites.add(
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Image.asset(ev.toDexPath(), width: 96, height: 96), Image.asset(ev.toDexPath(), width: 64, height: 64),
ev.getTypeWidgets(), ev.getTypeWidgets(),
], ],
), ),
@ -190,8 +195,9 @@ enum Pokemon {
if (ev.hasEvolutions) { if (ev.hasEvolutions) {
sprites.add( sprites.add(
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Icon(Icons.arrow_forward, size: 48), Icon(Icons.arrow_downward, size: 48),
Text( Text(
"Level ${ev.evolution!.level}", "Level ${ev.evolution!.level}",
style: TextStyle(fontSize: 24), style: TextStyle(fontSize: 24),
@ -200,9 +206,9 @@ enum Pokemon {
), ),
); );
//sprites.add(Icon(Icons.arrow_forward, size: 48)); //sprites.add(Icon(Icons.arrow_forward, size: 48));
sprites.add(ev.getEvolutions(subID + 1)); sprites.addAll(ev.getEvolutions(subID + 1));
} }
return Row(children: sprites); return sprites;
} }
} }