# rit3zh/morphlet architecture

> Architecture diagram of the GitHub repository rit3zh/morphlet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rit3zh/morphlet
- Repository: https://github.com/rit3zh/morphlet

## Overview

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: [`src/components/tray-root.tsx`](https://github.com/rit3zh/morphlet/blob/main/src/components/tray-root.tsx) (Tray Root), [`src/components/tray-content.tsx`](https://github.com/rit3zh/morphlet/blob/main/src/components/tray-content.tsx) (Tray Content), [`android/src/main/java/com/morphlet/controllers/MorphletController.kt`](https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/controllers/MorphletController.kt) (Tray controller), [`android/src/main/java/com/morphlet/components/MorphletHostViewManager.kt`](https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/components/MorphletHostViewManager.kt) (Host view manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_react["React tray API"]
  node_root["Tray Root<br/>[tray-root.tsx]"]
  node_trigger["Trigger and Close<br/>[tray-trigger.tsx]"]
  node_content["Tray Content<br/>[tray-content.tsx]"]
  node_sections["Tray sections<br/>[tray-body.tsx]"]
  node_view_switch["Named views<br/>[tray-view.tsx]"]
  node_morph["Morph transition<br/>[tray-morph.tsx]"]
end

subgraph group_state["State and navigation"]
  node_tray_state["Tray state"]
  node_context["Tray context<br/>[tray.context.ts]"]
  node_tray_hook["useTray API<br/>[use-tray.ts]"]
end

subgraph group_bridge["Native view bridge"]
  node_native_host_js["Host native view"]
  node_native_container_js["Container native view"]
  node_native_switch_js["Switch native view"]
end

subgraph group_runtime["Android tray runtime"]
  node_host_manager["Host view manager"]
  node_host_view["Host view"]
  node_container_view["Container view"]
  node_controller["Tray controller"]
  node_switch_view["View switcher"]
end

subgraph group_motion["Gestures and animation"]
  node_drag["Drag handler"]
  node_spring["Spring engine<br/>[MorphletSpring.kt]"]
  node_spring_config["Spring configuration"]
  node_snapshot["Snapshot utility"]
end

node_consumer(("App consumer"))

node_consumer -->|"composes"| node_root
node_root -->|"hosts"| node_trigger
node_root -->|"hosts"| node_content
node_content -->|"contains"| node_sections
node_sections -->|"switches views"| node_view_switch
node_consumer -->|"configures"| node_morph
node_root -.->|"controls"| node_tray_state
node_root -.->|"provides"| node_context
node_tray_hook -.->|"reads"| node_context
node_root -.->|"renders"| node_native_host_js
node_content -->|"imports views"| node_native_container_js
node_content -->|"imports views"| node_native_switch_js
node_native_host_js -.->|"dispatches to"| node_host_manager
node_host_manager -->|"creates and configures"| node_host_view
node_host_view -->|"delegates control"| node_controller
node_host_manager -->|"attaches content"| node_container_view
node_controller -->|"uses gestures"| node_drag
node_drag -->|"updates drag"| node_controller
node_controller -->|"animates with"| node_spring
node_spring -->|"uses config"| node_spring_config
node_switch_view -->|"animates transitions"| node_spring
node_switch_view -->|"captures snapshots"| node_snapshot

click node_root "https://github.com/rit3zh/morphlet/blob/main/src/components/tray-root.tsx"
click node_trigger "https://github.com/rit3zh/morphlet/blob/main/src/components/tray-trigger.tsx"
click node_content "https://github.com/rit3zh/morphlet/blob/main/src/components/tray-content.tsx"
click node_sections "https://github.com/rit3zh/morphlet/blob/main/src/components/tray-body.tsx"
click node_view_switch "https://github.com/rit3zh/morphlet/blob/main/src/components/tray-view.tsx"
click node_morph "https://github.com/rit3zh/morphlet/blob/main/src/components/tray-morph.tsx"
click node_tray_state "https://github.com/rit3zh/morphlet/blob/main/src/interfaces/tray-state.interface.ts"
click node_context "https://github.com/rit3zh/morphlet/blob/main/src/context/tray.context.ts"
click node_tray_hook "https://github.com/rit3zh/morphlet/blob/main/src/hooks/use-tray.ts"
click node_native_host_js "https://github.com/rit3zh/morphlet/blob/main/src/views/MorphletHostViewNativeComponent.ts"
click node_native_container_js "https://github.com/rit3zh/morphlet/blob/main/src/views/MorphletContainerViewNativeComponent.ts"
click node_native_switch_js "https://github.com/rit3zh/morphlet/blob/main/src/views/MorphletSwitchViewNativeComponent.ts"
click node_host_manager "https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/components/MorphletHostViewManager.kt"
click node_host_view "https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/components/MorphletHostView.kt"
click node_container_view "https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/components/MorphletContainerView.kt"
click node_controller "https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/controllers/MorphletController.kt"
click node_switch_view "https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/components/MorphletSwitchView.kt"
click node_drag "https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/controllers/MorphletDragHandler.kt"
click node_spring "https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/animation/MorphletSpring.kt"
click node_spring_config "https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/animation/MorphletSpringConfig.kt"
click node_snapshot "https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/utils/MorphletSnapshot.kt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_root,node_trigger,node_content,node_sections,node_view_switch,node_morph toneBlue
class node_tray_state,node_context,node_tray_hook toneAmber
class node_native_host_js,node_native_container_js,node_native_switch_js toneMint
class node_host_manager,node_host_view,node_container_view,node_controller,node_switch_view toneRose
class node_drag,node_spring,node_spring_config,node_snapshot,node_consumer toneIndigo
```

## Components

### React tray API

- [Tray Root](https://github.com/rit3zh/morphlet/blob/main/src/components/tray-root.tsx): `src/components/tray-root.tsx`
- [Trigger and Close](https://github.com/rit3zh/morphlet/blob/main/src/components/tray-trigger.tsx): `src/components/tray-trigger.tsx`
- [Tray Content](https://github.com/rit3zh/morphlet/blob/main/src/components/tray-content.tsx): `src/components/tray-content.tsx`
- [Tray sections](https://github.com/rit3zh/morphlet/blob/main/src/components/tray-body.tsx): `src/components/tray-body.tsx`
- [Named views](https://github.com/rit3zh/morphlet/blob/main/src/components/tray-view.tsx): `src/components/tray-view.tsx`
- [Morph transition](https://github.com/rit3zh/morphlet/blob/main/src/components/tray-morph.tsx): `src/components/tray-morph.tsx`

### State and navigation

- [Tray state](https://github.com/rit3zh/morphlet/blob/main/src/interfaces/tray-state.interface.ts): `src/interfaces/tray-state.interface.ts`
- [Tray context](https://github.com/rit3zh/morphlet/blob/main/src/context/tray.context.ts): `src/context/tray.context.ts`
- [useTray API](https://github.com/rit3zh/morphlet/blob/main/src/hooks/use-tray.ts): `src/hooks/use-tray.ts`

### Native view bridge

- [Host native view](https://github.com/rit3zh/morphlet/blob/main/src/views/MorphletHostViewNativeComponent.ts): `src/views/MorphletHostViewNativeComponent.ts`
- [Container native view](https://github.com/rit3zh/morphlet/blob/main/src/views/MorphletContainerViewNativeComponent.ts): `src/views/MorphletContainerViewNativeComponent.ts`
- [Switch native view](https://github.com/rit3zh/morphlet/blob/main/src/views/MorphletSwitchViewNativeComponent.ts): `src/views/MorphletSwitchViewNativeComponent.ts`

### Android tray runtime

- [Host view manager](https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/components/MorphletHostViewManager.kt): `android/src/main/java/com/morphlet/components/MorphletHostViewManager.kt`
- [Host view](https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/components/MorphletHostView.kt): `android/src/main/java/com/morphlet/components/MorphletHostView.kt`
- [Container view](https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/components/MorphletContainerView.kt): `android/src/main/java/com/morphlet/components/MorphletContainerView.kt`
- [Tray controller](https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/controllers/MorphletController.kt): `android/src/main/java/com/morphlet/controllers/MorphletController.kt`
- [View switcher](https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/components/MorphletSwitchView.kt): `android/src/main/java/com/morphlet/components/MorphletSwitchView.kt`

### Gestures and animation

- [Drag handler](https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/controllers/MorphletDragHandler.kt): `android/src/main/java/com/morphlet/controllers/MorphletDragHandler.kt`
- [Spring engine](https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/animation/MorphletSpring.kt): `android/src/main/java/com/morphlet/animation/MorphletSpring.kt`
- [Spring configuration](https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/animation/MorphletSpringConfig.kt): `android/src/main/java/com/morphlet/animation/MorphletSpringConfig.kt`
- [Snapshot utility](https://github.com/rit3zh/morphlet/blob/main/android/src/main/java/com/morphlet/utils/MorphletSnapshot.kt): `android/src/main/java/com/morphlet/utils/MorphletSnapshot.kt`

### Other components

- **App consumer**

## Connections

- 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 (evidence: `src/components/tray-content.tsx`)
- Tray Content → Switch native view: imports views (evidence: `src/components/tray-content.tsx`)
- Host native view → Host view manager: dispatches to
- Host view manager → Host view: creates and configures (evidence: `android/src/main/java/com/morphlet/components/MorphletHostViewManager.kt`)
- Host view → Tray controller: delegates control (evidence: `android/src/main/java/com/morphlet/components/MorphletHostView.kt`)
- Host view manager → Container view: attaches content (evidence: `android/src/main/java/com/morphlet/components/MorphletHostViewManager.kt`)
- Tray controller → Drag handler: uses gestures (evidence: `android/src/main/java/com/morphlet/controllers/MorphletController.kt`)
- Drag handler → Tray controller: updates drag (evidence: `android/src/main/java/com/morphlet/controllers/MorphletDragHandler.kt`)
- Tray controller → Spring engine: animates with (evidence: `android/src/main/java/com/morphlet/controllers/MorphletController.kt`)
- Spring engine → Spring configuration: uses config (evidence: `android/src/main/java/com/morphlet/animation/MorphletSpring.kt`)
- View switcher → Spring engine: animates transitions (evidence: `android/src/main/java/com/morphlet/components/MorphletSwitchView.kt`)
- View switcher → Snapshot utility: captures snapshots (evidence: `android/src/main/java/com/morphlet/components/MorphletSwitchView.kt`)
