#include "ProjectsScreen.h" #include "MaterialIcons.h" #include "../Widgets/IconButton.h" #include "../Widgets/Panel.h" #include "../Widgets/ArtworkCard.h" #include "../ManagementContext/ArtworkManagementContext.h" #include "../Widgets/ScrollArea.h" #include "../UserInterface/Layout/StackLayout.h" #include "../UserInterface/Layout/VirtualizingGridLayout.h" #include "../UserInterface/Layout/VirtualizingStackLayout.h" #include "../AppLayers/ScreenLayer.h" #include "Widgets/Widget.h" #include ProjectsScreen::ProjectsScreen() : Screen(nullptr), currentArtwork(nullptr) { rootWidget = CreateRoot(); dirtyManager.SetRootWidget(rootWidget.get()); inputRouter.SetRootWidget(rootWidget.get()); } ProjectsScreen::ProjectsScreen(Artwork* openTarget) : Screen(nullptr), currentArtwork(openTarget) { rootWidget = CreateRoot(); dirtyManager.SetRootWidget(rootWidget.get()); inputRouter.SetRootWidget(rootWidget.get()); } ProjectsScreen::~ProjectsScreen() { rootWidget.reset(); } std::unique_ptr ProjectsScreen::CreateRoot() { auto root = std::make_unique(UI::Orientation::Vertical, 0.0f); root->AddChild(CreateHeader()); root->AddChild(CreateProjects()); return root; } #include "EditorScreen.h" std::unique_ptr ProjectsScreen::CreateHeader() { auto panel = std::make_unique(); panel->SetBgColor(UI::Color(0, 0, 0, 1.0f)); panel->SetVerticalAlignment(UI::VerticalAlignment::Center); panel->SetPadding(UI::Thickness(24.0f, 12.0f)); auto layout = std::make_unique(UI::Orientation::Horizontal, 0.0f); layout->SetVerticalAlignment(UI::VerticalAlignment::Center); auto spacer = std::make_unique(); spacer->SetHorizontalAlignment(UI::HorizontalAlignment::Stretch); spacer->SetMaxSize(UI::Size(1000000.0f, 1000000.0f)); layout->AddChild(std::make_unique(ICON_MS_ARROW_BACK, "Back", [](){ ScreenLayer::CloseScreen(); } )); layout->AddChild(std::move(spacer)); layout->AddChild(std::make_unique(ICON_MS_ADD, "Create")); layout->AddChild(std::make_unique(ICON_MS_PUBLISH, "Publish")); // profesional sharing, integrates with atproto, also can share multiple artworks as once serverside artwork? unsure on design, REVISIT: once we go networking if (currentArtwork) { layout->AddChild(std::make_unique(ICON_MS_SHARE, "Share")); // simple sharing, copy as png or open system share sheet layout->AddChild(std::make_unique(ICON_MS_PLAY_ARROW, "Replay")); // implemented, eventuallyâ„¢ } layout->AddChild(std::make_unique(ICON_MS_MORE_HORIZ, "Menu")); // manage importing and location layout->AddChild(std::make_unique(ICON_MS_INFO, "Info")); // show full gallery information/artwork information if (currentArtwork) { layout->AddChild(std::make_unique(ICON_MS_EDIT_SQUARE, "Edit",[this](){ ScreenLayer::OpenScreen(std::make_unique(currentArtwork)); })); } panel->AddChild(std::move(layout)); return panel; } std::unique_ptr ProjectsScreen::CreateProjects() { const auto artworks = ArtworkManagementContext::GetAll(); if (!currentArtwork) { auto layout = std::make_unique( artworks.size(), 220.0f, 24.0f, 164.0f, 240.0f, [artworks](std::size_t index) { return UI::ArtworkCard::GetSizeForArtwork(artworks[index], true); }, [artworks](std::size_t index) { return std::make_unique(artworks[index], true, UI::ArtworkCardSizeMode::Fill); } ); auto scrollable = std::make_unique(UI::OverflowFlags::Vertical); scrollable->SetPadding(UI::Thickness(32.0f, 24.0f)); scrollable->AddChild(std::move(layout)); return scrollable; } auto layout = std::make_unique( artworks.size(), 0.0f, 200.0f, nullptr, // PERCHANCE: maybe we use nullptr as a signal for fill instead? [artworks](std::size_t index) { return std::make_unique(artworks[index], true, UI::ArtworkCardSizeMode::FillExtra); }, UI::VirtualizingStackSizing::Fill ); auto scrollable = std::make_unique(UI::OverflowFlags::Horizontal, artworks.size() - 1); scrollable->SetPadding(UI::Thickness(0.0f, 24.0f)); // 32 scrollable->AddChild(std::move(layout)); auto it = std::find(artworks.begin(), artworks.end(), currentArtwork); scrollable->SetPage(it - artworks.begin()); return scrollable; }