From cddc307b682c37f9615d67fb155c09efb79fcc68 Mon Sep 17 00:00:00 2001 From: xushunjie Date: Thu, 16 Oct 2025 15:35:45 +0800 Subject: [PATCH] Add a return button to test cases Signed-off-by: xushunjie --- .../entry/src/main/ets/pages/page_form.ets | 162 ++++++++++-------- .../main/resources/base/element/string.json | 4 + 2 files changed, 90 insertions(+), 76 deletions(-) diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/page_form.ets b/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/page_form.ets index 3518cf1f..5f60e4c3 100644 --- a/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/page_form.ets +++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/page_form.ets @@ -310,91 +310,101 @@ struct Index { build() { Column() { - Text($r('app.string.native_node_example')) - .fontSize(24) - .margin(10) - .fontWeight(FontWeight.Bold) - .height('10%') Row() { - Button($r('app.string.select_node_type')) - .width('30%') - .margin(10) - .bindMenu(this.SubMenuNodeType) - Button($r('app.string.create')) - .width('25%') - .margin(10) + Button($r('app.string.return_node')) + .height(25) + .width('10%') .onClick(() => { - Napi.removeFormNode(this.nodeId); - this.nodeId = -1; - - this.nodeId = Napi.createFormNode(getNodeType(this.curNodeType), this.nativeCallback); - this.nodeStatus = (this.nodeId == -1) ? FAIL_TAG : SUCC_TAG; + this.getUIContext().getRouter().pushUrl({ + url: 'pages/Index', + }) }) - Button($r('app.string.remove')) - .width('25%') + Text($r('app.string.native_node_example')) + .fontSize(24) .margin(10) - .onClick(() => { - Napi.removeFormNode(this.nodeId); - this.nodeId = -1; - this.nodeStatus = FAIL_TAG; - }) + .fontWeight(FontWeight.Bold) + .height('10%') } + Row() { + Button($r('app.string.select_node_type')) + .width('30%') + .margin(10) + .bindMenu(this.SubMenuNodeType) + Button($r('app.string.create')) + .width('25%') + .margin(10) + .onClick(() => { + Napi.removeFormNode(this.nodeId); + this.nodeId = -1; - Row() { - Text($r('app.string.current_type', `${this.curNodeType}`)) - .style(TextAlign.Start) - .fontSize(10) - .margin(5) - .width('48%') - Text($r('app.string.current_status', `${this.nodeStatus}`)) - .style(TextAlign.Start) - .fontSize(11) - .margin(5) - .width('48%') - } + this.nodeId = Napi.createFormNode(getNodeType(this.curNodeType), this.nativeCallback); + this.nodeStatus = (this.nodeId == -1) ? FAIL_TAG : SUCC_TAG; + }) + Button($r('app.string.remove')) + .width('25%') + .margin(10) + .onClick(() => { + Napi.removeFormNode(this.nodeId); + this.nodeId = -1; + this.nodeStatus = FAIL_TAG; + }) + } - Row() { - Button($r('app.string.select_node_attribute')) - .bindMenu(this.SubMenuAttributeType) - .fontSize(10) - .onClick(() => { - this.status = Visibility.Visible - }) - Button($r('app.string.set_attribute_value')) - .alignSelf(ItemAlign.End) - .fontSize(10) - .onClick( - () => { + Row() { + Text($r('app.string.current_type', `${this.curNodeType}`)) + .style(TextAlign.Start) + .fontSize(10) + .margin(5) + .width('48%') + Text($r('app.string.current_status', `${this.nodeStatus}`)) + .style(TextAlign.Start) + .fontSize(11) + .margin(5) + .width('48%') + } + + Row() { + Button($r('app.string.select_node_attribute')) + .bindMenu(this.SubMenuAttributeType) + .fontSize(10) + .onClick(() => { + this.status = Visibility.Visible + }) + Button($r('app.string.set_attribute_value')) + .alignSelf(ItemAlign.End) + .fontSize(10) + .onClick( + () => { + this.curAttrStatus = -1; + this.curAttrStatus = Napi.setFormAttribute(this.nodeId, getNodeType(this.curNodeType), + this.attributeTypeId, this.attributeValue); + } + ) + Button($r('app.string.get_attribute_value')) + .alignSelf(ItemAlign.End) + .fontSize(10) + .onClick( + () => { + this.resultValue = Napi.getFormAttribute(this.nodeId, getNodeType(this.curNodeType), + this.attributeTypeId); + } + ) + Button($r('app.string.reset_attribute_value')) + .fontSize(11) + .alignSelf(ItemAlign.End) + .onClick(() => { this.curAttrStatus = -1; - this.curAttrStatus = Napi.setFormAttribute(this.nodeId, getNodeType(this.curNodeType), - this.attributeTypeId, this.attributeValue); - } - ) - Button($r('app.string.get_attribute_value')) - .alignSelf(ItemAlign.End) - .fontSize(10) - .onClick( - () => { - this.resultValue = Napi.getFormAttribute(this.nodeId, getNodeType(this.curNodeType), + this.curAttrStatus = Napi.resetFormAttribute(this.nodeId, getNodeType(this.curNodeType), this.attributeTypeId); - } - ) - Button($r('app.string.reset_attribute_value')) - .fontSize(11) - .alignSelf(ItemAlign.End) - .onClick(() => { - this.curAttrStatus = -1; - this.curAttrStatus = Napi.resetFormAttribute(this.nodeId, getNodeType(this.curNodeType), - this.attributeTypeId); - }) - } - Row() { - Text($r('app.string.current_attribute_type', `${this.attributeType}`)) - .style(TextAlign.Start) - .fontSize(11) - .margin(5) - .width('95%') - } + }) + } + Row() { + Text($r('app.string.current_attribute_type', `${this.attributeType}`)) + .style(TextAlign.Start) + .fontSize(11) + .margin(5) + .width('95%') + } Row() { Text($r('app.string.response', `${this.resultValue}`)) .style(TextAlign.Start) diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/element/string.json b/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/element/string.json index 2afe0077..6f94bec7 100644 --- a/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/element/string.json +++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/element/string.json @@ -83,6 +83,10 @@ { "name": "reset_attribute_value", "value": "重置属性值" + }, + { + "name": "return_node", + "value": "<-" } ] } \ No newline at end of file -- Gitee