Skip to content

Commit

Permalink
fix: layout structure when title is null and status section title
Browse files Browse the repository at this point in the history
  • Loading branch information
brunogabriel committed Oct 31, 2024
1 parent 5b02310 commit 0f45968
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pokedex/lib/design/components/pokemon_information.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PokemonInformation extends StatelessWidget {
),
const SizedBox(height: PokedexSpacing.kXS),
FittedBox(
fit: BoxFit.fitWidth,
fit: BoxFit.scaleDown,
child: Text(
pokemon.name.capitalizeName(),
overflow: TextOverflow.ellipsis,
Expand Down
11 changes: 8 additions & 3 deletions pokedex/lib/design/components/stat_line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ class StatLine extends StatelessWidget {
children: [
Expanded(
flex: 2,
child: Text(
title,
style: textTheme.labelMedium?.copyWith(fontWeight: FontWeight.bold),
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.topLeft,
child: Text(
title,
style:
textTheme.labelMedium?.copyWith(fontWeight: FontWeight.bold),
),
),
),
Expanded(
Expand Down
19 changes: 11 additions & 8 deletions pokedex/lib/feature/about/presentation/widgets/about_success.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,20 @@ class AboutSuccess extends StatelessWidget {
color: primaryColor,
fontWeight: FontWeight.bold,
);
final pokemonDescription = species?.flavorTextEntries
.firstWhereOrNull((element) => element.language.name == 'en')
?.flavorText
.replaceScapeChars();

final items = <Widget>[
// Title
Text(
species?.flavorTextEntries
.firstWhereOrNull((element) => element.language.name == 'en')
?.flavorText
.replaceScapeChars() ??
'',
style: textTheme.bodyLarge?.copyWith(color: PokedexThemeData.textGrey),
),
if (pokemonDescription != null) ...{
Text(
pokemonDescription,
style:
textTheme.bodyLarge?.copyWith(color: PokedexThemeData.textGrey),
),
},
// Pokedex Data
Text(AboutStrings.pokedexData, style: sectionTheme),
if (species != null) ...{
Expand Down
25 changes: 19 additions & 6 deletions pokedex/lib/feature/evolution/domain/evolution_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,27 @@ class EvolutionUseCaseImpl implements EvolutionUseCase {

@override
Future<EvolutionEntity> getEvoluions(Pokemon pokemon) async {
final species = await _pokedex.pokemonSpecies.get(id: pokemon.id);
final evolutionChain = await _pokedex.evolutionChains
.getByUrl(species.evolutionChain?.url ?? '');
PokemonSpecies? species;
try {
species = await _pokedex.pokemonSpecies.get(id: pokemon.id);
} catch (_) {
species = null;
}
EvolutionChain? evolutionChain;
if (species != null) {
evolutionChain = await _pokedex.evolutionChains
.getByUrl(species.evolutionChain?.url ?? '');
} else {
evolutionChain = null;
}

return EvolutionEntity(
pokemon: pokemon,
evolutions: _calculateBreadthFirstSearch(evolutionChain.chain)
.map((e) => _evolutionMapper.toEntity(e))
.toList(),
evolutions: evolutionChain != null
? _calculateBreadthFirstSearch(evolutionChain.chain)
.map((e) => _evolutionMapper.toEntity(e))
.toList()
: [],
);
}

Expand Down

0 comments on commit 0f45968

Please sign in to comment.