How maitrungduc1410/react-native-loader-kit works
Project type and purpose
• This is a React Native UI component library (“react-native-loader-kit”) that exposes a cross-platform LoaderKitView component.
• It provides various loading animations by bridging from JavaScript/TypeScript into native Android (Kotlin) and iOS (Objective-C++) code.
• The “example” folder is a sample React Native app that consumes the library to demonstrate usage.
File structure
• Top-level files: configuration for Yarn, ESLint, Babel, TypeScript, GitHub Actions, Podspec, Turbo.
• android/: Kotlin code under android/src/main/java/com/loaderkit:
– LoaderKitPackage.kt (module registration)
– LoaderKitViewManager.kt (ViewManager)
– LoaderKitView.kt (custom native view wrapping an Android animation library)
• ios/: LoaderKitView.h/.mm (Objective-C++ implementation of the native view)
• src/: JavaScript/TypeScript wrapper:
– LoaderKitViewNativeComponent.ts (JS-side native component)
– index.tsx (exports)
– types.ts (API typings)
– __tests__ (unit tests)
• example/: A full React Native app scaffold (Android + iOS folders, App.tsx, config files) to demonstrate the library.
README for additional insights
• It mentions underlying inspirations (AVLoadingIndicatorView, NVActivityIndicatorView) which are likely pulled in by the native code.
a. Main components:
• Consumer App (example or any RN app)
• JavaScript/TypeScript layer (src/index.tsx, NativeComponent)
• React Native Bridge
• Android native module (LoaderKitPackage → LoaderKitViewManager → LoaderKitView → Android animation library)
• iOS native module (LoaderKitView.h/.mm → iOS animation library)
• Build & toolchain components (Metro, Babel, TypeScript compiler, Gradle, CocoaPods)
b. Relationships & interactions:
1. App JS imports LoaderKitView API → calls into JS wrapper.
2. JS wrapper uses React Native’s UIManager to dispatch commands via the Bridge.
3. On Android, the bridge invokes LoaderKitViewManager.createViewInstance(), which instantiates LoaderKitView (backed by NVActivityIndicatorView).
4. On iOS, the bridge invokes the native view factory in LoaderKitView.mm, which uses AVLoadingIndicatorView.
6. Build tools compile TS → JS bundle (Metro), compile native code (Gradle, Xcode), and package artifacts (npm).
c. Architectural patterns & design principles:
• React Native Native Module / Native UI Component pattern (bridge + ViewManager).
• Separation of concerns: JS API layer vs. platform-specific implementations.
• Single Responsibility: each component does one job (JS exports, bridge, view creation, animation rendering).
d. Key technologies:
• React Native (Bridge, UIManager)
• TypeScript, Babel, Metro bundler
• Kotlin for Android native modules
• Objective-C++ for iOS native modules
• Gradle & CocoaPods for native builds