+
+
+> [!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