-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathHostStyle.h
34 lines (26 loc) · 1.18 KB
/
HostStyle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once
#include <jsi/jsi.h>
#include "StyleSheet.h"
#include "Constants.h"
#include "Parser.h"
#include "UnistyleWrapper.h"
#include "HybridUnistylesRuntime.h"
namespace margelo::nitro::unistyles::core {
using Variants = std::vector<std::pair<std::string, std::string>>;
struct JSI_EXPORT HostStyle : public jsi::HostObject {
HostStyle(std::shared_ptr<StyleSheet> styleSheet, std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime)
: _styleSheet{styleSheet}, _unistylesRuntime{unistylesRuntime} {};
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& rt);
jsi::Value get(jsi::Runtime& rt, const jsi::PropNameID& propNameId);
void set(jsi::Runtime& rt, const jsi::PropNameID& propNameId, const jsi::Value& value);
jsi::Function createAddVariantsProxyFunction(jsi::Runtime& rt);
private:
// to additionally distinguish between empty variants
// that are set at the beginning
bool hasVariantsSet = false;
std::shared_ptr<StyleSheet> _styleSheet;
std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
std::vector<std::pair<std::string, std::string>> _variants{};
std::unordered_map<std::string, jsi::Value> _styleCache{};
};
}