diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/pasteButton.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/pasteButton.ts index ae336a26f7b517667af3a16040adfd91f067bda6..02fba1babb4880438605c8261cc4b67e116e6eb0 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/pasteButton.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/pasteButton.ts @@ -125,14 +125,12 @@ export class ArkPasteButtonComponent extends ArkSecurityComponentMethodComponent export function PasteButtonImpl( /** @memo */ style: ((attributes: PasteButtonAttribute) => void) | undefined, - /** @memo */ - content_?: (() => void) | undefined, ): void { const receiver = remember(() => { return new ArkPasteButtonComponent() }) NodeAttach((): ArkPasteButtonPeer => ArkPasteButtonPeer.create(receiver), (_: ArkPasteButtonPeer) => { style?.(receiver) - content_?.() + receiver.applyAttributesFinish() }) } diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/saveButton.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/saveButton.ts index a3b8dd4657d932c4a50c95afc7d30d5c15aab647..fcd8f66457a6ae14efdcaaf9c0ee7dc5854b3243 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/saveButton.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/saveButton.ts @@ -139,14 +139,12 @@ export class ArkSaveButtonComponent extends ArkSecurityComponentMethodComponent export function SaveButtonImpl( /** @memo */ style: ((attributes: SaveButtonAttribute) => void) | undefined, - /** @memo */ - content_?: (() => void) | undefined, ): void { const receiver = remember(() => { return new ArkSaveButtonComponent() }) NodeAttach((): ArkSaveButtonPeer => ArkSaveButtonPeer.create(receiver), (_: ArkSaveButtonPeer) => { style?.(receiver) - content_?.() + receiver.applyAttributesFinish() }) } diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/securityComponent.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/securityComponent.ts index a63c0cac097bf48cc9e28888570d7df300e2c6f9..7599c12c33817fa0605886b67fc000ae264292d2 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/securityComponent.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/securityComponent.ts @@ -141,7 +141,7 @@ export class ArkSecurityComponentMethodPeer extends PeerNode { ArkUIGeneratedNativeModule._SecurityComponentMethod_fontStyle(this.peer.ptr, thisSerializer.asBuffer(), thisSerializer.length()) thisSerializer.release() } - fontWeightAttribute(value: number | FontWeight | string | undefined): void { + fontWeightAttribute(value: int32 | FontWeight | string | Resource | undefined): void { const thisSerializer : Serializer = Serializer.hold() let value_type : int32 = RuntimeType.UNDEFINED value_type = runtimeType(value) @@ -150,16 +150,16 @@ export class ArkSecurityComponentMethodPeer extends PeerNode { const value_value = value! let value_value_type : int32 = RuntimeType.UNDEFINED value_value_type = runtimeType(value_value) - if (RuntimeType.NUMBER == value_value_type) { - thisSerializer.writeInt8(0 as int32) - const value_value_0 = value_value as number - thisSerializer.writeNumber(value_value_0) - } - else if (TypeChecker.isFontWeight(value_value)) { + if (TypeChecker.isFontWeight(value_value)) { thisSerializer.writeInt8(1 as int32) const value_value_1 = value_value as FontWeight thisSerializer.writeInt32(TypeChecker.FontWeight_ToNumeric(value_value_1)) } + else if (RuntimeType.NUMBER == value_value_type) { + thisSerializer.writeInt8(0 as int32) + const value_value_0 = value_value as int32 + thisSerializer.writeNumber(value_value_0) + } else if (RuntimeType.STRING == value_value_type) { thisSerializer.writeInt8(2 as int32) const value_value_2 = value_value as string @@ -727,7 +727,7 @@ export interface SecurityComponentMethod { offset(value: Position | Edges | LocalizedEdges | undefined): this fontSize(value: Dimension | undefined): this fontStyle(value: FontStyle | undefined): this - fontWeight(value: number | FontWeight | string | undefined): this + fontWeight(value: int32 | FontWeight | string | Resource | undefined): this fontFamily(value: string | Resource | undefined): this fontColor(value: ResourceColor | undefined): this iconColor(value: ResourceColor | undefined): this @@ -735,7 +735,7 @@ export interface SecurityComponentMethod { borderStyle(value: BorderStyle | undefined): this borderWidth(value: Dimension | undefined): this borderColor(value: ResourceColor | undefined): this - borderRadius(value: Dimension | undefined | Dimension | BorderRadiuses | undefined): this + borderRadius(value: Dimension | BorderRadiuses | undefined): this padding(value: Padding | Dimension | undefined): this textIconSpace(value: Dimension | undefined): this key(value: string | undefined): this @@ -763,7 +763,7 @@ export class ArkSecurityComponentMethodStyle implements SecurityComponentMethod offset_value?: Position | Edges | LocalizedEdges | undefined fontSize_value?: Dimension | undefined fontStyle_value?: FontStyle | undefined - fontWeight_value?: number | FontWeight | string | undefined + fontWeight_value?: int32 | FontWeight | string | Resource | undefined fontFamily_value?: string | Resource | undefined fontColor_value?: ResourceColor | undefined iconColor_value?: ResourceColor | undefined @@ -810,7 +810,7 @@ export class ArkSecurityComponentMethodStyle implements SecurityComponentMethod public fontStyle(value: FontStyle | undefined): this { return this } - public fontWeight(value: number | FontWeight | string | undefined): this { + public fontWeight(value: int32 | FontWeight | string | Resource | undefined): this { return this } public fontFamily(value: string | Resource | undefined): this { @@ -834,7 +834,7 @@ export class ArkSecurityComponentMethodStyle implements SecurityComponentMethod public borderColor(value: ResourceColor | undefined): this { return this } - public borderRadius(value: Dimension | undefined | Dimension | BorderRadiuses | undefined): this { + public borderRadius(value: Dimension | BorderRadiuses | undefined): this { return this } public padding(value: Padding | Dimension | undefined): this { @@ -952,9 +952,9 @@ export class ArkSecurityComponentMethodComponent extends ComponentBase implement } return this } - public fontWeight(value: number | FontWeight | string | undefined): this { + public fontWeight(value: int32 | FontWeight | string | Resource | undefined): this { if (this.checkPriority("fontWeight")) { - const value_casted = value as (number | FontWeight | string | undefined) + const value_casted = value as (int32 | FontWeight | string | Resource | undefined) this.getPeer()?.fontWeightAttribute(value_casted) return this } @@ -1016,14 +1016,9 @@ export class ArkSecurityComponentMethodComponent extends ComponentBase implement } return this } - public borderRadius(value: Dimension | undefined | Dimension | BorderRadiuses | undefined): this { + public borderRadius(value: Dimension | BorderRadiuses | undefined): this { if (this.checkPriority("borderRadius")) { const value_type = runtimeType(value) - if ((RuntimeType.NUMBER == value_type) || (RuntimeType.STRING == value_type) || (RuntimeType.OBJECT == value_type) || (RuntimeType.UNDEFINED == value_type)) { - const value_casted = value as (Dimension | undefined) - this.getPeer()?.borderRadius0Attribute(value_casted) - return this - } if ((RuntimeType.NUMBER == value_type) || (RuntimeType.STRING == value_type) || (RuntimeType.OBJECT == value_type) || (RuntimeType.OBJECT == value_type) || (RuntimeType.UNDEFINED == value_type)) { const value_casted = value as (Dimension | BorderRadiuses | undefined) this.getPeer()?.borderRadius1Attribute(value_casted) diff --git a/frameworks/core/interfaces/native/implementation/paste_button_modifier.cpp b/frameworks/core/interfaces/native/implementation/paste_button_modifier.cpp index 6f7ad648839e1c87f39fd5d8de7f2f2fe86ffeea..a96e0639e75749467c41145bbf5f501537331c9b 100644 --- a/frameworks/core/interfaces/native/implementation/paste_button_modifier.cpp +++ b/frameworks/core/interfaces/native/implementation/paste_button_modifier.cpp @@ -20,7 +20,6 @@ #include "core/interfaces/native/utility/converter.h" #include "core/interfaces/native/utility/reverse_converter.h" #include "core/interfaces/native/utility/callback_helper.h" -#include "core/interfaces/native/generated/interface/ui_node_api.h" #include "arkoala_api_generated.h" namespace OHOS::Ace::NG::Converter { @@ -84,11 +83,7 @@ void OnClickImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - auto optValue = Converter::GetOptPtr(value); - if (!optValue) { - // TODO: Reset value - return; - } + CHECK_NULL_VOID(value); auto onEvent = [arkCallback = CallbackHelper(value->value), frameNode](GestureEvent& info) { auto res = SecurityComponentHandleResult::CLICK_GRANT_FAILED; std::string message; @@ -107,15 +102,14 @@ void OnClickImpl(Ark_NativePointer node, #endif const auto event = Converter::ArkClickEventSync(info); auto arkResult = Converter::ArkValue(res); - auto error = Opt_BusinessError{ + arkCallback.InvokeSync(event.ArkValue(), arkResult, Opt_BusinessError{ .value = Ark_BusinessError{ - .name = Converter::ArkValue("", Converter::FC), + .name = Converter::ArkValue("123", Converter::FC), .message = Converter::ArkValue(message, Converter::FC), - .stack = Converter::ArkValue("", Converter::FC), + .stack = Converter::ArkValue("asdf", Converter::FC), .code = Converter::ArkValue(code) } - }; - arkCallback.InvokeSync(event.ArkValue(), arkResult, error); + }); }; ViewAbstract::SetOnClick(frameNode, std::move(onEvent)); } diff --git a/frameworks/core/interfaces/native/implementation/save_button_modifier.cpp b/frameworks/core/interfaces/native/implementation/save_button_modifier.cpp index e76e4148dc6e4f807ed9630c1b12caf76b8bdfa2..2e2f212f774bc10e1b2b06ad4916495f52110c47 100644 --- a/frameworks/core/interfaces/native/implementation/save_button_modifier.cpp +++ b/frameworks/core/interfaces/native/implementation/save_button_modifier.cpp @@ -20,7 +20,6 @@ #include "core/interfaces/native/utility/callback_helper.h" #include "core/interfaces/native/utility/converter.h" #include "core/interfaces/native/utility/reverse_converter.h" -#include "core/interfaces/native/generated/interface/ui_node_api.h" #include "arkoala_api_generated.h" namespace OHOS::Ace::NG::Converter { @@ -98,11 +97,7 @@ void OnClickImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - auto optValue = Converter::GetOptPtr(value); - if (!optValue) { - // TODO: Reset value - return; - } + CHECK_NULL_VOID(value); auto onEvent = [arkCallback = CallbackHelper(value->value)](GestureEvent& info) { auto res = SecurityComponentHandleResult::CLICK_GRANT_FAILED; std::string message; @@ -121,15 +116,12 @@ void OnClickImpl(Ark_NativePointer node, #endif const auto event = Converter::ArkClickEventSync(info); Ark_SaveButtonOnClickResult arkResult = Converter::ArkValue(res); - auto error = Opt_BusinessError{ + arkCallback.InvokeSync(event.ArkValue(), arkResult, Opt_BusinessError{ .value = Ark_BusinessError{ - .name = Converter::ArkValue("", Converter::FC), .message = Converter::ArkValue(message, Converter::FC), - .stack = Converter::ArkValue("", Converter::FC), .code = Converter::ArkValue(code) } - }; - arkCallback.InvokeSync(event.ArkValue(), arkResult, error); + }); }; ViewAbstract::SetOnClick(frameNode, std::move(onEvent)); diff --git a/frameworks/core/interfaces/native/implementation/security_component_method_modifier.cpp b/frameworks/core/interfaces/native/implementation/security_component_method_modifier.cpp index 357368470e4717b48fdd68d3ad2590924cf5f4cd..455883ad65a493408e96d430bd4501749821a5d3 100644 --- a/frameworks/core/interfaces/native/implementation/security_component_method_modifier.cpp +++ b/frameworks/core/interfaces/native/implementation/security_component_method_modifier.cpp @@ -17,7 +17,6 @@ #include "core/components_ng/pattern/security_component/security_component_model_ng.h" #include "core/interfaces/native/utility/converter.h" #include "core/interfaces/native/utility/validators.h" -#include "core/interfaces/native/generated/interface/ui_node_api.h" #include "arkoala_api_generated.h" namespace OHOS::Ace::NG::Converter { @@ -84,6 +83,10 @@ void ConstraintSizeImpl(Ark_NativePointer node, const Opt_ConstraintSizeOptions* value); void OffsetImpl(Ark_NativePointer node, const Opt_Union_Position_Edges_LocalizedEdges* value); +void MarkAnchorImpl(Ark_NativePointer node, + const Opt_Position* value); +void PositionImpl(Ark_NativePointer node, + const Opt_Position* value); void IdImpl(Ark_NativePointer node, const Opt_String* value); void AlignRules0Impl(Ark_NativePointer node, @@ -107,6 +110,7 @@ void IconSizeImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto valueOpt = Converter::OptConvert(*value); Validator::ValidateNonNegative(valueOpt); SecurityComponentModelNG::SetIconSize(frameNode, valueOpt); @@ -116,27 +120,31 @@ void LayoutDirectionImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - auto layoutDirection = Converter::OptConvert(*value); + CHECK_NULL_VOID(value); + auto layoutDirection = Converter::OptConvert(value->value); SecurityComponentModelNG::SetTextIconLayoutDirection(frameNode, layoutDirection); } void PositionImpl(Ark_NativePointer node, const Opt_Position* value) { - auto frameNode = reinterpret_cast(node); + auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - auto convValue = Converter::OptConvert>(*value); - if (!convValue) { - // TODO: Reset value - return; - } - // ViewAbstract::SetPosition(frameNode, *convValue); + CHECK_NULL_VOID(value); + auto optValue = Converter::GetOptPtr(value); + auto x = Converter::ConvertOrDefault(optValue->x, Dimension()); + auto y = Converter::ConvertOrDefault(optValue->y, Dimension()); + ViewAbstract::SetPosition(frameNode, { x, y }); } void MarkAnchorImpl(Ark_NativePointer node, const Opt_Position* value) { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - // ViewAbstract::MarkAnchor(frameNode, Converter::OptConvert>(*value)); + CHECK_NULL_VOID(value); + auto optValue = Converter::GetOptPtr(value); + auto x = Converter::ConvertOrDefault(optValue->x, Dimension()); + auto y = Converter::ConvertOrDefault(optValue->y, Dimension()); + ViewAbstract::MarkAnchor(frameNode, { x, y }); } void OffsetImpl(Ark_NativePointer node, const Opt_Union_Position_Edges_LocalizedEdges* value) @@ -148,6 +156,7 @@ void FontSizeImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto fontSize = Converter::OptConvert(*value); Validator::ValidatePositive(fontSize); Validator::ValidateNonPercent(fontSize); @@ -158,6 +167,7 @@ void FontStyleImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); SecurityComponentModelNG::SetFontStyle(frameNode, Converter::OptConvert(*value)); } void FontWeightImpl(Ark_NativePointer node, @@ -165,6 +175,7 @@ void FontWeightImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); SecurityComponentModelNG::SetFontWeight(frameNode, Converter::OptConvert(*value)); } void FontFamilyImpl(Ark_NativePointer node, @@ -172,6 +183,7 @@ void FontFamilyImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); std::optional families; if (auto fontfamiliesOpt = Converter::OptConvert(*value); fontfamiliesOpt) { families = fontfamiliesOpt->families; @@ -184,6 +196,7 @@ void FontColorImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto fontColor = Converter::OptConvert(*value); SecurityComponentModelNG::SetFontColor(frameNode, fontColor); } @@ -192,6 +205,7 @@ void IconColorImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto iconColor = Converter::OptConvert(*value); SecurityComponentModelNG::SetIconColor(frameNode, iconColor); } @@ -200,14 +214,16 @@ void BackgroundColorImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - auto сolor = Converter::OptConvert(*value); - SecurityComponentModelNG::SetBackgroundColor(frameNode, сolor); + CHECK_NULL_VOID(value); + auto color = Converter::OptConvert(*value); + SecurityComponentModelNG::SetBackgroundColor(frameNode, color); } void BorderStyleImpl(Ark_NativePointer node, const Opt_BorderStyle* value) { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto optValue = Converter::OptConvert(*value); SecurityComponentModelNG::SetBackgroundBorderStyle(frameNode, optValue); } @@ -216,6 +232,7 @@ void BorderWidthImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto convValue = Converter::OptConvert(*value); Validator::ValidateNonNegative(convValue); SecurityComponentModelNG::SetBackgroundBorderWidth(frameNode, convValue); @@ -225,6 +242,7 @@ void BorderColorImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto color = Converter::OptConvert(*value); SecurityComponentModelNG::SetBackgroundBorderColor(frameNode, color); } @@ -233,6 +251,7 @@ void BorderRadius0Impl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto convValue = Converter::OptConvert(*value); Validator::ValidateNonNegative(convValue); SecurityComponentModelNG::SetBackgroundBorderRadius(frameNode, convValue); @@ -242,6 +261,7 @@ void BorderRadius1Impl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto convValue = Converter::OptConvert(*value); SecurityComponentModelNG::SetBackgroundBorderRadius(frameNode, convValue); } @@ -250,6 +270,7 @@ void PaddingImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto padding = Converter::OptConvert>(*value); if (padding) { SecurityComponentModelNG::SetBackgroundPadding(frameNode, padding->left, padding->right, padding->top, @@ -264,6 +285,7 @@ void TextIconSpaceImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto valueOpt = Converter::OptConvert(*value); Validator::ValidateNonNegative(valueOpt); SecurityComponentModelNG::SetTextIconSpace(frameNode, valueOpt); @@ -273,12 +295,9 @@ void KeyImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - auto convValue = Converter::OptConvert(*value); - if (!convValue) { - // TODO: Reset value - return; - } - // ViewAbstract::SetInspectorId(frameNode, *convValue); + CHECK_NULL_VOID(value); + auto convValue = Converter::Convert(value->value); + ViewAbstract::SetInspectorId(frameNode, convValue); } void WidthImpl(Ark_NativePointer node, const Opt_Length* value) @@ -305,6 +324,7 @@ void AlignImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto convValue = Converter::OptConvert(*value); SecurityComponentModelNG::SetAlign(frameNode, convValue); } @@ -328,6 +348,7 @@ void MinFontScaleImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto minFontScale = Converter::OptConvert(*value); Validator::ValidatePositive(minFontScale); const auto maxValue = 1.f; @@ -339,6 +360,7 @@ void MaxFontScaleImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto maxFontScale = Converter::OptConvert(*value); const auto minValue = 1.f; Validator::ValidateGreatOrEqual(maxFontScale, minValue); @@ -349,6 +371,7 @@ void MaxLinesImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto maxLines = Converter::OptConvert(*value); Validator::ValidateNonNegative(maxLines); SecurityComponentModelNG::SetMaxLines(frameNode, maxLines); @@ -358,6 +381,7 @@ void MinFontSizeImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto fontSize = Converter::OptConvert(*value); Validator::ValidateNonNegative(fontSize); Validator::ValidateNonPercent(fontSize); @@ -368,6 +392,7 @@ void MaxFontSizeImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto fontSize = Converter::OptConvert(*value); Validator::ValidateNonNegative(fontSize); Validator::ValidateNonPercent(fontSize); @@ -378,6 +403,7 @@ void HeightAdaptivePolicyImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + CHECK_NULL_VOID(value); auto convValue = Converter::OptConvert(*value); SecurityComponentModelNG::SetHeightAdaptivePolicy(frameNode, convValue); }