From df992ce15f6656b1ee73134beb9732399d58fbcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A6=83=E8=B4=9E=E5=BA=86?= Date: Thu, 7 Aug 2025 20:25:50 +0800 Subject: [PATCH 1/5] =?UTF-8?q?[ui=E5=AF=B9=E6=AF=94]=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?UiComponentFrameNodeText29=E6=9D=A1=E7=94=A8=E4=BE=8B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 覃贞庆 --- ...tButtonSliderSelectedBorderRadius.test.ets | 345 +++++++++ .../UiComponentFrameNodeText.test.ets | 698 ++++++++++++++++++ 2 files changed, 1043 insertions(+) create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius.test.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiComponentFrameNodeText/UiComponentFrameNodeText.test.ets diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius.test.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius.test.ets new file mode 100644 index 00000000..fb6a37cd --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius.test.ets @@ -0,0 +1,345 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, Level } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Driver, ON,Component ,MouseButton } from '@ohos.UiTest' +/* + * SUB_ACE_UI_ATTRIBUTES_FONT_INTERFACE_0010:设置文本颜色 + * + * Settings.createWindow(config.url): + * 创建窗口,更改窗口基本配置,更改方式详见model/Settings createWindow方法 + * + * windowSnap.snapShot(globalThis.context): + * 窗口截屏&图片文件保存,存储在设备端 + * 存储文件固定,单挑用例执行后覆盖,用于自动化UI对比 + * 支持调试更改文件名为时间戳格式,更改model/snapShot createAndGetFile方法 注释L35,放开L32,L33 + * + * Logger日志使用方法: + * import Logger form './model/Logger' + * Logger.info(TAG,`config = ${config}, err = ${JSON.stringify(exception)}`) + * */ + +export default function UiComponentButtonSliderSelectedBorderRadius() { + + describe('UiComponentButtonSliderSelectedBorderRadius', () => { + afterEach(async (done: Function) => { + if (Settings.windowClass == undefined) { + return + } + + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0110 + * @tc.name Set the Style property to NONE, and set the showSteps property to the default value, and the property takes effect + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0110', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0110 start.`); + Settings.createWindow("testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius01") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0110 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0080 + * @tc.name The Style attribute is set to NONE, but the blockColor attribute does not take effect + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0080', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0080 start.`); + Settings.createWindow("testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius02") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0080 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0100 + * @tc.name Set the Style property to NONE and set selectedColor to the default value, and the property takes effect + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0100', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0100 start.`); + Settings.createWindow("testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius03") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0100 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0060 + * @tc.name If the Style property is set to NONE, the blockBorderColor property does not take effect + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0060', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0060 start.`); + Settings.createWindow("testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius04") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0060 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0180 + * @tc.name Set the Style attribute to: NONE, and set the selected part of the slide fillet attribute value: 50% + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0180', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0180 start.`); + Settings.createWindow("testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius05") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0180 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0070 + * @tc.name If the Style property is set to NONE, the blockBorderWidth property does not take effect + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0070', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0070 start.`); + Settings.createWindow("testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius06") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0070 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0090 + * @tc.name If the Style attribute is set to NONE, the blockStyle attribute does not take effect + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0090', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0090 start.`); + Settings.createWindow("testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius07") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0090 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0160 + * @tc.name If the Style attribute is set to NONE, the selectedBorderRadius attribute does not take effect + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0160', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0160 start.`); + Settings.createWindow("testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius08") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0160 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0140 + * @tc.name Set the Style attribute to NONE, and set trackColor to the default value, and the attribute takes effect + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0140', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0140 start.`); + Settings.createWindow("testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius09") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0140 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0150 + * @tc.name Set the Style property to NONE, and set the selected partial rail fillet to the default value + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0150', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0150 start.`); + Settings.createWindow("testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius10") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0150 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0250 + * @tc.name Set the Style property to undefined and the slider is on the slider + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0250', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0250 start.`); + Settings.createWindow("testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius11") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0250 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0270 + * @tc.name The Style property is not set, and the slider is on the slide + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0270', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0270 start.`); + Settings.createWindow("testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius12") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0270 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0230 + * @tc.name Set the Style property to OutSet, and the slider is on the slider + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0230', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0230 start.`); + Settings.createWindow("testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius13") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0230 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0040 + * @tc.name Set the Style property to inset, and the slider is on the slider + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0040', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0040 start.`); + Settings.createWindow("testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius14") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0040 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0120 + * @tc.name Set the Style attribute to NONE, set the showTips attribute to true, and set the content to take effect + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0120', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0120 start.`); + Settings.createWindow("testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius15") + let driver:Driver=Driver.create(); + let slider: Component = await driver.waitForComponent(ON.id('UiComponentButtonSliderSelectedBorderRadius15'),1000); + await slider.click() + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_BUTTON_SLIDER_SELECTEDBORDERRADIUS_0120 finish.`); + done() + }) + + }) +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiComponentFrameNodeText/UiComponentFrameNodeText.test.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiComponentFrameNodeText/UiComponentFrameNodeText.test.ets new file mode 100644 index 00000000..f144b220 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/test/UiComponentFrameNodeText/UiComponentFrameNodeText.test.ets @@ -0,0 +1,698 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, Level } from '@ohos/hypium' +import Settings from '../model/Settings' +import windowSnap from '../model/snapShot' +import Logger from '../model/Logger' +import Utils from '../model/Utils' +import { Driver, ON,Component ,MouseButton } from '@ohos.UiTest' +/* + * SUB_ACE_UI_ATTRIBUTES_FONT_INTERFACE_0010:设置文本颜色 + * + * Settings.createWindow(config.url): + * 创建窗口,更改窗口基本配置,更改方式详见model/Settings createWindow方法 + * + * windowSnap.snapShot(globalThis.context): + * 窗口截屏&图片文件保存,存储在设备端 + * 存储文件固定,单挑用例执行后覆盖,用于自动化UI对比 + * 支持调试更改文件名为时间戳格式,更改model/snapShot createAndGetFile方法 注释L35,放开L32,L33 + * + * Logger日志使用方法: + * import Logger form './model/Logger' + * Logger.info(TAG,`config = ${config}, err = ${JSON.stringify(exception)}`) + * */ + +export default function UiComponentFrameNodeText() { + + describe('UiComponentFrameNodeText', () => { + afterEach(async (done: Function) => { + if (Settings.windowClass == undefined) { + return + } + + Settings.windowClass.destroyWindow((err) => { + if (err.code) { + Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`) + return; + } + Logger.info('TEST', `Succeeded in destroy the window.`); + }) + await Utils.sleep(1000); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0230 + * @tc.name ComponentCotent's dispose method test + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0230', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0230 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText01") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let textarea: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText01'),1000); + await textarea.inputText('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0230 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0540 + * @tc.name TextArea component, using the onDidInsert method + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0540', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0540 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText02") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let textarea: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText02'),1000); + await textarea.inputText('a') + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0540 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0450 + * @tc.name TextArea component, using the onchange method + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0450', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0450 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText03") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let textarea: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText03'),1000); + await textarea.inputText('a') + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0450 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0460 + * @tc.name TextArea component, using the onEditChange method + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0460', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0460 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText04") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let textarea: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText04'),1000); + await textarea.inputText('a') + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0460 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0530 + * @tc.name TextArea component, using the onWillInsert method + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0530', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0530 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText05") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let textarea: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText05'),1000); + await textarea.inputText('aaaa') + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0530 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0510 + * @tc.name TextArea component, using the onContentScroll method + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0510', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0510 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText06") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let textarea: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText06'),1000); + let point = await textarea.getBoundsCenter(); + await driver.mouseDrag({x:point.x, y:point.y},{x:point.x-10, y:point.y-10},600); + await driver.waitForIdle(500,2000); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0510 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0070 + * @tc.name TextArea component to set the prompt text color + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0070', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0070 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText07") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let button: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText07_02'),1000); + for(let i = 0 ; i<4 ; ++i) + { + await button.click(); + windowSnap.snapShot() + await driver.waitForIdle(500,2000); + } + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0070 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0400 + * @tc.name TextArea component to set the line splitting rules + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0400', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0400 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText08") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let button: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText08_02'),1000); + for(let i = 0 ; i<4 ; ++i) + { + await button.click(); + windowSnap.snapShot() + await driver.waitForIdle(500,2000); + } + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0400 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0380 + * @tc.name TextArea component to set how text is displayed when it is very long + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0380', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0380 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText09") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let button: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText09_02'),1000); + for(let i = 0 ; i<4 ; ++i) + { + await button.click(); + windowSnap.snapShot() + await driver.waitForIdle(500,2000); + } + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0380 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0150 + * @tc.name TextArea component to set the polymorphic style of the text box + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0150', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0150 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText10") + let driver:Driver=Driver.create(); + let textarea: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText10_01'),1000); + let button: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText10_02'),1000); + let point = await textarea.getBoundsCenter() + await textarea.click(); + windowSnap.snapShot(); + await Utils.sleep(1000) + await button.click(); + await Utils.sleep(1000) + await driver.click(point.x,point.y) + windowSnap.snapShot() + await driver.waitForIdle(500,2000) + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0150 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0090 + * @tc.name TextArea component to set the horizontal alignment of the text + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0090', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0090 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText11") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let button: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText11_02'),1000); + for(let i = 0 ; i<4 ; ++i) + { + await button.click(); + windowSnap.snapShot() + await driver.waitForIdle(500,2000); + } + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0090 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0340 + * @tc.name TextArea component to set the text breakage rule + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0340', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0340 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText12") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let button: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText12_02'),1000); + for(let i = 0 ; i<4 ; ++i) + { + await button.click(); + windowSnap.snapShot() + await driver.waitForIdle(500,2000); + } + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0340 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0350 + * @tc.name TextArea component to set the text breakage rule + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0350', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0350 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText13") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let textarea: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText13_01'),1000); + let button: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText13_02'),1000); + let point = await textarea.getBoundsCenter() + for(let i = 0 ; i<4 ; ++i) + { + await driver.click(point.x,point.y) + await driver.waitForIdle(500,2000); + await driver.mouseDrag({x:point.x, y:point.y},{x:point.x-100, y:point.y},600); + await driver.waitForIdle(500,2000); + await button.click(); + windowSnap.snapShot() + await driver.waitForIdle(500,2000); + } + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0350 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0310 + * @tc.name TextArea component, which sets the text decoration + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0310', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0310 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText14") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let button: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText14_02'),1000); + for(let i = 0 ; i<5 ; ++i) + { + await button.click(); + windowSnap.snapShot() + await driver.waitForIdle(500,2000); + } + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0310 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0320 + * @tc.name TextArea component to set text character spacing + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0320', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0320 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText15") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let button: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText15_02'),1000); + for(let i = 0 ; i<3 ; ++i) + { + await button.click(); + windowSnap.snapShot() + await driver.waitForIdle(500,2000); + } + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0320 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0290 + * @tc.name TextArea component, which sets the input method enter key type + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0290', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0290 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText16") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let textarea: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText16_01'),1000); + let button: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText16_02'),1000); + let point = await textarea.getBoundsCenter() + for(let i = 0 ; i<6 ; ++i) + { + await driver.click(point.x,point.y) + await driver.waitForIdle(500,2000); + await button.click(); + windowSnap.snapShot() + await driver.waitForIdle(500,2000); + } + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0290 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0370 + * @tc.name Turk Componin, Whitsett Furstreen Ben Texter Indent Tashen + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0370', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0370 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText17") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let button: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText17_02'),1000); + for(let i = 0 ; i<3 ; ++i) + { + await button.click(); + windowSnap.snapShot() + await driver.waitForIdle(500,2000); + } + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0370 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0300 + * @tc.name TextArea component to set the line height + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0300', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0300 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText18") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let button: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText18_02'),1000); + for(let i = 0 ; i<3 ; ++i) + { + await button.click(); + windowSnap.snapShot() + await driver.waitForIdle(500,2000); + } + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0300 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0220 + * @tc.name TextArea component, which sets the display mode of the scroll bar when the input box is edited + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0220', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0220 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText19") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let button: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText19_02'),1000); + let textarea: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText19_01'),1000); + let point = await textarea.getBoundsCenter() + for(let i = 0 ; i<3 ; ++i) + { + await driver.click(point.x,point.y) + windowSnap.snapShot() + await Utils.sleep(2100) + windowSnap.snapShot() + await button.click(); + } + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0220 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0240 + * @tc.name TextArea component, which sets the input box type + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0240', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0240 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText20") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let button: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText20_02'),1000); + for(let i = 0 ; i<7 ; ++i) + { + await button.click(); + windowSnap.snapShot() + await driver.waitForIdle(500,2000); + } + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0240 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0390 + * @tc.name TextArea component to set the minimum display size, maximum display size, and text adaptive height + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0390', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0390 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText21") + let driver:Driver=Driver.create(); + windowSnap.snapShot() + let button: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText21_02'),1000); + for(let i = 0 ; i<3 ; ++i) + { + await button.click(); + windowSnap.snapShot() + await driver.waitForIdle(500,2000); + } + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0390 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0140 + * @tc.name TextArea component, which sets the counter to be displayed when the number of characters entered via InputCounterOptions exceeds the threshold + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0140', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0140 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText22") + let driver:Driver=Driver.create(); + let textarea: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText22_01'),1000); + windowSnap.snapShot(); + await driver.waitForIdle(500,2000); + await textarea.inputText('aa') + windowSnap.snapShot(); + await driver.waitForIdle(500,2000); + await textarea.inputText('aaaaa') + windowSnap.snapShot(); + await Utils.sleep(1000); + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0140 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0110 + * @tc.name TextArea component to set the minimum display size, maximum display size, and text adaptive height + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0110', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0110 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText23") + let driver:Driver=Driver.create(); + let textarea: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText23_01'),1000); + let button: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText23_02'),1000); + let point = await textarea.getBoundsCenter(); + await textarea.inputText('aa11') + windowSnap.snapShot() + await driver.waitForIdle(500,2000); + await button.click(); + await driver.inputText(point, 'a123'); + windowSnap.snapShot() + await driver.waitForIdle(500,2000); + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0110 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0200 + * @tc.name TextArea component, which is set to pop up the system text selection menu + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0200', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0200 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText24") + let driver:Driver=Driver.create(); + let textarea: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText24_01'),1000); + let point = await textarea.getBoundsCenter(); + await driver.mouseClick({x:point.x, y:point.y}, MouseButton.MOUSE_BUTTON_RIGHT); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0200 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0410 + * @tc.name TextArea component, which sets the custom menu extension + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0410', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0410 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText25") + let driver:Driver=Driver.create(); + let textarea: Component = await driver.waitForComponent(ON.id('UiComponentFrameNodeText25_01'),1000); + let point = await textarea.getBoundsCenter(); + await driver.mouseClick({x:point.x, y:point.y}, MouseButton.MOUSE_BUTTON_RIGHT); + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0410 finish.`); + done() + }) + + /* + * @tc.number SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0330 + * @tc.name TextArea component to set the effect of text characteristics + * @tc.desc Function test + * @tc.size MediumTest + * @tc.type Function + * @tc.level 0 + */ + it('SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0330', Level.LEVEL0, async (done: Function) => { + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0330 start.`); + Settings.createWindow("testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText26") + let driver:Driver=Driver.create(); + await driver.waitForIdle(500,2000) + windowSnap.snapShot() + await Utils.sleep(1000) + Logger.info('TEST', `SUB_ACE_UI_COMPONENT_FRAMENODE_TEXT_0330 finish.`); + done() + }) + + + + }) +} -- Gitee From df48c52b82fd322b379e2bc44aeda18b8f57a550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A6=83=E8=B4=9E=E5=BA=86?= Date: Thu, 7 Aug 2025 20:26:40 +0800 Subject: [PATCH 2/5] =?UTF-8?q?[ui=E5=AF=B9=E6=AF=94]=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?UiComponentFrameNodeText29=E6=9D=A1=E7=94=A8=E4=BE=8B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 覃贞庆 --- ...nentButtonSliderSelectedBorderRadius01.ets | 171 +++++++++++++++++ ...nentButtonSliderSelectedBorderRadius02.ets | 172 +++++++++++++++++ ...nentButtonSliderSelectedBorderRadius03.ets | 174 +++++++++++++++++ ...nentButtonSliderSelectedBorderRadius04.ets | 175 +++++++++++++++++ ...nentButtonSliderSelectedBorderRadius05.ets | 176 +++++++++++++++++ ...nentButtonSliderSelectedBorderRadius06.ets | 177 +++++++++++++++++ ...nentButtonSliderSelectedBorderRadius07.ets | 178 +++++++++++++++++ ...nentButtonSliderSelectedBorderRadius08.ets | 179 +++++++++++++++++ ...nentButtonSliderSelectedBorderRadius09.ets | 180 ++++++++++++++++++ ...nentButtonSliderSelectedBorderRadius10.ets | 180 ++++++++++++++++++ 10 files changed, 1762 insertions(+) create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius01.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius02.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius03.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius04.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius05.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius06.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius07.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius08.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius09.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius10.ets diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius01.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius01.ets new file mode 100644 index 00000000..dfea6fc2 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius01.ets @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Builder +function sliderBuilder(config: SliderConfiguration) { + Row() { + Column({ space: 30 }) { + Progress({ value: config.value, total: config.max, type: ProgressType.Ring }) + .margin({ top: 20 }) + + Button('增加') + .onClick(() => { + config.value = config.value + config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value < config.max) + + Button('减少') + .onClick(() => { + config.value = config.value - config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ + overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value > config.min) + + Slider({ + value: config.value, + min: config.min, + max: config.max, + step: config.step, + style: SliderStyle.NONE + }) + .width(300) + .height(100) + .visibility((config.contentModifier as MySliderStyle).showSlider ? Visibility.Visible : Visibility.Hidden) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + config.triggerChange(value, mode); + }) + Text('当前状态:' + ((config.contentModifier as MySliderStyle).sliderChangeMode == 0 ? "Begin" + : ((config.contentModifier as MySliderStyle).sliderChangeMode == 1 ? "Moving" + : ((config.contentModifier as MySliderStyle).sliderChangeMode == 2 ? "End" + : ((config.contentModifier as MySliderStyle).sliderChangeMode == 3 ? "Click" : "无"))))) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('进度值:' + config.value) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最小值:' + config.min) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最大值:' + config.max) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('步长:' + config.step) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + } + .width('80%') + + } + .width('100%') +} + +class MySliderStyle implements ContentModifier { + showSlider: boolean = true; + sliderChangeMode: number = 0; + + constructor(showSlider: boolean, sliderChangeMode: number) { + this.showSlider = showSlider; + this.sliderChangeMode = sliderChangeMode; + } + + applyContent(): WrappedBuilder<[SliderConfiguration]> { + return wrapBuilder(sliderBuilder); + } +} + +@Entry +@Component +struct UiComponentButtonSliderSelectedBorderRadius01 { + @State showSlider: boolean = true; + @State sliderValue: number = 10; + @State sliderMin: number = 0; + @State sliderMax: number = 100; + @State sliderStep: number = 20; + @State sliderChangeMode: number = 0; + @State text : string = 'slider set Style to none and show step to false' + + build() { + Column({ space: 8 }) { + + Row() { + Slider({ + value: this.sliderValue, + min: this.sliderMin, + max: this.sliderMax, + step: this.sliderStep, + }) + .showSteps(true) + .onChange((value: number, mode: SliderChangeMode) => { + this.sliderValue = value; + this.sliderChangeMode = mode; + console.info('【SliderLog】value:' + value + 'mode:' + mode.toString()); + }) + .contentModifier(new MySliderStyle(this.showSlider, this.sliderChangeMode)) + } + .width('100%') + Text(this.text) + .width("100%") + .fontSize(18) + .maxLines(3) + .textAlign(TextAlign.Start) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .border({ width: 1, color: 0xEEEEEE }) + .margin({ + left: 6, + right: 6, + bottom:30, + top:60 + }) + } + .width('100%') + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius02.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius02.ets new file mode 100644 index 00000000..b34a5b8b --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius02.ets @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Builder +function sliderBuilder2(config: SliderConfiguration) { + Row() { + Column({ space: 30 }) { + Progress({ value: config.value, total: config.max, type: ProgressType.Ring }) + .margin({ top: 20 }) + + Button('增加') + .onClick(() => { + config.value = config.value + config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ + overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value < config.max) + + Button('减少') + .onClick(() => { + config.value = config.value - config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value > config.min) + + Slider({ + value: config.value, + min: config.min, + max: config.max, + step: config.step, + style: SliderStyle.NONE + }) + .width(300) + .height(100) + .blockColor(Color.Orange) + .visibility((config.contentModifier as MySliderStyle2).showSlider ? Visibility.Visible : Visibility.Hidden) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + config.triggerChange(value, mode); + }) + Text('当前状态:' + ((config.contentModifier as MySliderStyle2).sliderChangeMode == 0 ? "Begin" + : ((config.contentModifier as MySliderStyle2).sliderChangeMode == 1 ? "Moving" + : ((config.contentModifier as MySliderStyle2).sliderChangeMode == 2 ? "End" + : ((config.contentModifier as MySliderStyle2).sliderChangeMode == 3 ? "Click" : "无"))))) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('进度值:' + config.value) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最小值:' + config.min) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最大值:' + config.max) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('步长:' + config.step) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + } + .width('80%') + + } + .width('100%') +} + +class MySliderStyle2 implements ContentModifier { + showSlider: boolean = true; + sliderChangeMode: number = 0; + + constructor(showSlider: boolean, sliderChangeMode: number) { + this.showSlider = showSlider; + this.sliderChangeMode = sliderChangeMode; + } + + applyContent(): WrappedBuilder<[SliderConfiguration]> { + return wrapBuilder(sliderBuilder2); + } +} + +@Entry +@Component +struct UiComponentButtonSliderSelectedBorderRadius02 { + @State showSlider: boolean = true; + @State sliderValue: number = 10; + @State sliderMin: number = 0; + @State sliderMax: number = 100; + @State sliderStep: number = 20; + @State sliderChangeMode: number = 0; + @State text : string = 'slider set Style to none and set blockColor to orange' + + build() { + Column({ space: 8 }) { + + Row() { + Slider({ + value: this.sliderValue, + min: this.sliderMin, + max: this.sliderMax, + step: this.sliderStep, + }) + .onChange((value: number, mode: SliderChangeMode) => { + this.sliderValue = value; + this.sliderChangeMode = mode; + console.info('【SliderLog】value:' + value + 'mode:' + mode.toString()); + }) + .contentModifier(new MySliderStyle2(this.showSlider, this.sliderChangeMode)) + } + .width('100%') + + Text(this.text) + .width("100%") + .fontSize(18) + .maxLines(3) + .textAlign(TextAlign.Start) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .border({ width: 1, color: 0xEEEEEE }) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius03.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius03.ets new file mode 100644 index 00000000..0f8eb4f7 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius03.ets @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Builder +function sliderBuilder3(config: SliderConfiguration) { + Row() { + Column({ space: 30 }) { + Progress({ value: config.value, total: config.max, type: ProgressType.Ring }) + .margin({ top: 20 }) + + Button('增加') + .onClick(() => { + config.value = config.value + config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ + overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value < config.max) + + Button('减少') + .onClick(() => { + config.value = config.value - config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value > config.min) + + Slider({ + value: config.value, + min: config.min, + max: config.max, + step: config.step, + style: SliderStyle.NONE + }) + .width(300) + .height(100) + .selectedColor('#007dff') + .blockColor(Color.Orange) + .visibility((config.contentModifier as MySliderStyle3).showSlider ? Visibility.Visible : Visibility.Hidden) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + config.triggerChange(value, mode); + }) + Text('当前状态:' + ((config.contentModifier as MySliderStyle3).sliderChangeMode == 0 ? "Begin" + : ((config.contentModifier as MySliderStyle3).sliderChangeMode == 1 ? "Moving" + : ((config.contentModifier as MySliderStyle3).sliderChangeMode == 2 ? "End" + : ((config.contentModifier as MySliderStyle3).sliderChangeMode == 3 ? "Click" : "无"))))) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('进度值:' + config.value) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最小值:' + config.min) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最大值:' + config.max) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('步长:' + config.step) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + } + .width('80%') + + } + .width('100%') +} + +class MySliderStyle3 implements ContentModifier { + showSlider: boolean = true; + sliderChangeMode: number = 0; + + constructor(showSlider: boolean, sliderChangeMode: number) { + this.showSlider = showSlider; + this.sliderChangeMode = sliderChangeMode; + } + + applyContent(): WrappedBuilder<[SliderConfiguration]> { + return wrapBuilder(sliderBuilder3); + } +} + + +@Entry +@Component +struct UiComponentButtonSliderSelectedBorderRadius03 { + @State showSlider: boolean = true; + @State sliderValue: number = 30; + @State sliderMin: number = 0; + @State sliderMax: number = 100; + @State sliderStep: number = 20; + @State sliderChangeMode: number = 0; + @State text : string = 'slider set Style to none and set selectedColor to #007dff' + + build() { + Column({ space: 8 }) { + + Row() { + Slider({ + value: this.sliderValue, + min: this.sliderMin, + max: this.sliderMax, + step: this.sliderStep, + }) + .onChange((value: number, mode: SliderChangeMode) => { + this.sliderValue = value; + this.sliderChangeMode = mode; + console.info('【SliderLog】value:' + value + 'mode:' + mode.toString()); + }) + .contentModifier(new MySliderStyle3(this.showSlider, this.sliderChangeMode)) + } + .width('100%') + + Text(this.text) + .width("100%") + .fontSize(18) + .maxLines(3) + .textAlign(TextAlign.Start) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .border({ width: 1, color: 0xEEEEEE }) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius04.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius04.ets new file mode 100644 index 00000000..4f8f1aa7 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius04.ets @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Builder +function sliderBuilder4(config: SliderConfiguration) { + Row() { + Column({ space: 30 }) { + Progress({ value: config.value, total: config.max, type: ProgressType.Ring }) + .margin({ top: 20 }) + + Button('增加') + .onClick(() => { + config.value = config.value + config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value < config.max) + + Button('减少') + .onClick(() => { + config.value = config.value - config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ + overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value > config.min) + + Slider({ + value: config.value, + min: config.min, + max: config.max, + step: config.step, + style: SliderStyle.NONE + }) + .width(300) + .height(100) + .blockBorderColor(Color.Pink) + .selectedColor('#007dff') + .blockColor(Color.Orange) + .visibility((config.contentModifier as MySliderStyle4).showSlider ? Visibility.Visible : Visibility.Hidden) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + config.triggerChange(value, mode); + }) + Text('当前状态:' + ((config.contentModifier as MySliderStyle4).sliderChangeMode == 0 ? "Begin" + : ((config.contentModifier as MySliderStyle4).sliderChangeMode == 1 ? "Moving" + : ((config.contentModifier as MySliderStyle4).sliderChangeMode == 2 ? "End" + : ((config.contentModifier as MySliderStyle4).sliderChangeMode == 3 ? "Click" : "无"))))) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('进度值:' + config.value) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最小值:' + config.min) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最大值:' + config.max) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('步长:' + config.step) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + } + .width('80%') + + } + .width('100%') +} + +class MySliderStyle4 implements ContentModifier { + showSlider: boolean = true; + sliderChangeMode: number = 0; + + constructor(showSlider: boolean, sliderChangeMode: number) { + this.showSlider = showSlider; + this.sliderChangeMode = sliderChangeMode; + } + + applyContent(): WrappedBuilder<[SliderConfiguration]> { + return wrapBuilder(sliderBuilder4); + } +} + + +@Entry +@Component +struct UiComponentButtonSliderSelectedBorderRadius04 { + @State showSlider: boolean = true; + @State sliderValue: number = 30; + @State sliderMin: number = 0; + @State sliderMax: number = 100; + @State sliderStep: number = 20; + @State sliderChangeMode: number = 0; + @State text : string = 'slider set Style to none and set blockBorderColor to Color.pink' + + build() { + Column({ space: 8 }) { + + Row() { + Slider({ + value: this.sliderValue, + min: this.sliderMin, + max: this.sliderMax, + step: this.sliderStep, + }) + .onChange((value: number, mode: SliderChangeMode) => { + this.sliderValue = value; + this.sliderChangeMode = mode; + console.info('【SliderLog】value:' + value + 'mode:' + mode.toString()); + }) + .contentModifier(new MySliderStyle4(this.showSlider, this.sliderChangeMode)) + } + .width('100%') + + Text(this.text) + .width("100%") + .fontSize(18) + .maxLines(3) + .textAlign(TextAlign.Start) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .border({ width: 1, color: 0xEEEEEE }) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius05.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius05.ets new file mode 100644 index 00000000..044de5ed --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius05.ets @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Builder +function sliderBuilder5(config: SliderConfiguration) { + Row() { + Column({ space: 30 }) { + Progress({ value: config.value, total: config.max, type: ProgressType.Ring }) + .margin({ top: 20 }) + + Button('增加') + .onClick(() => { + config.value = config.value + config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value < config.max) + + Button('减少') + .onClick(() => { + config.value = config.value - config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ + overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value > config.min) + + Slider({ + value: config.value, + min: config.min, + max: config.max, + step: config.step, + style: SliderStyle.NONE + }) + .width(300) + .height(100) + .selectedBorderRadius('50%') + .blockBorderColor(Color.Pink) + .selectedColor('#007dff') + .blockColor(Color.Orange) + .visibility((config.contentModifier as MySliderStyle5).showSlider ? Visibility.Visible : Visibility.Hidden) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + config.triggerChange(value, mode); + }) + Text('当前状态:' + ((config.contentModifier as MySliderStyle5).sliderChangeMode == 0 ? "Begin" + : ((config.contentModifier as MySliderStyle5).sliderChangeMode == 1 ? "Moving" + : ((config.contentModifier as MySliderStyle5).sliderChangeMode == 2 ? "End" + : ((config.contentModifier as MySliderStyle5).sliderChangeMode == 3 ? "Click" : "无"))))) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('进度值:' + config.value) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最小值:' + config.min) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最大值:' + config.max) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('步长:' + config.step) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + } + .width('80%') + + } + .width('100%') +} + +class MySliderStyle5 implements ContentModifier { + showSlider: boolean = true; + sliderChangeMode: number = 0; + + constructor(showSlider: boolean, sliderChangeMode: number) { + this.showSlider = showSlider; + this.sliderChangeMode = sliderChangeMode; + } + + applyContent(): WrappedBuilder<[SliderConfiguration]> { + return wrapBuilder(sliderBuilder5); + } +} + + +@Entry +@Component +struct UiComponentButtonSliderSelectedBorderRadius05 { + @State showSlider: boolean = true; + @State sliderValue: number = 30; + @State sliderMin: number = 0; + @State sliderMax: number = 100; + @State sliderStep: number = 20; + @State sliderChangeMode: number = 0; + @State text : string = 'slider set Style to none and set selectedBorderRadius to 50%' + + build() { + Column({ space: 8 }) { + + Row() { + Slider({ + value: this.sliderValue, + min: this.sliderMin, + max: this.sliderMax, + step: this.sliderStep, + }) + .onChange((value: number, mode: SliderChangeMode) => { + this.sliderValue = value; + this.sliderChangeMode = mode; + console.info('【SliderLog】value:' + value + 'mode:' + mode.toString()); + }) + .contentModifier(new MySliderStyle5(this.showSlider, this.sliderChangeMode)) + } + .width('100%') + + Text(this.text) + .width("100%") + .fontSize(18) + .maxLines(3) + .textAlign(TextAlign.Start) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .border({ width: 1, color: 0xEEEEEE }) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius06.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius06.ets new file mode 100644 index 00000000..2e5f260c --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius06.ets @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Builder +function sliderBuilder6(config: SliderConfiguration) { + Row() { + Column({ space: 30 }) { + Progress({ value: config.value, total: config.max, type: ProgressType.Ring }) + .margin({ top: 20 }) + + Button('增加') + .onClick(() => { + config.value = config.value + config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value < config.max) + + Button('减少') + .onClick(() => { + config.value = config.value - config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ + overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value > config.min) + + Slider({ + value: config.value, + min: config.min, + max: config.max, + step: config.step, + style: SliderStyle.NONE + }) + .width(300) + .height(100) + .blockBorderWidth(3) + .selectedBorderRadius('50%') + .blockBorderColor(Color.Pink) + .selectedColor('#007dff') + .blockColor(Color.Orange) + .visibility((config.contentModifier as MySliderStyle6).showSlider ? Visibility.Visible : Visibility.Hidden) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + config.triggerChange(value, mode); + }) + Text('当前状态:' + ((config.contentModifier as MySliderStyle6).sliderChangeMode == 0 ? "Begin" + : ((config.contentModifier as MySliderStyle6).sliderChangeMode == 1 ? "Moving" + : ((config.contentModifier as MySliderStyle6).sliderChangeMode == 2 ? "End" + : ((config.contentModifier as MySliderStyle6).sliderChangeMode == 3 ? "Click" : "无"))))) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('进度值:' + config.value) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最小值:' + config.min) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最大值:' + config.max) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('步长:' + config.step) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + } + .width('80%') + + } + .width('100%') +} + +class MySliderStyle6 implements ContentModifier { + showSlider: boolean = true; + sliderChangeMode: number = 0; + + constructor(showSlider: boolean, sliderChangeMode: number) { + this.showSlider = showSlider; + this.sliderChangeMode = sliderChangeMode; + } + + applyContent(): WrappedBuilder<[SliderConfiguration]> { + return wrapBuilder(sliderBuilder6); + } +} + + +@Entry +@Component +struct UiComponentButtonSliderSelectedBorderRadius06 { + @State showSlider: boolean = true; + @State sliderValue: number = 30; + @State sliderMin: number = 0; + @State sliderMax: number = 100; + @State sliderStep: number = 20; + @State sliderChangeMode: number = 0; + @State text : string = 'slider set Style to none and set blockBorderWidth to 3' + + build() { + Column({ space: 8 }) { + + Row() { + Slider({ + value: this.sliderValue, + min: this.sliderMin, + max: this.sliderMax, + step: this.sliderStep, + }) + .onChange((value: number, mode: SliderChangeMode) => { + this.sliderValue = value; + this.sliderChangeMode = mode; + console.info('【SliderLog】value:' + value + 'mode:' + mode.toString()); + }) + .contentModifier(new MySliderStyle6(this.showSlider, this.sliderChangeMode)) + } + .width('100%') + + Text(this.text) + .width("100%") + .fontSize(18) + .maxLines(3) + .textAlign(TextAlign.Start) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .border({ width: 1, color: 0xEEEEEE }) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius07.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius07.ets new file mode 100644 index 00000000..58654102 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius07.ets @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Builder +function sliderBuilder7(config: SliderConfiguration) { + Row() { + Column({ space: 30 }) { + Progress({ value: config.value, total: config.max, type: ProgressType.Ring }) + .margin({ top: 20 }) + + Button('增加') + .onClick(() => { + config.value = config.value + config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value < config.max) + + Button('减少') + .onClick(() => { + config.value = config.value - config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ + overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value > config.min) + + Slider({ + value: config.value, + min: config.min, + max: config.max, + step: config.step, + style: SliderStyle.NONE + }) + .width(300) + .height(100) + .blockStyle({type:SliderBlockType.DEFAULT}) + .blockBorderWidth(3) + .selectedBorderRadius('50%') + .blockBorderColor(Color.Pink) + .selectedColor('#007dff') + .blockColor(Color.Orange) + .visibility((config.contentModifier as MySliderStyle7).showSlider ? Visibility.Visible : Visibility.Hidden) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + config.triggerChange(value, mode); + }) + Text('当前状态:' + ((config.contentModifier as MySliderStyle7).sliderChangeMode == 0 ? "Begin" + : ((config.contentModifier as MySliderStyle7).sliderChangeMode == 1 ? "Moving" + : ((config.contentModifier as MySliderStyle7).sliderChangeMode == 2 ? "End" + : ((config.contentModifier as MySliderStyle7).sliderChangeMode == 3 ? "Click" : "无"))))) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('进度值:' + config.value) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最小值:' + config.min) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最大值:' + config.max) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('步长:' + config.step) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + } + .width('80%') + + } + .width('100%') +} + +class MySliderStyle7 implements ContentModifier { + showSlider: boolean = true; + sliderChangeMode: number = 0; + + constructor(showSlider: boolean, sliderChangeMode: number) { + this.showSlider = showSlider; + this.sliderChangeMode = sliderChangeMode; + } + + applyContent(): WrappedBuilder<[SliderConfiguration]> { + return wrapBuilder(sliderBuilder7); + } +} + + +@Entry +@Component +struct UiComponentButtonSliderSelectedBorderRadius07 { + @State showSlider: boolean = true; + @State sliderValue: number = 30; + @State sliderMin: number = 0; + @State sliderMax: number = 100; + @State sliderStep: number = 20; + @State sliderChangeMode: number = 0; + @State text : string = 'slider set Style to none and set SliderBlockType to DEFAULT' + + build() { + Column({ space: 8 }) { + + Row() { + Slider({ + value: this.sliderValue, + min: this.sliderMin, + max: this.sliderMax, + step: this.sliderStep, + }) + .onChange((value: number, mode: SliderChangeMode) => { + this.sliderValue = value; + this.sliderChangeMode = mode; + console.info('【SliderLog】value:' + value + 'mode:' + mode.toString()); + }) + .contentModifier(new MySliderStyle7(this.showSlider, this.sliderChangeMode)) + } + .width('100%') + + Text(this.text) + .width("100%") + .fontSize(18) + .maxLines(3) + .textAlign(TextAlign.Start) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .border({ width: 1, color: 0xEEEEEE }) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius08.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius08.ets new file mode 100644 index 00000000..40e0853d --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius08.ets @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Builder +function sliderBuilder8(config: SliderConfiguration) { + Row() { + Column({ space: 30 }) { + Progress({ value: config.value, total: config.max, type: ProgressType.Ring }) + .margin({ top: 20 }) + + Button('增加') + .onClick(() => { + config.value = config.value + config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value < config.max) + + Button('减少') + .onClick(() => { + config.value = config.value - config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ + overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value > config.min) + + Slider({ + value: config.value, + min: config.min, + max: config.max, + step: config.step, + style: SliderStyle.NONE + }) + .width(300) + .height(100) + .selectedBorderRadius('10px') + .blockStyle({type:SliderBlockType.DEFAULT}) + .blockBorderWidth(3) + .selectedBorderRadius('50%') + .blockBorderColor(Color.Pink) + .selectedColor('#007dff') + .blockColor(Color.Orange) + .visibility((config.contentModifier as MySliderStyle8).showSlider ? Visibility.Visible : Visibility.Hidden) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + config.triggerChange(value, mode); + }) + Text('当前状态:' + ((config.contentModifier as MySliderStyle8).sliderChangeMode == 0 ? "Begin" + : ((config.contentModifier as MySliderStyle8).sliderChangeMode == 1 ? "Moving" + : ((config.contentModifier as MySliderStyle8).sliderChangeMode == 2 ? "End" + : ((config.contentModifier as MySliderStyle8).sliderChangeMode == 3 ? "Click" : "无"))))) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('进度值:' + config.value) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最小值:' + config.min) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最大值:' + config.max) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('步长:' + config.step) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + } + .width('80%') + + } + .width('100%') +} + +class MySliderStyle8 implements ContentModifier { + showSlider: boolean = true; + sliderChangeMode: number = 0; + + constructor(showSlider: boolean, sliderChangeMode: number) { + this.showSlider = showSlider; + this.sliderChangeMode = sliderChangeMode; + } + + applyContent(): WrappedBuilder<[SliderConfiguration]> { + return wrapBuilder(sliderBuilder8); + } +} + + +@Entry +@Component +struct UiComponentButtonSliderSelectedBorderRadius08 { + @State showSlider: boolean = true; + @State sliderValue: number = 30; + @State sliderMin: number = 0; + @State sliderMax: number = 100; + @State sliderStep: number = 20; + @State sliderChangeMode: number = 0; + @State text : string = 'slider set Style to none and set selectedBorderRadius to 10px' + + build() { + Column({ space: 8 }) { + + Row() { + Slider({ + value: this.sliderValue, + min: this.sliderMin, + max: this.sliderMax, + step: this.sliderStep, + }) + .onChange((value: number, mode: SliderChangeMode) => { + this.sliderValue = value; + this.sliderChangeMode = mode; + console.info('【SliderLog】value:' + value + 'mode:' + mode.toString()); + }) + .contentModifier(new MySliderStyle8(this.showSlider, this.sliderChangeMode)) + } + .width('100%') + + Text(this.text) + .width("100%") + .fontSize(18) + .maxLines(3) + .textAlign(TextAlign.Start) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .border({ width: 1, color: 0xEEEEEE }) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius09.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius09.ets new file mode 100644 index 00000000..fa210ac3 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius09.ets @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Builder +function sliderBuilder9(config: SliderConfiguration) { + Row() { + Column({ space: 30 }) { + Progress({ value: config.value, total: config.max, type: ProgressType.Ring }) + .margin({ top: 20 }) + + Button('增加') + .onClick(() => { + config.value = config.value + config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value < config.max) + + Button('减少') + .onClick(() => { + config.value = config.value - config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ + overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value > config.min) + + Slider({ + value: config.value, + min: config.min, + max: config.max, + step: config.step, + style: SliderStyle.NONE + }) + .width(300) + .height(100) + .trackColor('#19182431') + .selectedBorderRadius('10px') + .blockStyle({type:SliderBlockType.DEFAULT}) + .blockBorderWidth(3) + .selectedBorderRadius('50%') + .blockBorderColor(Color.Pink) + .selectedColor('#007dff') + .blockColor(Color.Orange) + .visibility((config.contentModifier as MySliderStyle9).showSlider ? Visibility.Visible : Visibility.Hidden) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + config.triggerChange(value, mode); + }) + Text('当前状态:' + ((config.contentModifier as MySliderStyle9).sliderChangeMode == 0 ? "Begin" + : ((config.contentModifier as MySliderStyle9).sliderChangeMode == 1 ? "Moving" + : ((config.contentModifier as MySliderStyle9).sliderChangeMode == 2 ? "End" + : ((config.contentModifier as MySliderStyle9).sliderChangeMode == 3 ? "Click" : "无"))))) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('进度值:' + config.value) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最小值:' + config.min) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最大值:' + config.max) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('步长:' + config.step) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + } + .width('80%') + + } + .width('100%') +} + +class MySliderStyle9 implements ContentModifier { + showSlider: boolean = true; + sliderChangeMode: number = 0; + + constructor(showSlider: boolean, sliderChangeMode: number) { + this.showSlider = showSlider; + this.sliderChangeMode = sliderChangeMode; + } + + applyContent(): WrappedBuilder<[SliderConfiguration]> { + return wrapBuilder(sliderBuilder9); + } +} + + +@Entry +@Component +struct UiComponentButtonSliderSelectedBorderRadius09 { + @State showSlider: boolean = true; + @State sliderValue: number = 30; + @State sliderMin: number = 0; + @State sliderMax: number = 100; + @State sliderStep: number = 20; + @State sliderChangeMode: number = 0; + @State text : string = 'slider set Style to none and set trackColor to #19182431' + + build() { + Column({ space: 8 }) { + + Row() { + Slider({ + value: this.sliderValue, + min: this.sliderMin, + max: this.sliderMax, + step: this.sliderStep, + }) + .onChange((value: number, mode: SliderChangeMode) => { + this.sliderValue = value; + this.sliderChangeMode = mode; + console.info('【SliderLog】value:' + value + 'mode:' + mode.toString()); + }) + .contentModifier(new MySliderStyle9(this.showSlider, this.sliderChangeMode)) + } + .width('100%') + + Text(this.text) + .width("100%") + .fontSize(18) + .maxLines(3) + .textAlign(TextAlign.Start) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .border({ width: 1, color: 0xEEEEEE }) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius10.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius10.ets new file mode 100644 index 00000000..ed4fe8ce --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius10.ets @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Builder +function sliderBuilder10(config: SliderConfiguration) { + Row() { + Column({ space: 30 }) { + Progress({ value: config.value, total: config.max, type: ProgressType.Ring }) + .margin({ top: 20 }) + + Button('增加') + .onClick(() => { + config.value = config.value + config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value < config.max) + + Button('减少') + .onClick(() => { + config.value = config.value - config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ + overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value > config.min) + + Slider({ + value: config.value, + min: config.min, + max: config.max, + step: config.step, + style: SliderStyle.NONE + }) + .width(300) + .height(100) + .trackColor('#19182431') + .selectedBorderRadius(0) + .blockStyle({type:SliderBlockType.DEFAULT}) + .blockBorderWidth(3) + .selectedBorderRadius('50%') + .blockBorderColor(Color.Pink) + .selectedColor('#007dff') + .blockColor(Color.Orange) + .visibility((config.contentModifier as MySliderStyle10).showSlider ? Visibility.Visible : Visibility.Hidden) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + config.triggerChange(value, mode); + }) + Text('当前状态:' + ((config.contentModifier as MySliderStyle10).sliderChangeMode == 0 ? "Begin" + : ((config.contentModifier as MySliderStyle10).sliderChangeMode == 1 ? "Moving" + : ((config.contentModifier as MySliderStyle10).sliderChangeMode == 2 ? "End" + : ((config.contentModifier as MySliderStyle10).sliderChangeMode == 3 ? "Click" : "无"))))) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('进度值:' + config.value) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最小值:' + config.min) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最大值:' + config.max) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('步长:' + config.step) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + } + .width('80%') + + } + .width('100%') +} + +class MySliderStyle10 implements ContentModifier { + showSlider: boolean = true; + sliderChangeMode: number = 0; + + constructor(showSlider: boolean, sliderChangeMode: number) { + this.showSlider = showSlider; + this.sliderChangeMode = sliderChangeMode; + } + + applyContent(): WrappedBuilder<[SliderConfiguration]> { + return wrapBuilder(sliderBuilder10); + } +} + + +@Entry +@Component +struct UiComponentButtonSliderSelectedBorderRadius10 { + @State showSlider: boolean = true; + @State sliderValue: number = 30; + @State sliderMin: number = 0; + @State sliderMax: number = 100; + @State sliderStep: number = 20; + @State sliderChangeMode: number = 0; + @State text : string = 'slider set Style to none and set selectedBorderRadius to default(0)' + + build() { + Column({ space: 8 }) { + + Row() { + Slider({ + value: this.sliderValue, + min: this.sliderMin, + max: this.sliderMax, + step: this.sliderStep, + }) + .onChange((value: number, mode: SliderChangeMode) => { + this.sliderValue = value; + this.sliderChangeMode = mode; + console.info('【SliderLog】value:' + value + 'mode:' + mode.toString()); + }) + .contentModifier(new MySliderStyle10(this.showSlider, this.sliderChangeMode)) + } + .width('100%') + + Text(this.text) + .width("100%") + .fontSize(18) + .maxLines(3) + .textAlign(TextAlign.Start) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .border({ width: 1, color: 0xEEEEEE }) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + } +} -- Gitee From 2e8b468797b6f5687687ae4d78a7dbffdf3c22e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A6=83=E8=B4=9E=E5=BA=86?= Date: Thu, 7 Aug 2025 20:26:54 +0800 Subject: [PATCH 3/5] =?UTF-8?q?[ui=E5=AF=B9=E6=AF=94]=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?UiComponentFrameNodeText29=E6=9D=A1=E7=94=A8=E4=BE=8B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 覃贞庆 --- ...nentButtonSliderSelectedBorderRadius11.ets | 180 +++++++++++++++++ ...nentButtonSliderSelectedBorderRadius12.ets | 179 +++++++++++++++++ ...nentButtonSliderSelectedBorderRadius13.ets | 180 +++++++++++++++++ ...nentButtonSliderSelectedBorderRadius14.ets | 180 +++++++++++++++++ ...nentButtonSliderSelectedBorderRadius15.ets | 182 ++++++++++++++++++ 5 files changed, 901 insertions(+) create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius11.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius12.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius13.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius14.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius15.ets diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius11.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius11.ets new file mode 100644 index 00000000..51e9fb2a --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius11.ets @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Builder +function sliderBuilder11(config: SliderConfiguration) { + Row() { + Column({ space: 30 }) { + Progress({ value: config.value, total: config.max, type: ProgressType.Ring }) + .margin({ top: 20 }) + + Button('增加') + .onClick(() => { + config.value = config.value + config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value < config.max) + + Button('减少') + .onClick(() => { + config.value = config.value - config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ + overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value > config.min) + + Slider({ + value: config.value, + min: config.min, + max: config.max, + step: config.step, + style: undefined + }) + .width(300) + .height(100) + .trackColor('#19182431') + .selectedBorderRadius(0) + .blockStyle({type:SliderBlockType.DEFAULT}) + .blockBorderWidth(3) + .selectedBorderRadius('50%') + .blockBorderColor(Color.Pink) + .selectedColor('#007dff') + .blockColor(Color.Orange) + .visibility((config.contentModifier as MySliderStyle11).showSlider ? Visibility.Visible : Visibility.Hidden) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + config.triggerChange(value, mode); + }) + Text('当前状态:' + ((config.contentModifier as MySliderStyle11).sliderChangeMode == 0 ? "Begin" + : ((config.contentModifier as MySliderStyle11).sliderChangeMode == 1 ? "Moving" + : ((config.contentModifier as MySliderStyle11).sliderChangeMode == 2 ? "End" + : ((config.contentModifier as MySliderStyle11).sliderChangeMode == 3 ? "Click" : "无"))))) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('进度值:' + config.value) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最小值:' + config.min) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最大值:' + config.max) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('步长:' + config.step) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + } + .width('80%') + + } + .width('100%') +} + +class MySliderStyle11 implements ContentModifier { + showSlider: boolean = true; + sliderChangeMode: number = 0; + + constructor(showSlider: boolean, sliderChangeMode: number) { + this.showSlider = showSlider; + this.sliderChangeMode = sliderChangeMode; + } + + applyContent(): WrappedBuilder<[SliderConfiguration]> { + return wrapBuilder(sliderBuilder11); + } +} + + +@Entry +@Component +struct UiComponentButtonSliderSelectedBorderRadius11 { + @State showSlider: boolean = true; + @State sliderValue: number = 30; + @State sliderMin: number = 0; + @State sliderMax: number = 100; + @State sliderStep: number = 20; + @State sliderChangeMode: number = 0; + @State text : string = 'slider set Style to undefined' + + build() { + Column({ space: 8 }) { + + Row() { + Slider({ + value: this.sliderValue, + min: this.sliderMin, + max: this.sliderMax, + step: this.sliderStep, + }) + .onChange((value: number, mode: SliderChangeMode) => { + this.sliderValue = value; + this.sliderChangeMode = mode; + console.info('【SliderLog】value:' + value + 'mode:' + mode.toString()); + }) + .contentModifier(new MySliderStyle11(this.showSlider, this.sliderChangeMode)) + } + .width('100%') + + Text(this.text) + .width("100%") + .fontSize(18) + .maxLines(3) + .textAlign(TextAlign.Start) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .border({ width: 1, color: 0xEEEEEE }) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius12.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius12.ets new file mode 100644 index 00000000..91bed863 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius12.ets @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Builder +function sliderBuilder12(config: SliderConfiguration) { + Row() { + Column({ space: 30 }) { + Progress({ value: config.value, total: config.max, type: ProgressType.Ring }) + .margin({ top: 20 }) + + Button('增加') + .onClick(() => { + config.value = config.value + config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value < config.max) + + Button('减少') + .onClick(() => { + config.value = config.value - config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ + overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value > config.min) + + Slider({ + value: config.value, + min: config.min, + max: config.max, + step: config.step, + }) + .width(300) + .height(100) + .trackColor('#19182431') + .selectedBorderRadius(0) + .blockStyle({type:SliderBlockType.DEFAULT}) + .blockBorderWidth(3) + .selectedBorderRadius('50%') + .blockBorderColor(Color.Pink) + .selectedColor('#007dff') + .blockColor(Color.Orange) + .visibility((config.contentModifier as MySliderStyle12).showSlider ? Visibility.Visible : Visibility.Hidden) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + config.triggerChange(value, mode); + }) + Text('当前状态:' + ((config.contentModifier as MySliderStyle12).sliderChangeMode == 0 ? "Begin" + : ((config.contentModifier as MySliderStyle12).sliderChangeMode == 1 ? "Moving" + : ((config.contentModifier as MySliderStyle12).sliderChangeMode == 2 ? "End" + : ((config.contentModifier as MySliderStyle12).sliderChangeMode == 3 ? "Click" : "无"))))) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('进度值:' + config.value) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最小值:' + config.min) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最大值:' + config.max) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('步长:' + config.step) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + } + .width('80%') + + } + .width('100%') +} + +class MySliderStyle12 implements ContentModifier { + showSlider: boolean = true; + sliderChangeMode: number = 0; + + constructor(showSlider: boolean, sliderChangeMode: number) { + this.showSlider = showSlider; + this.sliderChangeMode = sliderChangeMode; + } + + applyContent(): WrappedBuilder<[SliderConfiguration]> { + return wrapBuilder(sliderBuilder12); + } +} + + +@Entry +@Component +struct UiComponentButtonSliderSelectedBorderRadius12 { + @State showSlider: boolean = true; + @State sliderValue: number = 30; + @State sliderMin: number = 0; + @State sliderMax: number = 100; + @State sliderStep: number = 20; + @State sliderChangeMode: number = 0; + @State text : string = 'not set slider Style ' + + build() { + Column({ space: 8 }) { + + Row() { + Slider({ + value: this.sliderValue, + min: this.sliderMin, + max: this.sliderMax, + step: this.sliderStep, + }) + .onChange((value: number, mode: SliderChangeMode) => { + this.sliderValue = value; + this.sliderChangeMode = mode; + console.info('【SliderLog】value:' + value + 'mode:' + mode.toString()); + }) + .contentModifier(new MySliderStyle12(this.showSlider, this.sliderChangeMode)) + } + .width('100%') + + Text(this.text) + .width("100%") + .fontSize(18) + .maxLines(3) + .textAlign(TextAlign.Start) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .border({ width: 1, color: 0xEEEEEE }) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius13.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius13.ets new file mode 100644 index 00000000..a1423699 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius13.ets @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Builder +function sliderBuilder13(config: SliderConfiguration) { + Row() { + Column({ space: 30 }) { + Progress({ value: config.value, total: config.max, type: ProgressType.Ring }) + .margin({ top: 20 }) + + Button('增加') + .onClick(() => { + config.value = config.value + config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value < config.max) + + Button('减少') + .onClick(() => { + config.value = config.value - config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ + overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value > config.min) + + Slider({ + value: config.value, + min: config.min, + max: config.max, + step: config.step, + style: SliderStyle.OutSet + }) + .width(300) + .height(100) + .trackColor('#19182431') + .selectedBorderRadius(0) + .blockStyle({type:SliderBlockType.DEFAULT}) + .blockBorderWidth(3) + .selectedBorderRadius('50%') + .blockBorderColor(Color.Pink) + .selectedColor('#007dff') + .blockColor(Color.Orange) + .visibility((config.contentModifier as MySliderStyle13).showSlider ? Visibility.Visible : Visibility.Hidden) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + config.triggerChange(value, mode); + }) + Text('当前状态:' + ((config.contentModifier as MySliderStyle13).sliderChangeMode == 0 ? "Begin" + : ((config.contentModifier as MySliderStyle13).sliderChangeMode == 1 ? "Moving" + : ((config.contentModifier as MySliderStyle13).sliderChangeMode == 2 ? "End" + : ((config.contentModifier as MySliderStyle13).sliderChangeMode == 3 ? "Click" : "无"))))) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('进度值:' + config.value) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最小值:' + config.min) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最大值:' + config.max) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('步长:' + config.step) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + } + .width('80%') + + } + .width('100%') +} + +class MySliderStyle13 implements ContentModifier { + showSlider: boolean = true; + sliderChangeMode: number = 0; + + constructor(showSlider: boolean, sliderChangeMode: number) { + this.showSlider = showSlider; + this.sliderChangeMode = sliderChangeMode; + } + + applyContent(): WrappedBuilder<[SliderConfiguration]> { + return wrapBuilder(sliderBuilder13); + } +} + + +@Entry +@Component +struct UiComponentButtonSliderSelectedBorderRadius13 { + @State showSlider: boolean = true; + @State sliderValue: number = 30; + @State sliderMin: number = 0; + @State sliderMax: number = 100; + @State sliderStep: number = 20; + @State sliderChangeMode: number = 0; + @State text : string = 'slider set Style to outsize' + + build() { + Column({ space: 8 }) { + + Row() { + Slider({ + value: this.sliderValue, + min: this.sliderMin, + max: this.sliderMax, + step: this.sliderStep, + }) + .onChange((value: number, mode: SliderChangeMode) => { + this.sliderValue = value; + this.sliderChangeMode = mode; + console.info('【SliderLog】value:' + value + 'mode:' + mode.toString()); + }) + .contentModifier(new MySliderStyle13(this.showSlider, this.sliderChangeMode)) + } + .width('100%') + + Text(this.text) + .width("100%") + .fontSize(18) + .maxLines(3) + .textAlign(TextAlign.Start) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .border({ width: 1, color: 0xEEEEEE }) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius14.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius14.ets new file mode 100644 index 00000000..7cfb9aeb --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius14.ets @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Builder +function sliderBuilder14(config: SliderConfiguration) { + Row() { + Column({ space: 30 }) { + Progress({ value: config.value, total: config.max, type: ProgressType.Ring }) + .margin({ top: 20 }) + + Button('增加') + .onClick(() => { + config.value = config.value + config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value < config.max) + + Button('减少') + .onClick(() => { + config.value = config.value - config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ + overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value > config.min) + + Slider({ + value: config.value, + min: config.min, + max: config.max, + step: config.step, + style: SliderStyle.InSet + }) + .width(300) + .height(100) + .trackColor('#19182431') + .selectedBorderRadius(0) + .blockStyle({type:SliderBlockType.DEFAULT}) + .blockBorderWidth(3) + .selectedBorderRadius('50%') + .blockBorderColor(Color.Pink) + .selectedColor('#007dff') + .blockColor(Color.Orange) + .visibility((config.contentModifier as MySliderStyle14).showSlider ? Visibility.Visible : Visibility.Hidden) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + config.triggerChange(value, mode); + }) + Text('当前状态:' + ((config.contentModifier as MySliderStyle14).sliderChangeMode == 0 ? "Begin" + : ((config.contentModifier as MySliderStyle14).sliderChangeMode == 1 ? "Moving" + : ((config.contentModifier as MySliderStyle14).sliderChangeMode == 2 ? "End" + : ((config.contentModifier as MySliderStyle14).sliderChangeMode == 3 ? "Click" : "无"))))) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('进度值:' + config.value) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最小值:' + config.min) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最大值:' + config.max) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('步长:' + config.step) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + } + .width('80%') + + } + .width('100%') +} + +class MySliderStyle14 implements ContentModifier { + showSlider: boolean = true; + sliderChangeMode: number = 0; + + constructor(showSlider: boolean, sliderChangeMode: number) { + this.showSlider = showSlider; + this.sliderChangeMode = sliderChangeMode; + } + + applyContent(): WrappedBuilder<[SliderConfiguration]> { + return wrapBuilder(sliderBuilder14); + } +} + + +@Entry +@Component +struct UiComponentButtonSliderSelectedBorderRadius14 { + @State showSlider: boolean = true; + @State sliderValue: number = 30; + @State sliderMin: number = 0; + @State sliderMax: number = 100; + @State sliderStep: number = 20; + @State sliderChangeMode: number = 0; + @State text : string = 'slider set Style to inset' + + build() { + Column({ space: 8 }) { + + Row() { + Slider({ + value: this.sliderValue, + min: this.sliderMin, + max: this.sliderMax, + step: this.sliderStep, + }) + .onChange((value: number, mode: SliderChangeMode) => { + this.sliderValue = value; + this.sliderChangeMode = mode; + console.info('【SliderLog】value:' + value + 'mode:' + mode.toString()); + }) + .contentModifier(new MySliderStyle14(this.showSlider, this.sliderChangeMode)) + } + .width('100%') + + Text(this.text) + .width("100%") + .fontSize(18) + .maxLines(3) + .textAlign(TextAlign.Start) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .border({ width: 1, color: 0xEEEEEE }) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius15.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius15.ets new file mode 100644 index 00000000..d6ebfc06 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentButtonSliderSelectedBorderRadius/UiComponentButtonSliderSelectedBorderRadius15.ets @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Builder +function sliderBuilder15(config: SliderConfiguration) { + Row() { + Column({ space: 30 }) { + Progress({ value: config.value, total: config.max, type: ProgressType.Ring }) + .margin({ top: 20 }) + + Button('增加') + .onClick(() => { + config.value = config.value + config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value < config.max) + + Button('减少') + .onClick(() => { + config.value = config.value - config.step; + config.triggerChange(config.value, SliderChangeMode.Click); + }) + .labelStyle({ + overflow: TextOverflow.Clip, + maxLines: 1, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .width(100) + .height(25) + .fontSize(10) + .enabled(config.value > config.min) + + Slider({ + value: config.value, + min: config.min, + max: config.max, + step: config.step, + style: SliderStyle.InSet + }) + .width(300) + .height(100) + .trackColor('#19182431') + .selectedBorderRadius(0) + .blockStyle({type:SliderBlockType.DEFAULT}) + .blockBorderWidth(3) + .selectedBorderRadius('50%') + .blockBorderColor(Color.Pink) + .selectedColor('#007dff') + .blockColor(Color.Orange) + .visibility((config.contentModifier as MySliderStyle15).showSlider ? Visibility.Visible : Visibility.Hidden) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + config.triggerChange(value, mode); + }) + Text('当前状态:' + ((config.contentModifier as MySliderStyle15).sliderChangeMode == 0 ? "Begin" + : ((config.contentModifier as MySliderStyle15).sliderChangeMode == 1 ? "Moving" + : ((config.contentModifier as MySliderStyle15).sliderChangeMode == 2 ? "End" + : ((config.contentModifier as MySliderStyle15).sliderChangeMode == 3 ? "Click" : "无"))))) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('进度值:' + config.value) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最小值:' + config.min) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('最大值:' + config.max) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + Text('步长:' + config.step) + .fontSize(10) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + } + .width('80%') + + } + .width('100%') +} + +class MySliderStyle15 implements ContentModifier { + showSlider: boolean = true; + sliderChangeMode: number = 0; + + constructor(showSlider: boolean, sliderChangeMode: number) { + this.showSlider = showSlider; + this.sliderChangeMode = sliderChangeMode; + } + + applyContent(): WrappedBuilder<[SliderConfiguration]> { + return wrapBuilder(sliderBuilder15); + } +} + + +@Entry +@Component +struct UiComponentButtonSliderSelectedBorderRadius15 { + @State showSlider: boolean = true; + @State sliderValue: number = 30; + @State sliderMin: number = 0; + @State sliderMax: number = 100; + @State sliderStep: number = 20; + @State sliderChangeMode: number = 0; + @State text : string = 'slider set Style to none and set showtips to true' + + build() { + Column({ space: 8 }) { + + Row() { + Slider({ + value: this.sliderValue, + min: this.sliderMin, + max: this.sliderMax, + step: this.sliderStep, + style: SliderStyle.NONE + }) + .onChange((value: number, mode: SliderChangeMode) => { + this.sliderValue = value; + this.sliderChangeMode = mode; + console.info('【SliderLog】value:' + value + 'mode:' + mode.toString()); + }) + .id('UiComponentButtonSliderSelectedBorderRadius15') + .showTips(true, this.sliderValue.toFixed()) + } + .width('100%') + + Text(this.text) + .width("100%") + .fontSize(18) + .maxLines(3) + .textAlign(TextAlign.Start) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .border({ width: 1, color: 0xEEEEEE }) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + } +} -- Gitee From 78e998f44b8405f69ffa18761b263c8a4b1d4cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A6=83=E8=B4=9E=E5=BA=86?= Date: Thu, 7 Aug 2025 20:30:01 +0800 Subject: [PATCH 4/5] =?UTF-8?q?[ui=E5=AF=B9=E6=AF=94]=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?UiComponentFrameNodeText29=E6=9D=A1=E7=94=A8=E4=BE=8B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 覃贞庆 --- .../UiComponentFrameNodeText07.ets | 158 ++++++++++++++ .../UiComponentFrameNodeText08.ets | 166 +++++++++++++++ .../UiComponentFrameNodeText09.ets | 170 +++++++++++++++ .../UiComponentFrameNodeText10.ets | 173 ++++++++++++++++ .../UiComponentFrameNodeText11.ets | 175 ++++++++++++++++ .../UiComponentFrameNodeText12.ets | 178 ++++++++++++++++ .../UiComponentFrameNodeText13.ets | 176 ++++++++++++++++ .../UiComponentFrameNodeText14.ets | 184 +++++++++++++++++ .../UiComponentFrameNodeText15.ets | 187 +++++++++++++++++ .../UiComponentFrameNodeText16.ets | 191 +++++++++++++++++ .../UiComponentFrameNodeText17.ets | 194 ++++++++++++++++++ 11 files changed, 1952 insertions(+) create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText07.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText08.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText09.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText10.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText11.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText12.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText13.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText14.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText15.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText16.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText17.ets diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText07.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText07.ets new file mode 100644 index 00000000..c84aa0ee --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText07.ets @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; + +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + + setPlaceholderColor(color: ResourceColor) { + this.placeholderColor = color; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(100) + .height(100) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.text, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .placeholderColor(this.placeholderColor) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText07_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText07 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentColorIndex: number = 0; + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changePlaceholderColor() { + this.currentColorIndex = (this.currentColorIndex + 1) % this.colors.length; + this.myNodeController.setPlaceholderColor(this.colors[this.currentColorIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea placeholderColor') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + Button('切换占位符颜色') + .fontSize(10) + .id('UiComponentFrameNodeText07_02') + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .padding({ + left: 15, + right: 15 + }) + .margin({ bottom: 10 }) + .onClick( + () => this.changePlaceholderColor() + ) + NodeContainer(this.myNodeController); + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText08.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText08.ets new file mode 100644 index 00000000..364aa68f --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText08.ets @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; + +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private message1: string = + "They can be classified as built-in components–those directly provided by the ArkUI framework and custom components – those defined by developers" + + "The built-in components include buttons radio buttonsprogress indicators and text You can set the rendering effectof thesecomponents in method " + + "chaining mode,page components are divided into independent UI units to implementindependent" + +"creation development and reuse of different units on pages making pages more engineering-oriented."; + + setLineBreakStrategy(lineBreakStrategy: LineBreakStrategy) { + this.lineBreakStrategy = lineBreakStrategy; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(300) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.message1, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText08_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText08 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentIndex: number = 0; + private lineBreakStrategy: LineBreakStrategy[]=[LineBreakStrategy.GREEDY,LineBreakStrategy.HIGH_QUALITY,LineBreakStrategy.BALANCED] + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changePlaceholderColor() { + this.currentIndex = (this.currentIndex + 1) % this.colors.length; + this.myNodeController.setLineBreakStrategy(this.lineBreakStrategy[this.currentIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea lineBreakStrategy') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + Button('切换折行规则') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiComponentFrameNodeText08_02') + .padding({ + left: 15, + right: 15 + }) + .margin({ bottom: 10 }) + .onClick( + () => this.changePlaceholderColor() + ) + NodeContainer(this.myNodeController); + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText09.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText09.ets new file mode 100644 index 00000000..e6eeaedb --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText09.ets @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; + +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private message1: string = + "They can be classified as built-in components–those directly provided by the ArkUI framework and custom components – those defined by developers" + + "The built-in components include buttons radio buttonsprogress indicators and text You can set the rendering effectof thesecomponents in method " + + "chaining mode,page components are divided into independent UI units to implementindependent" + +"creation development and reuse of different units on pages making pages more engineering-oriented."; + + settextOverflow(textOverflow: TextOverflow) { + this.textOverflow = textOverflow; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(300) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.message1, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .maxLines(3) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText09_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText09 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentIndex: number = 0; + private lineBreakStrategy: LineBreakStrategy[]=[LineBreakStrategy.GREEDY,LineBreakStrategy.HIGH_QUALITY,LineBreakStrategy.BALANCED] + private textOverflow: TextOverflow[]=[TextOverflow.None,TextOverflow.Clip,TextOverflow.Ellipsis,TextOverflow.MARQUEE] + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changetextOverflow() { + this.currentIndex = (this.currentIndex + 1) % this.colors.length; + this.myNodeController.settextOverflow(this.textOverflow[this.currentIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea textOverflow') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + Button('切换textOverflow') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiComponentFrameNodeText09_02') + .padding({ + left: 15, + right: 15 + }) + .margin({ bottom: 10 }) + .onClick( + () => this.changetextOverflow() + ) + NodeContainer(this.myNodeController); + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText10.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText10.ets new file mode 100644 index 00000000..09950a48 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText10.ets @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; + +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private message1: string = + "They can be classified as built-in components–those directly provided by the ArkUI framework and custom components – those defined by developers" + + "The built-in components include buttons radio buttonsprogress indicators and text You can set the rendering effectof thesecomponents in method " + + "chaining mode,page components are divided into independent UI units to implementindependent" + +"creation development and reuse of different units on pages making pages more engineering-oriented."; + + settextContentStyle(textContentStyle: TextContentStyle) { + this.textContentStyle = textContentStyle; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(100) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.message1, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .style(this.textContentStyle) + .maxLines(3) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText10_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText10 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentIndex: number = 0; + private lineBreakStrategy: LineBreakStrategy[]=[LineBreakStrategy.GREEDY,LineBreakStrategy.HIGH_QUALITY,LineBreakStrategy.BALANCED] + private textOverflow: TextOverflow[]=[TextOverflow.None,TextOverflow.Clip,TextOverflow.Ellipsis,TextOverflow.MARQUEE] + private textContentStyle: TextContentStyle[]=[TextContentStyle.DEFAULT,TextContentStyle.INLINE] + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changetextOverflow() { + this.currentIndex = (this.currentIndex + 1) % this.textContentStyle.length; + this.myNodeController.settextContentStyle(this.textContentStyle[this.currentIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea textContentStyle') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + Button('切换文本框多态样式') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiComponentFrameNodeText10_02') + .padding({ + left: 15, + right: 15 + }) + .margin({ bottom: 10 }) + .onClick( + () => this.changetextOverflow() + ) + NodeContainer(this.myNodeController); + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText11.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText11.ets new file mode 100644 index 00000000..0f531af1 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText11.ets @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; + +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private textalign: TextAlign = TextAlign.Center; + private message1: string = + "They can be classified as built-in components–those directly provided by the ArkUI framework and custom components – those defined by developers" + + "The built-in components include buttons radio buttonsprogress indicators and text You can set the rendering effectof thesecomponents in method " + + "chaining mode,page components are divided into independent UI units to implementindependent" + +"creation development and reuse of different units on pages making pages more engineering-oriented."; + + settextalign(textalign: TextAlign) { + this.textalign = textalign; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(300) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.message1, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .textAlign(this.textalign) + .style(this.textContentStyle) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText10_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText11 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentIndex: number = 0; + private lineBreakStrategy: LineBreakStrategy[]=[LineBreakStrategy.GREEDY,LineBreakStrategy.HIGH_QUALITY,LineBreakStrategy.BALANCED] + private textOverflow: TextOverflow[]=[TextOverflow.None,TextOverflow.Clip,TextOverflow.Ellipsis,TextOverflow.MARQUEE] + private textContentStyle: TextContentStyle[]=[TextContentStyle.DEFAULT,TextContentStyle.INLINE] + private textalign: TextAlign[]=[TextAlign.Center,TextAlign.Start,TextAlign.End] + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changetextOverflow() { + this.currentIndex = (this.currentIndex + 1) % this.textalign.length; + this.myNodeController.settextalign(this.textalign[this.currentIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea textalign') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + Button('切换textalign') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiComponentFrameNodeText11_02') + .padding({ + left: 15, + right: 15 + }) + .margin({ bottom: 10 }) + .onClick( + () => this.changetextOverflow() + ) + NodeContainer(this.myNodeController); + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText12.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText12.ets new file mode 100644 index 00000000..1cbbc0d7 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText12.ets @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; + +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private textalign: TextAlign = TextAlign.Start; + private wordBreak: WordBreak = WordBreak.NORMAL; + private message1: string = + "They can be classified as built-in components–those directly provided by the ArkUI framework and custom components – those defined by developers" + + "The built-in components include buttons radio buttonsprogress indicators and text You can set the rendering effectof thesecomponents in method " + + "chaining mode,page components are divided into independent UI units to implementindependent" + +"creation development and reuse of different units on pages making pages more engineering-oriented."; + + setwordBreak(wordBreak: WordBreak) { + this.wordBreak = wordBreak; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(300) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.message1, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .wordBreak(this.wordBreak) + .textAlign(this.textalign) + .style(this.textContentStyle) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText12_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText12 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentIndex: number = 0; + private lineBreakStrategy: LineBreakStrategy[]=[LineBreakStrategy.GREEDY,LineBreakStrategy.HIGH_QUALITY,LineBreakStrategy.BALANCED] + private textOverflow: TextOverflow[]=[TextOverflow.None,TextOverflow.Clip,TextOverflow.Ellipsis,TextOverflow.MARQUEE] + private textContentStyle: TextContentStyle[]=[TextContentStyle.DEFAULT,TextContentStyle.INLINE] + private textalign: TextAlign[]=[TextAlign.Center,TextAlign.Start,TextAlign.End] + private wordBreak: WordBreak[] = [WordBreak.NORMAL,WordBreak.BREAK_ALL,WordBreak.BREAK_WORD]; + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changetextOverflow() { + this.currentIndex = (this.currentIndex + 1) % this.wordBreak.length; + this.myNodeController.setwordBreak(this.wordBreak[this.currentIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea wordBreak') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + Button('切换wordBreak') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiComponentFrameNodeText12_02') + .padding({ + left: 15, + right: 15 + }) + .margin({ bottom: 10 }) + .onClick( + () => this.changetextOverflow() + ) + NodeContainer(this.myNodeController); + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText13.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText13.ets new file mode 100644 index 00000000..70420858 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText13.ets @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; + +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private textalign: TextAlign = TextAlign.Start; + private wordBreak: WordBreak = WordBreak.NORMAL; + private selectedcolor: ResourceColor = Color.Green; + private message1: string = + "They can be classified as built-in components–those directly provided by the ArkUI framework and custom components – those defined by developers" + + "The built-in components include buttons radio buttonsprogress indicators and text You can set the rendering effectof thesecomponents in method " + + "chaining mode,page components are divided into independent UI units to implementindependent" + +"creation development and reuse of different units on pages making pages more engineering-oriented."; + + setselectedcolor(selectedcolor: ResourceColor) { + this.selectedcolor = selectedcolor; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(100) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.message1, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .selectedBackgroundColor(this.selectedcolor) + .wordBreak(this.wordBreak) + .textAlign(this.textalign) + .style(this.textContentStyle) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText13_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText13 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentIndex: number = 0; + private selectedcolor: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changeselectedcolor() { + this.currentIndex = (this.currentIndex + 1) % this.selectedcolor.length; + this.myNodeController.setselectedcolor(this.selectedcolor[this.currentIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea selectedcolor') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + Button('切换selectedcolor') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiComponentFrameNodeText13_02') + .padding({ + left: 15, + right: 15 + }) + .margin({ bottom: 10 }) + .onClick( + () => this.changeselectedcolor() + ) + NodeContainer(this.myNodeController); + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText14.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText14.ets new file mode 100644 index 00000000..59c065d7 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText14.ets @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; + +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private textalign: TextAlign = TextAlign.Start; + private wordBreak: WordBreak = WordBreak.NORMAL; + private selectedcolor: ResourceColor = Color.Green; + private decoration: TextDecorationStyle = TextDecorationStyle.SOLID; + private message1: string = + "They can be classified as built-in components–those directly provided by the ArkUI framework and custom components – those defined by developers" + + "The built-in components include buttons radio buttonsprogress indicators and text You can set the rendering effectof thesecomponents in method " + + "chaining mode,page components are divided into independent UI units to implementindependent" + +"creation development and reuse of different units on pages making pages more engineering-oriented."; + + setdecoration(decoration: TextDecorationStyle) { + this.decoration = decoration; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(300) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.message1, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .decoration({ + type: TextDecorationType.LineThrough, + color: Color.Red, + style: this.decoration + }) + .selectedBackgroundColor(this.selectedcolor) + .wordBreak(this.wordBreak) + .textAlign(this.textalign) + .style(this.textContentStyle) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText14_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText14 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentIndex: number = 0; + private selectedcolor: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private decoration: TextDecorationStyle[] = [TextDecorationStyle.SOLID,TextDecorationStyle.DOUBLE,TextDecorationStyle.DOTTED, + TextDecorationStyle.DASHED,TextDecorationStyle.WAVY]; + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changeselectedcolor() { + this.currentIndex = (this.currentIndex + 1) % this.decoration.length; + this.myNodeController.setdecoration(this.decoration[this.currentIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea decoration') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + Button('切换decoration') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiComponentFrameNodeText14_02') + .padding({ + left: 15, + right: 15 + }) + .margin({ bottom: 10 }) + .onClick( + () => this.changeselectedcolor() + ) + NodeContainer(this.myNodeController); + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText15.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText15.ets new file mode 100644 index 00000000..bc0cd607 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText15.ets @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; + +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private textalign: TextAlign = TextAlign.Start; + private wordBreak: WordBreak = WordBreak.NORMAL; + private selectedcolor: ResourceColor = Color.Green; + private decoration: TextDecorationStyle = TextDecorationStyle.SOLID; + private letterSpacing: number | string | Resource =3; + private message1: string = + "They can be classified as built-in components–those directly provided by the ArkUI framework and custom components – those defined by developers" + + "The built-in components include buttons radio buttonsprogress indicators and text You can set the rendering effectof thesecomponents in method " + + "chaining mode,page components are divided into independent UI units to implementindependent" + +"creation development and reuse of different units on pages making pages more engineering-oriented."; + + setletterSpacing(letterSpacing: number | string | Resource) { + this.letterSpacing = letterSpacing; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(300) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.message1, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .letterSpacing(this.letterSpacing) + .decoration({ + type: TextDecorationType.LineThrough, + color: Color.Red, + style: this.decoration + }) + .selectedBackgroundColor(this.selectedcolor) + .wordBreak(this.wordBreak) + .textAlign(this.textalign) + .style(this.textContentStyle) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText15_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText15 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentIndex: number = 0; + private selectedcolor: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private letterSpacing: (number | string | Resource)[] = [0, '3vp', $r('app.string.letterSpacing')]; + private decoration: TextDecorationStyle[] = [TextDecorationStyle.SOLID,TextDecorationStyle.DOUBLE,TextDecorationStyle.DOTTED, + TextDecorationStyle.DASHED,TextDecorationStyle.WAVY]; + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changeselectedcolor() { + this.currentIndex = (this.currentIndex + 1) % this.letterSpacing.length; + this.myNodeController.setletterSpacing(this.letterSpacing[this.currentIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea letterSpacing') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + Button('切换letterSpacing') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiComponentFrameNodeText15_02') + .padding({ + left: 15, + right: 15 + }) + .margin({ bottom: 10 }) + .onClick( + () => this.changeselectedcolor() + ) + NodeContainer(this.myNodeController); + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText16.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText16.ets new file mode 100644 index 00000000..d7f99aef --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText16.ets @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; + +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private textalign: TextAlign = TextAlign.Start; + private wordBreak: WordBreak = WordBreak.NORMAL; + private selectedcolor: ResourceColor = Color.Green; + private decoration: TextDecorationStyle = TextDecorationStyle.SOLID; + private letterSpacing: number | string | Resource =3; + private enterKeyType: EnterKeyType =EnterKeyType.Next; + private message1: string = + "They can be classified as built-in components–those directly provided by the ArkUI framework and custom components – those defined by developers" + + "The built-in components include buttons radio buttonsprogress indicators and text You can set the rendering effectof thesecomponents in method " + + "chaining mode,page components are divided into independent UI units to implementindependent" + +"creation development and reuse of different units on pages making pages more engineering-oriented."; + + setenterKeyType(enterKeyType: EnterKeyType) { + this.letterSpacing = enterKeyType; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(300) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.message1, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .letterSpacing(this.letterSpacing) + .decoration({ + type: TextDecorationType.LineThrough, + color: Color.Red, + style: this.decoration + }) + .enterKeyType(this.enterKeyType) + .selectedBackgroundColor(this.selectedcolor) + .wordBreak(this.wordBreak) + .textAlign(this.textalign) + .style(this.textContentStyle) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText16_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText16 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentIndex: number = 0; + private selectedcolor: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private letterSpacing: (number | string | Resource)[] = [0, '3vp', $r('app.string.letterSpacing')]; + private decoration: TextDecorationStyle[] = [TextDecorationStyle.SOLID,TextDecorationStyle.DOUBLE,TextDecorationStyle.DOTTED, + TextDecorationStyle.DASHED,TextDecorationStyle.WAVY]; + private entertype: EnterKeyType[] = [EnterKeyType.Go,EnterKeyType.Search,EnterKeyType.Send, + EnterKeyType.Next,EnterKeyType.Done,EnterKeyType.PREVIOUS,EnterKeyType.NEW_LINE]; + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changeselectedcolor() { + this.currentIndex = (this.currentIndex + 1) % this.entertype.length; + this.myNodeController.setenterKeyType(this.entertype[this.currentIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea entertypr') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + Button('切换entertypr') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiComponentFrameNodeText16_02') + .padding({ + left: 15, + right: 15 + }) + .margin({ bottom: 10 }) + .onClick( + () => this.changeselectedcolor() + ) + NodeContainer(this.myNodeController); + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText17.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText17.ets new file mode 100644 index 00000000..a2d7932f --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText17.ets @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; + +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private textalign: TextAlign = TextAlign.Start; + private wordBreak: WordBreak = WordBreak.NORMAL; + private selectedcolor: ResourceColor = Color.Green; + private decoration: TextDecorationStyle = TextDecorationStyle.SOLID; + private letterSpacing: number | string | Resource =3; + private enterKeyType: EnterKeyType =EnterKeyType.Next; + private textIndent: Dimension ='10px'; + private message1: string = + "They can be classified as built-in components–those directly provided by the ArkUI framework and custom components – those defined by developers" + + "The built-in components include buttons radio buttonsprogress indicators and text You can set the rendering effectof thesecomponents in method " + + "chaining mode,page components are divided into independent UI units to implementindependent" + +"creation development and reuse of different units on pages making pages more engineering-oriented."; + + settextIndent(textIndent: Dimension) { + this.letterSpacing = textIndent; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(300) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.message1, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .letterSpacing(this.letterSpacing) + .decoration({ + type: TextDecorationType.LineThrough, + color: Color.Red, + style: this.decoration + }) + .textIndent(this.textIndent) + .enterKeyType(this.enterKeyType) + .selectedBackgroundColor(this.selectedcolor) + .wordBreak(this.wordBreak) + .textAlign(this.textalign) + .style(this.textContentStyle) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText17_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText17 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentIndex: number = 0; + private selectedcolor: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private letterSpacing: (number | string | Resource)[] = [0, '3vp', $r('app.string.letterSpacing')]; + private decoration: TextDecorationStyle[] = [TextDecorationStyle.SOLID,TextDecorationStyle.DOUBLE,TextDecorationStyle.DOTTED, + TextDecorationStyle.DASHED,TextDecorationStyle.WAVY]; + private entertype: EnterKeyType[] = [EnterKeyType.Go,EnterKeyType.Search,EnterKeyType.Send, + EnterKeyType.Next,EnterKeyType.Done,EnterKeyType.PREVIOUS,EnterKeyType.NEW_LINE]; + private textIndent: Dimension[] = ['10px','10vp','10fp','10lpx','10%',$r('app.string.textIndent')]; + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changetextIndent() { + this.currentIndex = (this.currentIndex + 1) % this.textIndent.length; + this.myNodeController.settextIndent(this.textIndent[this.currentIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea textIndent') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + Button('切换textIndent') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiComponentFrameNodeText17_02') + .padding({ + left: 15, + right: 15 + }) + .margin({ bottom: 10 }) + .onClick( + () => this.changetextIndent() + ) + NodeContainer(this.myNodeController); + } + } +} -- Gitee From 9b00c30f9dc1e38c1e046250e87bac3b3346f4fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A6=83=E8=B4=9E=E5=BA=86?= Date: Thu, 7 Aug 2025 20:30:19 +0800 Subject: [PATCH 5/5] =?UTF-8?q?[ui=E5=AF=B9=E6=AF=94]=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?UiComponentFrameNodeText29=E6=9D=A1=E7=94=A8=E4=BE=8B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 覃贞庆 --- .../UiComponentFrameNodeText18.ets | 197 +++++++++++++++++ .../UiComponentFrameNodeText19.ets | 200 +++++++++++++++++ .../UiComponentFrameNodeText20.ets | 196 +++++++++++++++++ .../UiComponentFrameNodeText21.ets | 190 ++++++++++++++++ .../UiComponentFrameNodeText22.ets | 162 ++++++++++++++ .../UiComponentFrameNodeText23.ets | 208 ++++++++++++++++++ .../UiComponentFrameNodeText24.ets | 169 ++++++++++++++ .../UiComponentFrameNodeText25.ets | 201 +++++++++++++++++ .../UiComponentFrameNodeText26.ets | 186 ++++++++++++++++ 9 files changed, 1709 insertions(+) create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText18.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText19.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText20.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText21.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText22.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText23.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText24.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText25.ets create mode 100644 sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText26.ets diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText18.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText18.ets new file mode 100644 index 00000000..6aa93a7f --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText18.ets @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; + +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private textalign: TextAlign = TextAlign.Start; + private wordBreak: WordBreak = WordBreak.NORMAL; + private selectedcolor: ResourceColor = Color.Green; + private decoration: TextDecorationStyle = TextDecorationStyle.SOLID; + private letterSpacing: number | string | Resource =3; + private enterKeyType: EnterKeyType =EnterKeyType.Next; + private textIndent: Dimension ='10px'; + private lineHeight: number | string | Resource =20; + private message1: string = + "They can be classified as built-in components–those directly provided by the ArkUI framework and custom components – those defined by developers" + + "The built-in components include buttons radio buttonsprogress indicators and text You can set the rendering effectof thesecomponents in method " + + "chaining mode,page components are divided into independent UI units to implementindependent" + +"creation development and reuse of different units on pages making pages more engineering-oriented."; + + setlineHeight(lineHeight: number | string | Resource) { + this.lineHeight = lineHeight; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(300) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.message1, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .letterSpacing(this.letterSpacing) + .decoration({ + type: TextDecorationType.LineThrough, + color: Color.Red, + style: this.decoration + }) + .lineHeight(this.lineHeight) + .textIndent(this.textIndent) + .enterKeyType(this.enterKeyType) + .selectedBackgroundColor(this.selectedcolor) + .wordBreak(this.wordBreak) + .textAlign(this.textalign) + .style(this.textContentStyle) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText18_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText18 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentIndex: number = 0; + private selectedcolor: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private letterSpacing: (number | string | Resource)[] = [0, '3vp', $r('app.string.letterSpacing')]; + private decoration: TextDecorationStyle[] = [TextDecorationStyle.SOLID,TextDecorationStyle.DOUBLE,TextDecorationStyle.DOTTED, + TextDecorationStyle.DASHED,TextDecorationStyle.WAVY]; + private entertype: EnterKeyType[] = [EnterKeyType.Go,EnterKeyType.Search,EnterKeyType.Send, + EnterKeyType.Next,EnterKeyType.Done,EnterKeyType.PREVIOUS,EnterKeyType.NEW_LINE]; + private textIndent: Dimension[] = ['10px','10vp','10fp','10lpx','10%',$r('app.string.textIndent')]; + private lineHeight: (number | string | Resource)[] = [20, '30', $r('app.string.letterSpacing')]; + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changelineHeight() { + this.currentIndex = (this.currentIndex + 1) % this.lineHeight.length; + this.myNodeController.setlineHeight(this.lineHeight[this.currentIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea lineHeight') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + Button('切换textIndent') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiComponentFrameNodeText18_02') + .padding({ + left: 15, + right: 15 + }) + .margin({ bottom: 10 }) + .onClick( + () => this.changelineHeight() + ) + NodeContainer(this.myNodeController); + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText19.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText19.ets new file mode 100644 index 00000000..2dd0ecb0 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText19.ets @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; + +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private textalign: TextAlign = TextAlign.Start; + private wordBreak: WordBreak = WordBreak.NORMAL; + private selectedcolor: ResourceColor = Color.Green; + private decoration: TextDecorationStyle = TextDecorationStyle.SOLID; + private letterSpacing: number | string | Resource =3; + private enterKeyType: EnterKeyType =EnterKeyType.Next; + private textIndent: Dimension ='10px'; + private lineHeight: number | string | Resource =20; + private barState: BarState =BarState.Off; + private message1: string = + "They can be classified as built-in components–those directly provided by the ArkUI framework and custom components – those defined by developers" + + "The built-in components include buttons radio buttonsprogress indicators and text You can set the rendering effectof thesecomponents in method " + + "chaining mode,page components are divided into independent UI units to implementindependent" + +"creation development and reuse of different units on pages making pages more engineering-oriented."; + + setbarState(barState: BarState) { + this.barState = barState; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(300) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.message1, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .letterSpacing(this.letterSpacing) + .decoration({ + type: TextDecorationType.LineThrough, + color: Color.Red, + style: this.decoration + }) + .barState(this.barState) + .lineHeight(this.lineHeight) + .textIndent(this.textIndent) + .enterKeyType(this.enterKeyType) + .selectedBackgroundColor(this.selectedcolor) + .wordBreak(this.wordBreak) + .textAlign(this.textalign) + .style(this.textContentStyle) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText19_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText19 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentIndex: number = 0; + private selectedcolor: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private letterSpacing: (number | string | Resource)[] = [0, '3vp', $r('app.string.letterSpacing')]; + private decoration: TextDecorationStyle[] = [TextDecorationStyle.SOLID,TextDecorationStyle.DOUBLE,TextDecorationStyle.DOTTED, + TextDecorationStyle.DASHED,TextDecorationStyle.WAVY]; + private entertype: EnterKeyType[] = [EnterKeyType.Go,EnterKeyType.Search,EnterKeyType.Send, + EnterKeyType.Next,EnterKeyType.Done,EnterKeyType.PREVIOUS,EnterKeyType.NEW_LINE]; + private textIndent: Dimension[] = ['10px','10vp','10fp','10lpx','10%',$r('app.string.textIndent')]; + private lineHeight: (number | string | Resource)[] = [20, '30', $r('app.string.letterSpacing')]; + private barstate: BarState[] = [BarState.Off,BarState.Auto,BarState.On]; + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changebarstate() { + this.currentIndex = (this.currentIndex + 1) % this.barstate.length; + this.myNodeController.setbarState(this.barstate[this.currentIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea barState') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + Button('切换barState') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiComponentFrameNodeText19_02') + .padding({ + left: 15, + right: 15 + }) + .margin({ bottom: 10 }) + .onClick( + () => this.changebarstate() + ) + NodeContainer(this.myNodeController); + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText20.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText20.ets new file mode 100644 index 00000000..954fbd19 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText20.ets @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; + +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private textalign: TextAlign = TextAlign.Start; + private wordBreak: WordBreak = WordBreak.NORMAL; + private selectedcolor: ResourceColor = Color.Green; + private decoration: TextDecorationStyle = TextDecorationStyle.SOLID; + private letterSpacing: number | string | Resource =3; + private enterKeyType: EnterKeyType =EnterKeyType.Next; + private textIndent: Dimension ='10px'; + private lineHeight: number | string | Resource =20; + private barState: BarState =BarState.Off; + private textAreaType: TextAreaType =TextAreaType.NORMAL; + private message1: string = + "1234 https: as built-in components–those directly provided by the ArkUI framework and custom components – those defined by developers" + + "The built-in components include buttons radio buttonsprogress indicators and text You can set the rendering effectof thesecomponents in method " + + "chaining mode,page components are divided into independent UI units to implementindependent" + +"creation development and reuse of different units on pages making pages more engineering-oriented."; + + settextAreaType(textAreaType: TextAreaType) { + this.textAreaType = textAreaType; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(300) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.message1, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .letterSpacing(this.letterSpacing) + .decoration({ + type: TextDecorationType.LineThrough, + color: Color.Red, + style: this.decoration + }) + .type(this.textAreaType) + .barState(this.barState) + .lineHeight(this.lineHeight) + .textIndent(this.textIndent) + .enterKeyType(this.enterKeyType) + .selectedBackgroundColor(this.selectedcolor) + .wordBreak(this.wordBreak) + .textAlign(this.textalign) + .style(this.textContentStyle) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText20_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText20 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentIndex: number = 0; + private barstate: BarState[] = [BarState.Off,BarState.Auto,BarState.On]; + private textAreaType: TextAreaType[] = [TextAreaType.NORMAL,TextAreaType.NUMBER,TextAreaType.PHONE_NUMBER,TextAreaType.EMAIL, + TextAreaType.NUMBER_DECIMAL,TextAreaType.URL,TextAreaType.ONE_TIME_CODE]; + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changetextAreaType() { + this.currentIndex = (this.currentIndex + 1) % this.textAreaType.length; + this.myNodeController.settextAreaType(this.textAreaType[this.currentIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea textAreaType') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + Button('切换textAreaType') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiComponentFrameNodeText20_02') + .padding({ + left: 15, + right: 15 + }) + .margin({ bottom: 10 }) + .onClick( + () => this.changetextAreaType() + ) + NodeContainer(this.myNodeController); + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText21.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText21.ets new file mode 100644 index 00000000..584c8580 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText21.ets @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; + +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private textalign: TextAlign = TextAlign.Start; + private selectedcolor: ResourceColor = Color.Green; + private decoration: TextDecorationStyle = TextDecorationStyle.SOLID; + private enterKeyType: EnterKeyType =EnterKeyType.Next; + private barState: BarState =BarState.Off; + private textAreaType: TextAreaType =TextAreaType.NORMAL; + private textHeightAdaptivePolicy: TextHeightAdaptivePolicy =TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST; + private message1: string = + "1234 https: as built-in components–those directly provided by the ArkUI framework and custom components – those defined by developers" + + "The built-in components include buttons radio buttonsprogress indicators and text You can set the rendering effectof thesecomponents in method " + + "chaining mode,page components are divided into independent UI units to implementindependent" + +"creation development and reuse of different units on pages making pages more engineering-oriented."; + + settextHeightAdaptivePolicy(textHeightAdaptivePolicy: TextHeightAdaptivePolicy) { + this.textHeightAdaptivePolicy = textHeightAdaptivePolicy; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(300) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.message1, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .minFontSize(4) + .maxFontSize(20) + .heightAdaptivePolicy(this.textHeightAdaptivePolicy) + .decoration({ + type: TextDecorationType.LineThrough, + color: Color.Red, + style: this.decoration + }) + .type(this.textAreaType) + .barState(this.barState) + .enterKeyType(this.enterKeyType) + .selectedBackgroundColor(this.selectedcolor) + .textAlign(this.textalign) + .style(this.textContentStyle) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText21_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText21 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentIndex: number = 0; + private textHeightAdaptivePolicy: TextHeightAdaptivePolicy[] =[TextHeightAdaptivePolicy.MAX_LINES_FIRST + ,TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST,TextHeightAdaptivePolicy.LAYOUT_CONSTRAINT_FIRST]; + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changetextAreaType() { + this.currentIndex = (this.currentIndex + 1) % this.textHeightAdaptivePolicy.length; + this.myNodeController.settextHeightAdaptivePolicy(this.textHeightAdaptivePolicy[this.currentIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea textHeightAdaptivePolicy') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + Button('切换textHeightAdaptivePolicy') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiComponentFrameNodeText21_02') + .padding({ + left: 15, + right: 15 + }) + .margin({ bottom: 10 }) + .onClick( + () => this.changetextAreaType() + ) + NodeContainer(this.myNodeController); + } + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText22.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText22.ets new file mode 100644 index 00000000..21962f7d --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText22.ets @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; + +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private textalign: TextAlign = TextAlign.Start; + private selectedcolor: ResourceColor = Color.Green; + private decoration: TextDecorationStyle = TextDecorationStyle.SOLID; + private enterKeyType: EnterKeyType =EnterKeyType.Next; + private barState: BarState =BarState.Off; + private textAreaType: TextAreaType =TextAreaType.NORMAL; + private textHeightAdaptivePolicy: TextHeightAdaptivePolicy =TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST; + + settextHeightAdaptivePolicy(textHeightAdaptivePolicy: TextHeightAdaptivePolicy) { + this.textHeightAdaptivePolicy = textHeightAdaptivePolicy; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(100) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.text, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .maxLength(4) + .showCounter(true,{ thresholdPercentage: 50, highlightBorder: true }) + .minFontSize(4) + .maxFontSize(20) + .heightAdaptivePolicy(this.textHeightAdaptivePolicy) + .decoration({ + type: TextDecorationType.LineThrough, + color: Color.Red, + style: this.decoration + }) + .type(this.textAreaType) + .barState(this.barState) + .enterKeyType(this.enterKeyType) + .selectedBackgroundColor(this.selectedcolor) + .textAlign(this.textalign) + .style(this.textContentStyle) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText22_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText22 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentIndex: number = 0; + private textHeightAdaptivePolicy: TextHeightAdaptivePolicy[] =[TextHeightAdaptivePolicy.MAX_LINES_FIRST + ,TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST,TextHeightAdaptivePolicy.LAYOUT_CONSTRAINT_FIRST]; + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changetextAreaType() { + this.currentIndex = (this.currentIndex + 1) % this.textHeightAdaptivePolicy.length; + this.myNodeController.settextHeightAdaptivePolicy(this.textHeightAdaptivePolicy[this.currentIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea maxLength and showCounter') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + NodeContainer(this.myNodeController); + } + } +} \ No newline at end of file diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText23.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText23.ets new file mode 100644 index 00000000..88fb0af9 --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText23.ets @@ -0,0 +1,208 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; +type InputFilter = [ + value: ResourceStr, + error?: (value: string) => void +]; +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private textalign: TextAlign = TextAlign.Start; + private wordBreak: WordBreak = WordBreak.NORMAL; + private selectedcolor: ResourceColor = Color.Green; + private decoration: TextDecorationStyle = TextDecorationStyle.SOLID; + private letterSpacing: number | string | Resource =3; + private enterKeyType: EnterKeyType =EnterKeyType.Next; + private textIndent: Dimension ='10px'; + private lineHeight: number | string | Resource =20; + private barState: BarState =BarState.Off; + private textAreaType: TextAreaType =TextAreaType.NORMAL; + private inputFilter: InputFilter = ['[a-zA-Z]+', (value) => { + console.error(`unsupport char ${value}`); + }]; + private message1: string = + "1234 https: as built-in components–those directly provided by the ArkUI framework and custom components – those defined by developers" + + "The built-in components include buttons radio buttonsprogress indicators and text You can set the rendering effectof thesecomponents in method " + + "chaining mode,page components are divided into independent UI units to implementindependent" + +"creation development and reuse of different units on pages making pages more engineering-oriented."; + + setinputFilter(inputFilter: InputFilter) { + this.inputFilter = inputFilter; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(50) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.text, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .inputFilter(this.inputFilter[0]) + .letterSpacing(this.letterSpacing) + .decoration({ + type: TextDecorationType.LineThrough, + color: Color.Red, + style: this.decoration + }) + .type(this.textAreaType) + .barState(this.barState) + .lineHeight(this.lineHeight) + .textIndent(this.textIndent) + .enterKeyType(this.enterKeyType) + .selectedBackgroundColor(this.selectedcolor) + .wordBreak(this.wordBreak) + .textAlign(this.textalign) + .style(this.textContentStyle) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText23_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText23 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private colors: ResourceColor[] = [Color.Green, 0xff0000, '#ff00ff',$r('app.color.ColorRed')]; + private currentIndex: number = 0; + private barstate: BarState[] = [BarState.Off,BarState.Auto,BarState.On]; + private textAreaType: TextAreaType[] = [TextAreaType.NORMAL,TextAreaType.NUMBER,TextAreaType.PHONE_NUMBER,TextAreaType.EMAIL, + TextAreaType.NUMBER_DECIMAL,TextAreaType.URL,TextAreaType.ONE_TIME_CODE]; + private inputFilter: InputFilter[] = [['[a-zA-Z]+', (value) => { + console.error(`unsupport char ${value}`); + }],['[0-9]', (value) => { + console.error(`unsupport char ${value}`); + }]] + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + private changeinputFilter() { + this.currentIndex = (this.currentIndex + 1) % this.inputFilter.length; + this.myNodeController.setinputFilter(this.inputFilter[this.currentIndex]); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea inputFilter') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + NodeContainer(this.myNodeController); + Button('切换inputFilter') + .fontSize(10) + .height(100) + .backgroundColor(0x317aff) + .width('90%') + .labelStyle({ overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 10, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .id('UiComponentFrameNodeText23_02') + .padding({ + left: 15, + right: 15 + }) + .margin({ bottom: 10 }) + .onClick( + () => this.changeinputFilter() + ) + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText24.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText24.ets new file mode 100644 index 00000000..6dde35bc --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText24.ets @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; +type InputFilter = [ + value: ResourceStr, + error?: (value: string) => void +]; +class MyNodeController extends NodeController { + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private textalign: TextAlign = TextAlign.Start; + private wordBreak: WordBreak = WordBreak.NORMAL; + private selectedcolor: ResourceColor = Color.Green; + private decoration: TextDecorationStyle = TextDecorationStyle.SOLID; + private letterSpacing: number | string | Resource =3; + private enterKeyType: EnterKeyType =EnterKeyType.Next; + private textIndent: Dimension ='10px'; + private lineHeight: number | string | Resource =20; + private barState: BarState =BarState.Off; + private textAreaType: TextAreaType =TextAreaType.NORMAL; + private inputFilter: InputFilter = ['[a-zA-Z]+', (value) => { + console.error(`unsupport char ${value}`); + }]; + + setinputFilter(inputFilter: InputFilter) { + this.inputFilter = inputFilter; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(200) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.text, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .selectionMenuHidden(false) + .inputFilter(this.inputFilter[0]) + .letterSpacing(this.letterSpacing) + .decoration({ + type: TextDecorationType.LineThrough, + color: Color.Red, + style: this.decoration + }) + .type(this.textAreaType) + .barState(this.barState) + .lineHeight(this.lineHeight) + .textIndent(this.textIndent) + .enterKeyType(this.enterKeyType) + .selectedBackgroundColor(this.selectedcolor) + .wordBreak(this.wordBreak) + .textAlign(this.textalign) + .style(this.textContentStyle) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText24_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText24 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private inputFilter: InputFilter[] = [['[a-zA-Z]+', (value) => { + console.error(`unsupport char ${value}`); + }],['[0-9]', (value) => { + console.error(`unsupport char ${value}`); + }]] + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea selectionMenuHidden to false') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + NodeContainer(this.myNodeController); + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText25.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText25.ets new file mode 100644 index 00000000..46b5790f --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText25.ets @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; +type InputFilter = [ + value: ResourceStr, + error?: (value: string) => void +]; +class MyNodeController extends NodeController { + onCreateMenu = (menuItems: Array) => { + let item1: TextMenuItem = { + content: 'custom1', + icon: $r('app.media.icon'), + id: TextMenuItemId.of('custom1'), + }; + let item2: TextMenuItem = { + content: 'custom2', + id: TextMenuItemId.of('custom2'), + icon: $r('app.media.icon'), + }; + menuItems.push(item1) + menuItems.unshift(item2) + return menuItems + }; + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private textalign: TextAlign = TextAlign.Start; + private wordBreak: WordBreak = WordBreak.NORMAL; + private selectedcolor: ResourceColor = Color.Green; + private decoration: TextDecorationStyle = TextDecorationStyle.SOLID; + private letterSpacing: number | string | Resource =3; + private enterKeyType: EnterKeyType =EnterKeyType.Next; + private textIndent: Dimension ='10px'; + private lineHeight: number | string | Resource =20; + private barState: BarState =BarState.Off; + private textAreaType: TextAreaType =TextAreaType.NORMAL; + private inputFilter: InputFilter = ['[a-zA-Z]+', (value) => { + console.error(`unsupport char ${value}`); + }]; + + setinputFilter(inputFilter: InputFilter) { + this.inputFilter = inputFilter; + this.rebuild(); + } + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(200) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.text, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .editMenuOptions({ + onCreateMenu: this.onCreateMenu, onMenuItemClick: (menuItem: TextMenuItem, textRange: TextRange) => { + if (menuItem.id.equals(TextMenuItemId.of("custom2"))) { + console.log("拦截 id: custom2 start:" + textRange.start + "; end:" + textRange.end) + return true; + } + if (menuItem.id.equals(TextMenuItemId.COPY)) { + console.log("拦截 COPY start:" + textRange.start + "; end:" + textRange.end) + return true; + } + if (menuItem.id.equals(TextMenuItemId.SELECT_ALL)) { + console.log("不拦截 SELECT_ALL start:" + textRange.start + "; end:" + textRange.end) + return false; + } + return false; + } + }) + .selectionMenuHidden(false) + .inputFilter(this.inputFilter[0]) + .letterSpacing(this.letterSpacing) + .decoration({ + type: TextDecorationType.LineThrough, + color: Color.Red, + style: this.decoration + }) + .type(this.textAreaType) + .barState(this.barState) + .lineHeight(this.lineHeight) + .textIndent(this.textIndent) + .enterKeyType(this.enterKeyType) + .selectedBackgroundColor(this.selectedcolor) + .wordBreak(this.wordBreak) + .textAlign(this.textalign) + .style(this.textContentStyle) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText25_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText25 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + private inputFilter: InputFilter[] = [['[a-zA-Z]+', (value) => { + console.error(`unsupport char ${value}`); + }],['[0-9]', (value) => { + console.error(`unsupport char ${value}`); + }]] + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea selectionMenuHidden to false') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + NodeContainer(this.myNodeController); + } + } +} diff --git a/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText26.ets b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText26.ets new file mode 100644 index 00000000..94a2e69f --- /dev/null +++ b/sample/ui_compare/uiCompareTest_02/entry/src/ohosTest/ets/testability/pages/UiComponentFrameNodeText/UiComponentFrameNodeText26.ets @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeController, FrameNode, typeNode } from '@kit.ArkUI'; +type InputFilter = [ + value: ResourceStr, + error?: (value: string) => void +]; +class MyNodeController extends NodeController { + onCreateMenu = (menuItems: Array) => { + let item1: TextMenuItem = { + content: 'custom1', + icon: $r('app.media.icon'), + id: TextMenuItemId.of('custom1'), + }; + let item2: TextMenuItem = { + content: 'custom2', + id: TextMenuItemId.of('custom2'), + icon: $r('app.media.icon'), + }; + menuItems.push(item1) + menuItems.unshift(item2) + return menuItems + }; + private onWillInsert: ((offset: number, value: string) => void) | null = null; + private areaController: TextAreaController = new TextAreaController(); + private text: string = '123456789' ; + private insertOffset: number = 0 ; + private insertValue: string = '' ; + private placeholderColor: ResourceColor = Color.Green; + private lineBreakStrategy: LineBreakStrategy = LineBreakStrategy.GREEDY; + private textOverflow: TextOverflow = TextOverflow.None; + private textContentStyle: TextContentStyle = TextContentStyle.DEFAULT; + private textalign: TextAlign = TextAlign.Start; + private wordBreak: WordBreak = WordBreak.NORMAL; + private selectedcolor: ResourceColor = Color.Green; + private letterSpacing: number | string | Resource =3; + private enterKeyType: EnterKeyType =EnterKeyType.Next; + private textIndent: Dimension ='10px'; + private lineHeight: number | string | Resource =20; + private barState: BarState =BarState.Off; + private textAreaType: TextAreaType =TextAreaType.NORMAL; + + setonWillInsertCallback(callback: (offset: number, value: string) => void) { + this.onWillInsert = callback; + } + + makeNode(uiContext: UIContext): FrameNode | null { + let node = new FrameNode(uiContext); + node.commonAttribute + .width(300) + .height(200) + .borderColor(Color.Gray) + .borderWidth(1) + .margin({ left: 10 }); + + let col = typeNode.createNode(uiContext, 'Column'); + col.initialize({ space: 5 }) + .width('100%') + .height('100%') + .margin({ top: 5 }); + node.appendChild(col); + + let textArea = typeNode.createNode(uiContext, "TextArea") + textArea.initialize({ + text: this.text, + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.areaController + }) + .onWillInsert((info: InsertValue) => { + this.insertOffset = info.insertOffset + this.insertValue = info.insertValue + this.onWillInsert?.(this.insertOffset, this.insertValue); + return true; + }) + .editMenuOptions({ + onCreateMenu: this.onCreateMenu, onMenuItemClick: (menuItem: TextMenuItem, textRange: TextRange) => { + if (menuItem.id.equals(TextMenuItemId.of("custom2"))) { + console.log("拦截 id: custom2 start:" + textRange.start + "; end:" + textRange.end) + return true; + } + if (menuItem.id.equals(TextMenuItemId.COPY)) { + console.log("拦截 COPY start:" + textRange.start + "; end:" + textRange.end) + return true; + } + if (menuItem.id.equals(TextMenuItemId.SELECT_ALL)) { + console.log("不拦截 SELECT_ALL start:" + textRange.start + "; end:" + textRange.end) + return false; + } + return false; + } + }) + .fontFeature("\"ss01\" on") + .selectionMenuHidden(false) + .letterSpacing(this.letterSpacing) + .decoration({ + type: TextDecorationType.None, + color: Color.Red, + }) + .type(this.textAreaType) + .barState(this.barState) + .lineHeight(this.lineHeight) + .textIndent(this.textIndent) + .enterKeyType(this.enterKeyType) + .selectedBackgroundColor(this.selectedcolor) + .wordBreak(this.wordBreak) + .textAlign(this.textalign) + .style(this.textContentStyle) + .textOverflow(this.textOverflow) + .placeholderColor(this.placeholderColor) + .lineBreakStrategy(this.lineBreakStrategy) + .fontColor(Color.Black) + .fontSize(16) + .enterKeyType(EnterKeyType.Go) + .id('UiComponentFrameNodeText26_01') + + col.appendChild(textArea); + return node; + } +} + +@Entry +@Component +struct UiComponentFrameNodeText26 { + private myNodeController: MyNodeController = new MyNodeController(); + @State text :string ='没触发submit回调' + @State insertInfo:string='没触发onWillInsert回调' + + aboutToAppear() { + this.myNodeController.setonWillInsertCallback((offset, value) => { + this.insertInfo = `插入位置:${offset},插入内容:${value || '空'}`; + }); + } + + build() { + Column() { + Row(){ + Text('FrameNode set textarea fontFeature to ss01') + .fontSize(15) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bolder) + .width('90%') + .lineHeight(20) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + + Row(){ + Text(this.insertInfo) + .fontSize(15) + .width('90%') + .lineHeight(20) + .margin(30) + .padding(10) + .fontColor(Color.Black) + .fontStyle(FontStyle.Italic) + .margin({ + left: 6, + right: 6, + bottom:30, + top:10 + }) + } + .width('100%') + .height(100) + + NodeContainer(this.myNodeController); + } + } +} -- Gitee