From 9487d26ac69de8a4ff95b05c747c6b7e443e5e7f Mon Sep 17 00:00:00 2001 From: sl Date: Fri, 5 Jul 2024 08:40:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?docs:=20[Issues:=20#IA9QHS]=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9Ereact-native-sensitive-ifno=E6=8C=87=E5=AF=BC=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zh-cn/react-native-sensitive-info.md | 473 +++++++++++++++++++++++++++ 1 file changed, 473 insertions(+) create mode 100644 zh-cn/react-native-sensitive-info.md diff --git a/zh-cn/react-native-sensitive-info.md b/zh-cn/react-native-sensitive-info.md new file mode 100644 index 00000000..f1d62e4a --- /dev/null +++ b/zh-cn/react-native-sensitive-info.md @@ -0,0 +1,473 @@ + +模板版本:v0.2.2 + +

+

react-native-sensitive-info

+

+ +

+ + Supported platforms + + + License + +

+ + +> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-sensitive-info) + + +## 安装与使用 + +请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-sensitive-info Releases](https://github.com/react-native-oh-library/react-native-sensitive-info/releases),并下载适用版本的 tgz 包。 + +进入到工程目录并输入以下命令: + +> [!TIP] # 处替换为 tgz 包的路径 + + + +#### **npm** + +```bash +npm install @react-native-oh-tpl/react-native-sensitive-info@file:# +``` + +#### **yarn** + +```bash +yarn add @react-native-oh-tpl/react-native-sensitive-info@file:# +``` + + + +下面的代码展示了这个库的基本使用场景: + +> [!WARNING] 使用时 import 的库名不变。 + +```js +import React, { useCallback, useState } from 'react'; +import { TestSuite, Tester, Filter } from '@rnoh/testerino'; +import { View, Alert, Button, ColorValue, } from 'react-native'; +import { TestCase } from '../components'; +import sensitive from 'react-native-sensitive-info' +import { boolean } from 'yargs'; + +export function SensitiveInfo() { + const handleSetItem = useCallback((key: string, value: string) => { + + sensitive.setItem(key, value, { + sharedPreferencesName: 'exampleApp', + keychainService: 'exampleApp', + }) + + }, []); + + const handleGetItem = useCallback((key: string) => { + sensitive.getItem(key, { + sharedPreferencesName: 'exampleApp', + keychainService: 'exampleApp', + }).then(res => { + Alert.alert(res) + }); + }, []); + + const handleHasItem = useCallback(() => { + sensitive.hasItem('key1', { + sharedPreferencesName: 'exampleApp', + keychainService: 'exampleApp', + kSecAccessControl: 'kSecAccessControlBiometryAny', // Enabling FaceID + touchID: true, + showModal: true, + }); + }, []); + + const handleDelItem = useCallback(() => { + sensitive.deleteItem('key1', { + sharedPreferencesName: 'exampleApp', + keychainService: 'exampleApp', + }); + }, []) + + const handleGetAllItems = useCallback(() => { + sensitive.getAllItems({ + sharedPreferencesName: 'exampleApp', + keychainService: 'exampleApp', + }); + }, []) + + const handleHasEnrolledFingerprints = useCallback(() => { + sensitive.hasEnrolledFingerprints(); + }, []) + + const handleIsSensorAvailable = useCallback(() => { + sensitive.isSensorAvailable().then(res => { + Alert.alert(JSON.stringify(res)) + }); + }, []) + + const handlecancelFingerprintAuth = (() => { + try { + sensitive.cancelFingerprintAuth() + } catch { + Alert.alert("Error") + } + }); + + const setInvalidatedByBiometricEnrollment = (() => { + try { + sensitive.setInvalidatedByBiometricEnrollment(false) + } catch { + Alert.alert("Error") + } + }); + + return ( + + + + + } + assert={({ expect, state }) => { + expect(state).to.be.eq(true); + }} + /> + + + + } + assert={({ expect, state }) => { + expect(state).to.be.eq(true); + }} + /> + + + + } + assert={({ expect, state }) => { + expect(state).to.be.eq(true); + }} + /> + + + + } + assert={({ expect, state }) => { + expect(state).to.be.eq(true); + }} + /> + + + + } + assert={({ expect, state }) => { + expect(state).to.be.eq(true); + }} + /> + + + + + } + assert={({ expect, state }) => { + expect(state).to.be.eq(true); + }} + /> + + + + + } + assert={({ expect, state }) => { + expect(state).to.be.eq(true); + }} + /> + + + + } + assert={({ expect, state }) => { + expect(state).to.be.eq(true); + }} + /> + + + + } + assert={({ expect, state }) => { + expect(state).to.be.eq(true); + }} + /> + + + + } + assert={({ expect, state }) => { + expect(state).to.be.eq(true); + }} + /> + + + + + } + assert={({ expect, state }) => { + expect(state).to.be.eq(true); + }} + /> + + + ); +} + + +``` + +## 使用 Codegen + +本库已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](/zh-cn/codegen.md)。 + +## Link + +目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。 + +首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony` + +### 在工程根目录的 `oh-package.json` 添加 overrides 字段 + +```json +{ + ... + "overrides": { + "@rnoh/react-native-openharmony" : "./react_native_openharmony" + } +} +``` + +### 引入原生端代码 + +目前有两种方法: + +1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法); +2. 直接链接源码。 + +方法一:通过 har 包引入(推荐) + +> [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。 + +打开 `entry/oh-package.json5`,添加以下依赖 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-oh-tpl/react-native-sensitive-info": "file:../../node_modules/@react-native-oh-tpl/react-native-sensitive-info/harmony/date-picker.har" + } +``` + +点击右上角的 `sync` 按钮 + +或者在终端执行: + +```bash +cd entry +ohpm install +``` + +方法二:直接链接源码 + + +> [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) + +在 ArkTs 侧引入 RNSensitiveInfoPackage +打开 entry/src/main/ets/组件RNPackagesFactory.ts,添加: + +```diff +... ++ import { RNSensitiveInfoPackage } from 'react_native_sensitive_info/ts'; + +@Builder +export function createRNPackages(ctx: RNPackageContext): RNPackage[] { + return [ + new SamplePackage(ctx), ++ new RNSensitiveInfoPackage(ctx) + ]; +} + +... +### 运行 + +点击右上角的 `sync` 按钮 + +或者在终端执行: + +```bash +cd entry +ohpm install +``` + +然后编译、运行即可。 + +### 权限要求 +在 YourProject/entry/src/main/module.json5补上配置 +```js +"requestPermissions": [ { "name": "ohos.permission.ACCESS_BIOMETRIC" }, ] +``` + +### 兼容性 + +要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 + + +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-sensitive-info Releases](https://github.com/react-native-oh-library/react-native-sensitive-info/releases) + + + +## API +[!tip] "Platform"列表示该属性在原三方库上支持的平台。 + +[!tip] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 + +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| ---------------- | ------------------------------------------------------------ | -------- | -------- | ------------ | ----------------- | +| isSensorAvailable() | Indicates the overall availability of fingerprint sensor. It will resolve to true or false | function | yes | Android、IOS | yes | +| cancelFingerprintAuth () | Canceling fingerprint authentication | function | yes | Android、IOS | yes | +| hasEnrolledFingerprints () | It will return true if detected otherwise returns false | function | yes | Android、IOS | yes | +| hasItem() | Check whether the data is in the memory. | function | yes | Android、IOS | yes | +setItem() | Insert new data into the storage. | function | yes | Android、IOS | yes | +getItem() | Get an item from storage | function | yes | Android、IOS | yes | +getAllItems() | Get all items from storage. | function | yes | Android、IOS | yes | +deleteItem() | Delete an item from storage | function | yes | Android、IOS | yes | +setInvalidatedByBiometricEnrollment() | Set invalid enrollment by biometrics | function | yes | Android | yes | + +## 遗留问题 + + +## 其他 + +## 开源协议 + +本项目基于 [The MIT License (MIT)](https://github.com/mCodex/react-native-sensitive-info) ,请自由地享受和参与开源。 + + \ No newline at end of file -- Gitee From dc12e8318e23f22867f4b54989ee94540cc02784 Mon Sep 17 00:00:00 2001 From: ShiLong Date: Mon, 8 Jul 2024 19:32:23 +0800 Subject: [PATCH 2/2] =?UTF-8?q?docs:=20[Issues:=20#IABGRD]=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0react-native-switch=E6=8C=87=E5=AF=BC=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zh-cn/react-native-switch.md | 150 +++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 zh-cn/react-native-switch.md diff --git a/zh-cn/react-native-switch.md b/zh-cn/react-native-switch.md new file mode 100644 index 00000000..7610fd5e --- /dev/null +++ b/zh-cn/react-native-switch.md @@ -0,0 +1,150 @@ + + +> 模板版本:v0.2.2 + +

