# vetster/react-native-action-sheet architecture

> Architecture diagram of the GitHub repository vetster/react-native-action-sheet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vetster/react-native-action-sheet
- Repository: https://github.com/vetster/react-native-action-sheet

## Overview

##### Project type and purpose
- This is an open-source React Native component library published as an NPM package (`@vetster/react-native-action-sheet`).
- Its goal is to provide a cross-platform Action Sheet: native UIActionSheet on iOS and a JS-based ActionSheet on Android.

##### File structure
- Top-level directories and files:
- src/ – the TS/JS core library (components, context, hooks, HOC)
- ios/ – native Swift/Objective-C bridge code for iOS
- example/ – a sample React Native app demonstrating usage (Android + iOS projects under example/android and example/ios)
- scripts/ – build and bootstrap helpers (e.g. for monorepo tooling)
- .github/ – CI and release workflows
- configs (babel.config.js, tsconfig.json, bob build config in package.json)

##### README for additional insights
- Confirms cross-platform approach, outlines the public API (ActionSheetProvider, useActionSheet hook, connectActionSheet HOC), platform-specific props, and installation/build instructions.
- Describes how JS context and native modules interact to invoke the appropriate UI.

- from App → ActionSheetProvider → showActionSheetWithOptions → platform module → user tap callback → back to App.
- from build scripts → compiled outputs → NPM package.
- Orange or gray for tooling (build, CI).

