How mensonones/rnsplash works
Project Type & Purpose
• RNSplash is a React Native module focused on providing customizable splash screen animations.
• The module includes both JavaScript (React Native) layers and native components for Android (and iOS) to integrate an animated splash experience.
• Key features include support for diverse animation types (fade, scale, none), configurable duration and delay, and integration with native lifecycle events.
Main Components
a. JavaScript Layer:
• App.tsx: Entry point where the splash is hidden via the native module.
• NativeSplash.ts: Contains the abstraction that calls the native code.
• Package.json, tsconfig.json, etc: Configuration for the React Native project.
b. Android Native Module:
• Files under android/app/src/main/java/com/rnsplash/ (SplashModule.kt, RCTSplashScreen.kt, SplashPackage.kt, MainActivity.kt, etc.) implementing the native splash functionality.
• Android resource files (AndroidManifest.xml, drawable assets) for styling and configuring the native splash screen.
c. iOS Native Module:
• Contained under the ios directory (RNSplash.xcodeproj, AppDelegate, Info.plist, LaunchScreen.storyboard, etc.) which provides the iOS counterpart for the splash functionality.
d. Assets & Configurations:
• assets directory, image resources (e.g., splash.png), and configuration files (babel.config.js, metro.config.js) that support project build and runtime behavior.
Relationships & Interactions
• The JavaScript code (NativeSplash.ts) exposes a hideSplashScreen function to the rest of the application.
• When invoked (e.g., in App.tsx), this function triggers native code via the React Native bridge.
• On Android, this bridges into the native module (SplashModule.kt) via package registration (SplashPackage.kt) and is hooked into the activity lifecycle (MainActivity.kt) to display/close the splash screen.
• In parallel, the iOS side (managed in Xcode) similarly utilizes native components to handle splash display logic.
• The assets (images, configuration files) support both native environments and inform the build process.
Architectural Patterns & Design Principles
• Bridge Pattern: Emphasize that the React Native bridge facilitates communication between JavaScript and native code.
• Modular Design: Highlight the encapsulated modules for splash functionality that can be customized via configuration options (animationType, duration, delay).
• One toward the Android module:
• MainActivity.kt, which initializes the splash on app startup.
• RCTSplashScreen.kt and SplashModule.kt managing the Android-specific splash screen.
• The drawable assets and resource configuration.
• One toward the iOS module:
• Xcode project layout with AppDelegate, LaunchScreen.storyboard, etc.
• How configuration settings (animationType, duration, delay) are passed throughout the system.
• Finally, include external build/process descriptors like Gradle, npm/yarn, and configuration tools (ESLint, Prettier, etc.) as ancillary components.