# bohdanorlov/bouncypageviewcontroller architecture

> Architecture diagram of the GitHub repository bohdanorlov/bouncypageviewcontroller, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bohdanorlov/bouncypageviewcontroller
- Repository: https://github.com/bohdanorlov/bouncypageviewcontroller

## Overview

##### Project type and purpose
- This is a UI component library (a CocoaPod/Carthage-friendly Swift framework) that wraps Apple’s UIPageViewController to provide a “bounce” interaction effect. It also includes an Example iOS app demonstrating how to integrate and configure the component.

##### File structure
- Top level:
- BouncyPageViewController.podspec – CocoaPods specification
- BouncyPageViewController/Classes – the framework source code
- BouncyPageViewController/Assets – any bundled images or resources
- Example/… – an Xcode workspace & project showing usage
- GIFs/, README.md, LICENSE, .travis.yml – documentation, CI config, sample animations
- The Example folder contains: AppDelegate, ViewController, storyboard & XIB, image assets, Podfile to pull in the framework, and tests.

##### README for additional insights
- It shows the public API:
- Init with initial view controllers
- Configure closures for next/previous controller resolution (`viewControllerAfterViewController`, `viewControllerBeforeViewController`)
- Configure a scroll callback (`didScroll`) exposing `offset` and `progress`
- It describes adjustable properties: `pageContentInset`, `pageBounceAnimationDuration`, `overscrollBounceMultiplier`.

##### Main components
a. Hosting iOS App (Example)
b. BouncyPageViewController Framework
- BouncyPageViewController.swift (core logic)
- Assets (if any visual resources are needed at runtime)
c. Apple UIKit Components
- UIPageViewController (underlying engine)
- UIGestureRecognizer for pan/swipe detection
d. Child ViewControllers (your content pages)

##### Relationships and data flow
- Host App → BouncyPageViewController API
- Initializes with two view controllers
- Supplies closure callbacks to the framework
- Receives scroll events via `didScroll` for UI updates
- BouncyPageViewController → UIPageViewController
- Acts as dataSource & delegate, forwarding the closure results
- Listens to UIPageViewController’s internal scroll to compute bounce offset & progress
- UIPageViewController → Child ViewControllers
- Presents one or two view controllers at once according to the paging flow
- BouncyPageViewController → Child ViewControllers
- On scroll, invokes `didScroll` and passes computed metrics so child VCs can animate their own UI

##### Architectural patterns & techs
- Composition over inheritance: the framework wraps Apple’s UIPageViewController rather than subclassing it
- Closure-based callbacks replacing delegate patterns for next/previous and scroll events
- Modular packaging via CocoaPods / Carthage (podspec file)
- Continuous Integration via Travis CI (`.travis.yml`)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Host Application Zone
    subgraph "Host Application (Example App)"
        direction TB
        WS["Xcode Workspace"] 
        PRJ["Xcode Project"]
        AD["AppDelegate.swift"]
        VC["ViewController.swift"]
        PP["PageViewControllerPresenter.swift"]
        SB["Main.storyboard"]
        LS["LaunchScreen.xib"]
        IA["Images.xcassets"]
        POD["Podfile"]
        TS["Tests.swift"]
    end

    %% Framework Module Zone
    subgraph "BouncyPageViewController Module"
        direction TB
        BouncyCore["BouncyPageViewController.swift"]
        AssetsBundle["Assets Bundle"]
        Podspec["BouncyPageViewController.podspec"]
        Travis[".travis.yml"]
    end

    %% External Dependencies Zone
    subgraph "External Dependency (UIKit)"
        direction TB
        UIPage["UIPageViewController"]
        Gesture["UIGestureRecognizer"]
    end

    %% Data Flow and Relationships
    VC -->|"init(with:controllers)"| BouncyCore
    PP -->|"register next/prev closures"| BouncyCore
    BouncyCore -->|"dataSource & delegate"| UIPage
    UIPage -->|"internal scroll events"| BouncyCore
    BouncyCore -->|"didScroll(offset,progress)"| VC
    Podspec -.->|"used by"| POD

    %% Click Events
    click WS "https://github.com/bohdanorlov/bouncypageviewcontroller/blob/master/Example/BouncyPageViewController.xcworkspace"
    click PRJ "https://github.com/bohdanorlov/bouncypageviewcontroller/blob/master/Example/BouncyPageViewController.xcodeproj"
    click AD "https://github.com/bohdanorlov/bouncypageviewcontroller/blob/master/Example/BouncyPageViewController/AppDelegate.swift"
    click VC "https://github.com/bohdanorlov/bouncypageviewcontroller/blob/master/Example/BouncyPageViewController/ViewController.swift"
    click PP "https://github.com/bohdanorlov/bouncypageviewcontroller/blob/master/Example/BouncyPageViewController/PageViewControllerPresenter.swift"
    click SB "https://github.com/bohdanorlov/bouncypageviewcontroller/blob/master/Example/BouncyPageViewController/Base.lproj/Main.storyboard"
    click LS "https://github.com/bohdanorlov/bouncypageviewcontroller/blob/master/Example/BouncyPageViewController/Base.lproj/LaunchScreen.xib"
    click IA "https://github.com/bohdanorlov/bouncypageviewcontroller/blob/master/Example/BouncyPageViewController/Images.xcassets"
    click POD "https://github.com/bohdanorlov/bouncypageviewcontroller/tree/master/Example/Podfile"
    click TS "https://github.com/bohdanorlov/bouncypageviewcontroller/blob/master/Example/Tests/Tests.swift"
    click BouncyCore "https://github.com/bohdanorlov/bouncypageviewcontroller/blob/master/BouncyPageViewController/Classes/BouncyPageViewController.swift"
    click AssetsBundle "https://github.com/bohdanorlov/bouncypageviewcontroller/tree/master/BouncyPageViewController/Assets"
    click Podspec "https://github.com/bohdanorlov/bouncypageviewcontroller/blob/master/BouncyPageViewController.podspec"
    click Travis "https://github.com/bohdanorlov/bouncypageviewcontroller/blob/master/.travis.yml"
    click README "https://github.com/bohdanorlov/bouncypageviewcontroller/blob/master/README.md"
    click GIFs "https://github.com/bohdanorlov/bouncypageviewcontroller/tree/master/GIFs/"
    click LICENSE "https://github.com/bohdanorlov/bouncypageviewcontroller/tree/master/LICENSE"

    %% Styles
    classDef host fill:#e0ffe0,stroke:#333
    classDef framework fill:#e0f0ff,stroke:#333
    classDef external fill:#f0f0f0,stroke:#333

    class WS,PRJ,AD,VC,PP,SB,LS,IA,POD,TS host
    class BouncyCore,AssetsBundle,Podspec,Travis framework
    class UIPage,Gesture external
```
