skydoves / pokedex-compose

🗡️ Pokedex Compose demonstrates modern Android development with Jetpack Compose, Hilt, Coroutines, Flow, Jetpack (Room, ViewModel), and Material Design based on MVVM architecture.
Apache License 2.0
730 stars 119 forks source link

Accurately Pull From Pokemon Base Stats #5

Closed cmhhelgeson closed 6 months ago

cmhhelgeson commented 6 months ago

🎯 Goal

Utilize the existing scaffolding of the Pokedex-Compose App to accurately display a given Pokemon's base stats, only falling back to randomized stats if the initial stat cannot be found in the Pokemon's StatsResponse object.

🛠 Implementation details

This pull request changes code across the application, but only in a way that facilitates the integration of a Pokemon's stats data rather than fundamentally changing any of the core architectural features of the application. As such, the code changes are distributed throughout core-model, core-database, and features, but mostly consist of changes meant to account for the additional fields introduced in PokemonInfo.kt

Core Model Changes

PokemonInfo.kt: Added new fields that corresponds to a Pokemon's 'stats' field, as outlined in the PokeAPI. Replaced existing hp, attack, speed, and defense fields with lazily initialized values that either return the relevant stat from the stats field or a random integer if the stat cannot be found.

Preview Changes

PreviewUtils.kt: Updated mockPokemonInfo() to reflect changes to the core model.

Core Database Changes

DatabseModule.kt: Added the StatsResponse type converter to the application database in provideAppDatabase()

StatsResponseConverter.kt: Added a type converter for StatsResponse.

Updated Pokemon Info DAO, Entity Mapper, and Entity Kotlin files to account for PokemonInfo's new stats fields.

✍️ Explain examples

image

image

cmhhelgeson commented 6 months ago

Apologies for the issues on the previous builds, I believe I was able to get spotlessApply to work correctly on my machine.