How doug821/react-native-squircle works
Project’s type and purpose
• This is a React Native UI library (“react-native-squircle-layout”) that provides a customizable “SquircleView” component.
• It consists of three logical layers:
• JavaScript/TypeScript wrapper (in src/)
• Native Android implementation (in android/)
• Native iOS implementation (in ios/)
• There is also an example/demo app (in example/) demonstrating usage on both platforms.
File‐structure and infer architectural choices
• Top-level directories:
• src/ – cross-platform JS/TS code, React component, hooks, types, tests.
• android/ – Android native code (ViewManager, View), two flavors: old architecture (legacy bridge) and new architecture (TurboModules/JSI spec).
• ios/ – iOS native code (Objective-C++/MM ViewManager, View).
• example/ – a full React Native app scaffold (android/, ios/, src/App.tsx) to test the library.
• Config & build:
• package.json, tsconfig.json, babel.config.js for building/publishing.
• react-native-squircle.podspec to integrate with CocoaPods.
• Yarn v3 workspace (.yarn/, turbo.json) to manage monorepo.
README insights
• It mentions it was generated with create-react-native-library (builder-bob), which imposes a standard RN native module pattern.
a. Main components
1. JS Layer
– SquircleView React component (src/components/SquircleView)
– Hook (useElementSize) for dynamic sizing
– Type definitions (src/@types)
2. React Native Bridge
– JS → Native calls
– Property serialization, event callbacks
3. Native Modules
– Android
• SquircleViewManager.kt
• SquircleView.kt (draws squircle via Canvas/Drawable)
• Two packages: legacy bridge (android/src/oldarch) and new architecture spec (android/src/newarch)
– iOS
• RCTSquircleViewManager.mm
• SquircleView.mm (CAShapeLayer or CoreGraphics)
4. Build/Test/Example
– Example app demonstrating integration
– Unit tests (src/__tests__)
– CI workflows (GitHub Actions)
b. Relationships & data flow
– The React component (JS) instantiates a native view via the bridge.
– The example app sits atop the published package, consuming the JS entry point (index.tsx) and linking native modules via Gradle/CocoaPods.
c. Architectural patterns & principles
– Layered architecture: clear separation between JS UI API, bridge, and platform-specific rendering.
– Bridge pattern in React Native: decoupling JS and native.
– Monorepo/workspace structure for co-development of JS, Android, iOS.
– Example-driven development: isolated “example” project to validate pipelines and manual QA.
d. Key technologies & frameworks
– React Native (JS bridge)
– TypeScript for type safety
– Android: Kotlin/Java, AndroidX, Canvas
– iOS: Objective-C++ (.mm), CoreGraphics/CALayer
– Yarn v3 workspaces, TurboRepo (turbo.json)
– CocoaPods for iOS integration
– Gradle for Android builds
– GitHub Actions for CI
Essential details to capture
• The dual-architecture approach on Android (legacy vs new).
• The podspec and Gradle plugin that handle native linking.
• The monorepo build flow: yarn build → ts-compile → native code compile.
• The test harness: unit tests in src/__tests__, CI → example app build/test.