# iou90/react-native-autoheight-webview architecture

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

- Interactive diagram: https://gitdiagram.com/iou90/react-native-autoheight-webview
- Repository: https://github.com/iou90/react-native-autoheight-webview

## Overview

##### Main Components Structure
- Create three main vertical sections:
a. Consumer Application Layer (Top)
b. React Native Auto Height WebView Component (Middle)
c. Platform-Specific Implementation Layer (Bottom)

##### Component Architecture Details

Core Component Layer:
- It to a 'Utils' module (utils.js)
- TypeScript definitions (index.d.ts) as a side connection

Platform Implementation Layer:
- Create two parallel sections for iOS and Android implementations
- Integration with react-native-webview as a dependency
- Native bridge connections

##### Data Flow Representation

- Props flow from parent to component
- Height/width calculations flow up through onSizeUpdated callback
- Custom script and style injections into WebView
- File loading paths for both platforms

##### Key Integration Points

- WebView configuration points (viewport, scaling)
- Custom script injection
- Style customization
- File system integration points
- Size update callbacks

##### Implementation Details

- Required props
- Optional configurations
- Platform-specific behaviors
- Default values
- Supported file types

**┌─────────────────────────────────────┐**
- Consumer React Native App      │
- ┬───────────────┘
- ↓
**┌─────────────────────────────────────┐**
- Auto Height WebView Component     │
- ┤
- Custom Script Injection          │
- Style Processing                 │
- Size Calculation                 │
- File Management                  │
- ┬───────────────┬────────┘
- ↓               ↓
**┌───────────────────┐ ┌────────────────┐**
- iOS WebView      │ │ Android WebView │
- ┘ └────────────────┘

Important Considerations:

##### Interaction Patterns
- Bidirectional communication between WebView and native layers
- Size calculation flow
- Viewport handling differences between platforms

##### Configuration Points
- CustomScript injection
- Style application process
- File loading paths
- Platform-specific configurations

##### Special Attention Areas
- Scale handling differences between platforms
- Viewport content handling
- File system integration points
- Size update callback flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Consumer
        App["React Native App"]:::consumer
        DemoApp["Demo Application"]:::consumer
        click DemoApp "https://github.com/iou90/react-native-autoheight-webview/blob/master/demo/App.js"
        DemoConfig["Demo Configuration"]:::consumer
        click DemoConfig "https://github.com/iou90/react-native-autoheight-webview/blob/master/demo/config.js"
        App --> DemoApp
        DemoApp --> DemoConfig
    end

    subgraph Core["Auto Height WebView Component"]
        MainEntry["Main Entry Point"]:::core
        click MainEntry "https://github.com/iou90/react-native-autoheight-webview/blob/master/index.js"
        AutoHeight["Auto Height WebView"]:::core
        click AutoHeight "https://github.com/iou90/react-native-autoheight-webview/blob/master/autoHeightWebView/index.js"
        Utils["Utils Module"]:::core
        click Utils "https://github.com/iou90/react-native-autoheight-webview/blob/master/autoHeightWebView/utils.js"
        TypeDefs["TypeScript Definitions"]:::core
        click TypeDefs "https://github.com/iou90/react-native-autoheight-webview/blob/master/index.d.ts"

        MainEntry --> AutoHeight
        AutoHeight --> Utils
        AutoHeight -.-> TypeDefs
    end

    subgraph Platform["Platform-Specific Implementation"]
        direction TB
        subgraph iOS
            IOSWebView["iOS WebView Implementation"]:::ios
            click IOSWebView "https://github.com/iou90/react-native-autoheight-webview/tree/master/demo/ios/demo"
        end

        subgraph Android
            AndroidWebView["Android WebView Implementation"]:::android
            click AndroidWebView "https://github.com/iou90/react-native-autoheight-webview/tree/master/demo/android/app/src/main"
        end
    end

    Consumer --> Core
    Core --> Platform

    %% Data Flow
    AutoHeight -- "Props Flow" --> IOSWebView
    AutoHeight -- "Props Flow" --> AndroidWebView
    IOSWebView -- "Height Updates" --> AutoHeight
    AndroidWebView -- "Height Updates" --> AutoHeight

    %% Styling
    classDef consumer fill:#a8dadc,stroke:#457b9d,color:#1d3557
    classDef core fill:#f1faee,stroke:#457b9d,color:#1d3557
    classDef ios fill:#e63946,stroke:#457b9d,color:#f1faee
    classDef android fill:#2a9d8f,stroke:#457b9d,color:#f1faee

    %% Legend
    subgraph Legend
        ConsumerLegend["Consumer Components"]:::consumer
        CoreLegend["Core Components"]:::core
        IOSLegend["iOS Implementation"]:::ios
        AndroidLegend["Android Implementation"]:::android
    end
```
