@onekeyfe/react-native-chart-webview 3.0.96 → 3.0.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.cpp +97 -67
- package/lib/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.hpp +6 -1
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewManager.kt +26 -10
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewStateUpdater.kt +2 -2
- package/lib/nitrogen/generated/ios/c++/views/HybridChartWebviewComponent.mm +116 -82
- package/lib/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.cpp +18 -175
- package/lib/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.hpp +59 -61
- package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.cpp +97 -67
- package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.hpp +6 -1
- package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewManager.kt +26 -10
- package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewStateUpdater.kt +2 -2
- package/lib/nitrogen/nitrogen/generated/ios/c++/views/HybridChartWebviewComponent.mm +116 -82
- package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.cpp +18 -175
- package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.hpp +59 -61
- package/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.cpp +97 -67
- package/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.hpp +6 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewManager.kt +26 -10
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewStateUpdater.kt +2 -2
- package/nitrogen/generated/ios/c++/views/HybridChartWebviewComponent.mm +116 -82
- package/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.cpp +18 -175
- package/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.hpp +59 -61
- package/package.json +4 -4
|
@@ -15,89 +15,119 @@ namespace margelo::nitro::chartwebview::views {
|
|
|
15
15
|
using namespace facebook;
|
|
16
16
|
using ConcreteStateData = react::ConcreteState<HybridChartWebviewState>;
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
std::shared_ptr<const HybridChartWebviewProps> JHybridChartWebviewStateUpdater::getPropsFromStateWrapper(
|
|
19
|
+
jni::alias_ref<JStateWrapper::javaobject> stateWrapper) {
|
|
20
|
+
if (stateWrapper.get() == nullptr) {
|
|
21
|
+
return nullptr;
|
|
22
|
+
}
|
|
23
23
|
// Get concrete StateWrapperImpl from passed StateWrapper interface object
|
|
24
|
-
jobject rawStateWrapper =
|
|
25
|
-
if (!
|
|
26
|
-
|
|
24
|
+
jobject rawStateWrapper = stateWrapper.get();
|
|
25
|
+
if (!stateWrapper->isInstanceOf(react::StateWrapperImpl::javaClassStatic())) [[unlikely]] {
|
|
26
|
+
throw std::runtime_error("StateWrapper is not a StateWrapperImpl");
|
|
27
|
+
}
|
|
28
|
+
auto stateWrapperImpl = jni::alias_ref<react::StateWrapperImpl::javaobject>{
|
|
29
|
+
static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)
|
|
30
|
+
};
|
|
31
|
+
std::shared_ptr<const react::State> state = stateWrapperImpl->cthis()->getState();
|
|
32
|
+
if (state == nullptr) {
|
|
33
|
+
return nullptr;
|
|
27
34
|
}
|
|
28
|
-
auto stateWrapper = jni::alias_ref<react::StateWrapperImpl::javaobject>{
|
|
29
|
-
static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)};
|
|
30
|
-
std::shared_ptr<const react::State> state = stateWrapper->cthis()->getState();
|
|
31
35
|
auto concreteState = std::static_pointer_cast<const ConcreteStateData>(state);
|
|
32
36
|
const HybridChartWebviewState& data = concreteState->getData();
|
|
33
|
-
const std::shared_ptr<HybridChartWebviewProps>& props = data.getProps();
|
|
37
|
+
const std::shared_ptr<const HybridChartWebviewProps>& props = data.getProps();
|
|
34
38
|
if (props == nullptr) [[unlikely]] {
|
|
35
|
-
// Props aren't set yet!
|
|
36
39
|
throw std::runtime_error("HybridChartWebviewState's data doesn't contain any props!");
|
|
37
40
|
}
|
|
41
|
+
return props;
|
|
42
|
+
}
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (props->entry.isDirty) {
|
|
49
|
-
hybridView->setEntry(props->entry.value);
|
|
50
|
-
props->entry.isDirty = false;
|
|
51
|
-
}
|
|
52
|
-
if (props->paramsJson.isDirty) {
|
|
53
|
-
hybridView->setParamsJson(props->paramsJson.value);
|
|
54
|
-
props->paramsJson.isDirty = false;
|
|
55
|
-
}
|
|
56
|
-
if (props->assetHost.isDirty) {
|
|
57
|
-
hybridView->setAssetHost(props->assetHost.value);
|
|
58
|
-
props->assetHost.isDirty = false;
|
|
59
|
-
}
|
|
60
|
-
if (props->bridgeScript.isDirty) {
|
|
61
|
-
hybridView->setBridgeScript(props->bridgeScript.value);
|
|
62
|
-
props->bridgeScript.isDirty = false;
|
|
63
|
-
}
|
|
64
|
-
if (props->reuseKey.isDirty) {
|
|
65
|
-
hybridView->setReuseKey(props->reuseKey.value);
|
|
66
|
-
props->reuseKey.isDirty = false;
|
|
67
|
-
}
|
|
68
|
-
if (props->pooled.isDirty) {
|
|
69
|
-
hybridView->setPooled(props->pooled.value);
|
|
70
|
-
props->pooled.isDirty = false;
|
|
71
|
-
}
|
|
72
|
-
if (props->active.isDirty) {
|
|
73
|
-
hybridView->setActive(props->active.value);
|
|
74
|
-
props->active.isDirty = false;
|
|
75
|
-
}
|
|
76
|
-
if (props->webviewDebuggingEnabled.isDirty) {
|
|
77
|
-
hybridView->setWebviewDebuggingEnabled(props->webviewDebuggingEnabled.value);
|
|
78
|
-
props->webviewDebuggingEnabled.isDirty = false;
|
|
79
|
-
}
|
|
80
|
-
if (props->onMessage.isDirty) {
|
|
81
|
-
hybridView->setOnMessage(props->onMessage.value);
|
|
82
|
-
props->onMessage.isDirty = false;
|
|
83
|
-
}
|
|
84
|
-
if (props->onLoadEnd.isDirty) {
|
|
85
|
-
hybridView->setOnLoadEnd(props->onLoadEnd.value);
|
|
86
|
-
props->onLoadEnd.isDirty = false;
|
|
44
|
+
void JHybridChartWebviewStateUpdater::updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
45
|
+
jni::alias_ref<JHybridChartWebviewSpec::JavaPart> javaView,
|
|
46
|
+
jni::alias_ref<JStateWrapper::javaobject> newState,
|
|
47
|
+
jni::alias_ref<JStateWrapper::javaobject> oldState) {
|
|
48
|
+
std::shared_ptr<JHybridChartWebviewSpec> hybridView = javaView->getJHybridChartWebviewSpec();
|
|
49
|
+
std::shared_ptr<const HybridChartWebviewProps> newProps = getPropsFromStateWrapper(newState);
|
|
50
|
+
std::shared_ptr<const HybridChartWebviewProps> oldProps = getPropsFromStateWrapper(oldState);
|
|
51
|
+
if (newProps == nullptr) [[unlikely]] {
|
|
52
|
+
throw std::runtime_error("Current StateWrapper doesn't contain any props!");
|
|
87
53
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
54
|
+
|
|
55
|
+
// Update only props that differ from the previous State snapshot.
|
|
56
|
+
if (oldProps == nullptr
|
|
57
|
+
? newProps->uri.isProvided()
|
|
58
|
+
: !newProps->uri.hasSameValue(oldProps->uri)) {
|
|
59
|
+
hybridView->setUri(newProps->uri.get());
|
|
60
|
+
}
|
|
61
|
+
if (oldProps == nullptr
|
|
62
|
+
? newProps->localBundle.isProvided()
|
|
63
|
+
: !newProps->localBundle.hasSameValue(oldProps->localBundle)) {
|
|
64
|
+
hybridView->setLocalBundle(newProps->localBundle.get());
|
|
65
|
+
}
|
|
66
|
+
if (oldProps == nullptr
|
|
67
|
+
? newProps->entry.isProvided()
|
|
68
|
+
: !newProps->entry.hasSameValue(oldProps->entry)) {
|
|
69
|
+
hybridView->setEntry(newProps->entry.get());
|
|
70
|
+
}
|
|
71
|
+
if (oldProps == nullptr
|
|
72
|
+
? newProps->paramsJson.isProvided()
|
|
73
|
+
: !newProps->paramsJson.hasSameValue(oldProps->paramsJson)) {
|
|
74
|
+
hybridView->setParamsJson(newProps->paramsJson.get());
|
|
75
|
+
}
|
|
76
|
+
if (oldProps == nullptr
|
|
77
|
+
? newProps->assetHost.isProvided()
|
|
78
|
+
: !newProps->assetHost.hasSameValue(oldProps->assetHost)) {
|
|
79
|
+
hybridView->setAssetHost(newProps->assetHost.get());
|
|
80
|
+
}
|
|
81
|
+
if (oldProps == nullptr
|
|
82
|
+
? newProps->bridgeScript.isProvided()
|
|
83
|
+
: !newProps->bridgeScript.hasSameValue(oldProps->bridgeScript)) {
|
|
84
|
+
hybridView->setBridgeScript(newProps->bridgeScript.get());
|
|
85
|
+
}
|
|
86
|
+
if (oldProps == nullptr
|
|
87
|
+
? newProps->reuseKey.isProvided()
|
|
88
|
+
: !newProps->reuseKey.hasSameValue(oldProps->reuseKey)) {
|
|
89
|
+
hybridView->setReuseKey(newProps->reuseKey.get());
|
|
90
|
+
}
|
|
91
|
+
if (oldProps == nullptr
|
|
92
|
+
? newProps->pooled.isProvided()
|
|
93
|
+
: !newProps->pooled.hasSameValue(oldProps->pooled)) {
|
|
94
|
+
hybridView->setPooled(newProps->pooled.get());
|
|
95
|
+
}
|
|
96
|
+
if (oldProps == nullptr
|
|
97
|
+
? newProps->active.isProvided()
|
|
98
|
+
: !newProps->active.hasSameValue(oldProps->active)) {
|
|
99
|
+
hybridView->setActive(newProps->active.get());
|
|
100
|
+
}
|
|
101
|
+
if (oldProps == nullptr
|
|
102
|
+
? newProps->webviewDebuggingEnabled.isProvided()
|
|
103
|
+
: !newProps->webviewDebuggingEnabled.hasSameValue(oldProps->webviewDebuggingEnabled)) {
|
|
104
|
+
hybridView->setWebviewDebuggingEnabled(newProps->webviewDebuggingEnabled.get());
|
|
105
|
+
}
|
|
106
|
+
if (oldProps == nullptr
|
|
107
|
+
? newProps->onMessage.isProvided()
|
|
108
|
+
: !newProps->onMessage.hasSameValue(oldProps->onMessage)) {
|
|
109
|
+
hybridView->setOnMessage(newProps->onMessage.get());
|
|
110
|
+
}
|
|
111
|
+
if (oldProps == nullptr
|
|
112
|
+
? newProps->onLoadEnd.isProvided()
|
|
113
|
+
: !newProps->onLoadEnd.hasSameValue(oldProps->onLoadEnd)) {
|
|
114
|
+
hybridView->setOnLoadEnd(newProps->onLoadEnd.get());
|
|
115
|
+
}
|
|
116
|
+
if (oldProps == nullptr
|
|
117
|
+
? newProps->onError.isProvided()
|
|
118
|
+
: !newProps->onError.hasSameValue(oldProps->onError)) {
|
|
119
|
+
hybridView->setOnError(newProps->onError.get());
|
|
91
120
|
}
|
|
92
121
|
|
|
93
122
|
// Update hybridRef if it changed
|
|
94
|
-
if (
|
|
123
|
+
if (oldProps == nullptr
|
|
124
|
+
? newProps->hybridRef.isProvided()
|
|
125
|
+
: !newProps->hybridRef.hasSameValue(oldProps->hybridRef)) {
|
|
95
126
|
// hybridRef changed - call it with new this
|
|
96
|
-
const auto& maybeFunc =
|
|
127
|
+
const auto& maybeFunc = newProps->hybridRef.get();
|
|
97
128
|
if (maybeFunc.has_value()) {
|
|
98
129
|
maybeFunc.value()(hybridView);
|
|
99
130
|
}
|
|
100
|
-
props->hybridRef.isDirty = false;
|
|
101
131
|
}
|
|
102
132
|
}
|
|
103
133
|
|
|
@@ -31,7 +31,12 @@ public:
|
|
|
31
31
|
public:
|
|
32
32
|
static void updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
33
33
|
jni::alias_ref<JHybridChartWebviewSpec::JavaPart> view,
|
|
34
|
-
jni::alias_ref<JStateWrapper::javaobject>
|
|
34
|
+
jni::alias_ref<JStateWrapper::javaobject> newState,
|
|
35
|
+
jni::alias_ref<JStateWrapper::javaobject> oldState);
|
|
36
|
+
|
|
37
|
+
private:
|
|
38
|
+
static std::shared_ptr<const HybridChartWebviewProps> getPropsFromStateWrapper(
|
|
39
|
+
jni::alias_ref<JStateWrapper::javaobject> stateWrapper);
|
|
35
40
|
|
|
36
41
|
public:
|
|
37
42
|
static void registerNatives() {
|
|
@@ -20,6 +20,14 @@ import com.margelo.nitro.chartwebview.*
|
|
|
20
20
|
* Represents the React Native `ViewManager` for the "ChartWebview" Nitro HybridView.
|
|
21
21
|
*/
|
|
22
22
|
public open class HybridChartWebviewManager: SimpleViewManager<View>() {
|
|
23
|
+
/**
|
|
24
|
+
* Represents the View and its last state snapshot (mutable)
|
|
25
|
+
*/
|
|
26
|
+
private class HybridViewHolder(
|
|
27
|
+
val hybridView: HybridChartWebview,
|
|
28
|
+
var lastState: StateWrapper? = null,
|
|
29
|
+
)
|
|
30
|
+
|
|
23
31
|
init {
|
|
24
32
|
if (RecyclableView::class.java.isAssignableFrom(HybridChartWebview::class.java)) {
|
|
25
33
|
// Enable view recycling
|
|
@@ -34,33 +42,41 @@ public open class HybridChartWebviewManager: SimpleViewManager<View>() {
|
|
|
34
42
|
override fun createViewInstance(reactContext: ThemedReactContext): View {
|
|
35
43
|
val hybridView = HybridChartWebview(reactContext)
|
|
36
44
|
val view = hybridView.view
|
|
37
|
-
view.setTag(associated_hybrid_view_tag, hybridView)
|
|
45
|
+
view.setTag(associated_hybrid_view_tag, HybridViewHolder(hybridView))
|
|
38
46
|
return view
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? {
|
|
42
|
-
val
|
|
50
|
+
val holder = getHybridViewHolder(view)
|
|
43
51
|
?: throw Error("Couldn't find view $view in local views table!")
|
|
52
|
+
val hybridView = holder.hybridView
|
|
53
|
+
val oldState = holder.lastState
|
|
54
|
+
val newState = stateWrapper
|
|
44
55
|
|
|
45
56
|
// 1. Update each prop individually
|
|
46
57
|
hybridView.beforeUpdate()
|
|
47
|
-
HybridChartWebviewStateUpdater.updateViewProps(hybridView,
|
|
58
|
+
HybridChartWebviewStateUpdater.updateViewProps(hybridView, newState, oldState)
|
|
48
59
|
hybridView.afterUpdate()
|
|
60
|
+
holder.lastState = newState
|
|
49
61
|
|
|
50
62
|
// 2. Continue in base View props
|
|
51
|
-
return super.updateState(view, props,
|
|
63
|
+
return super.updateState(view, props, newState)
|
|
52
64
|
}
|
|
53
65
|
|
|
54
66
|
override fun onDropViewInstance(view: View) {
|
|
55
|
-
val
|
|
56
|
-
|
|
67
|
+
val holder = getHybridViewHolder(view)
|
|
68
|
+
holder?.lastState = null
|
|
69
|
+
holder?.hybridView?.onDropView()
|
|
57
70
|
return super.onDropViewInstance(view)
|
|
58
71
|
}
|
|
59
72
|
|
|
60
73
|
protected override fun prepareToRecycleView(reactContext: ThemedReactContext, view: View): View? {
|
|
61
|
-
super.prepareToRecycleView(reactContext, view)
|
|
62
|
-
|
|
74
|
+
val preparedView = super.prepareToRecycleView(reactContext, view)
|
|
75
|
+
?: return null
|
|
76
|
+
val holder = getHybridViewHolder(preparedView)
|
|
63
77
|
?: return null
|
|
78
|
+
val hybridView = holder.hybridView
|
|
79
|
+
holder.lastState = null
|
|
64
80
|
|
|
65
81
|
@Suppress("USELESS_IS_CHECK")
|
|
66
82
|
if (hybridView is RecyclableView) {
|
|
@@ -74,7 +90,7 @@ public open class HybridChartWebviewManager: SimpleViewManager<View>() {
|
|
|
74
90
|
}
|
|
75
91
|
}
|
|
76
92
|
|
|
77
|
-
private fun
|
|
78
|
-
return view.getTag(associated_hybrid_view_tag) as?
|
|
93
|
+
private fun getHybridViewHolder(view: View): HybridViewHolder? {
|
|
94
|
+
return view.getTag(associated_hybrid_view_tag) as? HybridViewHolder
|
|
79
95
|
}
|
|
80
96
|
}
|
|
@@ -14,10 +14,10 @@ internal class HybridChartWebviewStateUpdater {
|
|
|
14
14
|
companion object {
|
|
15
15
|
/**
|
|
16
16
|
* Updates the props for [view] through C++.
|
|
17
|
-
* The [
|
|
17
|
+
* The [newState] prop is expected to contain [view]'s props as wrapped Fabric state.
|
|
18
18
|
*/
|
|
19
19
|
@Suppress("KotlinJniMissingFunction")
|
|
20
20
|
@JvmStatic
|
|
21
|
-
external fun updateViewProps(view: HybridChartWebviewSpec,
|
|
21
|
+
external fun updateViewProps(view: HybridChartWebviewSpec, newState: StateWrapper, oldState: StateWrapper?)
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -37,6 +37,7 @@ using namespace margelo::nitro::chartwebview::views;
|
|
|
37
37
|
|
|
38
38
|
@implementation HybridChartWebviewComponent {
|
|
39
39
|
std::shared_ptr<HybridChartWebviewSpecSwift> _hybridView;
|
|
40
|
+
BOOL _didDropView;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
+ (void) load {
|
|
@@ -50,6 +51,7 @@ using namespace margelo::nitro::chartwebview::views;
|
|
|
50
51
|
|
|
51
52
|
- (instancetype) init {
|
|
52
53
|
if (self = [super init]) {
|
|
54
|
+
_props = HybridChartWebviewShadowNode::defaultSharedProps();
|
|
53
55
|
std::shared_ptr<HybridChartWebviewSpec> hybridView = ChartWebview::ChartWebviewAutolinking::createChartWebview();
|
|
54
56
|
_hybridView = std::dynamic_pointer_cast<HybridChartWebviewSpecSwift>(hybridView);
|
|
55
57
|
[self updateView];
|
|
@@ -69,95 +71,127 @@ using namespace margelo::nitro::chartwebview::views;
|
|
|
69
71
|
[self setContentView:view];
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
- (void) notifyOnDropView {
|
|
75
|
+
// A recycled component can later be invalidated. Notify only once per mount.
|
|
76
|
+
if (_didDropView) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
ChartWebview::HybridChartWebviewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
80
|
+
swiftPart.onDropView();
|
|
81
|
+
_didDropView = YES;
|
|
82
|
+
}
|
|
83
|
+
|
|
72
84
|
- (void) updateProps:(const std::shared_ptr<const react::Props>&)props
|
|
73
85
|
oldProps:(const std::shared_ptr<const react::Props>&)oldProps {
|
|
86
|
+
// A props update marks a newly mounted or still-active component.
|
|
87
|
+
_didDropView = NO;
|
|
88
|
+
|
|
74
89
|
// 1. Downcast props
|
|
75
|
-
const auto&
|
|
76
|
-
auto
|
|
90
|
+
const auto& newViewProps = *std::static_pointer_cast<const HybridChartWebviewProps>(props);
|
|
91
|
+
const auto* oldViewProps = static_cast<const HybridChartWebviewProps*>(oldProps.get());
|
|
77
92
|
ChartWebview::HybridChartWebviewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
78
93
|
|
|
79
|
-
// 2. Update
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
swiftPart.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
94
|
+
// 2. Update only props that differ from the previous Props snapshot.
|
|
95
|
+
const bool hasTransactionPropChanges = oldViewProps == nullptr
|
|
96
|
+
? newViewProps.hasAnyProvidedProps()
|
|
97
|
+
: !newViewProps.hasSameProps(*oldViewProps);
|
|
98
|
+
if (hasTransactionPropChanges) {
|
|
99
|
+
swiftPart.beforeUpdate();
|
|
100
|
+
|
|
101
|
+
// uri: optional
|
|
102
|
+
if (oldViewProps == nullptr
|
|
103
|
+
? newViewProps.uri.isProvided()
|
|
104
|
+
: !newViewProps.uri.hasSameValue(oldViewProps->uri)) {
|
|
105
|
+
swiftPart.setUri(newViewProps.uri.get());
|
|
106
|
+
}
|
|
107
|
+
// localBundle: optional
|
|
108
|
+
if (oldViewProps == nullptr
|
|
109
|
+
? newViewProps.localBundle.isProvided()
|
|
110
|
+
: !newViewProps.localBundle.hasSameValue(oldViewProps->localBundle)) {
|
|
111
|
+
swiftPart.setLocalBundle(newViewProps.localBundle.get());
|
|
112
|
+
}
|
|
113
|
+
// entry: optional
|
|
114
|
+
if (oldViewProps == nullptr
|
|
115
|
+
? newViewProps.entry.isProvided()
|
|
116
|
+
: !newViewProps.entry.hasSameValue(oldViewProps->entry)) {
|
|
117
|
+
swiftPart.setEntry(newViewProps.entry.get());
|
|
118
|
+
}
|
|
119
|
+
// paramsJson: optional
|
|
120
|
+
if (oldViewProps == nullptr
|
|
121
|
+
? newViewProps.paramsJson.isProvided()
|
|
122
|
+
: !newViewProps.paramsJson.hasSameValue(oldViewProps->paramsJson)) {
|
|
123
|
+
swiftPart.setParamsJson(newViewProps.paramsJson.get());
|
|
124
|
+
}
|
|
125
|
+
// assetHost: optional
|
|
126
|
+
if (oldViewProps == nullptr
|
|
127
|
+
? newViewProps.assetHost.isProvided()
|
|
128
|
+
: !newViewProps.assetHost.hasSameValue(oldViewProps->assetHost)) {
|
|
129
|
+
swiftPart.setAssetHost(newViewProps.assetHost.get());
|
|
130
|
+
}
|
|
131
|
+
// bridgeScript: optional
|
|
132
|
+
if (oldViewProps == nullptr
|
|
133
|
+
? newViewProps.bridgeScript.isProvided()
|
|
134
|
+
: !newViewProps.bridgeScript.hasSameValue(oldViewProps->bridgeScript)) {
|
|
135
|
+
swiftPart.setBridgeScript(newViewProps.bridgeScript.get());
|
|
136
|
+
}
|
|
137
|
+
// reuseKey: optional
|
|
138
|
+
if (oldViewProps == nullptr
|
|
139
|
+
? newViewProps.reuseKey.isProvided()
|
|
140
|
+
: !newViewProps.reuseKey.hasSameValue(oldViewProps->reuseKey)) {
|
|
141
|
+
swiftPart.setReuseKey(newViewProps.reuseKey.get());
|
|
142
|
+
}
|
|
143
|
+
// pooled: optional
|
|
144
|
+
if (oldViewProps == nullptr
|
|
145
|
+
? newViewProps.pooled.isProvided()
|
|
146
|
+
: !newViewProps.pooled.hasSameValue(oldViewProps->pooled)) {
|
|
147
|
+
swiftPart.setPooled(newViewProps.pooled.get());
|
|
148
|
+
}
|
|
149
|
+
// active: optional
|
|
150
|
+
if (oldViewProps == nullptr
|
|
151
|
+
? newViewProps.active.isProvided()
|
|
152
|
+
: !newViewProps.active.hasSameValue(oldViewProps->active)) {
|
|
153
|
+
swiftPart.setActive(newViewProps.active.get());
|
|
154
|
+
}
|
|
155
|
+
// webviewDebuggingEnabled: optional
|
|
156
|
+
if (oldViewProps == nullptr
|
|
157
|
+
? newViewProps.webviewDebuggingEnabled.isProvided()
|
|
158
|
+
: !newViewProps.webviewDebuggingEnabled.hasSameValue(oldViewProps->webviewDebuggingEnabled)) {
|
|
159
|
+
swiftPart.setWebviewDebuggingEnabled(newViewProps.webviewDebuggingEnabled.get());
|
|
160
|
+
}
|
|
161
|
+
// onMessage: optional
|
|
162
|
+
if (oldViewProps == nullptr
|
|
163
|
+
? newViewProps.onMessage.isProvided()
|
|
164
|
+
: !newViewProps.onMessage.hasSameValue(oldViewProps->onMessage)) {
|
|
165
|
+
swiftPart.setOnMessage(newViewProps.onMessage.get());
|
|
166
|
+
}
|
|
167
|
+
// onLoadEnd: optional
|
|
168
|
+
if (oldViewProps == nullptr
|
|
169
|
+
? newViewProps.onLoadEnd.isProvided()
|
|
170
|
+
: !newViewProps.onLoadEnd.hasSameValue(oldViewProps->onLoadEnd)) {
|
|
171
|
+
swiftPart.setOnLoadEnd(newViewProps.onLoadEnd.get());
|
|
172
|
+
}
|
|
173
|
+
// onError: optional
|
|
174
|
+
if (oldViewProps == nullptr
|
|
175
|
+
? newViewProps.onError.isProvided()
|
|
176
|
+
: !newViewProps.onError.hasSameValue(oldViewProps->onError)) {
|
|
177
|
+
swiftPart.setOnError(newViewProps.onError.get());
|
|
178
|
+
}
|
|
149
179
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
maybeFunc.
|
|
180
|
+
// Update hybridRef if it changed
|
|
181
|
+
if (oldViewProps == nullptr
|
|
182
|
+
? newViewProps.hybridRef.isProvided()
|
|
183
|
+
: !newViewProps.hybridRef.hasSameValue(oldViewProps->hybridRef)) {
|
|
184
|
+
// hybridRef changed - call it with new this
|
|
185
|
+
const auto& maybeFunc = newViewProps.hybridRef.get();
|
|
186
|
+
if (maybeFunc.has_value()) {
|
|
187
|
+
maybeFunc.value()(_hybridView);
|
|
188
|
+
}
|
|
156
189
|
}
|
|
157
|
-
|
|
190
|
+
|
|
191
|
+
swiftPart.afterUpdate();
|
|
158
192
|
}
|
|
159
193
|
|
|
160
|
-
//
|
|
194
|
+
// 3. Continue in base class
|
|
161
195
|
[super updateProps:props oldProps:oldProps];
|
|
162
196
|
}
|
|
163
197
|
|
|
@@ -166,6 +200,7 @@ using namespace margelo::nitro::chartwebview::views;
|
|
|
166
200
|
}
|
|
167
201
|
|
|
168
202
|
- (void)prepareForRecycle {
|
|
203
|
+
[self notifyOnDropView];
|
|
169
204
|
[super prepareForRecycle];
|
|
170
205
|
ChartWebview::HybridChartWebviewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
171
206
|
swiftPart.maybePrepareForRecycle();
|
|
@@ -173,8 +208,7 @@ using namespace margelo::nitro::chartwebview::views;
|
|
|
173
208
|
|
|
174
209
|
#ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
|
|
175
210
|
- (void)invalidate {
|
|
176
|
-
|
|
177
|
-
swiftPart.onDropView();
|
|
211
|
+
[self notifyOnDropView];
|
|
178
212
|
[super invalidate];
|
|
179
213
|
}
|
|
180
214
|
#endif
|