@startuml metrics_storybook_class_diagram

package widgets/theme {
    class ThemeNotifier {
        - _selectedTheme : ThemeType
        + isDark : bool
        + selectedTheme : ThemeType

        + changeTheme(ThemeType themeType) : void
        + toggleTheme() : void
        + setTheme(Brightness brightness) : void
        - _isBrightnessDark(Brightness brightness) : bool
    }
}

package metrics/core/lib/src/domain/entities {
    abstract class Enum<T> {
        + value : T
    }
}

package storybook {
    package state {
        class ChaptersNotifier {
            + currentChapter : Chapter

            + selectChapter(Chapter chapter) : void
            + refreshChapter() : void
        }

        class StoriesNotifier {
            + stories : List<Story>
        }
    }

    package stories {
        package buttons {
            package chapters {
                class InactiveButtonChapter {
                    - _chapterControls : ChapterControls
                    + name : String
                    + controls : Map<String, ChapterControl>

                    + build() : Widget
                }
            }
            package controls {
                class InactiveButtonChapterControls {
                    + addControls() : void
                }
                class ButtonsChapterControlName {
                    + {static} const label : ButtonsChapterControlName
                    + {static} const  values : Set<ButtonsChapterControlName>
                    + toString() : String
                }
            }
            class ButtonsStory {
                + name : String
                + chapters : List<Chapter>
            }
        }

        abstract class Story {
            + name : String
            + chapters : List<Chapter>
        }

        abstract class Chapter {
            + name : String
            + controls : ChapterControls

            + build() : Widget
        }

        class ChapterControls {
            + controls : Map<String, ChapterControl>

            + addTextControl(String name, String value) : void
            + addBoolControl(String name, bool value) : void
            + addColorControl(String name, Color value) : void
            + addNumberControl(String name, Number value) : void
            + getControlValue(String name) : dynamic
        }

        class ChapterControl<T> {
            + name : String
            + value : T
        }
    }

    package mappers {
        class ChapterControlMapper {
            + map(ChapterControl<T> control) : Widget
        }
    }

    package widgets {
        class Storybook {
            + stories : List<Story>
        }

        class InjectionContainer {
            + stories : List<Story>
        }

        class Sidebar {
            + build(BuildContext context) : Widget
        }

        class Preview {
            + build(BuildContext context) : Widget
        }

        class EditingPanel {
            - _widgets : List<Widget>

            + build(BuildContext context) : Widget
        }

        package control_fields {
            class ChapterControlField {
                + label : String
                + child : Widget
            }

            class ChapterControlTextField {
                + property : ChapterControl<String>

                + build(BuildContext context) : Widget
            }

            class ChapterControlCheckboxField {
                + property : ChapterControl<Bool>

                + build(BuildContext context) : Widget
            }

            class ChapterControlColorField {
                + property : ChapterControl<Color>

                + build(BuildContext context) : Widget
            }

            class ChapterControlSliderField {
                + property : ChapterControl<Number>

                + build(BuildContext context) : Widget
            }
        }
    }
}

Storybook -up-> InjectionContainer : creates and provides a list of stories
Storybook -up-> EditingPanel : creates
Storybook -up-> Sidebar : creates
Storybook -up-> Preview : creates
InjectionContainer -up-> StoriesNotifier : creates
InjectionContainer -up-> ChaptersNotifier : creates
InjectionContainer -up-> ThemeNotifier : creates
Storybook -down-> ButtonsStory : uses
Story -right-> Chapter : uses
Chapter -right-> ChapterControls : creates
ChapterControls -> ChapterControl : creates

ButtonsStory -down-|> Story : extends
ButtonsStory -> InactiveButtonChapter : creates
InactiveButtonChapter -down-|> Chapter : extends
InactiveButtonChapterControls -down-|> ChapterControls: extends
InactiveButtonChapter -right-> InactiveButtonChapterControls : creates
InactiveButtonChapterControls -right-> ButtonsChapterControlName : uses
ButtonsChapterControlName -right-|> Enum : extends

EditingPanel -up-> ChaptersNotifier : uses
Sidebar -up-> StoriesNotifier : uses
Preview -up-> ChaptersNotifier : uses
EditingPanel -up-> ChapterControlMapper : uses
ChapterControlField -> ChaptersNotifier : uses

ChapterControlMapper -> ChapterControlTextField : uses
ChapterControlMapper -> ChapterControlCheckboxField : uses
ChapterControlMapper -> ChapterControlColorField : uses
ChapterControlMapper -> ChapterControlSliderField : uses

ChapterControlTextField -down-> ChapterControlField : uses
ChapterControlCheckboxField -down-> ChapterControlField : uses
ChapterControlColorField -down-> ChapterControlField : uses
ChapterControlSliderField -down-> ChapterControlField : uses

@enduml
