How reidevl/rn-pokedex works
Main components
• Mobile Native Layers – Two distinct native layers for Android and iOS. These directories contain platform-specific files (e.g., “android/app/src/main/…” and “ios/Pokedex…”). They play the role of providing the native bridge to the React Native framework.
• React Native JavaScript Layer – The heart of your cross-platform code. The main entry point is in “index.js”, with “App.tsx” serving as the primary component that bootstraps the app.
• UI Components – Located under the “src/components” directory (such as PokemonCard, PokemonDetails, FadeInImage, Loading, and SearchInput). These are individual reusable UI elements.
• Screens and Navigation – Found in “src/screens” (for various screens like HomeScreen, PokemonScreen, and SearchScreen) and “src/navigator” (which defines Tab-based navigation). These modules are responsible for the user flow and view management.
• Business Logic and Hooks – “src/hooks” contains custom hooks (e.g., usePokemon, usePokemonSearch, useAnimation) that handle state management, animations, and communication with the API.
• API Layer – “src/api/pokemonApi.tsx” encapsulates calls to the Pokemon API, abstracting network communication.
• Assets and Theme – “src/assets” holds any image or asset files, while “src/theme” configures the visual style (appTheme.tsx).
Relationships and interactions
• The React Native layer (App.tsx) initializes the application and invokes the navigator from “src/navigator/Tabs.tsx” to manage view switching.
• Each screen (Home, Pokemon, Search) connects with UI components to render content and interacts with custom hooks to fetch and manage data.
• The hooks layer connects the UI with the API layer, ensuring data fetched from “src/api” (for instance, data about Pokémon) is then passed to components.
• Native modules in the “android” and “ios” directories serve as the bridge to the device’s capabilities and eventually interact with the React Native runtime.
Architectural patterns and design principles
• Component-based architecture – With separate directories for screens, components, hooks, and API logic, the design favors reusability and separation of concerns.
• MV* or layered architecture phenomenon – Although not explicitly an MVC pattern, the separation between UI components, business logic (hooks), and data fetching (API layer) establishes clear boundaries between different concerns.
• Cross-platform design – Using React Native, the codebase abstracts away platform differences, while native directories ensure platform-specific implementations are in place for Android and iOS.