提交 ebdfc6aa 编写于 作者: B bayanxing

attr api 覆盖

Signed-off-by: Nbayanxing <bayanxing@kaihong.com>
上级 3ddec422
......@@ -16,6 +16,7 @@ group("arkui") {
deps = [
"ace_ets_component:ActsAceEtsComponentTest",
"ace_ets_component_apilack:ActsAceEtsApiLackTest",
"ace_ets_component_attrlack:ActsAceEtsAttrLackTest",
"ace_ets_component_five:ActsAceEtsComponentFiveTest",
"ace_ets_component_four:ActsAceEtsComponentFourTest",
"ace_ets_component_three:ActsAceEtsComponentThreeTest",
......
......@@ -81,8 +81,10 @@
"pages/curves",
"pages/ellipse",
"pages/featureAbility",
"pages/focusControl",
"pages/form_component",
"pages/gauge",
"pages/global",
"pages/grid",
"pages/grid_col",
"pages/grid_row",
......@@ -95,6 +97,7 @@
"pages/mediaQuery",
"pages/navigator",
"pages/page1",
"pages/pageRoute",
"pages/page_transition",
"pages/panel",
"pages/path",
......
// @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 FocusControlExample {
@State inputValue: string = ''
@State touchOnFocusName: string = 'OnTouchGrpBtn'
@State touchOnFocusName1: string = 'OnTouchBtn1'
@State touchOnFocusName2: string = 'OnTouchBtn2'
@State touchOnFocusName3: string = 'OnTouchBtn3'
@State touchOnFocusName4: string = 'OnTouchBtn4'
build() {
Scroll() {
Row({ space: 20 }) {
Column({ space: 20 }) {
Column({ space: 5 }) {
Button(this.touchOnFocusName)
.width(165)
.height(40)
.key('OnTouchGrpBtn')
.fontColor(Color.White)
.focusable(true)
.onFocus(() => {
try {
this.touchOnFocusName = 'Focus' + this.touchOnFocusName
console.info("onFocus value changed " + this.touchOnFocusName)
var eventData = {
data: {
"value": this.touchOnFocusName,
}
}
var event = {
eventId: 60232,
priority: events_emitter.EventPriority.LOW
}
console.info("OnTouchGrpBtn start to emit action state")
events_emitter.emit(event, eventData)
} catch (err) {
console.info("OnTouchGrpBtn emit action state err: " + JSON.stringify(err.message))
}
})
.focusOnTouch(true) //该Button组件点击后可获焦
Row({ space: 5 }) {
Button(this.touchOnFocusName1)
.width(80)
.height(40)
.key('OnTouchBtn1')
.fontColor(Color.White)
.focusable(true)
.onFocus(() => {
try {
this.touchOnFocusName1 = 'Focus' + this.touchOnFocusName1
console.info("onFocus value changed " + this.touchOnFocusName1)
var eventData = {
data: {
"value": this.touchOnFocusName1,
}
}
var event = {
eventId: 60233,
priority: events_emitter.EventPriority.LOW
}
console.info("OnTouchBtn1 start to emit action state")
events_emitter.emit(event, eventData)
} catch (err) {
console.info("OnTouchBtn1 emit action state err: " + JSON.stringify(err.message))
}
})
.focusOnTouch(true)
Button(this.touchOnFocusName2)
.width(80)
.height(40)
.key('OnTouchBtn2')
.fontColor(Color.White)
.focusable(true)
.onFocus(() => {
try {
this.touchOnFocusName2 = 'Focus' + this.touchOnFocusName2
console.info("onFocus value changed " + this.touchOnFocusName2)
var eventData = {
data: {
"value": this.touchOnFocusName2,
}
}
var event = {
eventId: 60234,
priority: events_emitter.EventPriority.LOW
}
console.info("OnTouchBtn2 start to emit action state")
events_emitter.emit(event, eventData)
} catch (err) {
console.info("OnTouchBtn2 emit action state err: " + JSON.stringify(err.message))
}
})
.focusOnTouch(true) //该Button组件点击后可获焦
}
Row({ space: 5 }) {
Button(this.touchOnFocusName3)
.width(80)
.height(40)
.key('OnTouchBtn3')
.fontColor(Color.White)
.focusable(true)
.onFocus(() => {
this.touchOnFocusName3 = 'Focus' + this.touchOnFocusName3
console.info("onFocus value changed " + this.touchOnFocusName3)
})
.onClick(() => {
try {
var eventData = {
data: {
"value": this.touchOnFocusName3,
}
}
var event = {
eventId: 60235,
priority: events_emitter.EventPriority.LOW
}
console.info("OnTouchBtn3 start to emit action state")
events_emitter.emit(event, eventData)
} catch (err) {
console.info("OnTouchBtn3 emit action state err: " + JSON.stringify(err.message))
}
})
Button(this.touchOnFocusName4)
.width(80)
.height(40)
.key('OnTouchBtn4')
.fontColor(Color.White)
.focusable(true)
.onFocus(() => {
this.touchOnFocusName4 = 'Focus' + this.touchOnFocusName4
console.info("onFocus value changed " + this.touchOnFocusName4)
})
.onClick(() => {
try {
console.info("onClick event " + this.touchOnFocusName4)
var eventData = {
data: {
"value": this.touchOnFocusName4,
}
}
var event = {
eventId: 60236,
priority: events_emitter.EventPriority.LOW
}
console.info("OnTouchBtn4 start to emit action state")
events_emitter.emit(event, eventData)
} catch (err) {
console.info("OnTouchBtn4 emit action state err: " + JSON.stringify(err.message))
}
})
}
}.borderWidth(2).borderColor(Color.Red).borderStyle(BorderStyle.Dashed)
.tabIndex(1) //该Column组件为按TAB键走焦的第一个获焦的组件
Column({ space: 5 }) {
Button('Group2')
.width(165)
.height(40)
.fontColor(Color.White)
Row({ space: 5 }) {
Button()
.width(80)
.height(40)
.fontColor(Color.White)
Button()
.width(80)
.height(40)
.fontColor(Color.White)
.groupDefaultFocus(true) //该Button组件上级Column组件获焦时获焦
}
Row({ space: 5 }) {
Button()
.width(80)
.height(40)
.fontColor(Color.White)
Button()
.width(80)
.height(40)
.fontColor(Color.White)
}
}.borderWidth(2).borderColor(Color.Green).borderStyle(BorderStyle.Dashed)
.tabIndex(2) //该Column组件为按TAB键走焦的第二个获焦的组件
}
Column({ space: 5 }) {
TextInput({placeholder: 'input', text: this.inputValue})
.onChange((value: string) => {
this.inputValue = value
})
.fontColor(Color.Blue)
.focusable(true)
.key('defaultFocusText')
.onFocus(() => {
try {
this.inputValue = 'defaultFocus'
console.info("onFocus value changed " + this.inputValue)
var eventData = {
data: {
"value": this.inputValue,
}
}
var event = {
eventId: 60237,
priority: events_emitter.EventPriority.LOW
}
console.info("defaultFocus test start to emit action start")
events_emitter.emit(event, eventData)
} catch (err) {
console.info("defaultFocus test emit action state err: " + JSON.stringify(err.message))
}
})
.defaultFocus(true) //该TextInput组件为页面的初始默认焦点
Button('Group3')
.width(165)
.height(40)
.fontColor(Color.White)
Row({ space: 5 }) {
Button()
.width(80)
.height(40)
.fontColor(Color.White)
Button()
.width(80)
.height(40)
.fontColor(Color.White)
}
Button()
.width(165)
.height(40)
.fontColor(Color.White)
Row({ space: 5 }) {
Button()
.width(80)
.height(40)
.fontColor(Color.White)
Button()
.width(80)
.height(40)
.fontColor(Color.White)
}
Button()
.width(165)
.height(40)
.fontColor(Color.White)
Row({ space: 5 }) {
Button()
.width(80)
.height(40)
.fontColor(Color.White)
Button()
.width(80)
.height(40)
.fontColor(Color.White)
}
}.borderWidth(2).borderColor(Color.Orange).borderStyle(BorderStyle.Dashed)
.tabIndex(3) //该Column组件为按TAB键走焦的第三个获焦的组件
}.alignItems(VerticalAlign.Top)
}
}
}
\ 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
struct GlobalLack {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear GlobalLack start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear GlobalLack end`)
}
build() {
Column() {
Button("Click2").fontSize(50)
.onClick(() => {
console.info("Click2" + JSON.stringify(sendEventByKey("Del", 10, "")));
}).key("Click2")
List({space:10}) {
ListItem() {
Text("Hello world") {
}
.width('100%')
.height(100)
.fontSize(16)
.textAlign(TextAlign.Center)
.borderRadius(10)
.backgroundColor(0xFFFFFF)
}
.key("ListItem")
.sticky(Sticky.None)
.selectable(false)
.editable(true)
}
}
.padding(10)
.backgroundColor(0xDCDCDC)
.width('100%')
.height('100%')
}
}
\ No newline at end of file
......@@ -21,10 +21,6 @@ import events_emitter from '@ohos.events.emitter';
@Component
export default
struct List_itemOnSelect {
@State selectIndex:boolean = false
@State arr: string[] = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"]
@State alignListItem: ListItemAlign = ListItemAlign.Start
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear List_itemOnSelect start`)
}
......@@ -33,70 +29,41 @@ struct List_itemOnSelect {
Log.showInfo(TAG, `aboutToDisAppear List_itemOnSelect end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("list_item-OnSelect")
.width(100)
.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("onSelectText")
List({ space: 20, initialIndex: 0 }) {
ForEach(this.arr, (item) => {
ListItem() {
Text('' + item)
.width('100%')
.height(100)
.fontSize(16)
@Builder itemEnd() {
Row () {
Button("Del").margin("4vp").key("Del")
Button("Set").margin("4vp").key("Set")
}.padding("4vp").justifyContent(FlexAlign.SpaceEvenly)
}
build() {
Column() {
Button("Click2").fontSize(50)
.onClick(() => {
console.info("Click2" + JSON.stringify(sendEventByKey("Del", 10, "")));
}).key("Click2")
List({space:10}) {
ListItem() {
Text("Hello world") {
}
.editable(true)
.sticky(Sticky.None)
.selectable(true)
.key("ListItem")
.onClick(()=> {
console.info("ListItem onClick")
})
.border({ width: 2, color: Color.Green })
.onSelect((index:boolean)=>{
console.info("Select: " + index)
this.selectIndex = index
try {
var backData = {
data: {
"selectIndex": this.selectIndex
}
}
let backEvent = {
eventId: 60217,
priority: events_emitter.EventPriority.LOW
}
console.info("listItemOnSelect start to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("listItemOnSelect emit action state err: " + JSON.stringify(err.message))
}
})
}, item => item)
.width('100%')
.height(100)
.fontSize(16)
.textAlign(TextAlign.Center)
.borderRadius(10)
.backgroundColor(0xFFFFFF)
}
.key("ListItem")
.sticky(Sticky.None)
.selectable(false)
.editable(true)
.swipeAction({ end:this.itemEnd})
}
.height(300)
.width("90%")
.editMode(true)
.border({ width: 3, color: Color.Red })
.lanes({ minLength: 40, maxLength: 60 })
//lanes(5)
.alignListItem(this.alignListItem)
}.width("100%").height("100%")
}
.padding(10)
.backgroundColor(0xDCDCDC)
.width('100%')
.height('100%')
}
}
// @ts-nocheck
/**
* 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';
@Entry
@Component
struct PageRouteExample {
@State private angle:number = 1;
@State private imageSize:number = 2;
@State private speed:number = 5;
@State private interval:number = 0;
@State private state:string = '';
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center })
{
Image($rawfile('test.png'))
.width(100).height(100).objectFit(ImageFit.Contain)
.margin({top:50,bottom:150,right:10})
.rotate({ x: 0, y: 0, z: 2, angle:this.angle}) // 组件以(1,1,1)为旋转轴,中心点顺时针旋转 300度
.scale({ x: this.imageSize, y: this.imageSize })
Text('speed '+ this.speed)
.fontSize(20).fontWeight(FontWeight.Bold)
Slider({
value: this.speed,
min: 1,
max: 50,
step: 1,
style: SliderStyle.OutSet
})
.blockColor(Color.Orange)
.onChange((value: number) => {
this.speed = value
})
Button('Next', { type: ButtonType.Capsule, stateEffect: true })
.backgroundColor(0x317aff)
.width(90)
.key('next')
.onClick(() => {
console.info('to next page')
router.push({
uri:'pages/index'
})
})
}
.width('100%')
.height('100%')
}
speedChange(){
var that = this
this.interval = setInterval(function(){
that.angle += that.speed
},15)
}
onPageHide() {
console.info('current page will be hidden, value changed')
this.state = 'onPageHide'
try {
var eventData = {
data: {
"value": this.state,
}
}
var event = {
eventId: 10,
priority: events_emitter.EventPriority.LOW
}
console.info("page start to emit action state")
events_emitter.emit(event, eventData)
} catch(err) {
console.info("page emit action state err: " + JSON.stringify(err.message))
}
}
onPageShow(){
this.speedChange()
}
}
\ No newline at end of file
......@@ -13,14 +13,14 @@
* limitations under the License.
*/
import events_emitter from '@ohos.events.emitter';
import Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default struct PanelBackgroundMask {
@State show1: boolean = false
@State show2: boolean = false
@State mode: PanelMode = PanelMode.Full
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear PanelBackgroundMask start`)
......@@ -31,24 +31,7 @@ export default struct PanelBackgroundMask {
}
build() {
// Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) {
Column() {
Text("panel-BackgroundMask")
.width(100)
.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("backgroundMaskText")
.onClick(() => {
this.show1 = !this.show1
})
Text("panel-OnHeightChange")
.width(100)
......@@ -64,40 +47,43 @@ export default struct PanelBackgroundMask {
.textOverflow({ overflow: TextOverflow.None })
.key("onHeightChangeText")
.onClick(() => {
this.show2 = !this.show2
this.mode = PanelMode.Half
})
Panel(this.show1) {
Panel(true) {
Column() {
Text("panel-BackgroundMask").fontSize(30)
}
}
.key("panel")
.mode(this.mode)
.backgroundColor('green')
.type(PanelType.Foldable)
.mode(PanelMode.Half)
.dragBar(false)
.halfHeight(300)
.onChange((width: number, height: number, mode: PanelMode) => {
Log.showInfo(TAG, `width:${width},height:${height},mode:${mode}`)
})
.backgroundMask('red')
Panel(this.show2) {
Column() {
Text("panel-OnHeightChange").fontSize(30)
}
}
.backgroundColor('red')
.type(PanelType.Foldable)
.mode(PanelMode.Half)
.dragBar(false)
.halfHeight(300)
.onChange((width: number, height: number, mode: PanelMode) => {
console.log(`width:${width},height:${height},mode:${mode}`)
})
.onHeightChange((value: number) => {
Log.showInfo(TAG, 'onHeightChange: ' + value)
})
try {
var backData = {
data: {
"result":"success"
}
}
let backEvent = {
eventId: 10111,
priority: events_emitter.EventPriority.LOW
}
console.info("onHeightChange start to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("testpanelOnHeightChange0002 emit action state err: " + JSON.stringify(err.message))
}
})
}.width("100%").height("100%")
}
}
......@@ -65,6 +65,7 @@ struct SideBarShowSideBar {
.showSideBar(true)
.autoHide(false)
.sideBarWidth(240)
.sideBarPosition(SideBarPosition.End)
.minSideBarWidth(210)
.maxSideBarWidth(260)
.onChange((value: boolean) => {
......
// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"
import router from '@system.router';
import events_emitter from '@ohos.events.emitter'
import Utils from './Utils';
export default function focusControlJsunit() {
describe('focusControlTest', function () {
beforeEach(async function (done) {
console.info("focusControlTest beforeEach start");
let options = {
uri: 'pages/focusControl',
}
let result;
try {
router.clear();
let pages = router.getState();
console.info("get focus state pages: " + JSON.stringify(pages));
if (!("focusControl" == pages.name)) {
console.info("get focus state pages.name: " + JSON.stringify(pages.name));
result = await router.push(options);
await Utils.sleep(2000);
console.info("push focus page result: " + JSON.stringify(result));
}
} catch (err) {
console.error("push focus page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("focus after each called");
})
it('testFocusOnTouch01', 0, async function (done) {
console.info('[testFocusOnTouch01] START');
await Utils.sleep(1000);
var callback = (eventData) => {
if (eventData != null) {
console.info("[testFocusOnTouch01] get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.value).assertEqual('FocusOnTouchGrpBtn')
done()
}
}
var innerEvent = {
eventId: 60232,
priority: events_emitter.EventPriority.LOW
}
try {
console.info("testFocusOnTouch01 click result is: " + JSON.stringify(sendEventByKey('OnTouchGrpBtn', 10, "")));
events_emitter.on(innerEvent, callback)
} catch (err) {
console.info("[testFocusOnTouch01] on events_emitter err : " + JSON.stringify(err));
}
console.info('[testFocusOnTouch01] testSendTouchEvent END');
});
it('testFocusOnTouch02', 0, async function (done) {
console.info('[testFocusOnTouch02] START');
await Utils.sleep(1000);
var callback = (eventData) => {
if (eventData != null) {
console.info("[testFocusOnTouch02] get event state result is: " + JSON.stringify(eventData))
expect(eventData.data.value).assertEqual('FocusOnTouchBtn1')
done()
}
}
var innerEvent = {
eventId: 60233,
priority: events_emitter.EventPriority.LOW
}
try {
console.info("testFocusOnTouch02 click result is: " + JSON.stringify(sendEventByKey('OnTouchBtn1', 10, "")));
events_emitter.on(innerEvent, callback)
} catch (err) {
console.info("[testFocusOnTouch02] on events_emitter err : " + JSON.stringify(err));
}
console.info('[testFocusOnTouch02] testSendTouchEvent END');
});
it('testFocusOnTouch03', 0, async function (done) {
console.info('[testFocusOnTouch03] START');
await Utils.sleep(1000);
var callback = (eventData) => {
if (eventData != null) {
console.info("[testFocusOnTouch03] get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.value).assertEqual('FocusOnTouchBtn2')
done()
}
}
var innerEvent = {
eventId: 60234,
priority: events_emitter.EventPriority.LOW
}
try {
console.info("testFocusOnTouch03 click result is: " + JSON.stringify(sendEventByKey('OnTouchBtn2', 10, "")));
events_emitter.on(innerEvent, callback)
} catch (err) {
console.info("[testFocusOnTouch03] on events_emitter err : " + JSON.stringify(err));
}
console.info('[testFocusOnTouch03] testSendTouchEvent END');
});
it('testFocusOnTouch04', 0, async function (done) {
console.info('[testFocusOnTouch04] START');
await Utils.sleep(1000);
var callback = (eventData) => {
if (eventData != null) {
console.info("[testFocusOnTouch04] get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.value).assertEqual('OnTouchBtn3')
done()
}
}
var innerEvent = {
eventId: 60235,
priority: events_emitter.EventPriority.LOW
}
try {
console.info("testFocusOnTouch04 click result is: " + JSON.stringify(sendEventByKey('OnTouchBtn3', 10, "")));
events_emitter.on(innerEvent, callback)
} catch (err) {
console.info("[testFocusOnTouch04] on events_emitter err : " + JSON.stringify(err));
}
console.info('[testFocusOnTouch04] testSendTouchEvent END');
});
it('testFocusOnTouch05', 0, async function (done) {
console.info('[testFocusOnTouch05] START');
await Utils.sleep(1000);
var callback = (eventData) => {
if (eventData != null) {
console.info("[testFocusOnTouch05] get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.value).assertEqual('OnTouchBtn4')
done()
}
}
var innerEvent = {
eventId: 60236,
priority: events_emitter.EventPriority.LOW
}
try {
console.info("testFocusOnTouch05 click result is: " + JSON.stringify(sendEventByKey('OnTouchBtn4', 10, "")));
events_emitter.on(innerEvent, callback)
} catch (err) {
console.info("[testFocusOnTouch05] on events_emitter err : " + JSON.stringify(err));
}
console.info('[testFocusOnTouch05] testSendTouchEvent END');
});
it('testDefaultFocus06', 0, async function (done) {
console.info('[testDefaultFocus06] START');
await Utils.sleep(1000);
var callback = (eventData) => {
if (eventData != null) {
console.info("[testDefaultFocus06] get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.value).assertEqual('defaultFocus')
done()
}
}
var innerEvent = {
eventId: 60237,
priority: events_emitter.EventPriority.LOW
}
try {
events_emitter.on(innerEvent, callback)
} catch (err) {
console.info("[testDefaultFocus06] on events_emitter err : " + JSON.stringify(err));
}
console.info('[testDefaultFocus06] END');
});
})
}
\ No newline at end of file
......@@ -21,8 +21,10 @@ import commonBackgroundBlurStyleJsunit from './common.test.ets';
import common_ts_ets_apiStaticClearJsunit from './common_ts_ets_api.test.ets';
import ellipseNeJsunit from './ellipse.test.ets';
import featureAbilityStartAbilityJsunit from './featureAbility.test.ets';
import focusControlJsunit from './FocusControlJsunit.test.ets'
import gaugeColorsJsunit from './gauge.test.ets';
import gestureSetDirectionJsunit from './gesture.test.ets';
import globalJsunit from './global.test.ets';
import gridMaxCountJsunit from './grid.test.ets';
import gridItemOnSelectJsunit from './gridItem.test.ets';
import grid_colSpanJsunit from './grid_col.test.ets';
......@@ -34,6 +36,7 @@ import listNewJsunit from './listTest.test.ets';
import list_itemOnSelectJsunit from './list_item.test.ets';
import mediaQueryOffJsunit from './mediaQuery.test.ets';
import navigatorTargetJsunit from './navigator.test.ets'
import pageRouteTest from './pageRoute.test.ets'
import panelBackgroundMaskJsunit from './panel.test.ets';
import pathNewTest from './path.test.ets';
import polygonNewJsunit from './polygon.test.ets';
......@@ -69,6 +72,7 @@ export default function testsuite() {
featureAbilityStartAbilityJsunit()
gaugeColorsJsunit()
gestureSetDirectionJsunit()
globalJsunit()
gridMaxCountJsunit()
gridItemOnSelectJsunit()
inspectorJsunit()
......@@ -77,6 +81,7 @@ export default function testsuite() {
list_itemOnSelectJsunit()
mediaQueryOffJsunit()
navigatorTargetJsunit()
pageRouteTest()
panelBackgroundMaskJsunit()
pathNewTest()
polygonNewJsunit()
......
/**
* 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 globalJsunit() {
describe('globalJsunit', function () {
beforeEach(async function (done) {
console.info("global beforeEach start");
let options = {
uri: 'pages/global',
}
try {
router.clear();
let pages = router.getState();
console.info("get global state pages:" + JSON.stringify(pages));
if (!("global" == pages.name)) {
console.info("get global state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push global page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push global page error:" + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0001
* @tc.name testglobal_getInspectorTree0001
* @tc.desic aceGlobal_getInspectorTree0001
*/
it('testglobal_getInspectorTree0001', 0, async function (done) {
console.info('testglobal_getInspectorTree0001 START');
await Utils.sleep(2000);
let strJson = getInspectorTree();
console.info("[testglobal_getInspectorTree0001] strJson:" + strJson);
expect(strJson !== null).assertTrue();
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0002
* @tc.name testglobal_sendKeyEvent0002
* @tc.desic aceGlobal_sendKeyEvent0002
*/
it('testglobal_sendKeyEvent0002', 0, async function (done) {
console.info('testglobal_sendKeyEvent0002 START');
await Utils.sleep(2000);
let KeyEvent = {type:1,keyCode:2027,keyText:"Unknown",keySource:4,deviceId:7,metaKey:0,timestamp:5284417765376};
let result = sendKeyEvent(KeyEvent);
console.info("[testglobal_sendKeyEvent0002] result:" + result);
expect(JSON.stringify(result)).assertEqual("true");
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0003
* @tc.name testglobal_sendMouseEvent0003
* @tc.desic aceGlobal_sendMouseEvent0003
*/
it('testglobal_sendMouseEvent0003', 0, async function (done) {
console.info('testglobal_sendMouseEvent0003 START');
await Utils.sleep(2000);
let mouseEvent = {button:0,action:3,screenX:202.66666666666666,screenY:102.66666666666667,x:34,y:34,timestamp:8261302454000,source:1,
target:{area:{position:{x:158.66666666666666,y:58.666666666666664},globalPosition:{x:168.66666666666666,y:68.66666666666666},width:142.66666666666666,height:58.666666666666664}}};
let result = sendMouseEvent(mouseEvent);
console.info("[testglobal_sendMouseEvent0003] result:" + result);
expect(JSON.stringify(result)).assertEqual("true");
done();
});
})
}
\ No newline at end of file
......@@ -96,5 +96,18 @@ export default function list_itemOnSelectJsunit() {
console.info("[testlist_itemOnSelect0003] sticky value :" + obj.$attrs.sticky);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0004
* @tc.name testlist_itemSwipeAction0004
* @tc.desic acelist_itemSwipeActionEtsTest0004
*/
it('testlist_itemSwipeAction0004', 0, async function (done) {
console.info('selectOnSelect testlist_itemSwipeAction0004 START');
await Utils.sleep(2000);
let obj = JSON.stringify(sendEventByKey('Del', 10, ""))
expect(obj).assertEqual('false');
done();
});
})
}
// @ts-nocheck
/**
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import router from '@system.router';
import events_emitter from '@ohos.events.emitter'
import Utils from './Utils'
export default function pageRouteTest() {
describe('pageRouteTest', function () {
beforeEach(async function (done) {
console.info("pageRouteTest beforeEach start");
let options = {
uri: 'pages/pageRoute',
}
let result;
try {
router.clear();
let pages = router.getState();
console.info("get pageRouteTest pages: " + JSON.stringify(pages));
if (!("pageRoute" == pages.name)) {
console.info("get pageRouteTest pages.name: " + JSON.stringify(pages.name));
result = await router.push(options);
await Utils.sleep(2000);
console.info("pageRouteTest page result: " + JSON.stringify(result));
}
} catch (err) {
console.error("pageRouteTest page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("pageRouteTest after each called");
})
it('testOnPageHide01', 0, function () {
console.info('[testOnPageHide01] START');
var callback = (eventData) => {
console.info("[testOnPageHide01] get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.value).assertEqual('onPageHide')
done()
}
var innerEvent = {
eventId: 10,
priority: events_emitter.EventPriority.LOW
}
try {
events_emitter.on(innerEvent, callback)
console.info("testOnPageHide01 click result is: " + JSON.stringify(sendEventByKey('next', 10, "")));
} catch (err) {
console.info("[testOnPageHide01] on events_emitter err : " + JSON.stringify(err));
}
console.info('[testOnPageHide01] testSendTouchEvent END');
});
})
}
\ No newline at end of file
......@@ -14,6 +14,7 @@
*/
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'
......@@ -53,149 +54,44 @@ export default function panelBackgroundMaskJsunit() {
it('testpanelBackgroundMask0001', 0, async function (done) {
console.info('panelBackgroundMask testpanelBackgroundMask0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('backgroundMaskText');
console.info("[testpanelBackgroundMask0001] component width strJson:" + strJson);
let strJson = getInspectorByKey('panel');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.width).assertEqual("100.00vp");
console.info("[testpanelBackgroundMask0001] width value :" + obj.$attrs.width);
console.info("get inspector value is: " + JSON.stringify(obj));
console.log(JSON.stringify(obj.$type))
expect(obj.$type).assertEqual('Panel')
console.log('Panel‘s backgroundMask is ' + JSON.stringify(obj.$attrs.backgroundMask))
expect(obj.$attrs.backgroundMask).assertEqual('#FFFF0000');
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0002
* @tc.name testpanelBackgroundMask0002
* @tc.name testpanelOnHeightChange0002
* @tc.desic acepanelBackgroundMaskEtsTest0002
*/
it('testpanelBackgroundMask0002', 0, async function (done) {
console.info('panelBackgroundMask testpanelBackgroundMask0002 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('backgroundMaskText');
console.info("[testpanelBackgroundMask0002] component height strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.height).assertEqual("70.00vp");
console.info("[testpanelBackgroundMask0002] height value :" + obj.$attrs.height);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0003
* @tc.name testpanelBackgroundMask0003
* @tc.desic acepanelBackgroundMaskEtsTest0003
*/
it('testpanelBackgroundMask0003', 0, async function (done) {
console.info('panelBackgroundMask testpanelBackgroundMask0003 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('backgroundMaskText');
console.info("[testpanelBackgroundMask0003] component fontSize strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.fontSize).assertEqual("20.00fp");
console.info("[testpanelBackgroundMask0003] fontSize value :" + obj.$attrs.fontSize);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0004
* @tc.name testpanelBackgroundMask0004
* @tc.desic acepanelBackgroundMaskEtsTest0004
*/
it('testpanelBackgroundMask0004', 0, async function (done) {
console.info('panelBackgroundMask testpanelBackgroundMask0004 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('backgroundMaskText');
console.info("[testpanelBackgroundMask0004] component opacity strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.opacity).assertEqual(1);
console.info("[testpanelBackgroundMask0004] opacity value :" + obj.$attrs.opacity);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0005
* @tc.name testpanelBackgroundMask0005
* @tc.desic acepanelBackgroundMaskEtsTest0005
*/
it('testpanelBackgroundMask0005', 0, async function (done) {
console.info('panelBackgroundMask testpanelBackgroundMask0005 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('backgroundMaskText');
console.info("[testpanelBackgroundMask0005] component align strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.align).assertEqual("Alignment.TopStart");
console.info("[testpanelBackgroundMask0005] align value :" + obj.$attrs.align);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0006
* @tc.name testpanelBackgroundMask0006
* @tc.desic acepanelBackgroundMaskEtsTest0006
*/
it('testpanelBackgroundMask0006', 0, async function (done) {
console.info('panelBackgroundMask testpanelBackgroundMask0006 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('backgroundMaskText');
console.info("[testpanelBackgroundMask0006] component fontColor strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.fontColor).assertEqual("#FFCCCCCC");
console.info("[testpanelBackgroundMask0006] fontColor value :" + obj.$attrs.fontColor);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0007
* @tc.name testpanelBackgroundMask0007
* @tc.desic acepanelBackgroundMaskEtsTest0007
*/
it('testpanelBackgroundMask0007', 0, async function (done) {
console.info('panelBackgroundMask testpanelBackgroundMask0007 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('backgroundMaskText');
console.info("[testpanelBackgroundMask0007] component lineHeight strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.lineHeight).assertEqual("25.00fp");
console.info("[testpanelBackgroundMask0007] lineHeight value :" + obj.$attrs.lineHeight);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0009
* @tc.name testpanelBackgroundMask0009
* @tc.desic acepanelBackgroundMaskEtsTest0009
*/
it('testpanelBackgroundMask0009', 0, async function (done) {
console.info('panelBackgroundMask testpanelBackgroundMask009 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('backgroundMaskText');
console.info("[testpanelBackgroundMask0009] component padding strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.padding).assertEqual("10.00vp");
console.info("[testpanelBackgroundMask0009] padding value :" + obj.$attrs.padding);
done();
it('testpanelOnHeightChange0002', 0, async function (done) {
console.info('panelBackgroundMask testpanelOnHeightChange0002 START');
var panelOnHeightChangeEvent = {
eventId: 10111,
priority: events_emitter.EventPriority.LOW
}
var callback1 = (backData) => {
console.info("testpanelOnHeightChange0002 backData.data.result is: " + backData.data.result);
try{
console.info("testpanelOnHeightChange0002 callback1 success" );
expect(backData.data.result).assertEqual("success");
done();
}catch(err){
console.info("testpanelOnHeightChange0002 on events_emitter err : " + JSON.stringify(err));
}
}
try {
console.info("testpanelOnHeightChange0002 click result is: " + JSON.stringify(sendEventByKey('onHeightChangeText', 10, "")));
events_emitter.on(panelOnHeightChangeEvent, callback1);
} catch (err) {
console.info("testpanelOnHeightChange0002 on events_emitter err : " + JSON.stringify(err));
}
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0010
* @tc.name testpanelBackgroundMask0010
* @tc.desic acepanelBackgroundMaskEtsTest0010
*/
it('testpanelBackgroundMask0010', 0, async function (done) {
console.info('panelBackgroundMask testpanelBackgroundMask0010 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('backgroundMaskText');
console.info("[testpanelBackgroundMask0010] component textAlign strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.textAlign).assertEqual("TextAlign.Left");
console.info("[testpanelBackgroundMask0010] textAlign value :" + obj.$attrs.textAlign);
done();
});
})
}
......@@ -79,5 +79,21 @@ export default function sideBarShowSideBarJsunit() {
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0003
* @tc.name testsideBarShowSideBar0003
* @tc.desic acesideBarShowSideBarEtsTest0003
*/
it('testsideBarShowSideBar0003', 0, async function (done) {
console.info('sideBarShowSideBar testsideBarShowSideBar0003 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('SideBarContainer');
console.info("[testsideBarShowSideBar0003] component autoHide strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('SideBarContainer');
expect(obj.$attrs.sideBarPosition).assertEqual(undefined);
console.info("[testsideBarShowSideBar0003] autoHide value :" + obj.$attrs.autoHide);
done();
});
})
}
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAceEtsAttrLackTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":ace_ets_dev_assets",
":ace_ets_dev_resources",
":ace_ets_dev_test_assets",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAceEtsAttrLackTest"
}
ohos_js_assets("ace_ets_dev_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_js_assets("ace_ets_dev_test_assets") {
source_dir = "./entry/src/main/ets/TestAbility"
}
ohos_resources("ace_ets_dev_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for aceEtsAttrLack Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.open.harmony.aceEtsAttrLack",
"package-name": "com.open.harmony.aceEtsAttrLack",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsAceEtsAttrLackTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.open.harmony.aceEtsAttrLack",
"vendor": "open",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 8
}
},
"deviceConfig": {},
"module": {
"package": "com.open.harmony.aceEtsAttrLack",
"name": ".MyApplication",
"mainAbility": "com.open.harmony.aceEtsAttrLack.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"formsEnabled": false,
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
},
{
"orientation": "unspecified",
"visible": true,
"srcPath": "TestAbility",
"name": ".TestAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"formsEnabled": false,
"label": "$string:TestAbility_label",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index",
"pages/page1",
"pages/page2",
"pages/alertDialog",
"pages/animate_play_mode",
"pages/animator",
"pages/app",
"pages/attr_animate",
"pages/canvas",
"pages/checkBox",
"pages/checkBoxGroup",
"pages/common",
"pages/curves",
"pages/datePicker",
"pages/edgeEffect",
"pages/enums",
"pages/featureAbility",
"pages/fill_mode",
"pages/gesture",
"pages/gridCol",
"pages/gridRow",
"pages/listtest",
"pages/loadingProgress",
"pages/pluginComponent",
"pages/progress",
"pages/radio",
"pages/refresh",
"pages/router",
"pages/scroll_edge",
"pages/sidebar",
"pages/slider",
"pages/stateManagement",
"pages/stepperItem",
"pages/swiper",
"pages/text_input",
"pages/units",
"pages/web",
"pages/copyOption",
"pages/responseType",
"pages/hoverEffect"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
/**
* 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('Application onCreate')
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ No newline at end of file
const TAG = 'ets_apiLack_add';
/**
* Basic log class
*/
export default class Log {
/**
* print info level log
*
* @param {string} tag - Page or class tag
* @param {string} log - Log needs to be printed
*/
static showInfo(tag, log) {
console.info(`${TAG} tag: ${tag} --> ${log}`);
}
/**
* print debug level log
*
* @param {string} tag - Page or class tag
* @param {string} log - Log needs to be printed
*/
static showDebug(tag, log) {
console.debug(`${TAG} tag: ${tag} --> ${log}`);
}
/**
* print error level log
*
* @param {string} tag - Page or class tag
* @param {string} log - Log needs to be printed
*/
static showError(tag, log) {
console.error(`${TAG} tag: ${tag} --> ${log}`);
}
}
// @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.
*/
export default class Utils {
static rect_left;
static rect_top;
static rect_right;
static rect_bottom;
static rect_value;
static sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
static getComponentRect(key) {
let strJson = getInspectorByKey(key);
let obj = JSON.parse(strJson);
console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj));
let rectInfo = JSON.parse('[' + obj.$rect + ']')
console.info("[getInspectorByKey] rectInfo is: " + rectInfo);
this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]
this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]
this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]
this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1]
return this.rect_value = {
"left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom
}
}
static async swipe(downX, downY, upX, upY, steps) {
console.info('start to swipe')
this.drags(downX, downY, upX, upY, steps, false)
}
static async drag(downX, downY, upX, upY, steps) {
console.info('start to drag')
this.drags(downX, downY, upX, upY, steps, true)
}
static async drags(downX, downY, upX, upY, steps, drag) {
var xStep;
var yStep;
var swipeSteps;
var ret;
xStep = 0;
yStep = 0;
ret = false;
swipeSteps = steps;
if (swipeSteps == 0) {
swipeSteps = 1;
}
xStep = (upX - downX) / swipeSteps;
yStep = (upY - downY) / swipeSteps;
console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep)
var downPoint: TouchObject = {
id: 1,
x: downX,
y: downY,
type: TouchType.Down,
}
console.info('down touch started: ' + JSON.stringify(downPonit))
sendTouchEvent(downPoint);
console.info('start to move')
if (drag) {
await this.sleep(500)
}
for (var i = 1;i <= swipeSteps; i++) {
var movePoint: TouchObject = {
id: 1,
x: downX + (xStep * i),
y: downY + (yStep * i),
type: TouchType.Move
}
console.info('move touch started: ' + JSON.stringify(movePoint))
ret = sendTouchEvent(movePoint)
if (ret == false) {
break;
}
await this.sleep(5)
}
console.info('start to up')
if (drag) {
await this.sleep(100)
}
var upPoint: TouchObject = {
id: 1,
x: upX,
y: upY,
type: TouchType.Up,
}
console.info('up touch started: ' + JSON.stringify(upPoint))
sendTouchEvent(upPoint)
await this.sleep(500)
}
}
/**
* 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 pluginComponentManager from '@ohos.pluginComponent'
function onPushListener(source, template, data, extraData) {
console.log("onPushListener template.source=" + template.source)
var jsonObject = JSON.parse(data.componentTemplate.source)
console.log("request_callback1:source json object" + jsonObject)
var jsonArry = jsonObject.ExternalComponent
for (var i in jsonArry) {
console.log(jsonArry[i])
}
console.log("onPushListener:source json object" + jsonObject)
console.log("onPushListener:source json string" + JSON.stringify(jsonObject))
console.log("onPushListener template.ability=" + template.ability)
console.log("onPushListener data=" + JSON.stringify(data))
console.log("onPushListener extraData=" + JSON.stringify(extraData))
}
function onRequestListener(source, name, data)
{
console.log("onRequestListener name=" + name);
console.log("onRequestListener data=" + JSON.stringify(data));
return {template:"plugintemplate", data:data};
}
export default {
//register listener
onListener() {
pluginComponentManager.on("push", onPushListener)
pluginComponentManager.on("request", onRequestListener)
},
Push() {
// 组件提供方主动发送事件
pluginComponentManager.push(
{
want: {
bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility",
},
name: "plugintemplate",
data: {
"key_1": "plugin component test",
"key_2": 34234
},
extraData: {
"extra_str": "this is push event"
},
jsonPath: "",
},
(err, data) => {
console.log("push_callback: push ok!");
}
)
},
Request() {
// 组件使用方主动发送事件
pluginComponentManager.request({
want: {
bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility",
},
name: "plugintemplate",
data: {
"key_1": "plugin component test",
"key_2": 34234
},
jsonPath: "",
},
(err, data) => {
console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability)
console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source)
var jsonObject = JSON.parse(data.componentTemplate.source)
console.log("request_callback:source json object" + jsonObject)
var jsonArry = jsonObject.ExternalComponent
for (var i in jsonArry) {
console.log(jsonArry[i])
}
console.log("request_callback:source json string" + JSON.stringify(jsonObject))
console.log("request_callback: data=" + JSON.stringify(data.data))
console.log("request_callback: extraData=" + JSON.stringify(data.extraData))
}
)
}
}
\ 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 plugin from "plugin_component.js"
@Entry
@Component
struct PluginProviderExample {
@State message: string = 'no click!'
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Button('Register Push Listener')
.fontSize(30)
.width(400)
.height(100)
.margin({top:20})
.onClick(()=>{
plugin.onListener()
console.log("Button('Register Push Listener')")
})
Button('Push')
.fontSize(30)
.width(400)
.height(100)
.margin({top:20})
.onClick(()=>{
plugin.Push()
this.message = "Button('Push')"
console.log("Button('Push')")
})
Text(this.message)
.height(150)
.fontSize(30)
.padding(5)
.margin(5)
}.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 })
}
}
\ 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 Log from '../common/Log.ets';
import events_emitter from '@ohos.events.emitter';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct AlertDialogCenterStart {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear AlertDialogCenterStart start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear AlertDialogCenterStart end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("alertDialog-CenterStart")
.width(100)
.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("CenterStartText")
Text("alertDialog-CenterEnd")
.width(100)
.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("CenterEndText")
Button('one button dialog')
.key("CenterStartButton")
.onClick(() => {
AlertDialog.show(
{
title: 'title',
message: 'text',
confirm: {
value: 'button',
action: () => {
console.info('Button-clicking callback')
}
},
cancel: () => {
console.info('Closed callbacks')
},
alignment:DialogAlignment.CenterStart
}
)
try {
var backData = {
data: {
"Result": true
}
}
let backEvent = {
eventId: 81601,
priority: events_emitter.EventPriority.LOW
}
console.info("CenterStart start to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("CenterStart emit action state err: " + JSON.stringify(err.message))
}
})
.backgroundColor(0x317aff)
Button('two button dialog')
.key("CenterEndButton")
.onClick(() => {
AlertDialog.show(
{
title: 'title',
message: 'text',
primaryButton: {
value: 'cancel',
action: () => {
console.info('Callback when the first button is clicked')
}
},
secondaryButton: {
value: 'ok',
action: () => {
console.info('Callback when the second button is clicked')
}
},
cancel: () => {
console.info('Closed callbacks')
},
alignment:DialogAlignment.CenterEnd
}
)
try {
var backData = {
data: {
"Result": true
}
}
let backEvent = {
eventId: 81602,
priority: events_emitter.EventPriority.LOW
}
console.info("CenterEnd start to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("CenterEnd emit action state err: " + JSON.stringify(err.message))
}
}).backgroundColor(0x317aff)
}.width("100%").height("100%")
}
}
/**
* 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
struct AttrAnimationExample {
@State widthSize: number = 200
@State heightSize: number = 100
@State flag: boolean = true
@State widthSizeAlternate: number = 200
@State heightSizeAlternate: number = 100
@State flagAlternate: boolean = true
@State widthSizeNormal: number = 200
@State heightSizeNormal: number = 100
@State flagNormal: boolean = true
@State widthSizeAlternateReverse: number = 200
@State heightSizeAlternateReverse: number = 100
@State flagAlternateReverse: boolean = true
build() {
Column() {
Button('PlayMode.Reverse')
.onClick((event: ClickEvent) => {
if (this.flag) {
this.widthSize = 100
this.heightSize = 50
} else {
this.widthSize = 200
this.heightSize = 100
}
this.flag = !this.flag
})
.width(this.widthSize).height(this.heightSize).backgroundColor(0x317aff)
.key("Reverse")
.animation({
duration: 3000, // 动画时长
curve: Curve.EaseOut, // 动画曲线
delay: 1000, // 动画延迟
iterations: 1, // 播放次数
playMode: PlayMode.Reverse // 动画模式
}) // 对Button组件的宽高属性进行动画配置
Button('PlayMode.Alternate')
.onClick((event: ClickEvent) => {
if (this.flagAlternate) {
this.widthSizeAlternate = 100
this.heightSizeAlternate = 50
} else {
this.widthSizeAlternate = 200
this.heightSizeAlternate = 100
}
this.flagAlternate = !this.flagAlternate
})
.width(this.widthSizeAlternate).height(this.heightSizeAlternate).backgroundColor(0x317aff)
.key("Alternate")
.animation({
duration: 3000,
curve: Curve.EaseOut,
delay: 1000,
iterations: 1,
playMode: PlayMode.Alternate
})
Button('PlayMode.Normal')
.onClick((event: ClickEvent) => {
if (this.flagNormal) {
this.widthSizeNormal = 100
this.heightSizeNormal = 50
} else {
this.widthSizeNormal = 200
this.heightSizeNormal = 100
}
this.flagNormal = !this.flagNormal
})
.width(this.widthSizeNormal).height(this.heightSizeNormal).backgroundColor(0x317aff)
.key("Normal")
.animation({
duration: 3000,
curve: Curve.EaseOut,
delay: 1000,
iterations: 1,
playMode: PlayMode.Normal
})
Button('PlayMode.AlternateReverse')
.onClick((event: ClickEvent) => {
if (this.flagAlternateReverse) {
this.widthSizeAlternateReverse = 100
this.heightSizeAlternateReverse = 50
} else {
this.widthSizeAlternateReverse = 200
this.heightSizeAlternateReverse = 100
}
this.flagAlternateReverse = !this.flagAlternateReverse
})
.width(this.widthSizeAlternateReverse).height(this.heightSizeAlternateReverse).backgroundColor(0x317aff)
.key("AlternateReverse")
.animation({
duration: 3000,
curve: Curve.EaseOut,
delay: 1000,
iterations: 1,
playMode: PlayMode.AlternateReverse
})
}.width('100%').margin({ top: 5 })
}
}
\ 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct AnimatorOnframe {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear AnimatorOnframe start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear AnimatorOnframe end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("animator-Onframe")
.width(100)
.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("onframeText")
}.width("100%").height("100%")
}
}
/**
* 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 app from '@system.app';
import events_emitter from '@ohos.events.emitter';
import Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
struct AppVersionCode {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear AppVersionCode start:`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear AppVersionCode end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("app-VersionCode")
.width(100)
.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("versionCodeText")
.onClick(()=>{
app.getInfo().versionCode = 1
try {
var backData = {
data: {
"Code": app.getInfo().versionCode
}
}
let backEvent = {
eventId: 60302,
priority: events_emitter.EventPriority.LOW
}
console.info("versionCode start to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("versionCode emit action state err: " + JSON.stringify(err.message))
}
})
}.width("100%").height("100%")
}
}
/**
* 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
struct AttrAnimationExample {
@State widthSize: number = 200
@State heightSize: number = 80
@State flag: boolean = true
@State widthSizeEaseOut: number = 200
@State heightSizeEaseOut: number = 80
@State flagEaseOut: boolean = true
@State widthSizeFastOutSlowIn: number = 200
@State heightSizeFastOutSlowIn: number = 80
@State flagFastOutSlowIn: boolean = true
@State widthSizeLinearOutSlowIn: number = 200
@State heightSizeLinearOutSlowIn: number = 80
@State flagLinearOutSlowIn: boolean = true
@State widthSizeFastOutLinearIn: number = 200
@State heightSizeFastOutLinearIn: number = 80
@State flagFastOutLinearIn: boolean = true
@State widthSizeExtremeDeceleration: number = 200
@State heightSizeExtremeDeceleration: number = 80
@State flagExtremeDeceleration: boolean = true
@State widthSizeSharp: number = 200
@State heightSizeSharp: number = 80
@State flagSharp: boolean = true
@State widthSizeRhythm: number = 200
@State heightSizeRhythm: number = 80
@State flagRhythm: boolean = true
@State widthSizeSmooth: number = 200
@State heightSizeSmooth: number = 80
@State flagSmooth: boolean = true
@State widthSizeFriction: number = 200
@State heightSizeFriction: number = 80
@State flagFriction: boolean = true
build() {
Column() {
Button('EaseInOut')
.onClick((event: ClickEvent) => {
if (this.flag) {
this.widthSize = 100
this.heightSize = 50
} else {
this.widthSize = 200
this.heightSize = 80
}
this.flag = !this.flag
})
.width(this.widthSize).height(this.heightSize).backgroundColor(0x317aff)
.animation({
duration: 2000, // 动画时长
curve: Curve.EaseInOut, // 动画曲线
delay: 500, // 动画延迟
iterations: 1, // 播放次数
playMode: PlayMode.Normal // 动画模式
})
Button('Curve.EaseOut')
.onClick((event: ClickEvent) => {
if (this.flagEaseOut) {
this.widthSizeEaseOut = 100
this.heightSizeEaseOut = 50
} else {
this.widthSizeEaseOut = 200
this.heightSizeEaseOut = 80
}
this.flagEaseOut = !this.flagEaseOut
})
.width(this.widthSizeEaseOut).height(this.heightSizeEaseOut).backgroundColor(0x317aff)
.animation({
duration: 2000,
curve: Curve.EaseOut,
delay: 500,
iterations: 1,
playMode: PlayMode.Normal
})
Button('FastOutSlowIn')
.onClick((event: ClickEvent) => {
if (this.flagFastOutSlowIn) {
this.widthSizeFastOutSlowIn = 100
this.heightSizeFastOutSlowIn = 50
} else {
this.widthSizeFastOutSlowIn = 200
this.heightSizeFastOutSlowIn = 80
}
this.flagFastOutSlowIn = !this.flagFastOutSlowIn
})
.width(this.widthSizeFastOutSlowIn).height(this.heightSizeFastOutSlowIn).backgroundColor(0x317aff)
.animation({
duration: 2000,
curve: Curve.FastOutSlowIn,
delay: 500,
iterations: 1,
playMode: PlayMode.Normal
})
Button('LinearOutSlowIn')
.onClick((event: ClickEvent) => {
if (this.flagLinearOutSlowIn) {
this.widthSizeLinearOutSlowIn = 100
this.heightSizeLinearOutSlowIn = 50
} else {
this.widthSizeLinearOutSlowIn = 200
this.heightSizeLinearOutSlowIn = 80
}
this.flagLinearOutSlowIn = !this.flagLinearOutSlowIn
})
.width(this.widthSizeLinearOutSlowIn).height(this.heightSizeLinearOutSlowIn).backgroundColor(0x317aff)
.animation({
duration: 2000,
curve: Curve.LinearOutSlowIn,
delay: 500,
iterations: 1,
playMode: PlayMode.Normal
})
Button('FastOutLinearIn')
.onClick((event: ClickEvent) => {
if (this.flagFastOutLinearIn) {
this.widthSizeFastOutLinearIn = 100
this.heightSizeFastOutLinearIn = 50
} else {
this.widthSizeFastOutLinearIn = 200
this.heightSizeFastOutLinearIn = 80
}
this.flagFastOutLinearIn = !this.flagFastOutLinearIn
})
.width(this.widthSizeFastOutLinearIn).height(this.heightSizeFastOutLinearIn).backgroundColor(0x317aff)
.animation({
duration: 2000,
curve: Curve.FastOutLinearIn,
delay: 500,
iterations: 1,
playMode: PlayMode.Normal
})
Button('ExtremeDeceleration')
.onClick((event: ClickEvent) => {
if (this.flagExtremeDeceleration) {
this.widthSizeExtremeDeceleration = 100
this.heightSizeExtremeDeceleration = 50
} else {
this.widthSizeExtremeDeceleration = 200
this.heightSizeExtremeDeceleration = 80
}
this.flagExtremeDeceleration = !this.flagExtremeDeceleration
})
.width(this.widthSizeExtremeDeceleration).height(this.heightSizeExtremeDeceleration).backgroundColor(0x317aff)
.animation({
duration: 2000,
curve: Curve.ExtremeDeceleration,
delay: 500,
iterations: 1,
playMode: PlayMode.Normal
})
Button('Sharp')
.onClick((event: ClickEvent) => {
if (this.flagSharp) {
this.widthSizeSharp = 100
this.heightSizeSharp = 50
} else {
this.widthSizeSharp = 200
this.heightSizeSharp = 80
}
this.flagSharp = !this.flagSharp
})
.width(this.widthSizeSharp).height(this.heightSizeSharp).backgroundColor(0x317aff)
.animation({
duration: 2000,
curve: Curve.Sharp,
delay: 500,
iterations: 1,
playMode: PlayMode.Normal
})
Button('Rhythm')
.onClick((event: ClickEvent) => {
if (this.flagRhythm) {
this.widthSizeRhythm = 100
this.heightSizeRhythm = 50
} else {
this.widthSizeRhythm = 200
this.heightSizeRhythm = 80
}
this.flagRhythm = !this.flagRhythm
})
.width(this.widthSizeRhythm).height(this.heightSizeRhythm).backgroundColor(0x317aff)
.animation({
duration: 2000,
curve: Curve.Rhythm,
delay: 500,
iterations: 1,
playMode: PlayMode.Normal
})
Button('Smooth')
.onClick((event: ClickEvent) => {
if (this.flagSmooth) {
this.widthSizeSmooth = 100
this.heightSizeSmooth = 50
} else {
this.widthSizeSmooth = 200
this.heightSizeSmooth = 80
}
this.flagSmooth = !this.flagSmooth
})
.width(this.widthSizeSmooth).height(this.heightSizeSmooth).backgroundColor(0x317aff)
.animation({
duration: 2000,
curve: Curve.Smooth,
delay: 500,
iterations: 1,
playMode: PlayMode.Normal
})
Button('Friction')
.onClick((event: ClickEvent) => {
if (this.flagFriction) {
this.widthSizeFriction = 100
this.heightSizeFriction = 50
} else {
this.widthSizeFriction = 200
this.heightSizeFriction = 80
}
this.flagFriction = !this.flagFriction
})
.width(this.widthSizeFriction).height(this.heightSizeFriction).backgroundColor(0x317aff)
.animation({
duration: 2000,
curve: Curve.Friction,
delay: 500,
iterations: 1,
playMode: PlayMode.Normal
})
}.width('100%').margin({ top: 5 })
}
}
\ No newline at end of file
/*
* 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
struct calendar {
@State curMonth: MonthData = { year: 0, month: 0, data: [] };
@State preMonth: MonthData = { year: 0, month: 0, data: [] };
@State nextMonth: MonthData = { year: 0, month: 0, data: [] }
@State year: number = 0
@State month: number = 0
Controller: CalendarController = new CalendarController();
private lunarMonthDays: string[] = [
'初一', '初二', '初三', '初四', '初五', '初六', '初七', '初八', '初九', '初十',
'十一', '十二', '十三', '十四', '十五', '十六', '十七', '十八', '十九', '二十',
'廿一', '廿二', '廿三', '廿四', '廿五', '廿六', '廿七', '廿八', '廿九', '三十']
private lunarMonthNames: string[] = ['正月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '冬月', '腊月']
build() {
Calendar({
date: { year: 2021, month: 8, day: 35 },
currentData: this.curMonth,
preData: this.preMonth,
nextData: this.nextMonth,
controller: this.Controller
})
.showLunar(true)
.showHoliday(true)
.needSlide(true)
.offDays(Week.Fri | Week.Sat | Week.Mon | Week.Thur)
.startOfWeek(Week.Sun)
.direction(Axis.Horizontal)
.currentDayStyle({
dayColor: Color.Black,
lunarColor: Color.Gray,
markLunarColor: Color.Black,
dayFontSize: 15,
lunarDayFontSize: 10,
boundaryColOffset: 10,
})
.nonCurrentDayStyle({
nonCurrentMonthDayColor: Color.Black,
nonCurrentMonthLunarColor: Color.Gray,
nonCurrentMonthWorkDayMarkColor: Color.Green,
nonCurrentMonthOffDayMarkColor: Color.Brown,
})
.todayStyle({
focusedDayColor: Color.Red,
focusedLunarColor: Color.Orange,
focusedAreaBackgroundColor: Color.Blue,
focusedAreaRadius: 20
})
.weekStyle({
weekColor: Color.Black,
weekendDayColor: Color.Orange,
weekendLunarColor: Color.Blue,
weekFontSize: 20,
weekHeight: 5,
weekWidth: 48,
})
.workStateStyle({
workDayMarkColor: Color.Red,
offDayMarkColor: Color.Orange,
workDayMarkSize: 10,
offDayMarkSize: 2,
workStateWidth: 12,
workStateHorizontalMovingDistance: 0,
workStateVerticalMovingDistance: 12,
})
.onSelectChange((request) => {
this.year = request.year;
this.month = request.month;
console.info('On Select change: ' + this.year + '/' + this.month)
})
}
}
\ 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct CanvasActualBoundingBoxAscent {
private settings: RenderingContextSettings = new RenderingContextSettings(true)//antialias:boolean
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear CanvasActualBoundingBoxAscent start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear CanvasActualBoundingBoxAscent end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context)
.key('Canvas')
.width('100%')
.height('100%')
.backgroundColor('#ffff00')
.position({x:3,y:5})
.align(Alignment.Center)
.onReady(() =>{
this.context.font = '50px sans-serif'
this.context.fillText("Hello World!", 20, 100)
this.context.textBaseline = 'top'
this.context.fillText("width:" + this.context.measureText("Hello World!").width, 20, 150)
this.context.fillText("actualBoundingBoxAscent:" + this.context.measureText("Hello World!").actualBoundingBoxAscent, 20, 200)
this.context.fillText("actualBoundingBoxDescent:" + this.context.measureText("Hello World!").actualBoundingBoxDescent, 20, 250)
this.context.fillText("actualBoundingBoxLeft:" + this.context.measureText("Hello World!").actualBoundingBoxLeft, 20, 300)
this.context.fillText("actualBoundingBoxRight:" + this.context.measureText("Hello World!").actualBoundingBoxRight, 20, 350)
this.context.fillText("alphabeticBaseline:" + this.context.measureText("Hello World!").alphabeticBaseline, 20, 400)
this.context.fillText("emHeightAscent:" + this.context.measureText("Hello World!").emHeightAscent, 20, 450)
this.context.fillText("emHeightDescent:" + this.context.measureText("Hello World!").emHeightDescent, 20, 500)
this.context.fillText("fontBoundingBoxAscent:" + this.context.measureText("Hello World!").fontBoundingBoxAscent, 20, 550)
this.context.fillText("fontBoundingBoxDescent:" + this.context.measureText("Hello World!").fontBoundingBoxDescent, 20, 600)
this.context.fillText("hangingBaseline:" + this.context.measureText("Hello World!").hangingBaseline, 20, 650)
this.context.fillText("ideographicBaseline" + this.context.measureText("Hello World!").ideographicBaseline, 20, 700)
//this.context.fillText("antialias" + this.context.measureText("Hello World!").antialias, 20, 700)
})
}
.width('100%')
.height('100%')
}
}
/**
* 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct CheckBoxGroup {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear CheckBoxGroup start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear CheckBoxGroup end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("checkBox-Group")
.width(100)
.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("groupText")
Row() {
CheckboxGroup({group : 'checkboxGroup'})
.selectedColor(0xed6f21)
.key('CheckboxGroup')
.onChange((itemName:CheckboxGroupResult) => {
console.info("TextPicker::dialogResult is" + JSON.stringify(itemName))
})
Text('select all').fontSize(20)
Checkbox({name: 'checkbox1', group: 'checkboxGroup'})
.key('Checkbox1')
.select(true)
.selectedColor(0xed6f21)
.onChange((value: boolean) => {
console.info('Checkbox1 change is'+ value)
})
Checkbox({name: 'checkbox2', group: 'checkboxGroup'})
.key('Checkbox2')
.select(false)
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox2 change is'+ value)
})
}
}.width("100%").height("100%")
}
}
/**
* 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 Log from '../common/Log.ets';
import events_emitter from '@ohos.events.emitter';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct CheckBoxGroupPart {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear CheckBoxGroupPart start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear CheckBoxGroupPart end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("checkBoxGroup-Part")
.width(100)
.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("PartText")
Text("checkBoxGroup-Group")
.width(100)
.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("groupText")
CheckboxGroup({group : 'checkboxGroup'})
.key('CheckboxGroup')
.selectedColor(0xed6f21)
.onChange((itemName:CheckboxGroupResult) => {
console.info("TextPicker::dialogResult is" + JSON.stringify(itemName))
try {
var backData = {
data: {
"STATUS": itemName.status
}
}
let backEvent = {
eventId: 60301,
priority: events_emitter.EventPriority.LOW
}
console.info("Part start to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("Part emit action state err: " + JSON.stringify(err.message))
}
})
Text('select all').fontSize(20)
Checkbox({name: 'checkbox1', group: 'checkboxGroup'})
.key('Checkbox1')
.select(true)
.selectedColor(0xed6f21)
.onChange((value: boolean) => {
console.info('Checkbox1 change is'+ value)
})
Checkbox({name: 'checkbox2', group: 'checkboxGroup'})
.key('Checkbox2')
.select(false)
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox2 change is'+ value)
})
}.width("100%").height("100%")
}
}
/**
* 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default struct CommonColorMode {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear CommonColorMode start`)
}
aboutToDisappear() {
Log.showInfo(TAG, `aboutToDisAppear CommonColorMode end`)
}
@Styles normalStyles() {
.backgroundColor("#0A59F7")
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text("common-FontScale")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("fontScaleText")
Text("common-OnFinish")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("onFinishText")
.animation({
onFinish: () => {
Log.showInfo(TAG, 'animation onFinish success')
}
})
Text("common-MotionPath")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("motionPathText")
.sharedTransition('motionPathText', {
motionPath: {
path: ''
}
})
Text("common-Middle")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("middleText")
.alignRules({
middle: { anchor: 'string', align: HorizontalAlign.Center }
})
Text("common-Area")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("areaText")
.onClick((event) => {
Log.showInfo(TAG, 'area: ' + JSON.stringify(event.target.area))
})
Text("common-Repeat")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("RepeatText")
.borderImage({
source: { angle: 90,
direction: GradientDirection.Left,
colors: [[0xAEE1E1, 0.0], [0xD3E0DC, 0.3], [0xFCD1D1, 1.0]]
},
slice: { top: 10, bottom: 10, left: 10, right: 10 },
width: { top: "10px", bottom: "10px", left: "10px", right: "10px" },
repeat: RepeatMode.Repeat,
fill: false
});
Text("common-Space")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("SpaceText")
.borderImage({
source: { angle: 90,
direction: GradientDirection.Left,
colors: [[0xAEE1E1, 0.0], [0xD3E0DC, 0.3], [0xFCD1D1, 1.0]]
},
slice: { top: 10, bottom: 10, left: 10, right: 10 },
width: { top: "10px", bottom: "10px", left: "10px", right: "10px" },
repeat: RepeatMode.Space,
fill: false
});
Text("common-Thin")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("ThinText")
.backgroundBlurStyle(BlurStyle.Thin)
Text("common-Thick")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("ThickText")
.backgroundBlurStyle(BlurStyle.Thick)
Text("common-Slice")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("sliceText")
.borderImage({
source: { angle: 90,
direction: GradientDirection.Left,
colors: [[0xAEE1E1, 0.0], [0xD3E0DC, 0.3], [0xFCD1D1, 1.0]]
},
slice: { top: 10, bottom: 10, left: 10, right: 10 },
width: { top: "10px", bottom: "10px", left: "10px", right: "10px" },
repeat: RepeatMode.Stretch,
fill: false
});
Text("common-Outset")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("outsetText")
.borderImage({
source: { angle: 90,
direction: GradientDirection.Left,
colors: [[0xAEE1E1, 0.0], [0xD3E0DC, 0.3], [0xFCD1D1, 1.0]]
},
slice: { top: 10, bottom: 10, left: 10, right: 10 },
width: { top: "10px", bottom: "10px", left: "10px", right: "10px" },
repeat: RepeatMode.Stretch,
fill: false,
outset: 2
});
Text("common-Touches")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("touchesText")
.onTouch((event) => {
Log.showInfo(TAG, 'touches: ' + JSON.stringify(event.touches))
})
Text("common-ChangedTouches")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("changedTouchesText")
.onTouch((event) => {
Log.showInfo(TAG, 'changedTouches: ' + JSON.stringify(event.changedTouches))
})
Text("common-KeyCode")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("keyCodeText")
.onKeyEvent((event) => {
Log.showInfo(TAG, 'keyCode: ' + event.keyCode)
})
Text("common-KeyText")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("keyTextText")
.onKeyEvent((event) => {
Log.showInfo(TAG, 'keyText: ' + event.keyText)
})
Text("common-KeySource")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("keySourceText")
.onKeyEvent((event) => {
Log.showInfo(TAG, 'keySource: ' + event.keySource)
})
Text("common-DeviceId")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("deviceIdText")
.onKeyEvent((event) => {
Log.showInfo(TAG, 'deviceId: ' + event.deviceId)
})
Text("common-MetaKey")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("metaKeyText")
.onKeyEvent((event) => {
Log.showInfo(TAG, 'metaKey: ' + event.metaKey)
})
Text("common-Normal")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("normalText")
.stateStyles({ normal: this.normalStyles })
Text("common-Pressed")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("pressedText")
.stateStyles({ pressed: this.normalStyles })
Text("common-Focused")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("focusedText")
.stateStyles({ focused: this.normalStyles })
Text("common-Clicked")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("clickedText")
.stateStyles({ clicked: this.normalStyles })
}.width("100%").height("100%")
}
}
@Preview({
locale: 'locale'
})
@Component
struct PreviewParamsLocale {
build() {
Flex() {
Text("common-locale")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("LocaleText")
}
}
}
@Preview({
colorMode: 'red',
})
@Component
struct PreviewParamsColorMode {
build() {
Flex() {
Text("common-colorMode")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("ColorModeText")
}
}
}
@Preview({
deviceType: 'phone'
})
@Component
struct PreviewParamsDeviceType {
build() {
Flex() {
Text("common-deviceType")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("DeviceTypeText")
}
}
}
@Preview({
dpi: 160
})
@Component
struct PreviewParamsDpi {
build() {
Flex() {
Text("common-dpi")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("DpiText")
}
}
}
@Preview({
orientation: ''
})
@Component
struct PreviewParamsOrientation {
build() {
Flex() {
Text("common-orientation")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("OrientationText")
}
}
}
@Preview({
roundScreen: true
})
@Component
struct PreviewParamsRoundScreen {
build() {
Flex() {
Text("common-roundScreen")
.width(320)
.height(40)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("RoundScreenText")
}
}
}
// @ts-nocheck
/**
* 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct CopyOption {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear CopyOption start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear CopyOption end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("copyOption-InApp")
.width(100)
.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("InAppText")
.copyOption(CopyOption.InApp)
.visibility(Visibility.None)
Text("copyOption-LocalDevice")
.width(100)
.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("LocalDeviceText")
.copyOption(CopyOption.LocalDevice)
.visibility(Visibility.None)
}.width("100%").height("100%")
}
}
\ 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct CurvesEaseOut {
@State widthSize: number = 400
@State heightSize: number = 200
@State flag: boolean = true
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear CurvesEaseOut start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear CurvesEaseOut end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Button('click me')
.align(Alignment.Center)
.onClick((event: ClickEvent) => {
if (this.flag) {
this.widthSize = 100
this.heightSize = 50
} else {
this.widthSize = 400
this.heightSize = 200
}
this.flag = !this.flag
})
.key("EaseOutText")
.width(this.widthSize).height(this.heightSize).backgroundColor(0x317aff)
.animation({
duration: 1000, // 动画时长
curve: Curve.EaseOut, // 动画曲线:以低速结束
delay: 100, // 动画延迟
iterations: 1, // 播放次数
playMode: PlayMode.Normal // 动画模式
}) // 对Button组件的宽高属性进行动画配置
Button('click me')
.align(Alignment.Center)
.onClick((event: ClickEvent) => {
if (this.flag) {
this.widthSize = 100
this.heightSize = 50
} else {
this.widthSize = 400
this.heightSize = 200
}
this.flag = !this.flag
})
.key("EaseInOutText")
.width(this.widthSize).height(this.heightSize).backgroundColor(0x317aff)
.animation({
duration: 1000,
curve: Curve.EaseInOut, //以低速开始和结束
delay: 100,
iterations: 1,
playMode: PlayMode.Normal
})
Button('click me')
.align(Alignment.Center)
.onClick((event: ClickEvent) => {
if (this.flag) {
this.widthSize = 100
this.heightSize = 50
} else {
this.widthSize = 400
this.heightSize = 200
}
this.flag = !this.flag
})
.key("FastOutSlowInText")
.width(this.widthSize).height(this.heightSize).backgroundColor(0x317aff)
.animation({
duration: 1000,
curve: Curve.FastOutSlowIn, //标准曲线
delay: 100,
iterations: 1,
playMode: PlayMode.Normal
})
Button('click me')
.align(Alignment.Center)
.onClick((event: ClickEvent) => {
if (this.flag) {
this.widthSize = 100
this.heightSize = 50
} else {
this.widthSize = 400
this.heightSize = 200
}
this.flag = !this.flag
})
.key("LinearOutSlowInText")
.width(this.widthSize).height(this.heightSize).backgroundColor(0x317aff)
.animation({
duration: 1000,
curve: Curve.LinearOutSlowIn, //减速曲线
delay: 100,
iterations: 1,
playMode: PlayMode.Normal
})
Button('click me')
.align(Alignment.Center)
.onClick((event: ClickEvent) => {
if (this.flag) {
this.widthSize = 100
this.heightSize = 50
} else {
this.widthSize = 400
this.heightSize = 200
}
this.flag = !this.flag
})
.key("FastOutLinearInText")
.width(this.widthSize).height(this.heightSize).backgroundColor(0x317aff)
.animation({
duration: 1000,
curve: Curve.FastOutLinearIn, //加速曲线
delay: 100,
iterations: 1,
playMode: PlayMode.Normal
})
Button('click me')
.align(Alignment.Center)
.onClick((event: ClickEvent) => {
if (this.flag) {
this.widthSize = 100
this.heightSize = 50
} else {
this.widthSize = 400
this.heightSize = 200
}
this.flag = !this.flag
})
.key("ExtremeDecelerationText")
.width(this.widthSize).height(this.heightSize).backgroundColor(0x317aff)
.animation({
duration: 1000,
curve: Curve.ExtremeDeceleration, //急缓曲线
delay: 100,
iterations: 1,
playMode: PlayMode.Normal
})
Button('click me')
.align(Alignment.Center)
.onClick((event: ClickEvent) => {
if (this.flag) {
this.widthSize = 100
this.heightSize = 50
} else {
this.widthSize = 400
this.heightSize = 200
}
this.flag = !this.flag
})
.key("SharpText")
.width(this.widthSize).height(this.heightSize).backgroundColor(0x317aff)
.animation({
duration: 1000,
curve: Curve.Sharp, //锐利曲线
delay: 100,
iterations: 1,
playMode: PlayMode.Normal
})
Button('click me')
.align(Alignment.Center)
.onClick((event: ClickEvent) => {
if (this.flag) {
this.widthSize = 100
this.heightSize = 50
} else {
this.widthSize = 400
this.heightSize = 200
}
this.flag = !this.flag
})
.key("RhythmText")
.width(this.widthSize).height(this.heightSize).backgroundColor(0x317aff)
.animation({
duration: 1000,
curve: Curve.Rhythm, //节奏曲线
delay: 100,
iterations: 1,
playMode: PlayMode.Normal
})
Button('click me')
.align(Alignment.Center)
.onClick((event: ClickEvent) => {
if (this.flag) {
this.widthSize = 100
this.heightSize = 50
} else {
this.widthSize = 400
this.heightSize = 200
}
this.flag = !this.flag
})
.key("SmoothText")
.width(this.widthSize).height(this.heightSize).backgroundColor(0x317aff)
.animation({
duration: 1000,
curve: Curve.Smooth, //平滑曲线
delay: 100,
iterations: 1,
playMode: PlayMode.Normal
})
Button('click me')
.align(Alignment.Center)
.onClick((event: ClickEvent) => {
if (this.flag) {
this.widthSize = 100
this.heightSize = 50
} else {
this.widthSize = 400
this.heightSize = 200
}
this.flag = !this.flag
})
.key("FrictionText")
.width(this.widthSize).height(this.heightSize).backgroundColor(0x317aff)
.animation({
duration: 1000,
curve: Curve.Friction, //阻尼曲线
delay: 100,
iterations: 1,
playMode: PlayMode.Normal
})
}.width("100%").height("100%")
}
}
/**
* 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default struct DatePickerLunar {
private selectedDate: Date = new Date('2021-08-08')
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear DatePickerLunar start`)
}
aboutToDisappear() {
Log.showInfo(TAG, `aboutToDisAppear DatePickerLunar end`)
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text("datePicker-Lunar")
.width(100)
.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("lunarText")
DatePicker({
start: new Date('1970-1-1'),
end: new Date('2100-1-1'),
selected: this.selectedDate,
})
.key("DatePicker")
.lunar(true)
.onChange((date: DatePickerResult) => {
Log.showInfo(TAG, 'select current date is: ' + JSON.stringify(date))
})
DatePicker({
start: new Date('1970-1-1'),
end: new Date('2100-1-1'),
selected: this.selectedDate,
})
.lunar(false)
.onChange((date: DatePickerResult) => {
Log.showInfo(TAG, 'select current date is: ' + JSON.stringify(date))
})
}.width("100%").height("100%")
}
}
/**
* 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';
import Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
struct ListExample {
private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
@State edgeEffect: EdgeEffect = EdgeEffect.Fade
build() {
Stack({ alignContent: Alignment.TopStart }) {
Column() {
List({ space: 20, initialIndex: 0 }) {
ForEach(this.arr, (item) => {
ListItem() {
Text('' + item)
.width('100%').height(100).fontSize(16)
.textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF)
}.editable(true)
}, item => item)
}
.key('list')
.listDirection(Axis.Vertical) // 排列方向
.divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // 每行之间的分界线
.edgeEffect(this.edgeEffect) // 滑动到边缘无效果
.chainAnimation(false) // 联动特效关闭
.onScrollIndex((firstIndex: number, lastIndex: number) => {
console.info('first' + firstIndex)
console.info('last' + lastIndex)
})
.onItemDelete((index: number) => {
console.info(this.arr[index] + 'Delete')
this.arr.splice(index, 1)
console.info(JSON.stringify(this.arr))
return true
}).width('90%')
}.width('100%')
}.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 })
}
}
// @ts-nocheck
/**
* 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct EnumsCancel {
@State widthSize: number = 200
@State heightSize: number = 100
@State flag: boolean = true
@State state: AnimationStatus = AnimationStatus.Initial
@State reverse: boolean = false
@State iterations: number = 1
@State value: string = ''
@State text: string = ''
@State eventType: string = ''
@State mouseText: string = 'MouseText'
@Styles pressedStyles() {
.backgroundColor('red')
.opacity(1)
}
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear EnumsCancel start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear EnumsCancel end`)
}
@State responseTypeClick: ResponseType = ResponseType.RightClick;
@State responseTypePress: ResponseType = ResponseType.LongPress;
@Builder ContextMenuBuilder() {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text('text3')
.fontSize(20)
.width(100)
.height(50)
.textAlign(TextAlign.Center)
Divider().height(10)
}
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text("enums-Cancel")
.width(100)
.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("CancelText")
.visibility(Visibility.None)
Text("enums-Middle")
.width(100)
.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("MiddleText")
.visibility(Visibility.None)
Text("enums-Forward")
.width(100)
.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("ForwardText")
.visibility(Visibility.None)
Text("enums-Press")
.width(100)
.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("PressText")
.visibility(Visibility.None)
Text("enums-EaseOut")
.width(100)
.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("EaseOutText")
.visibility(Visibility.None)
Text("enums-EaseInOut")
.width(100)
.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("EaseInOutText")
.visibility(Visibility.None)
Text("enums-FastOutSlowIn")
.width(100)
.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("FastOutSlowInText")
.visibility(Visibility.None)
Text("enums-LinearOutSlowIn")
.width(100)
.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("LinearOutSlowInText")
.visibility(Visibility.None)
Text("enums-FastOutLinearIn")
.width(100)
.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("FastOutLinearInText")
.visibility(Visibility.None)
Text("enums-ExtremeDeceleration")
.width(100)
.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("ExtremeDecelerationText")
.visibility(Visibility.None)
Text("enums-Sharp")
.width(100)
.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("SharpText")
.visibility(Visibility.None)
Text("enums-Rhythm")
.width(100)
.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("RhythmText")
.visibility(Visibility.None)
Text("enums-Smooth")
.width(100)
.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("SmoothText")
.visibility(Visibility.None)
Text("enums-Friction")
.width(100)
.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("FrictionText")
.visibility(Visibility.None)
Text("enums-Forwards")
.width(100)
.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("ForwardsText")
.visibility(Visibility.None)
Text("enums-Reverse")
.width(100)
.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("ReverseText")
.visibility(Visibility.None)
Text("enums-Alternate")
.width(100)
.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("AlternateText")
.visibility(Visibility.None)
Text("enums-Keyboard")
.width(100)
.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("KeyboardText")
.visibility(Visibility.None)
Text("enums-Middle")
.width(100)
.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("MiddleText")
.visibility(Visibility.None)
Text("enums-Mon")
.width(100)
.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("MonText")
.visibility(Visibility.None)
Text("enums-Thur")
.width(100)
.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("ThurText")
.visibility(Visibility.None)
Text("enums-Fri")
.width(100)
.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("FriText")
.visibility(Visibility.None)
Text("enums-Sat")
.width(100)
.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("SatText")
.visibility(Visibility.None)
Text("enums-Fade")
.width(100)
.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("FadeText")
.visibility(Visibility.None)
Text("enums-FILL")
.width(100)
.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("FILLText")
.visibility(Visibility.None)
Text("enums-FIT")
.width(100)
.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("FITText")
.visibility(Visibility.None)
Text("enums-RightClick")
.width(100)
.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("RightClickText")
.bindContextMenu(this.ContextMenuBuilder(), this.responseTypeClick)
.visibility(Visibility.None)
Text("enums-LongPress")
.width(100)
.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("LongPressText")
.bindContextMenu(this.ContextMenuBuilder(), this.responseTypePress)
.visibility(Visibility.None)
Text("enums-Scale")
.width(100)
.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("ScaleText")
.hoverEffect(HoverEffect.Scale)
.visibility(Visibility.None)
Text("enums-Highlight")
.width(100)
.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("HighlightText")
.hoverEffect(HoverEffect.Highlight)
.visibility(Visibility.None)
Text("enums-InApp")
.width(100)
.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("InAppText")
.copyOption(CopyOptions.InApp)
.visibility(Visibility.None)
Text("enums-LocalDevice")
.width(100)
.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("LocalDeviceText")
.copyOption(CopyOptions.LocalDevice)
.visibility(Visibility.None)
Text("enums-CrossDevice")
.width(100)
.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("CrossDeviceText")
.copyOption(CopyOption.CrossDevice)
.visibility(Visibility.None)
Button('Touch').backgroundColor(0x2788D9).height(40).width(80)
.onTouch((event: TouchEvent) => {
if (event.type === TouchType.Down) {
this.eventType = 'Down'
}
if (event.type === TouchType.Up) {
this.eventType = 'Up'
}
if (event.type === TouchType.Move) {
this.eventType = 'Move'
}
if (event.type === TouchType.Cancel) {
this.eventType = 'Cancel'
}
console.info(this.text = 'TouchType:' + this.eventType + '\nDistance between touch point and touch element:\nx: '
+ event.touches[0].x + '\n' + 'y: ' + event.touches[0].y + '\ncomponent globalPos:('
+ event.target.area.globalPosition.x + ',' + event.target.area.globalPosition.y + ')\nwidth:'
+ event.target.area.width + '\nheight:' + event.target.area.height)
})
Text(this.text)
Button(this.mouseText)
.onMouse((event: MouseEvent) => {
if (MouseAction.Press || MouseButton.Middle) {
console.log(this.mouseText = 'onMouse:\nButton = ' + event.button +
'\nAction = ' + event.action + '\nlocalXY=(' + event.x + ',' + event.y + ')' +
'\nscreenXY=(' + event.screenX + ',' + event.screenY + ')')
}
else if (MouseAction.Press && MouseButton.Forward) {
console.log(this.mouseText = 'onMouse:\nButton = ' + event.button +
'\nAction = ' + event.action + '\nlocalXY=(' + event.x + ',' + event.y + ')' +
'\nscreenXY=(' + event.screenX + ',' + event.screenY + ')')
}
else if (MouseAction.Press) {
console.info("pressed")
}
})
Text("enums-FillMode")
.width(100)
.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("FillModeText")
.visibility(Visibility.None)
}.width("100%").height("100%")
}
}
/**
* 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default struct FeatureAbilityAbilityName {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear FeatureAbilityAbilityName start`)
}
aboutToDisappear() {
Log.showInfo(TAG, `aboutToDisAppear FeatureAbilityAbilityName end`)
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text("featureAbility-SubscribeMessageResponse-DeviceId")
.width(320)
.height(50)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("subscribeMessageResponseDeviceIdText")
.onClick(() => {
FeatureAbility.subscribeMsg({
success: (data) => {
console.log(`deviceId: ${data.deviceId}`)
},
fail: (data, code) => {
console.log(`data: ${data} code: ${code}`)
}
})
})
Text("featureAbility-SubscribeMessageResponse-AbilityName")
.width(320)
.height(50)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("subscribeMessageResponseAbilityNameText")
.onClick(() => {
FeatureAbility.subscribeMsg({
success: (data) => {
console.log(`deviceId: ${data.abilityName}`)
},
fail: (data, code) => {
console.log(`data: ${data} code: ${code}`)
}
})
})
Text("featureAbility-CallAbilityParam-AbilityName")
.width(320)
.height(50)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("callAbilityParamAbilityNameText")
.onClick(() => {
FeatureAbility.callAbility({
bundleName: 'com.example.hiaceservice',
abilityName: 'com.example.hiaceservice.ComputeServiceAbility',
messageCode: 1001,
data: {
firstNum: 1024,
secondNum: 2048
},
abilityType: 0,
syncOption: 0
})
})
Text("featureAbility-CallAbilityParam-MessageCode")
.width(320)
.height(50)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("callAbilityParamMessageCodeText")
.onClick(() => {
FeatureAbility.callAbility({
bundleName: 'com.example.hiaceservice',
abilityName: 'com.example.hiaceservice.ComputeServiceAbility',
messageCode: 1001,
data: {
firstNum: 1024,
secondNum: 2048
},
abilityType: 0,
syncOption: 0
})
})
Text("featureAbility-CallAbilityParam-AbilityType")
.width(320)
.height(50)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("callAbilityParamAbilityTypeText")
.onClick(() => {
FeatureAbility.callAbility({
bundleName: 'com.example.hiaceservice',
abilityName: 'com.example.hiaceservice.ComputeServiceAbility',
messageCode: 1001,
data: {
firstNum: 1024,
secondNum: 2048
},
abilityType: 0,
syncOption: 0
})
})
Text("featureAbility-CallAbilityParam-SyncOption")
.width(320)
.height(50)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("callAbilityParamSyncOptionText")
.onClick(() => {
FeatureAbility.callAbility({
bundleName: 'com.example.hiaceservice',
abilityName: 'com.example.hiaceservice.ComputeServiceAbility',
messageCode: 1001,
data: {
firstNum: 1024,
secondNum: 2048
},
abilityType: 0,
syncOption: 0
})
})
Text("featureAbility-SubscribeAbilityEventParam-AbilityName")
.width(320)
.height(50)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("subscribeAbilityEventParamAbilityNameText")
.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));
})
})
Text("featureAbility-SubscribeAbilityEventParam-MessageCode")
.width(320)
.height(50)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("subscribeAbilityEventParammessageCodeText")
.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));
})
})
Text("featureAbility-SubscribeAbilityEventParam-AbilityType")
.width(320)
.height(50)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("subscribeAbilityEventParamAbilityTypeText")
.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));
})
})
Text("featureAbility-SubscribeAbilityEventParam-SyncOption")
.width(320)
.height(50)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("subscribeAbilityEventParamSyncOptionText")
.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));
})
})
Text("featureAbility-SendMessageOptions-DeviceId")
.width(320)
.height(50)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("sendMessageOptionsDeviceIdText")
.onClick(() => {
FeatureAbility.sendMsg({
deviceId: '1001',
bundleName: 'com.example.hiaceservice',
abilityName: 'com.example.hiaceservice.ComputeServiceAbility'
})
})
Text("featureAbility-SendMessageOptions-AbilityName")
.width(320)
.height(50)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("sendMessageOptionsAbilityNameText")
.onClick(() => {
FeatureAbility.sendMsg({
deviceId: '1001',
bundleName: 'com.example.hiaceservice',
abilityName: 'com.example.hiaceservice.ComputeServiceAbility'
})
})
Text("featureAbility-RequestParams-AbilityName")
.width(320)
.height(50)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("requestParamsAbilityNameText")
.onClick(() => {
FeatureAbility.startAbility({
bundleName: 'com.example.hiaceservice',
abilityName: 'com.example.hiaceservice.ComputeServiceAbility'
})
})
Text("featureAbility-Entities")
.width(320)
.height(50)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("entitiesText")
.onClick(() => {
FeatureAbility.startAbility({
bundleName: 'com.example.hiaceservice',
abilityName: 'com.example.hiaceservice.ComputeServiceAbility',
entities: ["this is a test"]
})
})
Text("featureAbility-DeviceType")
.width(320)
.height(50)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("deviceTypeText")
.onClick(() => {
FeatureAbility.startAbility({
bundleName: 'com.example.hiaceservice',
abilityName: 'com.example.hiaceservice.ComputeServiceAbility',
deviceType: 1001
})
})
}.width("100%").height("100%")
}
}
//@ts-nocheck
/**
* 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct HoverEffect {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear HoverEffect start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear HoverEffect end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("hoverEffect-Scale")
.width(100)
.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("ScaleText")
.hoverEffect(HoverEffect.Scale)
.visibility(Visibility.None)
Text("hoverEffect-Highlight")
.width(100)
.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("HighlightText")
.hoverEffect(HoverEffect.Highlight)
.visibility(Visibility.None)
}.width("100%").height("100%")
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册