|
8 | 8 | #include "RNOH/arkui/NativeNodeApi.h"
|
9 | 9 | #include "react/renderer/imagemanager/primitives.h"
|
10 | 10 | #include "SmartRefreshState.h"
|
| 11 | +#include "SmartUtils.h" |
11 | 12 |
|
12 | 13 | namespace rnoh {
|
13 | 14 |
|
@@ -57,18 +58,26 @@ namespace rnoh {
|
57 | 58 |
|
58 | 59 | void RNCDefaultHeaderComponentInstance::onPropsChanged(SharedConcreteProps const &props) {
|
59 | 60 | if (props != nullptr) {
|
60 |
| - facebook::react::SharedColor headerColor = props->primaryColor; |
61 |
| - if (props->accentColor) { |
62 |
| - textNode.setFontColor(props->accentColor); |
63 |
| - imageNode.setTintColor(props->accentColor); |
| 61 | + primaryColor = props->primaryColor; |
| 62 | + if (props->accentColor != "") { |
| 63 | + textNode.setFontColor(SmartUtils::parseColor(props->accentColor)); |
| 64 | + imageNode.setTintColor(SmartUtils::parseColor(props->accentColor)); |
| 65 | + progressNode.setLoadingProgressNodeColor(SmartUtils::parseColor(props->accentColor)); |
64 | 66 | }
|
65 | 67 | }
|
66 | 68 | }
|
67 |
| - |
| 69 | + facebook::react::SharedColor RNCDefaultHeaderComponentInstance::GetPrimaryColor() { |
| 70 | + return SmartUtils::parseColor(primaryColor); |
| 71 | + } |
68 | 72 | void RNCDefaultHeaderComponentInstance::finalizeUpdates() {
|
69 |
| - ArkUI_NumberValue heightNumberValue[] = {60}; |
70 |
| - ArkUI_AttributeItem heightItem = {heightNumberValue, 1}; |
71 |
| - NativeNodeApi::getInstance()->setAttribute(m_stackNode.getArkUINodeHandle(), NODE_HEIGHT, &heightItem); |
| 73 | + auto rnInstancePtr = this->m_deps->rnInstance.lock(); |
| 74 | + if (rnInstancePtr != nullptr) { |
| 75 | + auto turboModule = rnInstancePtr->getTurboModule("RNCSmartRefreshContext"); |
| 76 | + auto arkTsTurboModule = std::dynamic_pointer_cast<rnoh::ArkTSTurboModule>(turboModule); |
| 77 | + folly::dynamic result = arkTsTurboModule->callSync("cvp2px", {getLayoutMetrics().frame.size.width}); |
| 78 | + folly::dynamic result1 = arkTsTurboModule->callSync("cvp2px", {60}); |
| 79 | + m_stackNode.setLayoutRect({0, 0}, {result["values"].asDouble(), result1["values"].asDouble()}, 1.0); |
| 80 | + } |
72 | 81 | m_stackNode.setAlignment(ARKUI_ALIGNMENT_BOTTOM);
|
73 | 82 | }
|
74 | 83 |
|
|
0 commit comments