提交 dcf94a51 编写于 作者: H hekun

ARKUI add interfac test

Signed-off-by: Nhekun <hekun18@huawei.com>
上级 b334eb7d
...@@ -115,7 +115,8 @@ ...@@ -115,7 +115,8 @@
"pages/responseType", "pages/responseType",
"pages/hoverEffect", "pages/hoverEffect",
"pages/hitTestMode", "pages/hitTestMode",
"pages/color" "pages/color",
"pages/navigation_lack"
], ],
"name": ".MainAbility", "name": ".MainAbility",
"window": { "window": {
......
...@@ -20,6 +20,13 @@ const TAG = 'ets_apiLack_add'; ...@@ -20,6 +20,13 @@ const TAG = 'ets_apiLack_add';
@Entry @Entry
@Component @Component
export default struct CommonColorMode { export default struct CommonColorMode {
// popup构造器定义弹框内容
@Builder popupBuilder() {
Row({ space: 2 }) {
Text('Custom Popup').fontSize(10)
}.width(100).height(50).padding(5)
}
aboutToAppear() { aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear CommonColorMode start`) Log.showInfo(TAG, `aboutToAppear CommonColorMode start`)
} }
...@@ -27,10 +34,44 @@ export default struct CommonColorMode { ...@@ -27,10 +34,44 @@ export default struct CommonColorMode {
aboutToDisappear() { aboutToDisappear() {
Log.showInfo(TAG, `aboutToDisAppear CommonColorMode end`) 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() { @Styles normalStyles() {
.backgroundColor("#0A59F7") .backgroundColor("#0A59F7")
} }
// add
configuration : Configuration = {
colorMode: "$000",
fontScale: 23
}
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
...@@ -48,6 +89,10 @@ export default struct CommonColorMode { ...@@ -48,6 +89,10 @@ export default struct CommonColorMode {
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None }) .textOverflow({ overflow: TextOverflow.None })
.key("fontScaleText") .key("fontScaleText")
.bindPopup(true,{
message:"23",
showInSubWindow:true
}).
Text("common-OnFinish") Text("common-OnFinish")
.width(320) .width(320)
...@@ -66,6 +111,9 @@ export default struct CommonColorMode { ...@@ -66,6 +111,9 @@ export default struct CommonColorMode {
onFinish: () => { onFinish: () => {
Log.showInfo(TAG, 'animation onFinish success') Log.showInfo(TAG, 'animation onFinish success')
} }
}).bindPopup(true,{
builder:this.popupBuilder,
showInSubWindow:true
}) })
Text("common-MotionPath") Text("common-MotionPath")
......
...@@ -36,6 +36,13 @@ struct EnumsCancel { ...@@ -36,6 +36,13 @@ struct EnumsCancel {
@State mouseText: string = 'MouseText' @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() { @Styles pressedStyles() {
.backgroundColor('red') .backgroundColor('red')
.opacity(1) .opacity(1)
......
...@@ -19,21 +19,21 @@ const TAG = 'ets_apiLack_add'; ...@@ -19,21 +19,21 @@ const TAG = 'ets_apiLack_add';
@Entry @Entry
@Component @Component
export default struct FeatureAbilityAbilityName { export default struct FeatureAbilityStartAbility {
aboutToAppear() { aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear FeatureAbilityAbilityName start`) Log.showInfo(TAG, `aboutToAppear FeatureAbilityStartAbility start`)
} }
aboutToDisappear() { aboutToDisappear() {
Log.showInfo(TAG, `aboutToDisAppear FeatureAbilityAbilityName end`) Log.showInfo(TAG, `aboutToDisAppear FeatureAbilityStartAbility end`)
} }
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text("featureAbility-SubscribeMessageResponse-DeviceId") Text("featureAbility-StartAbility")
.width(320) .width(320)
.height(50) .height(70)
.fontSize(20) .fontSize(20)
.opacity(1) .opacity(1)
.align(Alignment.TopStart) .align(Alignment.TopStart)
...@@ -43,21 +43,17 @@ export default struct FeatureAbilityAbilityName { ...@@ -43,21 +43,17 @@ export default struct FeatureAbilityAbilityName {
.padding(10) .padding(10)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None }) .textOverflow({ overflow: TextOverflow.None })
.key("subscribeMessageResponseDeviceIdText") .key("startAbilityText")
.onClick(() => { .onClick(() => {
FeatureAbility.subscribeMsg({ FeatureAbility.startAbility({
success: (data) => { bundleName: "com.example.testapp",
console.log(`deviceId: ${data.deviceId}`) abilityName: "com.example.testApp.MainAbility"
},
fail: (data, code) => {
console.log(`data: ${data} code: ${code}`)
}
}) })
}) })
Text("featureAbility-SubscribeMessageResponse-AbilityName") Text("featureAbility-StartAbilityForResult")
.width(320) .width(320)
.height(50) .height(70)
.fontSize(20) .fontSize(20)
.opacity(1) .opacity(1)
.align(Alignment.TopStart) .align(Alignment.TopStart)
...@@ -67,21 +63,16 @@ export default struct FeatureAbilityAbilityName { ...@@ -67,21 +63,16 @@ export default struct FeatureAbilityAbilityName {
.padding(10) .padding(10)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None }) .textOverflow({ overflow: TextOverflow.None })
.key("subscribeMessageResponseAbilityNameText") .key("startAbilityForResultText")
.onClick(() => { .onClick(() => {
FeatureAbility.subscribeMsg({ FeatureAbility.startAbilityForResult({
success: (data) => { bundleName: "com.example.testapp",
console.log(`deviceId: ${data.abilityName}`) abilityName: "com.example.testApp.MainAbility" })
},
fail: (data, code) => {
console.log(`data: ${data} code: ${code}`)
}
})
}) })
Text("featureAbility-CallAbilityParam-AbilityName") Text("featureAbility-FinishWithResult")
.width(320) .width(320)
.height(50) .height(70)
.fontSize(20) .fontSize(20)
.opacity(1) .opacity(1)
.align(Alignment.TopStart) .align(Alignment.TopStart)
...@@ -91,24 +82,14 @@ export default struct FeatureAbilityAbilityName { ...@@ -91,24 +82,14 @@ export default struct FeatureAbilityAbilityName {
.padding(10) .padding(10)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None }) .textOverflow({ overflow: TextOverflow.None })
.key("callAbilityParamAbilityNameText") .key("finishWithResultText")
.onClick(() => { .onClick(() => {
FeatureAbility.callAbility({ FeatureAbility.finishWithResult({ code: 200, result: null })
bundleName: 'com.example.hiaceservice',
abilityName: 'com.example.hiaceservice.ComputeServiceAbility',
messageCode: 1001,
data: {
firstNum: 1024,
secondNum: 2048
},
abilityType: 0,
syncOption: 0
})
}) })
Text("featureAbility-CallAbilityParam-MessageCode") Text("featureAbility-GetDeviceList")
.width(320) .width(320)
.height(50) .height(70)
.fontSize(20) .fontSize(20)
.opacity(1) .opacity(1)
.align(Alignment.TopStart) .align(Alignment.TopStart)
...@@ -118,24 +99,14 @@ export default struct FeatureAbilityAbilityName { ...@@ -118,24 +99,14 @@ export default struct FeatureAbilityAbilityName {
.padding(10) .padding(10)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None }) .textOverflow({ overflow: TextOverflow.None })
.key("callAbilityParamMessageCodeText") .key("getDeviceListText")
.onClick(() => { .onClick(() => {
FeatureAbility.callAbility({ FeatureAbility.getDeviceList(1)
bundleName: 'com.example.hiaceservice',
abilityName: 'com.example.hiaceservice.ComputeServiceAbility',
messageCode: 1001,
data: {
firstNum: 1024,
secondNum: 2048
},
abilityType: 0,
syncOption: 0
})
}) })
Text("featureAbility-CallAbilityParam-AbilityType") Text("featureAbility-CallAbility")
.width(320) .width(320)
.height(50) .height(70)
.fontSize(20) .fontSize(20)
.opacity(1) .opacity(1)
.align(Alignment.TopStart) .align(Alignment.TopStart)
...@@ -145,24 +116,19 @@ export default struct FeatureAbilityAbilityName { ...@@ -145,24 +116,19 @@ export default struct FeatureAbilityAbilityName {
.padding(10) .padding(10)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None }) .textOverflow({ overflow: TextOverflow.None })
.key("callAbilityParamAbilityTypeText") .key("callAbilityText")
.onClick(() => { .onClick(() => {
FeatureAbility.callAbility({ FeatureAbility.callAbility({
bundleName: 'com.example.hiaceservice', bundleName: "com.example.testapp",
abilityName: 'com.example.hiaceservice.ComputeServiceAbility', abilityName: "com.example.testApp.MainAbility",
messageCode: 1001, messageCode: 200,
data: { abilityType: 1
firstNum: 1024,
secondNum: 2048
},
abilityType: 0,
syncOption: 0
}) })
}) })
Text("featureAbility-CallAbilityParam-SyncOption") Text("featureAbility-ContinueAbility")
.width(320) .width(320)
.height(50) .height(70)
.fontSize(20) .fontSize(20)
.opacity(1) .opacity(1)
.align(Alignment.TopStart) .align(Alignment.TopStart)
...@@ -172,24 +138,14 @@ export default struct FeatureAbilityAbilityName { ...@@ -172,24 +138,14 @@ export default struct FeatureAbilityAbilityName {
.padding(10) .padding(10)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None }) .textOverflow({ overflow: TextOverflow.None })
.key("callAbilityParamSyncOptionText") .key("continueAbilityText")
.onClick(() => { .onClick(() => {
FeatureAbility.callAbility({ FeatureAbility.continueAbility()
bundleName: 'com.example.hiaceservice',
abilityName: 'com.example.hiaceservice.ComputeServiceAbility',
messageCode: 1001,
data: {
firstNum: 1024,
secondNum: 2048
},
abilityType: 0,
syncOption: 0
})
}) })
Text("featureAbility-SubscribeAbilityEventParam-AbilityName") Text("featureAbility-SubscribeAbilityEvent")
.width(320) .width(320)
.height(50) .height(70)
.fontSize(20) .fontSize(20)
.opacity(1) .opacity(1)
.align(Alignment.TopStart) .align(Alignment.TopStart)
...@@ -199,23 +155,20 @@ export default struct FeatureAbilityAbilityName { ...@@ -199,23 +155,20 @@ export default struct FeatureAbilityAbilityName {
.padding(10) .padding(10)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None }) .textOverflow({ overflow: TextOverflow.None })
.key("subscribeAbilityEventParamAbilityNameText") .key("subscribeAbilityEventText")
.onClick(() => { .onClick(() => {
FeatureAbility.subscribeAbilityEvent({ FeatureAbility.subscribeAbilityEvent({
bundleName: 'com.example.hiaceservice', bundleName: "com.example.testapp",
abilityName: 'com.example.hiaceservice.ComputeServiceAbility', abilityName: "com.example.testApp.MainAbility",
messageCode: 1005, messageCode: 200,
abilityType: 0, abilityType: 1
syncOption: 0 }, () => {
}, (callbackData) => {
var callbackJson = JSON.parse(callbackData);
console.info('eventData is: ' + JSON.stringify(callbackJson.data));
}) })
}) })
Text("featureAbility-SubscribeAbilityEventParam-MessageCode") Text("featureAbility-UnsubscribeAbilityEvent")
.width(320) .width(320)
.height(50) .height(70)
.fontSize(20) .fontSize(20)
.opacity(1) .opacity(1)
.align(Alignment.TopStart) .align(Alignment.TopStart)
...@@ -225,23 +178,19 @@ export default struct FeatureAbilityAbilityName { ...@@ -225,23 +178,19 @@ export default struct FeatureAbilityAbilityName {
.padding(10) .padding(10)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None }) .textOverflow({ overflow: TextOverflow.None })
.key("subscribeAbilityEventParammessageCodeText") .key("unsubscribeAbilityEventText")
.onClick(() => { .onClick(() => {
FeatureAbility.subscribeAbilityEvent({ FeatureAbility.unsubscribeAbilityEvent({
bundleName: 'com.example.hiaceservice', bundleName: "com.example.testapp",
abilityName: 'com.example.hiaceservice.ComputeServiceAbility', abilityName: "com.example.testApp.MainAbility",
messageCode: 1005, messageCode: 200,
abilityType: 0, abilityType: 1
syncOption: 0
}, (callbackData) => {
var callbackJson = JSON.parse(callbackData);
console.info('eventData is: ' + JSON.stringify(callbackJson.data));
}) })
}) })
Text("featureAbility-SubscribeAbilityEventParam-AbilityType") Text("featureAbility-SendMsg")
.width(320) .width(320)
.height(50) .height(70)
.fontSize(20) .fontSize(20)
.opacity(1) .opacity(1)
.align(Alignment.TopStart) .align(Alignment.TopStart)
...@@ -251,23 +200,28 @@ export default struct FeatureAbilityAbilityName { ...@@ -251,23 +200,28 @@ export default struct FeatureAbilityAbilityName {
.padding(10) .padding(10)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None }) .textOverflow({ overflow: TextOverflow.None })
.key("subscribeAbilityEventParamAbilityTypeText") .key("sendMsgText")
.onClick(() => { .onClick(() => {
FeatureAbility.subscribeAbilityEvent({ FeatureAbility.sendMsg({
bundleName: 'com.example.hiaceservice', deviceId: '1001',
abilityName: 'com.example.hiaceservice.ComputeServiceAbility', bundleName: "com.example.testapp",
messageCode: 1005, abilityName: "com.example.testApp.MainAbility",
abilityType: 0, message: 'success',
syncOption: 0 success: () => {
}, (callbackData) => { Log.showInfo(TAG, `FeatureAbility.sendMsg success`)
var callbackJson = JSON.parse(callbackData); },
console.info('eventData is: ' + JSON.stringify(callbackJson.data)); 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) .width(320)
.height(50) .height(70)
.fontSize(20) .fontSize(20)
.opacity(1) .opacity(1)
.align(Alignment.TopStart) .align(Alignment.TopStart)
...@@ -277,24 +231,21 @@ export default struct FeatureAbilityAbilityName { ...@@ -277,24 +231,21 @@ export default struct FeatureAbilityAbilityName {
.padding(10) .padding(10)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None }) .textOverflow({ overflow: TextOverflow.None })
.key("subscribeAbilityEventParamSyncOptionText") .key("subscribeMsgText")
.onClick(() => { .onClick(() => {
FeatureAbility.subscribeAbilityEvent({ FeatureAbility.subscribeMsg({
bundleName: 'com.example.hiaceservice', success: (data) => {
abilityName: 'com.example.hiaceservice.ComputeServiceAbility', Log.showInfo(TAG, `FeatureAbility.subscribeMsg success: data: ${JSON.stringify(data)}`)
messageCode: 1005, },
abilityType: 0, fail: (data, code) => {
syncOption: 0 Log.showInfo(TAG, `FeatureAbility.subscribeMsg fail: data: ${data},code: ${code}`)
}, (callbackData) => { }
var callbackJson = JSON.parse(callbackData);
console.info('eventData is: ' + JSON.stringify(callbackJson.data));
}) })
}) })
Text("featureAbility-UnsubscribeMsg")
Text("featureAbility-SendMessageOptions-DeviceId")
.width(320) .width(320)
.height(50) .height(70)
.fontSize(20) .fontSize(20)
.opacity(1) .opacity(1)
.align(Alignment.TopStart) .align(Alignment.TopStart)
...@@ -304,18 +255,14 @@ export default struct FeatureAbilityAbilityName { ...@@ -304,18 +255,14 @@ export default struct FeatureAbilityAbilityName {
.padding(10) .padding(10)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None }) .textOverflow({ overflow: TextOverflow.None })
.key("sendMessageOptionsDeviceIdText") .key("unsubscribeMsgText")
.onClick(() => { .onClick(() => {
FeatureAbility.sendMsg({ FeatureAbility.unsubscribeMsg()
deviceId: '1001',
bundleName: 'com.example.hiaceservice',
abilityName: 'com.example.hiaceservice.ComputeServiceAbility'
})
}) })
Text("featureAbility-SendMessageOptions-AbilityName") Text("featureAbility-StartAbility")
.width(320) .width(320)
.height(50) .height(70)
.fontSize(20) .fontSize(20)
.opacity(1) .opacity(1)
.align(Alignment.TopStart) .align(Alignment.TopStart)
...@@ -325,18 +272,50 @@ export default struct FeatureAbilityAbilityName { ...@@ -325,18 +272,50 @@ export default struct FeatureAbilityAbilityName {
.padding(10) .padding(10)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None }) .textOverflow({ overflow: TextOverflow.None })
.key("sendMessageOptionsAbilityNameText") .key("featureAbility-StartAbility")
.onClick(() => { .onClick(() => {
FeatureAbility.sendMsg({ FeatureAbility.startAbility(
deviceId: '1001', {
bundleName: 'com.example.hiaceservice',
abilityName: 'com.example.hiaceservice.ComputeServiceAbility' bundleName :"com.example.myapplication",
abilityName : "com.example.entry.secondAbility",
entities:['a','b'],
url:""
}
).then((data) => {
console.info("==========================>startAbility=======================>");
});
}) })
Text("featureAbility-startAbilityForResult")
.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-startAbilityForResult")
.onClick(() => {
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) .width(320)
.height(50) .height(70)
.fontSize(20) .fontSize(20)
.opacity(1) .opacity(1)
.align(Alignment.TopStart) .align(Alignment.TopStart)
...@@ -346,17 +325,38 @@ export default struct FeatureAbilityAbilityName { ...@@ -346,17 +325,38 @@ export default struct FeatureAbilityAbilityName {
.padding(10) .padding(10)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None }) .textOverflow({ overflow: TextOverflow.None })
.key("requestParamsAbilityNameText") .key("featureAbility-finishWithResult")
.onClick(() => { .onClick(() => {
FeatureAbility.startAbility({ FeatureAbility.finishWithResult({
bundleName: 'com.example.hiaceservice', code:20002,
abilityName: 'com.example.hiaceservice.ComputeServiceAbility' result:{}
}).then((data) => {
console.info("==========================>startAbilityForResult=======================>");
});
}) })
Text("featureAbility-getDeviceList")
.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-finishWithResult")
.onClick(() => {
FeatureAbility.getDeviceList(23).then((data) => {
console.info("==========================>startAbilityForResult=======================>");
});
}) })
Text("featureAbility-Entities") Text("featureAbility-getDeviceList")
.width(320) .width(320)
.height(50) .height(70)
.fontSize(20) .fontSize(20)
.opacity(1) .opacity(1)
.align(Alignment.TopStart) .align(Alignment.TopStart)
...@@ -366,18 +366,40 @@ export default struct FeatureAbilityAbilityName { ...@@ -366,18 +366,40 @@ export default struct FeatureAbilityAbilityName {
.padding(10) .padding(10)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None }) .textOverflow({ overflow: TextOverflow.None })
.key("entitiesText") .key("featureAbility-finishWithResult")
.onClick(() => { .onClick(() => {
FeatureAbility.startAbility({ FeatureAbility.getDeviceList(23).then((data) => {
bundleName: 'com.example.hiaceservice', console.info("==========================>startAbilityForResult=======================>");
abilityName: 'com.example.hiaceservice.ComputeServiceAbility', });
entities: ["this is a test"]
}) })
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-DeviceType") Text("featureAbility-continueAbility")
.width(320) .width(320)
.height(50) .height(70)
.fontSize(20) .fontSize(20)
.opacity(1) .opacity(1)
.align(Alignment.TopStart) .align(Alignment.TopStart)
...@@ -387,13 +409,61 @@ export default struct FeatureAbilityAbilityName { ...@@ -387,13 +409,61 @@ export default struct FeatureAbilityAbilityName {
.padding(10) .padding(10)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None }) .textOverflow({ overflow: TextOverflow.None })
.key("deviceTypeText") .key("featureAbility-continueAbility")
.onClick(() => { .onClick(() => {
FeatureAbility.startAbility({ FeatureAbility.continueAbility().then((data) => {
bundleName: 'com.example.hiaceservice', console.info("==========================>startAbilityForResult=======================>");
abilityName: 'com.example.hiaceservice.ComputeServiceAbility', });
deviceType: 1001
}) })
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%") }.width("100%").height("100%")
......
...@@ -21,6 +21,8 @@ const TAG = 'ets_apiLack_add'; ...@@ -21,6 +21,8 @@ const TAG = 'ets_apiLack_add';
@Component @Component
export default export default
struct LoadingProgressCircular { struct LoadingProgressCircular {
@State circular:LoadingProgressStyle = LoadingProgressStyle.Circular;
@State orbital:LoadingProgressStyle = LoadingProgressStyle.Orbital;
aboutToAppear() { aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear LoadingProgressCircular start`) Log.showInfo(TAG, `aboutToAppear LoadingProgressCircular start`)
} }
...@@ -63,6 +65,7 @@ struct LoadingProgressCircular { ...@@ -63,6 +65,7 @@ struct LoadingProgressCircular {
Text('Orbital LoadingProgress ').fontSize(9).fontColor(0xCCCCCC).width('100%') Text('Orbital LoadingProgress ').fontSize(9).fontColor(0xCCCCCC).width('100%')
LoadingProgress() LoadingProgress()
.color(Color.Blue) .color(Color.Blue)
}.width("100%").height("100%") }.width("100%").height("100%")
} }
} }
......
// @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
...@@ -22,7 +22,8 @@ const TAG = 'ets_apiLack_add'; ...@@ -22,7 +22,8 @@ const TAG = 'ets_apiLack_add';
@Entry @Entry
@Component @Component
export default struct SliderMoving { export default struct SliderMoving {
@State outSetValue: number = 40 @State outSetValue: number = 40;
@State move:SliderChangeMode = SliderChangeMode.Moving;
slide() { slide() {
var rect = Utils.getComponentRect("Slider") var rect = Utils.getComponentRect("Slider")
Utils.drag(rect["left"],rect["top"],rect["right"],rect["bottom"],20) Utils.drag(rect["left"],rect["top"],rect["right"],rect["bottom"],20)
......
...@@ -100,7 +100,8 @@ ...@@ -100,7 +100,8 @@
"pages/search", "pages/search",
"pages/scrollBar", "pages/scrollBar",
"pages/ohosRouterA", "pages/ohosRouterA",
"pages/ohosRouterB" "pages/ohosRouterB",
"pages/WaterflowDemo"
], ],
"name": ".MainAbility", "name": ".MainAbility",
"window": { "window": {
......
// 实现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
// 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)
}
}
}
...@@ -132,7 +132,7 @@ struct NavigationExample { ...@@ -132,7 +132,7 @@ struct NavigationExample {
.titleMode(NavigationTitleMode.Free) .titleMode(NavigationTitleMode.Free)
.hideTitleBar(false) .hideTitleBar(false)
.hideBackButton(false) .hideBackButton(false)
.onTitleModeChanged((titleModel: NavigationTitleMode) => { .onTitleModeChange((titleModel: NavigationTitleMode) => {
console.log('titleMode') console.log('titleMode')
}) })
.toolBar({ items: [ .toolBar({ items: [
......
...@@ -39,6 +39,8 @@ import flexDirectionJsunit from './FlexDirectionJsunit.test.ets'; ...@@ -39,6 +39,8 @@ import flexDirectionJsunit from './FlexDirectionJsunit.test.ets';
import flexWrapJsunit from './FlexWrapJsunit.test.ets'; import flexWrapJsunit from './FlexWrapJsunit.test.ets';
import datePickerJsunit from './DatePickerJsunit.test.ets'; import datePickerJsunit from './DatePickerJsunit.test.ets';
import direction2Jsunit from './Direction2Jsunit.test.ets'; import direction2Jsunit from './Direction2Jsunit.test.ets';
import waterFlowDemoJsunit from './waterFlowDemo.test.ets';
export default function testsuite() { export default function testsuite() {
navigationJsunit(); navigationJsunit();
...@@ -68,4 +70,5 @@ export default function testsuite() { ...@@ -68,4 +70,5 @@ export default function testsuite() {
rowJsunit(); rowJsunit();
systempromptJsunit(); systempromptJsunit();
sourceTypeJsunit(); sourceTypeJsunit();
waterFlowDemoJsunit();
} }
\ No newline at end of file
/**
* 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();
});
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册