已合并
docs: complete ViewShot API documentation #41
sunkaiyang创建于 9 天前
docs: complete ViewShot API documentation #41
已合并
共 2 个文件变更+60-52
| @@ -43,7 +43,7 @@ yarn add @react-native-ohos/react-native-view-shot | |||
| 43 | 43 | ||
| 44 | | | 是否支持autolink | RN框架版本 | | 44 | | | 是否支持autolink | RN框架版本 | |
| 45 | |---------------------------|-----------------|------------| | 45 | |---------------------------|-----------------|------------| |
| 46 | -| ~4.0.0 | 是 | 0.84 | | 46 | +| ~4.0.0 | 是 | 0.84.* / 0.82.* | |
| 47 | 47 | ||
| 48 | 使用AutoLink的工程需要根据该文档配置,Autolink框架指导文档:https://gitcode.com/CPF-RN/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md | 48 | 使用AutoLink的工程需要根据该文档配置,Autolink框架指导文档:https://gitcode.com/CPF-RN/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md |
| 49 | 49 | ||
| @@ -184,6 +184,7 @@ ohpm install | |||
| 184 | 本文档内容基于以下环境验证通过: | 184 | 本文档内容基于以下环境验证通过: |
| 185 | 185 | ||
| 186 | 1. RNOH: 0.84.1; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112; | 186 | 1. RNOH: 0.84.1; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112; |
| 187 | + 2. RNOH: 0.82.1; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112; | ||
| 187 | 188 | ||
| 188 | ## 使用示例 | 189 | ## 使用示例 |
| 189 | 190 | ||
| @@ -243,8 +244,8 @@ export function ViewShotDemo() { | |||
| 243 | <Button | 244 | <Button |
| 244 | title="ViewShot capture" | 245 | title="ViewShot capture" |
| 245 | onPress={() => { | 246 | onPress={() => { |
| 246 | - captureRef(ref).then((res) => { | 247 | + ref.current?.capture().then((res) => { |
| 247 | - console.info(`captureRef: ${res}`); | 248 | + console.info(`ViewShotRef.capture: ${res}`); |
| 248 | }); | 249 | }); |
| 249 | }} | 250 | }} |
| 250 | /> | 251 | /> |
| @@ -267,26 +268,28 @@ export function ViewShotDemo() { | |||
| 267 | 268 | ||
| 268 | > [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 | 269 | > [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 |
| 269 | 270 | ||
| 270 | -| Name | Description | Type | Required | Platform | HarmonyOS Support | | 271 | +| 名称 | 参数类型 | 默认值 | 必填 | 平台 | HarmonyOS平台支持 | 描述 | |
| 271 | -| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- | -------- | ------------ | ----------------- | | 272 | +| ---- | -------- | ------ | ---- | ---- | ----------------- | ---- | |
| 272 | -| captureMode | 未定义时(默认),截图不会自动进行,需要使用 ref 并手动调用 `capture()`。<br>`"mount"`:在组件挂载时自动截图一次。(需注意图片加载不会被等待,如需等待图片加载完成,建议使用 `"none"` 并在 Image#onLoad 后调用 viewShotRef.capture()。)<br>`"continuous"` 实验性功能,会持续不断地截图。仅适用于非常特殊的场景。<br> `"update"` 实验性功能,每次 React 重绘(on did update)时都会截图。仅适用于非常特殊的场景。 | ( 'mount' \| 'continuous' \| 'update') | no | Android, iOS | yes | | 273 | +| captureMode | `"mount"` \| `"continuous"` \| `"update"` | `undefined` | No | Android, iOS | Yes | 未定义时(默认),截图不会自动进行,需要使用 ref 并手动调用 `capture()`。<br>`"mount"`:在组件挂载时自动截图一次。(需注意图片加载不会被等待,如需等待图片加载完成,建议使用 `"none"` 并在 Image#onLoad 后调用 viewShotRef.capture()。)<br>`"continuous"` 实验性功能,会持续不断地截图。仅适用于非常特殊的场景。<br> `"update"` 实验性功能,每次 React 重绘(on did update)时都会截图。仅适用于非常特殊的场景。 | |
| 273 | -| onCapture | 当定义了 `captureMode` 时,截图成功后会调用此回调函数,并传入截图结果。 | function | no | Android, iOS | yes | | 274 | +| onCapture | `(uri: string) => void` | None | No | Android, iOS | Yes | 当定义了 `captureMode` 时,截图成功后会调用此回调函数,并传入截图结果。 | |
| 274 | -| onCaptureFailure | 当定义了 `captureMode` 时,截图失败时会调用此回调函数。 | function | no | Android, iOS | yes | | 275 | +| onCaptureFailure | `(error: Error) => void` | None | No | Android, iOS | Yes | 当定义了 `captureMode` 时,截图失败时会调用此回调函数。 | |
| 275 | -| options | 截图配置项。 | object | no | Android, iOS | partially | | 276 | +| options | `CaptureOptions` | None | No | Android, iOS | Partially | 截图配置项。 | |
| 276 | -| children | 实际需要被栅格化(截图)的内容。 | ReactNode | no | Android, iOS | yes | | 277 | +| children | `ReactNode` | None | No | Android, iOS | Yes | 实际需要被栅格化(截图)的内容。 | |
| 278 | +| onLayout | `(event: LayoutChangeEvent) => void` | None | No | Android, iOS | Yes | 组件挂载或布局变化时调用,并接收布局事件。 | | ||
| 279 | +| style | `StyleProp<ViewStyle>` | None | No | Android, iOS | Yes | 应用于 ViewShot 容器的视图样式。 | | ||
| 277 | 280 | ||
| 278 | ### options属性详情 | 281 | ### options属性详情 |
| 279 | 282 | ||
| 280 | -| Name | Description | Type | Required | Platform | HarmonyOS Support | | 283 | +| 名称 | 参数类型 | 默认值 | 必填 | 平台 | HarmonyOS平台支持 | 描述 | |
| 281 | -| ------------------------ | ------------------------------------------------------------ | ------------------------------------ | -------- | ------------ | ----------------- | | 284 | +| ---- | -------- | ------ | ---- | ---- | ----------------- | ---- | |
| 282 | -| fileName | 文件名,长度必须至少为 3 个字符。 | string | no | Android, iOS | yes | | 285 | +| fileName | `string` | None | No | Android | Yes | 文件名,长度必须至少为 3 个字符。 | |
| 283 | -| width / height | 最终图片的宽度和高度(会根据 View 的边界进行缩放。如果需要保持原始像素大小,请勿提供此参数)。 | number | no | Android, iOS | yes | | 286 | +| width / height | `number` | None | No | Android, iOS | Yes | 最终图片的宽度和高度(会根据 View 的边界进行缩放。如果需要保持原始像素大小,请勿提供此参数)。 | |
| 284 | -| quality | 图片质量,范围为 0.0 - 1.0(默认值)。(仅适用于有损压缩格式,如 jpg) | number | no | Android, iOS | yes | | 287 | +| quality | `number` | `1` | No | Android, iOS | Yes | 图片质量,范围为 0.0 - 1.0(默认值)。(仅适用于有损压缩格式,如 jpg) | |
| 285 | -| format | 图片格式,可选 png/jpg/webp/webm,默认为 png。 | string | no | Android, iOS | yes | | 288 | +| format | `"jpg"` \| `"png"` \| `"webp"` \| `"webm"` \| `"raw"` | `"png"` | No | Android, iOS | Partially | 图片格式,可选 png/jpg/webp/webm,默认为 png。鸿蒙平台不支持 raw 格式(仅 Android 支持)。 | |
| 286 | -| result | 保存截图的方式,可选值如下:<br/>"tmpfile"(默认):保存到临时文件(仅在应用运行期间有效)。<br/>"base64":编码为 base64 并返回原始字符串。建议仅用于小图片,因为可能会导致卡顿(字符串会通过桥接传输)。注意:这不是 data uri,如需 data uri 请使用 data-uri。<br/>"data-uri":与 base64 相同,但会包含 Data URI scheme 请求头。<br/>"zip-base64":使用 Zip/Deflate 算法压缩数据,然后转换为 Base64 并返回原始字符串 | ( 'tmpfile' \|'base64' \|'data-uri' \|'zip-base64' ) | no | Android, iOS | partially(不支持zip-base64) | | 289 | +| result | `"tmpfile"` \| `"base64"` \| `"data-uri"` \| `"zip-base64"` | `"tmpfile"` | No | Android, iOS | Partially | 保存截图的方式,可选值如下:<br/>"tmpfile"(默认):保存到临时文件(仅在应用运行期间有效)。<br/>"base64":编码为 base64 并返回原始字符串。建议仅用于小图片,因为可能会导致卡顿(字符串会通过桥接传输)。注意:这不是 data uri,如需 data uri 请使用 data-uri。<br/>"data-uri":与 base64 相同,但会包含 Data URI scheme 请求头。<br/>"zip-base64":使用 Zip/Deflate 算法压缩数据,然后转换为 Base64 并返回原始字符串。注意:鸿蒙平台不支持 zip-base64(仅 Android 支持)。 | |
| 287 | -| snapshotContentContainer | 如果为 true 且 view 为 ScrollView,则会使用 "content container" 的高度,而非容器本身的高度。 | boolean | no | Android, iOS | no | | 290 | +| snapshotContentContainer | `boolean` | `false` | No | Android, iOS | No | 如果为 true 且 view 为 ScrollView,则会使用 "content container" 的高度,而非容器本身的高度。 | |
| 288 | -| handleGLSurfaceViewOnAndroid | 当 handleGLSurfaceViewOnAndroid 设置为true且视图是 SurfaceView(或包含在视图树中)时,该视图的内容将会被捕获。 | boolean | no | Android| no | | 291 | +| useRenderInContext | `boolean` | None | No | iOS | No | 修改 iOS 截图策略,使用 renderInContext 方法替代 drawViewHierarchyInRect,可能适用于某些特定场景。 | |
| 289 | -| useRenderInContext | 修改 iOS 截图策略,使用 renderInContext 方法替代 drawViewHierarchyInRect,可能适用于某些特定场景。 | boolean | no | Android, iOS | no | | 292 | +| handleGLSurfaceViewOnAndroid | `boolean` | `false` | No | Android | No | 当 handleGLSurfaceViewOnAndroid 设置为true且视图是 SurfaceView(或包含在视图树中)时,该视图的内容将会被捕获。 | |
| 290 | 293 | ||
| 291 | ## API | 294 | ## API |
| 292 | 295 | ||
| @@ -294,11 +297,12 @@ export function ViewShotDemo() { | |||
| 294 | 297 | ||
| 295 | > [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 | 298 | > [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 |
| 296 | 299 | ||
| 297 | -| Name | Description | Type | Required | Platform | HarmonyOS Support | | 300 | +| 名称 | 类型 | 参数类型 | 返回值 | 必填 | 平台 | 鸿蒙平台支持 | 描述 | |
| 298 | -| ---------------- | ----------- | -------- | -------- | ------------ | ----------------- | | 301 | +| ---- | ---- | -------- | ------ | ---- | ---- | ------------------- | ---- | |
| 299 | -| `captureRef` | 组件截图 | function | no | Android, iOS | yes | | 302 | +| `captureRef` | function | `view: CaptureTarget; optionsObject?: CaptureOptions` | `Promise<string>` | `view`: yes; `optionsObject`: no | Android, iOS | yes | 组件截图 | |
| 300 | -| `captureScreen` | 屏幕截图 | function | no | Android, iOS | yes | | 303 | +| `captureScreen` | function | `optionsObject?: CaptureOptions` | `Promise<string>` | no | Android, iOS | yes | 屏幕截图 | |
| 301 | -| `releaseCapture` | 资源释放 | function | no | Android, iOS | yes | | 304 | +| `releaseCapture` | function | `uri: string` | `void` | yes | Android, iOS | yes | 资源释放 | |
| 305 | +| `ViewShotRef.capture()` | function | / | `Promise<string>` | / | Android, iOS | yes | ViewShot 组件的命令式截图方法,通过 `viewShotRef.current.capture()` 调用,并使用组件 `options` 属性中的截图配置;未设置 `captureMode` 时可用它手动触发截图。 | | ||
| 302 | 306 | ||
| 303 | ## 遗留问题 | 307 | ## 遗留问题 |
| 304 | - [ ] 被截图组件需要设置背景色,否则截图效果全黑 [issues#3](https://github.com/react-native-oh-library/react-native-view-shot/issues/3)。 | 308 | - [ ] 被截图组件需要设置背景色,否则截图效果全黑 [issues#3](https://github.com/react-native-oh-library/react-native-view-shot/issues/3)。 |
| @@ -363,4 +367,4 @@ export function ViewShotDemo() { | |||
| 363 | 367 | ||
| 364 | ## 开源协议 | 368 | ## 开源协议 |
| 365 | 369 | ||
| 366 | -本项目基于 [The MIT License (MIT)](https://github.com/gre/react-native-view-shot/blob/master/LICENSE) ,请自由地享受和参与开源。 | 370 | +本项目基于 [The MIT License (MIT)](https://github.com/gre/react-native-view-shot/blob/master/LICENSE) ,请自由地享受和参与开源。 |
| @@ -46,7 +46,7 @@ yarn add @react-native-ohos/react-native-view-shot | |||
| 46 | 46 | ||
| 47 | | | Is supported autolink | Supported RN Version | | 47 | | | Is supported autolink | Supported RN Version | |
| 48 | |------------------------------------|-----------------------|----------------------| | 48 | |------------------------------------|-----------------------|----------------------| |
| 49 | -| ~4.0.0 | Yes | 0.84 | | 49 | +| ~4.0.0 | Yes | 0.84.* / 0.82.* | |
| 50 | 50 | ||
| 51 | 51 | ||
| 52 | Using AutoLink need to be configured according to this document, Autolink Framework Guide Documentation: https://gitcode.com/CPF-RN/ohos_react_native/blob/master/docs/en/Autolinking.md | 52 | Using AutoLink need to be configured according to this document, Autolink Framework Guide Documentation: https://gitcode.com/CPF-RN/ohos_react_native/blob/master/docs/en/Autolinking.md |
| @@ -187,6 +187,7 @@ Then build and run the code. | |||
| 187 | The content in this document has been verified under the following environment: | 187 | The content in this document has been verified under the following environment: |
| 188 | 188 | ||
| 189 | 1. RNOH: 0.84.1; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112; | 189 | 1. RNOH: 0.84.1; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112; |
| 190 | +2. RNOH: 0.82.1; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112; | ||
| 190 | 191 | ||
| 191 | ## Example | 192 | ## Example |
| 192 | 193 | ||
| @@ -246,8 +247,8 @@ export function ViewShotDemo() { | |||
| 246 | <Button | 247 | <Button |
| 247 | title="ViewShot capture" | 248 | title="ViewShot capture" |
| 248 | onPress={() => { | 249 | onPress={() => { |
| 249 | - captureRef(ref).then((res) => { | 250 | + ref.current?.capture().then((res) => { |
| 250 | - console.info(`captureRef: ${res}`); | 251 | + console.info(`ViewShotRef.capture: ${res}`); |
| 251 | }); | 252 | }); |
| 252 | }} | 253 | }} |
| 253 | /> | 254 | /> |
| @@ -270,26 +271,28 @@ export function ViewShotDemo() { | |||
| 270 | 271 | ||
| 271 | > [!TIP] If the value of **HarmonyOS Support** is **yes**, it means that the HarmonyOS platform supports this property; **no** means the opposite; **partially** means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android. | 272 | > [!TIP] If the value of **HarmonyOS Support** is **yes**, it means that the HarmonyOS platform supports this property; **no** means the opposite; **partially** means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android. |
| 272 | 273 | ||
| 273 | -| Name | Description | Type | Required | Platform | HarmonyOS Support | | 274 | +| Name | Parameter Type | Default Value | Required | Platform | OpenHarmony Platform Support | Description | |
| 274 | -| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- | -------- | ------------ | ----------------- | | 275 | +| ---- | -------------- | ------------- | -------- | -------- | ---------------------------- | ----------- | |
| 275 | -| captureMode | if not defined (default). the capture is not automatic and you need to use the ref and call `capture()` yourself<br>`"mount"`. Capture the view once at mount. (It is important to understand image loading won't be waited, in such case you want to use "none" with viewShotRef.capture() after Image#onLoad.) <br>`"continuous"` EXPERIMENTAL, this will capture A LOT of images continuously. For very specific use-cases.<br> `"update"` EXPERIMENTAL, this will capture images each time React redraw (on did update). For very specific use-cases. | ( 'mount' \| 'continuous' \| 'update') | no | Android, iOS | yes | | 276 | +| captureMode | `"mount"` \| `"continuous"` \| `"update"` | `undefined` | No | Android, iOS | Yes | if not defined (default). the capture is not automatic and you need to use the ref and call `capture()` yourself<br>`"mount"`. Capture the view once at mount. (It is important to understand image loading won't be waited, in such case you want to use "none" with viewShotRef.capture() after Image#onLoad.) <br>`"continuous"` EXPERIMENTAL, this will capture A LOT of images continuously. For very specific use-cases.<br> `"update"` EXPERIMENTAL, this will capture images each time React redraw (on did update). For very specific use-cases. | |
| 276 | -| onCapture | when a `captureMode` is defined, this callback will be called with the capture result. | function | no | Android, iOS | yes | | 277 | +| onCapture | `(uri: string) => void` | None | No | Android, iOS | Yes | when a `captureMode` is defined, this callback will be called with the capture result. | |
| 277 | -| onCaptureFailure | when a `captureMode` is defined, this callback will be called when a capture fails. | function | no | Android, iOS | yes | | 278 | +| onCaptureFailure | `(error: Error) => void` | None | No | Android, iOS | Yes | when a `captureMode` is defined, this callback will be called when a capture fails. | |
| 278 | -| options | view shot configuration. | object | no | Android, iOS | partially | | 279 | +| options | `CaptureOptions` | None | No | Android, iOS | Partially | view shot configuration. | |
| 279 | -| children | the actual content to rasterize. | ReactNode | no | Android, iOS | yes | | 280 | +| children | `ReactNode` | None | No | Android, iOS | Yes | the actual content to rasterize. | |
| 281 | +| onLayout | `(event: LayoutChangeEvent) => void` | None | No | Android, iOS | Yes | Invoked when the component mounts or its layout changes, with the layout event. | | ||
| 282 | +| style | `StyleProp<ViewStyle>` | None | No | Android, iOS | Yes | View styles applied to the ViewShot container. | | ||
| 280 | 283 | ||
| 281 | ### options | 284 | ### options |
| 282 | 285 | ||
| 283 | -| Name | Description | Type | Required | Platform | HarmonyOS Support | | 286 | +| Name | Parameter Type | Default Value | Required | Platform | OpenHarmony Platform Support | Description | |
| 284 | -| ------------------------ | ------------------------------------------------------------ | ------------------------------------ | -------- | ------------ | ----------------- | | 287 | +| ---- | -------------- | ------------- | -------- | -------- | ---------------------------- | ----------- | |
| 285 | -| fileName | the file name of the file. Must be at least 3 characters long. | string | no | Android, iOS | yes | | 288 | +| fileName | `string` | None | No | Android | Yes | the file name of the file. Must be at least 3 characters long. | |
| 286 | -| width / height | the width and height of the final image (resized from the View bound. don't provide it if you want the original pixel size). | number | no | Android, iOS | yes | | 289 | +| width / height | `number` | None | No | Android, iOS | Yes | the width and height of the final image (resized from the View bound. don't provide it if you want the original pixel size). | |
| 287 | -| quality | the quality. 0.0 - 1.0 (default). (only available on lossy formats like jpg) | number | no | Android, iOS | yes | | 290 | +| quality | `number` | `1` | No | Android, iOS | Yes | the quality. 0.0 - 1.0 (default). (only available on lossy formats like jpg) | |
| 288 | -| format | either png/jpg/webp/webm. Defaults to png. | string | no | Android, iOS | yes | | 291 | +| format | `"jpg"` \| `"png"` \| `"webp"` \| `"webm"` \| `"raw"` | `"png"` | No | Android, iOS | Partially | either png/jpg/webp/webm. Defaults to png. The raw format is not supported on OpenHarmony (Android only). | |
| 289 | -| result | the method you want to use to save the snapshot, one of:<br/>"tmpfile" (default): save to a temporary file (that will only exist for as long as the app is running).<br/>"base64": encode as base64 and returns the raw string. Use only with small images as this may result of lags (the string is sent over the bridge). N.B. This is not a data uri, use data-uri instead.<br/>"data-uri": same as base64 but also includes the Data URI scheme header. <br/>"zip-base64": compress data with zip deflate algorithm and than convert to base64 and return as a raw string | ( 'tmpfile' \|'base64' \|'data-uri' \|'zip-base64' ) | no | Android, iOS | partially(not supporrt zip-base64) | | 292 | +| result | `"tmpfile"` \| `"base64"` \| `"data-uri"` \| `"zip-base64"` | `"tmpfile"` | No | Android, iOS | Partially | the method you want to use to save the snapshot, one of:<br/>"tmpfile" (default): save to a temporary file (that will only exist for as long as the app is running).<br/>"base64": encode as base64 and returns the raw string. Use only with small images as this may result of lags (the string is sent over the bridge). N.B. This is not a data uri, use data-uri instead.<br/>"data-uri": same as base64 but also includes the Data URI scheme header. <br/>"zip-base64": compress data with zip deflate algorithm and than convert to base64 and return as a raw string. Note: zip-base64 is not supported on OpenHarmony (Android only). | |
| 290 | -| snapshotContentContainer | if true and when view is a ScrollView, the "content container" height will be evaluated instead of the container height. | boolean | no | Android, iOS | no | | 293 | +| snapshotContentContainer | `boolean` | `false` | No | Android, iOS | No | if true and when view is a ScrollView, the "content container" height will be evaluated instead of the container height. | |
| 291 | -| handleGLSurfaceViewOnAndroid | if true and when view is a SurfaceView or have it in the view tree, view will be captured. | boolean | no | Android | no | | 294 | +| useRenderInContext | `boolean` | None | No | iOS | No | change the iOS snapshot strategy to use method renderInContext instead of drawViewHierarchyInRect which may help for some use cases. | |
| 292 | -| useRenderInContext | change the iOS snapshot strategy to use method renderInContext instead of drawViewHierarchyInRect which may help for some use cases. | boolean | no | Android, iOS | no | | 295 | +| handleGLSurfaceViewOnAndroid | `boolean` | `false` | No | Android | No | if true and when view is a SurfaceView or have it in the view tree, view will be captured. | |
| 293 | 296 | ||
| 294 | ## APIs | 297 | ## APIs |
| 295 | 298 | ||
| @@ -297,11 +300,12 @@ export function ViewShotDemo() { | |||
| 297 | 300 | ||
| 298 | > [!TIP] If the value of **HarmonyOS Support** is **yes**, it means that the HarmonyOS platform supports this property; **no** means the opposite; **partially** means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android. | 301 | > [!TIP] If the value of **HarmonyOS Support** is **yes**, it means that the HarmonyOS platform supports this property; **no** means the opposite; **partially** means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android. |
| 299 | 302 | ||
| 300 | -| Name | Description | Type | Required | Platform | HarmonyOS Support | | 303 | +| Name | Type | Parameter Type | Return Value | Required | Platform | OpenHarmony Platform Support | Description | |
| 301 | -| ---------------- | ----------- | -------- | -------- | ------------ | ----------------- | | 304 | +| ---- | ---- | -------------- | ------------ | -------- | -------- | ---------------------------- | ----------- | |
| 302 | -| `captureRef` | component screenshot | function | no | Android, iOS | yes | | 305 | +| `captureRef` | function | `view: CaptureTarget; optionsObject?: CaptureOptions` | `Promise<string>` | `view`: yes; `optionsObject`: no | Android, iOS | yes | component screenshot | |
| 303 | -| `captureScreen` | screenshot | function | no | Android, iOS | yes | | 306 | +| `captureScreen` | function | `optionsObject?: CaptureOptions` | `Promise<string>` | no | Android, iOS | yes | screenshot | |
| 304 | -| `releaseCapture` | resource release | function | no | Android, iOS | yes | | 307 | +| `releaseCapture` | function | `uri: string` | `void` | yes | Android, iOS | yes | resource release | |
| 308 | +| `ViewShotRef.capture()` | function | / | `Promise<string>` | / | Android, iOS | yes | Imperatively captures the ViewShot component through `viewShotRef.current.capture()` using the component's `options`; use it to trigger a capture manually when `captureMode` is not set. | | ||
| 305 | 309 | ||
| 306 | ## Known Issues | 310 | ## Known Issues |
| 307 | - [ ] The captured component needs to set a background color, otherwise the screenshot effect will be completely black [issues#3](https://github.com/react-native-oh-library/react-native-view-shot/issues/3)。 | 311 | - [ ] The captured component needs to set a background color, otherwise the screenshot effect will be completely black [issues#3](https://github.com/react-native-oh-library/react-native-view-shot/issues/3)。 |
| @@ -366,4 +370,4 @@ If you find any problem when using react-native-view-shot, submit an [Issue](htt | |||
| 366 | 370 | ||
| 367 | ## License | 371 | ## License |
| 368 | 372 | ||
| 369 | -This project is licensed under [The MIT License (MIT)](https://github.com/gre/react-native-view-shot/blob/master/LICENSE). | 373 | +This project is licensed under [The MIT License (MIT)](https://github.com/gre/react-native-view-shot/blob/master/LICENSE). |
加上0.82的验证结果