How rit3zh/morphlet works
Morphlet is a React Native library for presenting a floating tray that morphs, animates, and supports named views. The main workflow is a consumer composing Root, Trigger, and Content; React state and props configure the tray and its native views, where the platform runtime presents and dismisses the card. The README documents transitions, spring presets, stacked presentation, drag dismissal, and view navigation. Android excerpts show the host manager-to-view setup and controller/gesture responsibilities; iOS runtime links are not inferred from headers alone.
Main entry points: tray-root.tsx Tray Root · tray-content.tsx Tray Content · MorphletController.kt Tray controller · MorphletHostViewManager.kt Host view manager
Components 22
React tray API
- Tray Root
src/components/tray-root.tsx - Trigger and Close
src/components/tray-trigger.tsx - Tray Content
src/components/tray-content.tsx - Tray sections
src/components/tray-body.tsx - Named views
src/components/tray-view.tsx - Morph transition
src/components/tray-morph.tsx
State and navigation
- Tray state
src/interfaces/tray-state.interface.ts - Tray context
src/context/tray.context.ts - useTray API
src/hooks/use-tray.ts
Native view bridge
- Host native view
src/views/MorphletHostViewNativeComponent.ts - Container native view
src/views/MorphletContainerViewNativeComponent.ts - Switch native view
src/views/MorphletSwitchViewNativeComponent.ts
Android tray runtime
- Host view manager
android/src/main/java/com/morphlet/components/MorphletHostViewManager.kt - Host view
android/src/main/java/com/morphlet/components/MorphletHostView.kt - Container view
android/src/main/java/com/morphlet/components/MorphletContainerView.kt - Tray controller
android/src/main/java/com/morphlet/controllers/MorphletController.kt - View switcher
android/src/main/java/com/morphlet/components/MorphletSwitchView.kt
Gestures and animation
- Drag handler
android/src/main/java/com/morphlet/controllers/MorphletDragHandler.kt - Spring engine
android/src/main/java/com/morphlet/animation/MorphletSpring.kt - Spring configuration
android/src/main/java/com/morphlet/animation/MorphletSpringConfig.kt - Snapshot utility
android/src/main/java/com/morphlet/utils/MorphletSnapshot.kt
Other components
- App consumer
Connections 22
- App consumer → Tray Root: composes
- Tray Root → Trigger and Close: hosts
- Tray Root → Tray Content: hosts
- Tray Content → Tray sections: contains
- Tray sections → Named views: switches views
- App consumer → Morph transition: configures
- Tray Root → Tray state: controls
- Tray Root → Tray context: provides
- useTray API → Tray context: reads
- Tray Root → Host native view: renders
- Tray Content → Container native view: imports views
src/components/tray-content.tsx - Tray Content → Switch native view: imports views
src/components/tray-content.tsx - Host native view → Host view manager: dispatches to
- Host view manager → Host view: creates and configures
android/src/main/java/com/morphlet/components/MorphletHostViewManager.kt - Host view → Tray controller: delegates control
android/src/main/java/com/morphlet/components/MorphletHostView.kt - Host view manager → Container view: attaches content
android/src/main/java/com/morphlet/components/MorphletHostViewManager.kt - Tray controller → Drag handler: uses gestures
android/src/main/java/com/morphlet/controllers/MorphletController.kt - Drag handler → Tray controller: updates drag
android/src/main/java/com/morphlet/controllers/MorphletDragHandler.kt - Tray controller → Spring engine: animates with
android/src/main/java/com/morphlet/controllers/MorphletController.kt - Spring engine → Spring configuration: uses config
android/src/main/java/com/morphlet/animation/MorphletSpring.kt - View switcher → Spring engine: animates transitions
android/src/main/java/com/morphlet/components/MorphletSwitchView.kt - View switcher → Snapshot utility: captures snapshots
android/src/main/java/com/morphlet/components/MorphletSwitchView.kt