#include "component.hh"
#include "modern-qt/utility/material-icon.hh"
#include <qstandardpaths.h>
#include <modern-qt/core/application.hh>
#include <modern-qt/layout/linear.hh>
#include <modern-qt/layout/mixer.hh>
#include <modern-qt/layout/scroll.hh>
#include <modern-qt/utility/material-icon.hh>
#include <modern-qt/utility/theme/preset/blue-miku.hh>
#include <modern-qt/utility/theme/theme.hh>
#include <modern-qt/widget/cards/filled-card.hh>
#include <modern-qt/widget/main-window.hh>
#include <qfontdatabase.h>

using namespace creeper;

namespace lnpro = linear::pro;
namespace mwpro = main_window::pro;
namespace capro = card::pro;

auto main(int argc, char *argv[]) -> int {
    app::init {
        app::pro::Attribute {Qt::AA_EnableHighDpiScaling},
        app::pro::Attribute {Qt::AA_UseHighDpiPixmaps},
        app::pro::Complete {argc, argv},
    };

    auto manager = ThemeManager {kBlueMikuThemePack};
    creeper::material::FontLoader::load_font();
    auto nav_component_state = NavComponentState {
        .manager = manager,
        .switch_callback = [&](int index, const auto& name) {

        },
        .buttons_context = {
            {"0", material::icon::kTouchSensor},
            {"1", material::icon::kStar},
            {"2", material::icon::kFavorite},
            {"3", material::icon::kExtension},
            {"4", material::icon::kLogout},
        },
    };
    auto view_component_state = ViewComponentState {.manager = manager};
    auto mask_window = (MixerMask*){};
    creeper::ShowWindow<MainWindow> {
        [&](MainWindow& window) noexcept {

        },
        // mwpro::FixedSize {1080, 720},
        mwpro::MinimumSize {
            1080,
            720
        },
        mwpro::Central<FilledCard> {
            capro::ThemeManager {manager},
            capro::Radius {0},
            capro::Level {CardLevel::HIGHEST},

            capro::Layout<Row> {
                lnpro::Margin{0},
                lnpro::Spacing{0},
                lnpro::Item {
                    NavComponent(nav_component_state),
                },
                lnpro::Item<Col> {
                    lnpro::ContentsMargin{{15, 15, 15, 15}},
                },
                lnpro::Item<Col> {
                    {255},
                    lnpro::ContentsMargin { { 5, 15, 15, 15 } },
                    lnpro::Item<ScrollArea> {
                        scroll::pro::ThemeManager { manager },
                        scroll::pro::HorizontalScrollBarPolicy {
                            Qt::ScrollBarAlwaysOff,
                        },
                        scroll::pro::Item {
                            ViewComponent(view_component_state),
                        },
                    },
                }
            }
        },
        mixer::pro::SetMixerMask {mask_window},
    };
    manager.apply_theme();
    manager.append_begin_callback([=](const auto&) {
        auto const point = mask_window->mapFromGlobal(QCursor::pos());
        mask_window->initiate_animation(point);
    });

    return app::exec();
}
