diff --git a/entry/src/main/cpp/classdef/src/ArkUIButtonNode.cpp b/entry/src/main/cpp/classdef/src/ArkUIButtonNode.cpp index 2190ae1434b45ac3dfeac768a62baf9cd8c8f0fb..758f4bfdc1608985acf72f80e0a09ea2d50e945d 100644 --- a/entry/src/main/cpp/classdef/src/ArkUIButtonNode.cpp +++ b/entry/src/main/cpp/classdef/src/ArkUIButtonNode.cpp @@ -48,7 +48,7 @@ void ArkUIButtonNode::SetTextAlign(ArkUI_TextAlignment align) ArkUI_AttributeItem item = {value, 1}; nativeModule_->setAttribute(handle_, NODE_TEXT_ALIGN, &item); } - +// [Start button_api] void ArkUIButtonNode::SetButtonType(int32_t buttonType) { assert(handle_); @@ -56,4 +56,5 @@ void ArkUIButtonNode::SetButtonType(int32_t buttonType) ArkUI_AttributeItem item = {value, 1}; nativeModule_->setAttribute(handle_, NODE_BUTTON_TYPE , &item); } +// [End button_api] } // namespace NativeModule \ No newline at end of file diff --git a/entry/src/main/cpp/function/src/IntegratingWithArkts.cpp b/entry/src/main/cpp/function/src/IntegratingWithArkts.cpp index e4d5cec7e3955c536137393bb9af256a77bd15f7..7741232233acaeecf89d2b0a08a4223eea9ec423 100644 --- a/entry/src/main/cpp/function/src/IntegratingWithArkts.cpp +++ b/entry/src/main/cpp/function/src/IntegratingWithArkts.cpp @@ -43,23 +43,28 @@ napi_value CreateButtonNativeRoot(napi_env env, napi_callback_info info) return nullptr; } - +// [Start button_api] std::shared_ptr CreateButtonExample() { auto textNode = std::make_shared(); textNode->SetTextContent(std::string("Hello World")); + // [StartExclude button_api] textNode->SetFontSize(TEXT_FONTSIZE); textNode->SetPercentWidth(1); textNode->SetHeight(50); textNode->SetTextAlign(ARKUI_TEXT_ALIGNMENT_CENTER); + // [EndExclude button_api] + // Regarding the proprietary interfaces of HarmonyOS, specifically the interfaces marked as since M.F.S(N). + // Compatibility judgment, the value corresponding to version 5.1.1(19) is 50101, + // which is derived from the new interface's since field 5*10000 + 1*100 + 1. if (OH_GetSdkApiVersion() >= 19) { textNode->SetButtonType(ARKUI_BUTTON_ROUNDED_RECTANGLE); } else { textNode->SetButtonType(ARKUI_BUTTON_TYPE_CAPSULE); } - return textNode; } +// [End button_api] napi_value DestroyButtonNativeRoot(napi_env env, napi_callback_info info) { diff --git a/entry/src/main/ets/components/ActionBarAdapter.ets b/entry/src/main/ets/components/ActionBarAdapter.ets index 3c468c8ba1511e2e807f9116ac93b2b2c76dd416..35a310373fefadd8d2d6cd804aaa51bdc38530c8 100644 --- a/entry/src/main/ets/components/ActionBarAdapter.ets +++ b/entry/src/main/ets/components/ActionBarAdapter.ets @@ -20,10 +20,12 @@ import { deviceInfo } from '@kit.BasicServicesKit'; export struct ActionBarAdapter { @State isExpand: boolean = true; @State isPrimaryIconChanged: boolean = false; - + // [Start action_bar_api] build() { Column() { - // Compatibility judgment, 60000 is derived from the since field of the new interface M*10000 F*100 S. + // Regarding the proprietary interfaces of HarmonyOS, specifically the interfaces marked as since M.F.S(N). + // Compatibility judgment, the value corresponding to version 6.0.0(20) is 60000, + // which is derived from the new interface's since field 6*10000 + 0*100 + 0. if (deviceInfo.distributionOSApiVersion >= 60000) { // Component that calls the API of version 6.0.0(20) HdsActionBar({ @@ -33,6 +35,7 @@ export struct ActionBarAdapter { endButtons: [new ActionBarButton({ baseIcon: $r('sys.symbol.mic_fill') })], + // [StartExclude action_bar_api] primaryButton: new ActionBarButton({ baseIcon: $r('sys.symbol.plus'), altIcon: $r('sys.symbol.play_fill'), @@ -45,10 +48,12 @@ export struct ActionBarAdapter { isPrimaryIconChanged: this.isPrimaryIconChanged }), isExpand: this.isExpand!! + // [EndExclude action_bar_api] }) } else { // Downgrading plan Row({ space: 25 }) { + // [StartExclude action_bar_api] if (this.isExpand) { Button({ type: ButtonType.Circle }) { SymbolGlyph($r('sys.symbol.stopwatch_fill')) @@ -69,7 +74,6 @@ export struct ActionBarAdapter { .aspectRatio(1) .height(55) .backgroundColor($r('sys.color.brand')) - .onClick(() => { this.isExpand = !this.isExpand; }) @@ -85,13 +89,19 @@ export struct ActionBarAdapter { .backgroundColor($r('sys.color.background_secondary')) .margin({ right: 10 }) } + // [EndExclude action_bar_api] } + // [StartExclude action_bar_api] .backgroundColor($r('sys.color.background_primary')) .borderRadius(30) + // [EndExclude action_bar_api] } } + // [StartExclude action_bar_api] .width('100%') .justifyContent(FlexAlign.Center) .alignItems(HorizontalAlign.Center) + // [EndExclude action_bar_api] } + // [End action_bar_api] } \ No newline at end of file diff --git a/entry/src/main/ets/components/ScrollComponentAdapter.ets b/entry/src/main/ets/components/ScrollComponentAdapter.ets index 1df808e58c06d5bf53d3642a4c6bdb211d03a55a..a33bad4a85e62612a730e25caf1a0a85511639cb 100644 --- a/entry/src/main/ets/components/ScrollComponentAdapter.ets +++ b/entry/src/main/ets/components/ScrollComponentAdapter.ets @@ -35,11 +35,12 @@ export struct ScrollComponentAdapter { build() { Scroll() { - // 'app.media.image1' is just an example, please replace the actual image. + // 'app.media.startIcon' is just an example, please replace the actual image. Image($r('app.media.startIcon')) + .width('80%') } .scrollable(ScrollDirection.FREE) - .width('100%') + .width('80%') .attributeModifier(this.adaptModifier) } }