From dcf94a51e2458e93557cb5b972e31ba13babe320 Mon Sep 17 00:00:00 2001 From: hekun Date: Fri, 21 Oct 2022 20:44:41 +0800 Subject: [PATCH] ARKUI add interfac test Signed-off-by: hekun --- .../entry/src/main/config.json | 3 +- .../src/main/ets/MainAbility/pages/common.ets | 50 ++- .../src/main/ets/MainAbility/pages/enums.ets | 7 + .../ets/MainAbility/pages/featureAbility.ets | 398 ++++++++++-------- .../ets/MainAbility/pages/loadingProgress.ets | 3 + .../ets/MainAbility/pages/navigation_lack.ets | 172 ++++++++ .../src/main/ets/MainAbility/pages/slider.ets | 3 +- .../entry/src/main/config.json | 5 +- .../MainAbility/pages/WaterFlowDataSource.ets | 115 +++++ .../ets/MainAbility/pages/WaterflowDemo.ets | 71 ++++ .../main/ets/MainAbility/pages/navigation.ets | 2 +- .../entry/src/main/ets/test/List.test.ets | 3 + .../src/main/ets/test/waterFlowDemo.test.ets | 66 +++ 13 files changed, 728 insertions(+), 170 deletions(-) create mode 100644 arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/navigation_lack.ets create mode 100644 arkui/ace_ets_component_two/entry/src/main/ets/MainAbility/pages/WaterFlowDataSource.ets create mode 100644 arkui/ace_ets_component_two/entry/src/main/ets/MainAbility/pages/WaterflowDemo.ets create mode 100644 arkui/ace_ets_component_two/entry/src/main/ets/test/waterFlowDemo.test.ets diff --git a/arkui/ace_ets_component_attrlack/entry/src/main/config.json b/arkui/ace_ets_component_attrlack/entry/src/main/config.json index 10dd537aa..a47c273c0 100644 --- a/arkui/ace_ets_component_attrlack/entry/src/main/config.json +++ b/arkui/ace_ets_component_attrlack/entry/src/main/config.json @@ -115,7 +115,8 @@ "pages/responseType", "pages/hoverEffect", "pages/hitTestMode", - "pages/color" + "pages/color", + "pages/navigation_lack" ], "name": ".MainAbility", "window": { diff --git a/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/common.ets b/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/common.ets index d5e9b6245..2ff0e22f9 100644 --- a/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/common.ets +++ b/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/common.ets @@ -20,6 +20,13 @@ const TAG = 'ets_apiLack_add'; @Entry @Component export default struct CommonColorMode { + + // popup构造器定义弹框内容 + @Builder popupBuilder() { + Row({ space: 2 }) { + Text('Custom Popup').fontSize(10) + }.width(100).height(50).padding(5) + } aboutToAppear() { Log.showInfo(TAG, `aboutToAppear CommonColorMode start`) } @@ -27,10 +34,44 @@ export default struct CommonColorMode { aboutToDisappear() { Log.showInfo(TAG, `aboutToDisAppear CommonColorMode end`) } + onLayout(children, constraint) { + Log.showInfo(TAG, `onLayout start` + JSON.stringify(children)); + children[0].borderInfo = { + borderWidth: 20, + margin: 30, + padding: 20 + } + children[0].constraint = { + maxWidth: 200 + } + children[0].layout({ + position: { + x:20, + y:20 + }, + constraint: { + maxWidth: 200 + } + }) + } + onMeasure(children, constraint) { + Log.showInfo(TAG, `onMeasurestart`) + + + } @Styles normalStyles() { .backgroundColor("#0A59F7") + } + // add + configuration : Configuration = { + + colorMode: "$000", + + fontScale: 23 + } + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { @@ -48,6 +89,10 @@ export default struct CommonColorMode { .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) .key("fontScaleText") + .bindPopup(true,{ + message:"23", + showInSubWindow:true + }). Text("common-OnFinish") .width(320) @@ -66,7 +111,10 @@ export default struct CommonColorMode { onFinish: () => { Log.showInfo(TAG, 'animation onFinish success') } - }) + }).bindPopup(true,{ + builder:this.popupBuilder, + showInSubWindow:true + }) Text("common-MotionPath") .width(320) diff --git a/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/enums.ets b/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/enums.ets index 8a6582865..e22cc6b40 100644 --- a/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/enums.ets +++ b/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/enums.ets @@ -36,6 +36,13 @@ struct EnumsCancel { @State mouseText: string = 'MouseText' + + @State fit:RelateType = RelateType.FIT; + @State fill:RelateType = RelateType.FILL; + @State mainonly:TitleHeight = TitleHeight.MainOnly; + @State MainWithSub:TitleHeight = TitleHeight.MainWithSub; + @State Block:HitTestMode = HitTestMode.Block; + @Styles pressedStyles() { .backgroundColor('red') .opacity(1) diff --git a/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/featureAbility.ets b/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/featureAbility.ets index f8c72d5fc..c2c1f8f74 100644 --- a/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/featureAbility.ets +++ b/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/featureAbility.ets @@ -19,21 +19,21 @@ const TAG = 'ets_apiLack_add'; @Entry @Component -export default struct FeatureAbilityAbilityName { +export default struct FeatureAbilityStartAbility { aboutToAppear() { - Log.showInfo(TAG, `aboutToAppear FeatureAbilityAbilityName start`) + Log.showInfo(TAG, `aboutToAppear FeatureAbilityStartAbility start`) } aboutToDisappear() { - Log.showInfo(TAG, `aboutToDisAppear FeatureAbilityAbilityName end`) + Log.showInfo(TAG, `aboutToDisAppear FeatureAbilityStartAbility end`) } build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text("featureAbility-SubscribeMessageResponse-DeviceId") + Text("featureAbility-StartAbility") .width(320) - .height(50) + .height(70) .fontSize(20) .opacity(1) .align(Alignment.TopStart) @@ -43,21 +43,17 @@ export default struct FeatureAbilityAbilityName { .padding(10) .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) - .key("subscribeMessageResponseDeviceIdText") + .key("startAbilityText") .onClick(() => { - FeatureAbility.subscribeMsg({ - success: (data) => { - console.log(`deviceId: ${data.deviceId}`) - }, - fail: (data, code) => { - console.log(`data: ${data} code: ${code}`) - } + FeatureAbility.startAbility({ + bundleName: "com.example.testapp", + abilityName: "com.example.testApp.MainAbility" }) }) - Text("featureAbility-SubscribeMessageResponse-AbilityName") + Text("featureAbility-StartAbilityForResult") .width(320) - .height(50) + .height(70) .fontSize(20) .opacity(1) .align(Alignment.TopStart) @@ -67,21 +63,16 @@ export default struct FeatureAbilityAbilityName { .padding(10) .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) - .key("subscribeMessageResponseAbilityNameText") + .key("startAbilityForResultText") .onClick(() => { - FeatureAbility.subscribeMsg({ - success: (data) => { - console.log(`deviceId: ${data.abilityName}`) - }, - fail: (data, code) => { - console.log(`data: ${data} code: ${code}`) - } - }) + FeatureAbility.startAbilityForResult({ + bundleName: "com.example.testapp", + abilityName: "com.example.testApp.MainAbility" }) }) - Text("featureAbility-CallAbilityParam-AbilityName") + Text("featureAbility-FinishWithResult") .width(320) - .height(50) + .height(70) .fontSize(20) .opacity(1) .align(Alignment.TopStart) @@ -91,24 +82,14 @@ export default struct FeatureAbilityAbilityName { .padding(10) .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) - .key("callAbilityParamAbilityNameText") + .key("finishWithResultText") .onClick(() => { - FeatureAbility.callAbility({ - bundleName: 'com.example.hiaceservice', - abilityName: 'com.example.hiaceservice.ComputeServiceAbility', - messageCode: 1001, - data: { - firstNum: 1024, - secondNum: 2048 - }, - abilityType: 0, - syncOption: 0 - }) + FeatureAbility.finishWithResult({ code: 200, result: null }) }) - Text("featureAbility-CallAbilityParam-MessageCode") + Text("featureAbility-GetDeviceList") .width(320) - .height(50) + .height(70) .fontSize(20) .opacity(1) .align(Alignment.TopStart) @@ -118,24 +99,14 @@ export default struct FeatureAbilityAbilityName { .padding(10) .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) - .key("callAbilityParamMessageCodeText") + .key("getDeviceListText") .onClick(() => { - FeatureAbility.callAbility({ - bundleName: 'com.example.hiaceservice', - abilityName: 'com.example.hiaceservice.ComputeServiceAbility', - messageCode: 1001, - data: { - firstNum: 1024, - secondNum: 2048 - }, - abilityType: 0, - syncOption: 0 - }) + FeatureAbility.getDeviceList(1) }) - Text("featureAbility-CallAbilityParam-AbilityType") + Text("featureAbility-CallAbility") .width(320) - .height(50) + .height(70) .fontSize(20) .opacity(1) .align(Alignment.TopStart) @@ -145,24 +116,19 @@ export default struct FeatureAbilityAbilityName { .padding(10) .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) - .key("callAbilityParamAbilityTypeText") + .key("callAbilityText") .onClick(() => { FeatureAbility.callAbility({ - bundleName: 'com.example.hiaceservice', - abilityName: 'com.example.hiaceservice.ComputeServiceAbility', - messageCode: 1001, - data: { - firstNum: 1024, - secondNum: 2048 - }, - abilityType: 0, - syncOption: 0 + bundleName: "com.example.testapp", + abilityName: "com.example.testApp.MainAbility", + messageCode: 200, + abilityType: 1 }) }) - Text("featureAbility-CallAbilityParam-SyncOption") + Text("featureAbility-ContinueAbility") .width(320) - .height(50) + .height(70) .fontSize(20) .opacity(1) .align(Alignment.TopStart) @@ -172,24 +138,14 @@ export default struct FeatureAbilityAbilityName { .padding(10) .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) - .key("callAbilityParamSyncOptionText") + .key("continueAbilityText") .onClick(() => { - FeatureAbility.callAbility({ - bundleName: 'com.example.hiaceservice', - abilityName: 'com.example.hiaceservice.ComputeServiceAbility', - messageCode: 1001, - data: { - firstNum: 1024, - secondNum: 2048 - }, - abilityType: 0, - syncOption: 0 - }) + FeatureAbility.continueAbility() }) - Text("featureAbility-SubscribeAbilityEventParam-AbilityName") + Text("featureAbility-SubscribeAbilityEvent") .width(320) - .height(50) + .height(70) .fontSize(20) .opacity(1) .align(Alignment.TopStart) @@ -199,23 +155,20 @@ export default struct FeatureAbilityAbilityName { .padding(10) .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) - .key("subscribeAbilityEventParamAbilityNameText") + .key("subscribeAbilityEventText") .onClick(() => { FeatureAbility.subscribeAbilityEvent({ - bundleName: 'com.example.hiaceservice', - abilityName: 'com.example.hiaceservice.ComputeServiceAbility', - messageCode: 1005, - abilityType: 0, - syncOption: 0 - }, (callbackData) => { - var callbackJson = JSON.parse(callbackData); - console.info('eventData is: ' + JSON.stringify(callbackJson.data)); + bundleName: "com.example.testapp", + abilityName: "com.example.testApp.MainAbility", + messageCode: 200, + abilityType: 1 + }, () => { }) }) - Text("featureAbility-SubscribeAbilityEventParam-MessageCode") + Text("featureAbility-UnsubscribeAbilityEvent") .width(320) - .height(50) + .height(70) .fontSize(20) .opacity(1) .align(Alignment.TopStart) @@ -225,23 +178,19 @@ export default struct FeatureAbilityAbilityName { .padding(10) .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) - .key("subscribeAbilityEventParammessageCodeText") + .key("unsubscribeAbilityEventText") .onClick(() => { - FeatureAbility.subscribeAbilityEvent({ - bundleName: 'com.example.hiaceservice', - abilityName: 'com.example.hiaceservice.ComputeServiceAbility', - messageCode: 1005, - abilityType: 0, - syncOption: 0 - }, (callbackData) => { - var callbackJson = JSON.parse(callbackData); - console.info('eventData is: ' + JSON.stringify(callbackJson.data)); + FeatureAbility.unsubscribeAbilityEvent({ + bundleName: "com.example.testapp", + abilityName: "com.example.testApp.MainAbility", + messageCode: 200, + abilityType: 1 }) }) - Text("featureAbility-SubscribeAbilityEventParam-AbilityType") + Text("featureAbility-SendMsg") .width(320) - .height(50) + .height(70) .fontSize(20) .opacity(1) .align(Alignment.TopStart) @@ -251,23 +200,28 @@ export default struct FeatureAbilityAbilityName { .padding(10) .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) - .key("subscribeAbilityEventParamAbilityTypeText") + .key("sendMsgText") .onClick(() => { - FeatureAbility.subscribeAbilityEvent({ - bundleName: 'com.example.hiaceservice', - abilityName: 'com.example.hiaceservice.ComputeServiceAbility', - messageCode: 1005, - abilityType: 0, - syncOption: 0 - }, (callbackData) => { - var callbackJson = JSON.parse(callbackData); - console.info('eventData is: ' + JSON.stringify(callbackJson.data)); + FeatureAbility.sendMsg({ + deviceId: '1001', + bundleName: "com.example.testapp", + abilityName: "com.example.testApp.MainAbility", + message: 'success', + success: () => { + Log.showInfo(TAG, `FeatureAbility.sendMsg success`) + }, + fail: (data, code) => { + Log.showInfo(TAG, `FeatureAbility.sendMsg fail: data: ${data},code: ${code}`) + }, + complete: () => { + Log.showInfo(TAG, `FeatureAbility.sendMsg complete`) + } }) }) - Text("featureAbility-SubscribeAbilityEventParam-SyncOption") + Text("featureAbility-SubscribeMsg") .width(320) - .height(50) + .height(70) .fontSize(20) .opacity(1) .align(Alignment.TopStart) @@ -277,24 +231,38 @@ export default struct FeatureAbilityAbilityName { .padding(10) .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) - .key("subscribeAbilityEventParamSyncOptionText") + .key("subscribeMsgText") .onClick(() => { - FeatureAbility.subscribeAbilityEvent({ - bundleName: 'com.example.hiaceservice', - abilityName: 'com.example.hiaceservice.ComputeServiceAbility', - messageCode: 1005, - abilityType: 0, - syncOption: 0 - }, (callbackData) => { - var callbackJson = JSON.parse(callbackData); - console.info('eventData is: ' + JSON.stringify(callbackJson.data)); + FeatureAbility.subscribeMsg({ + success: (data) => { + Log.showInfo(TAG, `FeatureAbility.subscribeMsg success: data: ${JSON.stringify(data)}`) + }, + fail: (data, code) => { + Log.showInfo(TAG, `FeatureAbility.subscribeMsg fail: data: ${data},code: ${code}`) + } }) }) + Text("featureAbility-UnsubscribeMsg") + .width(320) + .height(70) + .fontSize(20) + .opacity(1) + .align(Alignment.TopStart) + .fontColor(0xCCCCCC) + .lineHeight(25) + .border({ width: 1 }) + .padding(10) + .textAlign(TextAlign.Center) + .textOverflow({ overflow: TextOverflow.None }) + .key("unsubscribeMsgText") + .onClick(() => { + FeatureAbility.unsubscribeMsg() + }) - Text("featureAbility-SendMessageOptions-DeviceId") + Text("featureAbility-StartAbility") .width(320) - .height(50) + .height(70) .fontSize(20) .opacity(1) .align(Alignment.TopStart) @@ -304,18 +272,24 @@ export default struct FeatureAbilityAbilityName { .padding(10) .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) - .key("sendMessageOptionsDeviceIdText") + .key("featureAbility-StartAbility") .onClick(() => { - FeatureAbility.sendMsg({ - deviceId: '1001', - bundleName: 'com.example.hiaceservice', - abilityName: 'com.example.hiaceservice.ComputeServiceAbility' - }) + FeatureAbility.startAbility( + { + + bundleName :"com.example.myapplication", + abilityName : "com.example.entry.secondAbility", + entities:['a','b'], + url:"" + } + ).then((data) => { + console.info("==========================>startAbility=======================>"); + }); }) - Text("featureAbility-SendMessageOptions-AbilityName") + Text("featureAbility-startAbilityForResult") .width(320) - .height(50) + .height(70) .fontSize(20) .opacity(1) .align(Alignment.TopStart) @@ -325,18 +299,23 @@ export default struct FeatureAbilityAbilityName { .padding(10) .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) - .key("sendMessageOptionsAbilityNameText") + .key("featureAbility-startAbilityForResult") .onClick(() => { - FeatureAbility.sendMsg({ - deviceId: '1001', - bundleName: 'com.example.hiaceservice', - abilityName: 'com.example.hiaceservice.ComputeServiceAbility' - }) + FeatureAbility.startAbilityForResult( + { + bundleName :"com.example.myapplication", + abilityName : "com.example.entry.secondAbility", + entities:['a','b'], + url:"" + }, + ).then((data) => { + console.info("==========================>startAbilityForResult=======================>"); + }); }) - Text("featureAbility-RequestParams-AbilityName") + Text("featureAbility-finishWithResult") .width(320) - .height(50) + .height(70) .fontSize(20) .opacity(1) .align(Alignment.TopStart) @@ -346,17 +325,19 @@ export default struct FeatureAbilityAbilityName { .padding(10) .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) - .key("requestParamsAbilityNameText") + .key("featureAbility-finishWithResult") .onClick(() => { - FeatureAbility.startAbility({ - bundleName: 'com.example.hiaceservice', - abilityName: 'com.example.hiaceservice.ComputeServiceAbility' - }) + FeatureAbility.finishWithResult({ + code:20002, + result:{} + }).then((data) => { + console.info("==========================>startAbilityForResult=======================>"); + }); }) - Text("featureAbility-Entities") + Text("featureAbility-getDeviceList") .width(320) - .height(50) + .height(70) .fontSize(20) .opacity(1) .align(Alignment.TopStart) @@ -366,18 +347,16 @@ export default struct FeatureAbilityAbilityName { .padding(10) .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) - .key("entitiesText") + .key("featureAbility-finishWithResult") .onClick(() => { - FeatureAbility.startAbility({ - bundleName: 'com.example.hiaceservice', - abilityName: 'com.example.hiaceservice.ComputeServiceAbility', - entities: ["this is a test"] - }) + FeatureAbility.getDeviceList(23).then((data) => { + console.info("==========================>startAbilityForResult=======================>"); + }); }) - Text("featureAbility-DeviceType") + Text("featureAbility-getDeviceList") .width(320) - .height(50) + .height(70) .fontSize(20) .opacity(1) .align(Alignment.TopStart) @@ -387,13 +366,104 @@ export default struct FeatureAbilityAbilityName { .padding(10) .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) - .key("deviceTypeText") + .key("featureAbility-finishWithResult") .onClick(() => { - FeatureAbility.startAbility({ - bundleName: 'com.example.hiaceservice', - abilityName: 'com.example.hiaceservice.ComputeServiceAbility', - deviceType: 1001 - }) + FeatureAbility.getDeviceList(23).then((data) => { + console.info("==========================>startAbilityForResult=======================>"); + }); + }) + + Text("featureAbility-callAbility") + .width(320) + .height(70) + .fontSize(20) + .opacity(1) + .align(Alignment.TopStart) + .fontColor(0xCCCCCC) + .lineHeight(25) + .border({ width: 1 }) + .padding(10) + .textAlign(TextAlign.Center) + .textOverflow({ overflow: TextOverflow.None }) + .key("featureAbility-callAbility") + .onClick(() => { + FeatureAbility.callAbility({ + bundleName: "com.example.myapplication", + abilityName: "com.example.entry.secondAbility", + messageCode: 50, + abilityType: 12 + }).then((data) => { + console.info("==========================>startAbilityForResult=======================>"); + }); + }) + + Text("featureAbility-continueAbility") + .width(320) + .height(70) + .fontSize(20) + .opacity(1) + .align(Alignment.TopStart) + .fontColor(0xCCCCCC) + .lineHeight(25) + .border({ width: 1 }) + .padding(10) + .textAlign(TextAlign.Center) + .textOverflow({ overflow: TextOverflow.None }) + .key("featureAbility-continueAbility") + .onClick(() => { + FeatureAbility.continueAbility().then((data) => { + console.info("==========================>startAbilityForResult=======================>"); + }); + }) + Text("featureAbility-subscribeAbilityEvent") + .width(320) + .height(70) + .fontSize(20) + .opacity(1) + .align(Alignment.TopStart) + .fontColor(0xCCCCCC) + .lineHeight(25) + .border({ width: 1 }) + .padding(10) + .textAlign(TextAlign.Center) + .textOverflow({ overflow: TextOverflow.None }) + .key("featureAbility-subscribeAbilityEvent") + .onClick(() => { + FeatureAbility.subscribeAbilityEvent({ + bundleName: "ss", + abilityName: "d", + messageCode: 50, + abilityType: 60, + syncOption:20 + },() => { + console.info("hello subscribeAbilityEvent") + }).then((data) => { + console.info("==========================>startAbilityForResult=======================>"); + }); + }) + Text("featureAbility-unsubscribeAbilityEvent") + .width(320) + .height(70) + .fontSize(20) + .opacity(1) + .align(Alignment.TopStart) + .fontColor(0xCCCCCC) + .lineHeight(25) + .border({ width: 1 }) + .padding(10) + .textAlign(TextAlign.Center) + .textOverflow({ overflow: TextOverflow.None }) + .key("featureAbility-unsubscribeAbilityEvent") + .onClick(() => { + FeatureAbility.unsubscribeAbilityEvent({ + bundleName: "d", + abilityName: "s", + messageCode: 20, + abilityType: 30, + syncOption: 40 + }).then((data) => { + console.info("==========================>startAbilityForResult=======================>"); + }); }) }.width("100%").height("100%") diff --git a/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/loadingProgress.ets b/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/loadingProgress.ets index 1353d00b7..42ef021b4 100644 --- a/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/loadingProgress.ets +++ b/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/loadingProgress.ets @@ -21,6 +21,8 @@ const TAG = 'ets_apiLack_add'; @Component export default struct LoadingProgressCircular { + @State circular:LoadingProgressStyle = LoadingProgressStyle.Circular; + @State orbital:LoadingProgressStyle = LoadingProgressStyle.Orbital; aboutToAppear() { Log.showInfo(TAG, `aboutToAppear LoadingProgressCircular start`) } @@ -63,6 +65,7 @@ struct LoadingProgressCircular { Text('Orbital LoadingProgress ').fontSize(9).fontColor(0xCCCCCC).width('100%') LoadingProgress() .color(Color.Blue) + }.width("100%").height("100%") } } diff --git a/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/navigation_lack.ets b/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/navigation_lack.ets new file mode 100644 index 000000000..841c5babb --- /dev/null +++ b/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/navigation_lack.ets @@ -0,0 +1,172 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 Huawei Device 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 events_emitter from '@ohos.events.emitter'; + +@Entry +@Component +struct NavigationExample { + private arr: number[] = [0, 1, 2, 3, 4, 5] + @State hideBar: boolean = true + @State toolBar: boolean = true + @State hideToolBar: boolean = false + @State hideTitleBar: boolean = false + @State hideBackButton: boolean = false + @State onActionCalled: boolean = false + @State titleMode: NavigationTitleMode = NavigationTitleMode.Free + @State navagationmode: NavigationMode = NavigationMode.Stack + @State navagationmode2: NavigationMode = NavigationMode.Split + + @state commonTile :NavigationCommonTitle = { + main:"main", + sub: "sub" + } + @State navTile:NavDestinationCommonTitle = { + main:"main_nav", + sub: "sub_nav" + } + + private stateChangCallBack = (eventData) => { + if (eventData != null) { + console.info("tabs page state change called:" + JSON.stringify(eventData)); + if (eventData.data.vertical != null) { + this.titleMode = eventData.data.titleMode; + } + if (eventData.data.hideToolBar != null) { + this.hideToolBar = parseInt(eventData.data.hideToolBar); + } + if (eventData.data.hideTitleBar != null) { + this.hideTitleBar = parseInt(eventData.data.hideTitleBar); + } + if (eventData.data.hideBackButton != null) { + this.hideBackButton = parseInt(eventData.data.hideBackButton); + } + } + } + + onPageShow() { + console.info('progress page show called'); + var stateChangeEvent = { + eventId: 135, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack) + } + + + + @Builder NavigationTitle() { + Column() { + Text('title') + .width(80) + .height(60) + .fontColor(Color.Blue) + .fontSize(30) + } + .onClick(() => { + console.log("title") + }) + } + + @Builder NavigationMenus() { + Row() { + Image('images/add.png') + .width(25) + .height(25) + Image('comment/more.png') + .width(25) + .height(25) + .margin({ left: 30 }) + }.width(100) + } + + build() { + Column() { + Navigation() { + Search({ value: '', placeholder: "" }).width('85%').margin(26) + List({ space: 5, initialIndex: 0 }) { + ForEach(this.arr, (item) => { + ListItem() { + Text('' + item) + .width('90%') + .height(80) + .backgroundColor('#3366CC') + .borderRadius(15) + .fontSize(16) + .textAlign(TextAlign.Center) + }.editable(true) + }, item => item) + } + .listDirection(Axis.Vertical) + .key('Navigation') + .height(300) + .margin({ top: 10, left: 18 }) + .width('100%') + + Button(this.hideBar ? "tool bar" : "hide bar") + .backgroundColor(0x2788D9).width(200).height(100).fontSize(20) + .key('NavigationContent1') + .onClick(() => { + this.hideBar = !this.hideBar; + console.info('navigationContent1 current action state is: ' + this.hideBar); + try { + var backData = { + data: { + "ACTION": this.hideBar, + } + } + var backEvent = { + eventId: 1366, + priority: events_emitter.EventPriority.LOW + } + console.info("navigationContent1 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("navigationContent1 emit action state err: " + JSON.stringify(err.message)) + } + }) + .margin({ left: 135, top: 60 }) + } + .title(this.NavigationTitle) + .subTitle('subtitle') + .menus(this.NavigationMenus) + .titleMode(NavigationTitleMode.Free) + .hideTitleBar(false) + .hideBackButton(false) + .navBarWidth(30) + .navBarPosition(NavBarPosition.start) + .backButtonIcon('images/grid.svg') + .hideNavBar(true) + .onNavBarStateChange((isVisible: boolean) => { + console.info("isvisible") + }) + .onTitleModeChange((titleModel: NavigationTitleMode) => { + console.log('titleMode') + }) + .toolBar({ items: [ + { value: 'app', icon: 'images/grid.svg', action: () => { + console.log("app") + } }, + { value: 'add', icon: 'images/add.svg', action: () => { + console.log("add") + } }, + { value: 'collect', icon: 'images/collect.svg', action: () => { + console.log("collect") + } }] }) + .hideToolBar(this.hideBar) + + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/slider.ets b/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/slider.ets index 91ee60b8f..645f0aaa0 100644 --- a/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/slider.ets +++ b/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/slider.ets @@ -22,7 +22,8 @@ const TAG = 'ets_apiLack_add'; @Entry @Component export default struct SliderMoving { - @State outSetValue: number = 40 + @State outSetValue: number = 40; + @State move:SliderChangeMode = SliderChangeMode.Moving; slide() { var rect = Utils.getComponentRect("Slider") Utils.drag(rect["left"],rect["top"],rect["right"],rect["bottom"],20) diff --git a/arkui/ace_ets_component_two/entry/src/main/config.json b/arkui/ace_ets_component_two/entry/src/main/config.json index 869c8c29a..3ba2793ce 100644 --- a/arkui/ace_ets_component_two/entry/src/main/config.json +++ b/arkui/ace_ets_component_two/entry/src/main/config.json @@ -18,7 +18,7 @@ "name": ".MyApplication", "mainAbility": "com.open.harmony.acetesttwo.MainAbility", "deviceType": [ - "default", + "default", "phone" ], "distro": { @@ -100,7 +100,8 @@ "pages/search", "pages/scrollBar", "pages/ohosRouterA", - "pages/ohosRouterB" + "pages/ohosRouterB", + "pages/WaterflowDemo" ], "name": ".MainAbility", "window": { diff --git a/arkui/ace_ets_component_two/entry/src/main/ets/MainAbility/pages/WaterFlowDataSource.ets b/arkui/ace_ets_component_two/entry/src/main/ets/MainAbility/pages/WaterFlowDataSource.ets new file mode 100644 index 000000000..8e94618ee --- /dev/null +++ b/arkui/ace_ets_component_two/entry/src/main/ets/MainAbility/pages/WaterFlowDataSource.ets @@ -0,0 +1,115 @@ +// 实现IDataSource接口的对象,用于瀑布流组件加载数据 +export class WaterFlowDataSource implements IDataSource { + + private dataArray: number[] = [] + private listeners: DataChangeListener[] = [] + + constructor() { + for (let i = 0; i <= 100; i++) { + this.dataArray.push(i); + } + } + + // 获取索引对应的数据 + public getData(index: number): any { + return this.dataArray[index] + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded() + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdded(index) + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChanged(index) + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDeleted(index) + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMoved(from, to) + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener) + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + this.listeners.splice(pos, 1) + } + } + + // 增加数据 + public Add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length) + this.notifyDataAdd(0) + } + + // 在数据尾部增加一个元素 + public AddLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) + this.notifyDataAdd(this.dataArray.length-1) + } + + // 在指定索引位置增加一个元素 + public AddItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length) + this.notifyDataAdd(index) + } + + // 删除第一个元素 + public Delete1stItem(): void { + this.dataArray.splice(0, 1) + this.notifyDataDelete(0) + } + + // 删除第二个元素 + public Delete2ndItem(): void { + this.dataArray.splice(1, 1) + this.notifyDataDelete(1) + } + + // 删除最后一个元素 + public DeleteLastItem(): void { + this.dataArray.splice(-1, 1) + this.notifyDataDelete(this.dataArray.length) + } + + // 重新加载数据 + public Reload(): void { + this.dataArray.splice(1, 1); + this.dataArray.splice(3, 2); + this.notifyDataReload(); + } +} \ No newline at end of file diff --git a/arkui/ace_ets_component_two/entry/src/main/ets/MainAbility/pages/WaterflowDemo.ets b/arkui/ace_ets_component_two/entry/src/main/ets/MainAbility/pages/WaterflowDemo.ets new file mode 100644 index 000000000..1ea58fc40 --- /dev/null +++ b/arkui/ace_ets_component_two/entry/src/main/ets/MainAbility/pages/WaterflowDemo.ets @@ -0,0 +1,71 @@ +// WaterflowDemo.ets +import { WaterFlowDataSource } from './WaterFlowDataSource' + +@Entry +@Component +struct WaterflowDemo { + @State minSize: number = 50 + @State maxSize: number = 100 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller(); + datasource: WaterFlowDataSource = new WaterFlowDataSource(); + + // 计算flow item宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + @Builder itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + WaterFlow({ footer: this.itemFoot, scroller: this.scroller }) { + LazyForEach(this.datasource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image('res/waterFlowTest(' + item % 5 + ').jpg') + .objectFit(ImageFit.Fill) + } + } + .width(this.getSize()) + .height(this.getSize()) + .backgroundColor(this.colors[item % 5]) + + }, item => item) + } + .columnsTemplate("1fr 1fr 1fr 1fr") + .itemConstraintSize({ + minWidth: 0, + maxWidth: '100%', + minHeight: 0, + maxHeight: '100%' + }) + .key('waterFlow') + .columnsGap(10) + .rowsGap(5) + .onReachStart(() => { + console.info("onReachStart") + }) + .onReachEnd(() => { + console.info("onReachEnd") + }) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('80%') + .layoutDirection(FlexDirection.Column) + } + } +} diff --git a/arkui/ace_ets_component_two/entry/src/main/ets/MainAbility/pages/navigation.ets b/arkui/ace_ets_component_two/entry/src/main/ets/MainAbility/pages/navigation.ets index ca7fa5b05..7a3931794 100644 --- a/arkui/ace_ets_component_two/entry/src/main/ets/MainAbility/pages/navigation.ets +++ b/arkui/ace_ets_component_two/entry/src/main/ets/MainAbility/pages/navigation.ets @@ -132,7 +132,7 @@ struct NavigationExample { .titleMode(NavigationTitleMode.Free) .hideTitleBar(false) .hideBackButton(false) - .onTitleModeChanged((titleModel: NavigationTitleMode) => { + .onTitleModeChange((titleModel: NavigationTitleMode) => { console.log('titleMode') }) .toolBar({ items: [ diff --git a/arkui/ace_ets_component_two/entry/src/main/ets/test/List.test.ets b/arkui/ace_ets_component_two/entry/src/main/ets/test/List.test.ets index fa73d85c0..73088369d 100644 --- a/arkui/ace_ets_component_two/entry/src/main/ets/test/List.test.ets +++ b/arkui/ace_ets_component_two/entry/src/main/ets/test/List.test.ets @@ -39,6 +39,8 @@ import flexDirectionJsunit from './FlexDirectionJsunit.test.ets'; import flexWrapJsunit from './FlexWrapJsunit.test.ets'; import datePickerJsunit from './DatePickerJsunit.test.ets'; import direction2Jsunit from './Direction2Jsunit.test.ets'; +import waterFlowDemoJsunit from './waterFlowDemo.test.ets'; + export default function testsuite() { navigationJsunit(); @@ -68,4 +70,5 @@ export default function testsuite() { rowJsunit(); systempromptJsunit(); sourceTypeJsunit(); + waterFlowDemoJsunit(); } \ No newline at end of file diff --git a/arkui/ace_ets_component_two/entry/src/main/ets/test/waterFlowDemo.test.ets b/arkui/ace_ets_component_two/entry/src/main/ets/test/waterFlowDemo.test.ets new file mode 100644 index 000000000..552b3d33b --- /dev/null +++ b/arkui/ace_ets_component_two/entry/src/main/ets/test/waterFlowDemo.test.ets @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index" +import Utils from './Utils.ets' + + +export default function waterFlowDemoJsunit() { + describe('waterFlowDemoTest', function () { + beforeAll(async function (done) { + console.info("waterFlow beforeEach start"); + let options = { + uri: 'pages/WaterflowDemo', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get waterflowDemo state success " + JSON.stringify(pages)); + if (!("waterflowDemo" == pages.name)) { + console.info("get waterflowDemo state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push waterflowDemo page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push waterflowDemo page error: " + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("waterflowDemo after each called"); + }); + + /* + * @tc.number SUB_ACE_BASIC_ETS_API_0001 + * @tc.name waterflowTest0001 + * @tc.desic 'waterflowTest0001 + */ + it('waterflowTest0001', 0, async function (done) { + console.info('waterflowDemo testalphabetIndexerWidth0001 START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('waterFlow'); + console.info("[waterflowTest0001] component width strJson:" + strJson); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('WaterFlow'); + done(); + }); + + }) +} -- GitLab