模板版本:v0.2.2
[!TIP] Github 地址
进入到工程目录并输入以下命令:
[!TIP] # 处替换为 tgz 包的路径
npm install [email protected]
yarn add [email protected]
下面的代码展示了这个库的基本使用场景:
[!WARNING] 使用时 import 的库名不变。
import React, { Component } from 'react';
import { AppRegistry, StatusBar, View, Platform, Dimensions } from 'react-native';
import {
BallIndicator,
BarIndicator,
DotIndicator,
MaterialIndicator,
PacmanIndicator,
PulseIndicator,
SkypeIndicator,
UIActivityIndicator,
WaveIndicator,
} from 'react-native-indicators';
const { width, height } = Dimensions.get('window');
export class IndicatorsTestExample extends Component {
render() {
return (
<View style={styles.container}>
<View style={styles.row}>
<View style={styles.flex}>
<BallIndicator color='white' animationDuration={800} />
</View>
<View style={styles.flex}>
<PulseIndicator color='white' />
</View>
<View style={styles.flex}>
<SkypeIndicator color='white' />
</View>
</View>
<View style={styles.row}>
<View style={styles.flex}>
<WaveIndicator color='white' />
</View>
<View style={styles.flex}>
<WaveIndicator color='white' waveMode='outline' />
</View>
<View style={styles.flex}>
<WaveIndicator color='white' count={2} waveFactor={0.1} />
</View>
</View>
<View style={styles.row}>
<View style={styles.flex}>
<UIActivityIndicator color='white' />
</View>
<View style={styles.flex}>
<MaterialIndicator color='white' />
</View>
<View style={styles.flex}>
<PacmanIndicator color='white' />
</View>
</View>
<View style={styles.row}>
<View style={styles.flex}>
<BarIndicator color='white' count={5} />
</View>
</View>
<View style={styles.row}>
<View style={styles.flex}>
<DotIndicator
count={3}
color='white'
animationDuration={800}
/>
</View>
<View style={styles.flex}>
<DotIndicator
style={styles.reverse}
count={3}
color='white'
animationDuration={800}
/>
</View>
</View>
</View>
);
}
}
const styles = {
container: {
height: height-100,
backgroundColor: '#01579B',
padding: 20,
},
row: {
flex: 1,
flexDirection: 'row',
},
reverse: {
transform: [{
rotate: '180deg',
}],
},
flex: {
flex: 1,
},
};
要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
本文档内容基于以下版本验证通过:
- RNOH: 0.72.27; SDK: HarmonyOS-Next-DB1 5.0.0.25 (API Version 12 Canary4); IDE: DevEco Studio 5.0.3.400; ROM: 3.0.0.25;
- RNOH:0.72.33; SDK:OpenHarmony 5.0.0.71(API Version 12 Release); IDE:DevEco Studio 5.0.3.900; ROM:NEXT.0.0.71;
[!TIP] "Platform"列表示该属性在原三方库上支持的平台。
[!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
Name | Description | Type | Required | Platform | HarmonyOS Support |
---|---|---|---|---|---|
animationEasing | Animation easing function | Function | NO | ALL | YES |
animationDuration | Animation duration in ms | Number | NO | ALL | YES |
animating | Animation toggle | Boolean | NO | ALL | YES |
interaction | Animation is interaction | Boolean | NO | ALL | YES |
hidesWhenStopped | Hide when not animating | Boolean | NO | ALL | YES |
Name | Description | Type | Required | Platform | HarmonyOS Support |
---|---|---|---|---|---|
color | Component color | String | NO | ALL | YES |
count | Component count | Number | NO | ALL | YES |
size | Base component size | Number | NO | ALL | YES |
Name | Description | Type | Required | Platform | HarmonyOS Support |
---|---|---|---|---|---|
color | Component color | String | NO | ALL | YES |
count | Component count | Number | NO | ALL | YES |
size | Base component size | Number | NO | ALL | YES |
Name | Description | Type | Required | Platform | HarmonyOS Support |
---|---|---|---|---|---|
color | Component color | String | NO | ALL | YES |
count | Component count | Number | NO | ALL | YES |
size | Base component size | Number | NO | ALL | YES |
Name | Description | Type | Required | Platform | HarmonyOS Support |
---|---|---|---|---|---|
color | Component color | String | NO | ALL | YES |
trackWidth | Indicator track width | Number | NO | ALL | YES |
size | Base component size | Number | NO | ALL | YES |
Name | Description | Type | Required | Platform | HarmonyOS Support |
---|---|---|---|---|---|
color | Component color | String | NO | ALL | YES |
size | Base component size | Number | NO | ALL | YES |
Name | Description | Type | Required | Platform | HarmonyOS Support |
---|---|---|---|---|---|
color | Component color | String | NO | ALL | YES |
size | Base component size | Number | NO | ALL | YES |
Name | Description | Type | Required | Platform | HarmonyOS Support |
---|---|---|---|---|---|
color | Component color | String | NO | ALL | YES |
count | Component count | Number | NO | ALL | YES |
size | Base component size | Number | NO | ALL | YES |
minScale | Minimum component scale | Number | NO | ALL | YES |
maxScale | Maximum component scale | Number | NO | ALL | YES |
Name | Description | Type | Required | Platform | HarmonyOS Support |
---|---|---|---|---|---|
color | Component color | String | NO | ALL | YES |
count | Component count | Number | NO | ALL | YES |
size | Base component size | Number | NO | ALL | YES |
Name | Description | Type | Required | Platform | HarmonyOS Support |
---|---|---|---|---|---|
color | Component color | String | NO | ALL | YES |
count | Component count | Number | NO | ALL | YES |
size | Base component size | Number | NO | ALL | YES |
waveFactor | Wave base number | Number | NO | ALL | YES |
waveMode | Wave appearance | String | NO | ALL | YES |
本项目基于 The BSD License (BSD) ,请自由地享受和参与开源。