#pragma once
#include <vector>
#include "Widget.h"

// 🔥 forward declaration
class PopupWidget;

class ScreenManager {
    std::vector<Widget*> _widgets;
    PopupWidget* _modal = nullptr;
	PopupWidget* _pendingClearModal = nullptr;		//Modal do wyczyszczenia
	bool _needsClearModal = false;
    static ScreenManager* _active;
	ScreenManager* _pendingClearScreen = nullptr; 	//Ekran do wyczyszczenia
    bool _needsClearPass = false;
	
	bool _zDirty = false;
	uint8_t _fillColor = 0;
	uint32_t _modalStartTime = 0, _modalDurationTime = 0;

public:
    void add(Widget* w);

    void activate();
    static void setActive(ScreenManager* s);
    static ScreenManager* active();

    void showModal( PopupWidget* p, uint16_t durationTime_ms=0 );
    void hideModal();

    void loop();
	
	void setFillColor( uint8_t c ){
		_fillColor = c;
	}
	
	void markZDirty( void ){
		_zDirty = true;
	}

};

