#include "mologram/ui/PremiumModel.hpp" namespace mologram::ui { void PremiumModel::set(PremiumState s) { if (s == state_) return; state_ = s; for (auto& fn : listeners_) fn(s); } bool PremiumModel::use(const std::string& featureId, const std::function& action) { if (has()) { if (action) action(); return true; } if (const PremiumFeature* f = PremiumFeatures::find(featureId)) { if (showPanel) showPanel(*f); } return false; } void PremiumModel::refused(const std::string& featureId) { set(PremiumState::NotPremium); if (const PremiumFeature* f = PremiumFeatures::find(featureId)) { if (showPanel) showPanel(*f); } } std::string PremiumModel::label(const std::string& text, bool ascii) const { if (has()) return text; return text + (ascii ? " [P]" : " \xF0\x9F\x94\x92"); } } // namespace mologram::ui