##### Be detailed and complete
- Break the library into all major sub-components (context provider, hook/HOC, component modules, native bridge, build pipeline).
- State flow and data flow: how options go from JS → native/custom UI → callback.
- Packaging and deployment artifacts (bob build, package.json, GitHub Actions).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External App
    subgraph "Consumer App"
        App["Consumer App"]:::external
    end

    %% Public API Layer
    subgraph "Public API Layer"
        Provider["ActionSheetProvider"]:::js
        Hook["useActionSheet"]:::js
        HOC["connectActionSheet"]:::js
    end

    %% Core JavaScript Engine
    subgraph "Core JS Engine"
        Context["context.ts"]:::js
        Index["src/index.ts"]:::js
        Types["types.ts"]:::js
        subgraph "ActionSheet Components"
            ASIndex["index.tsx"]:::js
            ASiOS["index.ios.tsx"]:::js
            ActionGroup["ActionGroup.tsx"]:::js
            CustomAS["CustomActionSheet.tsx"]:::js
            TouchableSafe["TouchableNativeFeedbackSafe.tsx"]:::js
        end
    end

    %% Platform-specific Modules
    subgraph "Platform Modules"
        subgraph "iOS Native Module"
            ObjC["ReactNativeActionSheet.mm"]:::native
            SwiftImpl["ReactNativeActionSheet.swift"]:::native
            Bridging["ReactNativeActionSheet-Bridging-Header.h"]:::native
            Controller["ActionSheetController.swift"]:::native
            Cell["ActionSheetTableViewCell.swift"]:::native
        end
        AndroidJS["CustomActionSheet (Android UI)"]:::js
    end

    %% Tooling & CI/CD
    subgraph "Tooling & CI/CD"
        Babel["babel.config.js"]:::tooling
        TSCBuild["tsconfig.build.json"]:::tooling
        Bootstrap["scripts/bootstrap.js"]:::tooling
        Package["package.json"]:::tooling
        Metro["example/metro.config.js"]:::tooling
        CI[".github/workflows/ci.yml"]:::tooling
        Release[".github/workflows/release.yml"]:::tooling
        GHAction[".github/actions/setup/action.yml"]:::tooling
    end

    %% Relationships
    App -->|"wraps root with"| Provider
    Provider -->|"provides API"| Hook
    Provider -->|"provides API"| HOC
    Hook -->|"calls"| Index
    HOC -->|"calls"| Index
    Index -->|"imports"| Context
    Index -->|"imports"| Types
    Index -->|"re-exports components"| ASIndex
    Index -->|"re-exports iOS wrapper"| ASiOS
    ASIndex -->|"uses"| ActionGroup
    ASIndex -->|"uses"| CustomAS
    ASIndex -->|"uses"| TouchableSafe
    ASIndex -->|"renders on Android"| AndroidJS
    ASiOS -->|"bridges to"| ObjC
    ObjC -->|"calls native"| SwiftImpl
    SwiftImpl -->|"presents UI"| Controller
    Controller -->|"uses cell"| Cell

    %% Build and Packaging Flow
    Babel -->|"transpile TS/JS"| Package
    TSCBuild -->|"compile types"| Package
    Bootstrap -->|"bootstrap monorepo"| Package
    Package -->|"published as NPM"| App
    Metro -->|"bundles example"| App
    CI -->|"runs lint/test/build"| Package
    Release -->|"publishes release"| Package
    GHAction -->|"custom setup"| CI

    %% Click Events
    click App "https://github.com/vetster/react-native-action-sheet/blob/master/example/App.tsx"
    click Provider "https://github.com/vetster/react-native-action-sheet/blob/master/src/ActionSheetProvider.tsx"
    click Hook "https://github.com/vetster/react-native-action-sheet/blob/master/src/useActionSheet.ts"
    click HOC "https://github.com/vetster/react-native-action-sheet/blob/master/src/connectActionSheet.tsx"
    click Context "https://github.com/vetster/react-native-action-sheet/blob/master/src/context.ts"
    click Index "https://github.com/vetster/react-native-action-sheet/blob/master/src/index.ts"
    click Types "https://github.com/vetster/react-native-action-sheet/blob/master/src/types.ts"
    click ActionGroup "https://github.com/vetster/react-native-action-sheet/blob/master/src/ActionSheet/ActionGroup.tsx"
    click CustomAS "https://github.com/vetster/react-native-action-sheet/blob/master/src/ActionSheet/CustomActionSheet.tsx"
    click TouchableSafe "https://github.com/vetster/react-native-action-sheet/blob/master/src/ActionSheet/TouchableNativeFeedbackSafe.tsx"
    click ASiOS "https://github.com/vetster/react-native-action-sheet/blob/master/src/ActionSheet/index.ios.tsx"
    click ASIndex "https://github.com/vetster/react-native-action-sheet/blob/master/src/ActionSheet/index.tsx"
    click ObjC "https://github.com/vetster/react-native-action-sheet/blob/master/ios/ReactNativeActionSheet.mm"
    click SwiftImpl "https://github.com/vetster/react-native-action-sheet/blob/master/ios/ReactNativeActionSheet.swift"
    click Bridging "https://github.com/vetster/react-native-action-sheet/blob/master/ios/ReactNativeActionSheet-Bridging-Header.h"
    click Controller "https://github.com/vetster/react-native-action-sheet/blob/master/ios/ActionSheetController.swift"
    click Cell "https://github.com/vetster/react-native-action-sheet/blob/master/ios/ActionSheetTableViewCell.swift"
    click Babel "https://github.com/vetster/react-native-action-sheet/blob/master/babel.config.js"
    click TSCBuild "https://github.com/vetster/react-native-action-sheet/blob/master/tsconfig.build.json"
    click Bootstrap "https://github.com/vetster/react-native-action-sheet/blob/master/scripts/bootstrap.js"
    click Package "https://github.com/vetster/react-native-action-sheet/blob/master/package.json"
    click Metro "https://github.com/vetster/react-native-action-sheet/blob/master/example/metro.config.js"
    click CI "https://github.com/vetster/react-native-action-sheet/blob/master/.github/workflows/ci.yml"
    click Release "https://github.com/vetster/react-native-action-sheet/blob/master/.github/workflows/release.yml"
    click GHAction "https://github.com/vetster/react-native-action-sheet/blob/master/.github/actions/setup/action.yml"

    %% Styles
    classDef js fill:#D0E8FF,stroke:#0288D1,color:#001F3F
    classDef native fill:#DFF0D8,stroke:#3C763D,color:#2E4E1C
    classDef tooling fill:#FFE0B2,stroke:#EF6C00,color:#4E342E
    classDef external fill:#ECEFF1,stroke:#607D8B,color:#263238
```
