未验证 提交 03af4feb 编写于 作者: O openharmony_ci 提交者: Gitee

!23829 update api md

Merge pull request !23829 from 李欣楠/monthly
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
## 导入模块 ## 导入模块
```js ```js
import animator from '@ohos.animator'; import animator, { AnimatorResult } from '@ohos.animator';
``` ```
## create<sup>9+</sup> ## create<sup>9+</sup>
...@@ -40,7 +40,7 @@ create(options: AnimatorOptions): AnimatorResult ...@@ -40,7 +40,7 @@ create(options: AnimatorOptions): AnimatorResult
**示例:** **示例:**
```js ```js
import animator, { AnimatorOptions } from '@ohos.animator'; import animator, { AnimatorResult } from '@ohos.animator';
let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型AnimatorOptions let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型AnimatorOptions
duration: 1500, duration: 1500,
...@@ -328,7 +328,7 @@ export default { ...@@ -328,7 +328,7 @@ export default {
### 基于TS扩展的声明式开发范式 ### 基于TS扩展的声明式开发范式
```ts ```ts
import animator from '@ohos.animator'; import animator, { AnimatorResult } from '@ohos.animator';
@Entry @Entry
@Component @Component
...@@ -459,6 +459,7 @@ struct AnimatorTest { ...@@ -459,6 +459,7 @@ struct AnimatorTest {
.onClick(() => { .onClick(() => {
if (this.flag) { if (this.flag) {
this.flag = false this.flag = false
if(this.backAnimator){
this.backAnimator.reset({ this.backAnimator.reset({
duration: 5000, duration: 5000,
easing: "ease-in", easing: "ease-in",
...@@ -469,6 +470,7 @@ struct AnimatorTest { ...@@ -469,6 +470,7 @@ struct AnimatorTest {
begin: 100, begin: 100,
end: 300 end: 300
}) })
}
} else { } else {
console.info(this.TAG, 'Animation not ended') console.info(this.TAG, 'Animation not ended')
} }
......
...@@ -203,7 +203,7 @@ struct OffscreenSnapshotExample { ...@@ -203,7 +203,7 @@ struct OffscreenSnapshotExample {
Column() { Column() {
Button("click to generate offscreen UI snapshot") Button("click to generate offscreen UI snapshot")
.onClick(() => { .onClick(() => {
componentSnapshot.createFromBuilder(this.RandomBuilder.bind(this), componentSnapshot.createFromBuilder(this.RandomBuilder(),
(error: Error, pixmap: image.PixelMap) => { (error: Error, pixmap: image.PixelMap) => {
this.pixmap = pixmap this.pixmap = pixmap
// save pixmap to file // save pixmap to file
...@@ -280,7 +280,7 @@ struct OffscreenSnapshotExample { ...@@ -280,7 +280,7 @@ struct OffscreenSnapshotExample {
Column() { Column() {
Button("click to generate offscreen UI snapshot") Button("click to generate offscreen UI snapshot")
.onClick(() => { .onClick(() => {
componentSnapshot.createFromBuilder(this.RandomBuilder.bind(this)) componentSnapshot.createFromBuilder(this.RandomBuilder())
.then((pixmap: image.PixelMap) => { .then((pixmap: image.PixelMap) => {
this.pixmap = pixmap this.pixmap = pixmap
// save pixmap to file // save pixmap to file
......
...@@ -37,7 +37,7 @@ executeDrag(custom: CustomBuilder | DragItemInfo, dragInfo: DragInfo, callback: ...@@ -37,7 +37,7 @@ executeDrag(custom: CustomBuilder | DragItemInfo, dragInfo: DragInfo, callback:
```ts ```ts
import dragController from "@ohos.arkui.dragController" import dragController from "@ohos.arkui.dragController"
import UDC from '@ohos.data.unifiedDataChannel'; import UDMF from '@ohos.data.UDMF';
@Entry @Entry
@Component @Component
...@@ -57,18 +57,23 @@ struct DragControllerPage { ...@@ -57,18 +57,23 @@ struct DragControllerPage {
.onTouch((event?:TouchEvent) => { .onTouch((event?:TouchEvent) => {
if(event){ if(event){
if (event.type == TouchType.Down) { if (event.type == TouchType.Down) {
let text:object = new UDMF.Text() let text = new UDMF.Text()
let unifiedData:object = new UDMF.UnifiedData(text) let unifiedData = new UDMF.UnifiedData(text)
let dragInfo: dragController.DragInfo = { let dragInfo: dragController.DragInfo = {
pointerId: 0, pointerId: 0,
data: unifiedData, data: unifiedData,
extraParams: '' extraParams: ''
} }
dragController.executeDrag(this.DraggingBuilder.bind(this), dragInfo, (err, {event, extraParams}) => { class tmp{
if (event.getResult() == DragResult.DRAG_SUCCESSFUL) { event:DragResult|undefined = undefined
extraParams:string = ''
}
let eve:tmp = new tmp()
dragController.executeDrag(this.DraggingBuilder(), dragInfo, (err, eve) => {
if (eve.event.getResult() == DragResult.DRAG_SUCCESSFUL) {
// ... // ...
} else if (event.getResult() == DragResult.DRAG_FAILED) { } else if (eve.event.getResult() == DragResult.DRAG_FAILED) {
// ... // ...
} }
}) })
...@@ -105,9 +110,9 @@ executeDrag(custom: CustomBuilder | DragItemInfo, dragInfo: DragInfo): Promise&l ...@@ -105,9 +110,9 @@ executeDrag(custom: CustomBuilder | DragItemInfo, dragInfo: DragInfo): Promise&l
```ts ```ts
import dragController from "@ohos.arkui.dragController" import dragController from "@ohos.arkui.dragController"
import UDC from '@ohos.data.unifiedDataChannel';
import componentSnapshot from '@ohos.arkui.componentSnapshot'; import componentSnapshot from '@ohos.arkui.componentSnapshot';
import image from '@ohos.multimedia.image'; import image from '@ohos.multimedia.image';
import UDMF from '@ohos.data.UDMF';
@Entry @Entry
@Component @Component
...@@ -138,31 +143,36 @@ struct DragControllerPage { ...@@ -138,31 +143,36 @@ struct DragControllerPage {
.onTouch((event?:TouchEvent) => { .onTouch((event?:TouchEvent) => {
if(event){ if(event){
if (event.type == TouchType.Down) { if (event.type == TouchType.Down) {
let text:object = new UDMF.Text() let text = new UDMF.Text()
let unifiedData:object = new UDMF.UnifiedData(text) let unifiedData = new UDMF.UnifiedData(text)
let dragInfo: dragController.DragInfo = { let dragInfo: dragController.DragInfo = {
pointerId: 0, pointerId: 0,
data: unifiedData, data: unifiedData,
extraParams: '' extraParams: ''
} }
componentSnapshot.createFromBuilder(this.PixmapBuilder.bind(this)).then((pix: image.PixelMap) => { componentSnapshot.createFromBuilder(this.PixmapBuilder()).then((pix: image.PixelMap) => {
this.pixmap = pix; this.pixmap = pix;
let dragItemInfo: DragItemInfo = { let dragItemInfo: DragItemInfo = {
pixelMap: this.pixmap, pixelMap: this.pixmap,
builder: this.DraggingBuilder.bind(this), builder: this.DraggingBuilder(),
extraInfo: "DragItemInfoTest" extraInfo: "DragItemInfoTest"
} }
class tmp{
event:DragResult|undefined = undefined
extraParams:string = ''
}
let eve:tmp = new tmp()
dragController.executeDrag(dragItemInfo, dragInfo) dragController.executeDrag(dragItemInfo, dragInfo)
.then(({event, extraParams}) => { .then((eve) => {
if (event.getResult() == DragResult.DRAG_SUCCESSFUL) { if (eve.event.getResult() == DragResult.DRAG_SUCCESSFUL) {
// ... // ...
} else if (event.getResult() == DragResult.DRAG_FAILED) { } else if (eve.event.getResult() == DragResult.DRAG_FAILED) {
// ... // ...
} }
}) })
.catch((err) => { .catch((err:Error) => {
}) })
}) })
} }
......
...@@ -80,10 +80,11 @@ getPixelMap(): image.PixelMap; ...@@ -80,10 +80,11 @@ getPixelMap(): image.PixelMap;
**示例:** **示例:**
```ts ```ts
import { DrawableDescriptor, LayeredDrawableDescriptor } from '@ohos.arkui.drawableDescriptor'
let resManager = getContext().resourceManager let resManager = getContext().resourceManager
let pixmap: DrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon') let pixmap: DrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon')
.id)) as DrawableDescriptor; .id)) as DrawableDescriptor;
let pixmapNew: DrawableDescriptor = pixmap.getPixelMap() let pixmapNew: object = pixmap.getPixelMap()
``` ```
## LayeredDrawableDescriptor.getPixelMap ## LayeredDrawableDescriptor.getPixelMap
...@@ -101,10 +102,11 @@ getPixelMap(): image.PixelMap; ...@@ -101,10 +102,11 @@ getPixelMap(): image.PixelMap;
**示例:** **示例:**
```ts ```ts
import { DrawableDescriptor, LayeredDrawableDescriptor } from '@ohos.arkui.drawableDescriptor'
let resManager = getContext().resourceManager let resManager = getContext().resourceManager
let pixmap: LayeredDrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon') let pixmap: LayeredDrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon')
.id)) as LayeredDrawableDescriptor; .id)) as LayeredDrawableDescriptor;
let pixmapNew: LayeredDrawableDescriptor = pixmap.getPixelMap() let pixmapNew: object = pixmap.getPixelMap()
``` ```
## LayeredDrawableDescriptor.getForeground ## LayeredDrawableDescriptor.getForeground
...@@ -122,10 +124,11 @@ getForeground(): DrawableDescriptor; ...@@ -122,10 +124,11 @@ getForeground(): DrawableDescriptor;
**示例:** **示例:**
```ts ```ts
import { DrawableDescriptor, LayeredDrawableDescriptor } from '@ohos.arkui.drawableDescriptor'
let resManager = getContext().resourceManager let resManager = getContext().resourceManager
let drawable: LayeredDrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon') let drawable: LayeredDrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon')
.id)) as LayeredDrawableDescriptor; .id)) as LayeredDrawableDescriptor;
let drawableNew: LayeredDrawableDescriptor =drawable.getForeground() let drawableNew: object =drawable.getForeground()
``` ```
## LayeredDrawableDescriptor.getBackground ## LayeredDrawableDescriptor.getBackground
...@@ -143,10 +146,11 @@ getBackground(): DrawableDescriptor; ...@@ -143,10 +146,11 @@ getBackground(): DrawableDescriptor;
**示例:** **示例:**
```ts ```ts
import { DrawableDescriptor, LayeredDrawableDescriptor } from '@ohos.arkui.drawableDescriptor'
let resManager = getContext().resourceManager let resManager = getContext().resourceManager
let drawable: LayeredDrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon') let drawable: LayeredDrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon')
.id)) as LayeredDrawableDescriptor; .id)) as LayeredDrawableDescriptor;
let drawableNew: LayeredDrawableDescriptor =drawable.getBackground() let drawableNew: object =drawable.getBackground()
``` ```
## LayeredDrawableDescriptor.getMask ## LayeredDrawableDescriptor.getMask
...@@ -164,10 +168,11 @@ getMask(): DrawableDescriptor; ...@@ -164,10 +168,11 @@ getMask(): DrawableDescriptor;
**示例:** **示例:**
```ts ```ts
import { DrawableDescriptor, LayeredDrawableDescriptor } from '@ohos.arkui.drawableDescriptor'
let resManager = getContext().resourceManager let resManager = getContext().resourceManager
let drawable: LayeredDrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon') let drawable: LayeredDrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon')
.id)) as LayeredDrawableDescriptor; .id)) as LayeredDrawableDescriptor;
let drawableNew: LayeredDrawableDescriptor =drawable.getMask() let drawableNew: object =drawable.getMask()
``` ```
## LayeredDrawableDescriptor.getMaskClipPath ## LayeredDrawableDescriptor.getMaskClipPath
static getMaskClipPath(): string static getMaskClipPath(): string
...@@ -184,6 +189,7 @@ LayeredDrawableDescriptor的静态方法,获取系统内置的裁切路径参 ...@@ -184,6 +189,7 @@ LayeredDrawableDescriptor的静态方法,获取系统内置的裁切路径参
**示例:** **示例:**
```ts ```ts
import { DrawableDescriptor, LayeredDrawableDescriptor } from '@ohos.arkui.drawableDescriptor'
Image($r('app.media.icon')) Image($r('app.media.icon'))
.width('200px').height('200px') .width('200px').height('200px')
.clip(new Path({commands:LayeredDrawableDescriptor.getMaskClipPath()})) .clip(new Path({commands:LayeredDrawableDescriptor.getMaskClipPath()}))
......
...@@ -129,19 +129,17 @@ off(type: 'draw', callback?: () => void): void ...@@ -129,19 +129,17 @@ off(type: 'draw', callback?: () => void): void
listener:inspector.ComponentObserver = inspector.createComponentObserver('IMAGE_ID') listener:inspector.ComponentObserver = inspector.createComponentObserver('IMAGE_ID')
aboutToAppear() { aboutToAppear() {
let FuncLayout = this.onLayoutComplete.bind(this) // bind current js instance let onLayoutComplete:()=>void=():void=>{
let FuncDraw = this.onDrawComplete.bind(this) // bind current js instance // do something here
this.listener.on('layout', FuncLayout)
this.listener.on('draw', FuncDraw)
} }
let onDrawComplete:()=>void=():void=>{
onLayoutComplete() {
// do something here // do something here
} }
let FuncLayout = onLayoutComplete // bind current js instance
let FuncDraw = onDrawComplete // bind current js instance
onDrawComplete() { this.listener.on('layout', FuncLayout)
// do something here this.listener.on('draw', FuncDraw)
} }
} }
``` ```
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
```ts ```ts
import app from '@system.app' import app, { AppResponse } from '@system.app'
``` ```
## App ## App
...@@ -33,9 +33,10 @@ static getInfo(): AppResponse ...@@ -33,9 +33,10 @@ static getInfo(): AppResponse
**示例:** **示例:**
```ts ```ts
export default { import app, { AppResponse } from '@system.app'
export default class Info {
getInfo() { getInfo() {
let info = app.getInfo() let info:AppResponse = app.getInfo()
console.log(JSON.stringify(info)) console.log(JSON.stringify(info))
} }
} }
...@@ -54,7 +55,8 @@ static terminate(): void ...@@ -54,7 +55,8 @@ static terminate(): void
**示例:** **示例:**
```ts ```ts
export default { import app, { AppResponse } from '@system.app'
export default class TerM {
terminate() { terminate() {
app.terminate() app.terminate()
} }
...@@ -78,9 +80,9 @@ static setImageCacheCount(value: number): void ...@@ -78,9 +80,9 @@ static setImageCacheCount(value: number): void
```ts ```ts
// app.ets // app.ets
import app from '@system.app' import app, { AppResponse } from '@system.app'
export default { export default class OnC {
onCreate() { onCreate() {
app.setImageCacheCount(100) // 设置解码后图片内存缓存上限为100张 app.setImageCacheCount(100) // 设置解码后图片内存缓存上限为100张
console.info('Application onCreate') console.info('Application onCreate')
...@@ -109,9 +111,9 @@ static setImageRawDataCacheSize(value: number): void ...@@ -109,9 +111,9 @@ static setImageRawDataCacheSize(value: number): void
```ts ```ts
// app.ets // app.ets
import app from '@system.app' import app, { AppResponse } from '@system.app'
export default { export default class OnC {
onCreate() { onCreate() {
app.setImageRawDataCacheSize(104857600) app.setImageRawDataCacheSize(104857600)
// 设置解码前图片数据内存缓存上限为100MB (100MB=100*1024*1024B=104857600B) // 设置解码前图片数据内存缓存上限为100MB (100MB=100*1024*1024B=104857600B)
...@@ -141,9 +143,9 @@ static setImageFileCacheSize(value: number): void ...@@ -141,9 +143,9 @@ static setImageFileCacheSize(value: number): void
```ts ```ts
// app.ets // app.ets
import app from '@system.app' import app, { AppResponse } from '@system.app'
export default { export default class OnC {
onCreate() { onCreate() {
app.setImageFileCacheSize(209715200) app.setImageFileCacheSize(209715200)
// 设置图片文件数据缓存上限为200MB (200MB=200*1024*1024B=209715200B) // 设置图片文件数据缓存上限为200MB (200MB=200*1024*1024B=209715200B)
...@@ -188,7 +190,8 @@ static requestFullWindow(options?: RequestFullWindowOptions): void ...@@ -188,7 +190,8 @@ static requestFullWindow(options?: RequestFullWindowOptions): void
**示例:** **示例:**
```ts ```ts
export default { import app, { AppResponse } from '@system.app'
export default class Req {
requestFullWindow() { requestFullWindow() {
app.requestFullWindow({ app.requestFullWindow({
duration: 200 duration: 200
......
...@@ -57,6 +57,8 @@ setDarkMode(mode: DarkMode, callback: AsyncCallback\<void>): void ...@@ -57,6 +57,8 @@ setDarkMode(mode: DarkMode, callback: AsyncCallback\<void>): void
**示例:** **示例:**
```ts ```ts
import uiAppearance from '@ohos.uiAppearance'
import { BusinessError } from '@ohos.base';
try { try {
uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK, (error) => { uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK, (error) => {
if (error) { if (error) {
...@@ -105,10 +107,12 @@ setDarkMode(mode: DarkMode): Promise\<void>; ...@@ -105,10 +107,12 @@ setDarkMode(mode: DarkMode): Promise\<void>;
**示例:** **示例:**
```ts ```ts
import uiAppearance from '@ohos.uiAppearance'
import { BusinessError } from '@ohos.base';
try { try {
uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK).then(() => { uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK).then(() => {
console.info('Set dark-mode successfully.'); console.info('Set dark-mode successfully.');
}).catch((error) => { }).catch((error:Error) => {
console.error('Set dark-mode failed, ' + error.message); console.error('Set dark-mode failed, ' + error.message);
}); });
} catch (error) { } catch (error) {
...@@ -145,9 +149,11 @@ getDarkMode(): DarkMode; ...@@ -145,9 +149,11 @@ getDarkMode(): DarkMode;
**示例:** **示例:**
```ts ```ts
import uiAppearance from '@ohos.uiAppearance'
import { BusinessError } from '@ohos.base';
try { try {
let darkMode = uiAppearance.getDarkMode(); let darkMode = uiAppearance.getDarkMode();
console.info('Get dark-mode ' + mode); console.info('Get dark-mode ' + darkMode);
} catch (error) { } catch (error) {
let message = (error as BusinessError).message; let message = (error as BusinessError).message;
console.error('Get dark-mode failed, ' + message); console.error('Get dark-mode failed, ' + message);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册