diff --git a/en/react-native-screen-capture.md b/en/react-native-screen-capture.md new file mode 100644 index 0000000000000000000000000000000000000000..beb074559558f8643575e85640c8522d6acac361 --- /dev/null +++ b/en/react-native-screen-capture.md @@ -0,0 +1,304 @@ +> Template version: v0.2.2 + +

+

react-native-screen-capture

+

+

+ + Supported platforms + + + License + +

+ +> [!TIP] [GitHub address](https://github.com/react-native-oh-library/react-native-screen-capture) + +## Installation and Usage + +Please refer to the Releases page of the third-party library for the corresponding version information + +| Version | Release Information |Supported RN Version | +|-----------------------------------|--------------------------------------------| -------------------- | +| 0.2.4 | [@react-native-ohos/react-native-screen-capture](https://gitcode.com/OpenHarmony-RN/rntpc_react-native-screen-capture/releases) | 0.72/0.77 + +Go to the project directory and execute the following instruction: + + + + +#### **npm** + +```bash +npm install @react-native-ohos/react-native-screen-capture +``` + +#### **yarn** + +```bash +yarn add @react-native-ohos/react-native-screen-capture +``` + + + + +The following code shows the basic use scenario of the repository: + +> [!WARNING] The name of the imported repository remains unchanged. + +```js +import React, { Component, useState } from 'react'; +import { Alert, View, Button, Text } from 'react-native'; +import { disallowScreenshot, keepAwake } from 'react-native-screen-capture'; + +class AppDemo extends React.Component { + state = { + isVisible: false, + screenOn: false, // false 表示允许截屏,true 表示禁止截屏 + }; + + handleDisallowScreenshot = () => { + // 切换状态:如果当前是 false(允许截屏),点击后变为 true(禁止截屏) + const newState = !this.state.screenOn; + this.setState({ screenOn: newState }); + disallowScreenshot(newState); + }; + + handleKeepAwake = () => { + const newState = !this.state.isVisible; + this.setState({ isVisible: newState }); + keepAwake(newState); + }; + + render() { + return ( + + + 防截屏状态: {this.state.screenOn ? '已禁止' : '已允许'} + +