@@ -29,6 +29,8 @@ namespace margelo::nitro::cssnitro {
2929
3030 void set (const std::string &className, const std::vector<HybridStyleRule> &styleRule);
3131
32+ void addStyleSheet (const HybridStyleSheet &stylesheet);
33+
3234 Declarations
3335 getDeclarations (const std::string &componentId, const std::string &classNames,
3436 const std::string &variableScope, const std::string &containerScope);
@@ -100,6 +102,10 @@ namespace margelo::nitro::cssnitro {
100102 impl_->set (className, styleRule);
101103 }
102104
105+ void HybridStyleRegistry::addStyleSheet (const HybridStyleSheet &stylesheet) {
106+ impl_->addStyleSheet (stylesheet);
107+ }
108+
103109 Declarations HybridStyleRegistry::getDeclarations (const std::string &componentId,
104110 const std::string &classNames,
105111 const std::string &variableScope,
@@ -183,6 +189,24 @@ namespace margelo::nitro::cssnitro {
183189 }
184190 }
185191
192+ void HybridStyleRegistry::Impl::addStyleSheet (const HybridStyleSheet &stylesheet) {
193+ // Create an Effect batch to process all style updates together
194+ reactnativecss::Effect::batch ([this , &stylesheet]() {
195+ // If the key "s" exists, loop over every entry
196+ if (stylesheet.s .has_value ()) {
197+ const auto &styles = stylesheet.s .value ();
198+ for (const auto &entry: styles) {
199+ // entry is a tuple<string, HybridStyleRule>
200+ // entry[0] is the className, entry[1] is the styleRule
201+ const std::string &className = std::get<0 >(entry);
202+ const std::vector<HybridStyleRule> &styleRule = std::get<1 >(entry);
203+
204+ // Call set with a vector containing the single styleRule
205+ set (className, styleRule);
206+ }
207+ }
208+ });
209+ }
186210
187211 Declarations HybridStyleRegistry::Impl::getDeclarations (const std::string &componentId,
188212 const std::string &classNames,
0 commit comments