+

react-native-switch

+

+

+ + Supported platforms + + + License + +

+ + +> [!TIP] [Github 地址](https://github.com/shahen94/react-native-switch) + +## 安装与使用 + + + +#### **npm** + +```bash +npm install --save react-native-switch +``` + +#### **yarn** + +```bash +yarn add react-native-switch +``` + + + +下面的代码展示了这个库的基本使用场景: + +> [!WARNING] 使用时 import 的库名不变。 + +```js +import React, { useState } from "react"; +import { Switch } from "react-native-switch"; +import {SafeAreaView, StyleSheet,Button, Text, View, Alert} from 'react-native'; + + +export function SwitchDemo(){ + const [isEnabled, setIsEnabled] = useState(false); + const toggleSwitch = (val:boolean) => {setIsEnabled(val) }; + + return( + + Welcome to React Native ! + toggleSwitch((val))} + disabled={false} + activeText={'On'} + inActiveText={'Off'} + circleSize={30} + barHeight={30} + circleBorderWidth={3} + backgroundActive={'green'} + backgroundInactive={'gray'} + circleActiveColor={'#30a566'} + circleInActiveColor={'#fff'} + renderInsideCircle={() => ''} // custom component to render inside the Switch circle (Text, Image, etc.) + changeValueImmediately={true} // if rendering inside circle, change state immediately or wait for animation to complete + innerCircleStyle={{ alignItems: "center", justifyContent: "center" }} // style for inner animated circle for what you (may) be rendering inside the circle + outerCircleStyle={{ }} // style for outer animated circle + renderActiveText={true} + renderInActiveText={true} + switchLeftPx={2} // denominator for logic when sliding to TRUE position. Higher number = more space from RIGHT of the circle to END of the slider + switchRightPx={2} // denominator for logic when sliding to FALSE position. Higher number = more space from LEFT of the circle to BEGINNING of the slider + switchWidthMultiplier={3} // multiplied by the `circleSize` prop to calculate total width of the Switch + switchBorderRadius={50} // Sets the border Radius of the switch slider. If unset, it remains the circleSize. + /> + To get started,edit index.harmony.js + Press Cmd +R to reload, + Cmd+D or shake for dev menu + + ) + } + const styles = StyleSheet.create({ + container: { + flex: 1, + alignItems: "center", + justifyContent: "center", + backgroundColor:"#fff", + + } + }); +``` + +## 约束与限制 + +### 兼容性 + +本文档内容基于以下版本验证通过: + +1. RNOH: 0.72.27; SDK: HarmonyOS-NEXT-DB1; IDE: DevEco Studio 5.0.3.400SP7; ROM: 3.0.0.29; + +## 属性 + +> [!tip] "Platform"列表示该属性在原三方库上支持的平台。 + +> [!tip] "HarmonyOS Support"列为 Yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 + +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| :----------------: | :----------------------------------------------------------: | :-----------------: | :------: | :---------: | :---------------: | +| onValueChange | when to change value(value: `boolean`) | function | No | Android/IOS | Yes | +| disabled | Display or not | boolean | No | Android/IOS | Yes | +| activeText | active text | string | No | Android/IOS | Yes | +| inActiveText | in Active Text | string | No | Android/IOS | Yes | +| backgroundActive | background active | string | No | Android/IOS | Yes | +| backgroundInactive | background in active | string | No | Android/IOS | Yes | +| value | swtich value | boolean | No | Android/IOS | Yes | +| circleActiveColor | circle active color | string | No | Android/IOS | Yes | +| circleInActiveColor | circle in active color | string | No | Android/IOS | Yes | +| circleSize | circle Size| number | No | Android/IOS | Yes | +| circleBorderWidth | circle Border Width | function | No | Android/IOS | Yes | +| circleBorderactiveColor | circle Border Active Color| function | No | Android/IOS | Yes | +| circleBorderInactiveColor |circle Border Inactive Color | boolean | No | Android/IOS | Yes | +| activeTextStyle | active Text Style | StyleProp` ` | No | Android/IOS |Yes +| inactiveTextStyle | in Active Text Style. | StyleProp` ` | No | Android/IOS | Yes | +| containerStyle | container Style | StyleProp` ` | No | Android/IOS | Yes | +| barHeight | Bar Height | number | No | Android/IOS | Yes | +| circleBorderWidth | circle Border Width | number | No | Android/IOS | Yes | +| renderInsideCircle | custom component to render inside the Switch circle (Text, Image, etc.) | function | No | Android/IOS | Yes | +| changeValueImmediately | if rendering inside circle, change state immediately or wait for animation to complete | boolean | No | Android/IOS | Yes | +| innerCircleStyle | style for inner animated circle for what you (may) be rendering inside the circle| StyleProp` ` | No | Android/IOS | Yes | +| outerCircleStyle | style for outer animated circle | StyleProp` ` | No | Android/IOS | Yes | +renderActiveText | render Active Text | boolean | No | Android/IOS | Yes | +renderInActiveText | render In Active Text | boolean | No | Android/IOS | Yes | +switchLeftPx | denominator for logic when sliding to TRUE position. Higher number = more space from RIGHT of the circle to END of the slider | number | No | Android/IOS | Yes | +switchRightPx | denominator for logic when sliding to FALSE position. Higher number = more space from LEFT of the circle to BEGINNING of the slider | number | No | Android/IOS | Yes | +switchWidthMultiplier | multiplied by the `circleSize` prop to calculate total width of the Switch | number | No | Android/IOS | Yes | +switchBorderRadius | Sets the border Radius of the switch slider. If unset, it remains the circleSize. | number | No | Android/IOS | Yes | +testID | swtich test ID | string | No | Android/IOS | Yes | + +## 遗留问题 + +## 其他 + +## 开源协议 + +本项目基于 [The MIT License](https://github.com/joshswan/react-native-autolink/blob/master/LICENSE) ,请自由地享受和参与开源。 + + \ No newline at end of file -- Gitee