boiler plate code for Pop up Screen to UI to allow for quick way to launch pages.

This will be huge for RAM saving as the page will de alloc when closed.
This commit is contained in:
MatthewColvin 2023-10-06 14:25:05 -05:00
parent 6343a48be1
commit a11b78c540
4 changed files with 39 additions and 0 deletions

View file

@ -9,6 +9,7 @@ public:
enum class Screens {
Background = static_cast<int>(INVALID) + 1,
Home,
PopUp,
INVALID_SCREEN_ID
};

View file

@ -3,6 +3,9 @@
#include "WidgetBase.hpp"
#include <vector>
namespace UI::Screen {
class PopUpScreen;
}
namespace UI::Page {
class Tab;
class TabView;
@ -10,6 +13,9 @@ class Base : public UIElement {
friend Tab; // Allow Tab to Forward all Key Events to its page
friend TabView; // Allow Tab view to call OnShow and OnHide Since it can show
// and Hide pages by swiping
friend UI::Screen::PopUpScreen; // Allow Pop up Screens pass events to the
// page it owns
public:
typedef std::unique_ptr<Base> Ptr;

View file

@ -0,0 +1,14 @@
#include "PopUpScreen.hpp"
using namespace UI;
using namespace UI::Screen;
PopUpScreen::PopUpScreen(Page::Base::Ptr aPage)
: Screen::Base(UI::ID::Screens::PopUp), mContentPage(std::move(aPage)) {
AddElement(mContentPage.get());
}
bool PopUpScreen::OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) {
return mContentPage->OnKeyEvent(aKeyEvent);
}

View file

@ -0,0 +1,18 @@
#pragma once
#include "PageBase.hpp"
#include "ScreenBase.hpp"
namespace UI::Screen {
/// @brief A Screen that allows easy display of a page that
/// can be dismissed easily by an x
class PopUpScreen : public Base {
public:
PopUpScreen(UI::Page::Base::Ptr aPage);
bool OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) override;
private:
UI::Page::Base::Ptr mContentPage;
};
} // namespace UI::Screen