Skip to content

Commit 9ae556f

Browse files
committed
feat: add loading bar height prop
1 parent 7896412 commit 9ae556f

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ class App extends Component {
4343

4444
**React Native Progress Webview** supports all React Native Webview props. Read the [API Reference](https://github.com/react-native-community/react-native-webview/blob/master/docs/Reference.md) to explore. There are a couple of exclusive props related to the loading bar.
4545

46-
| prop | type | default | description |
47-
| ----------------- | ------ | ------- | ------------------------------------------------------- |
48-
| color | string | #3B78E7 | normal color of loading bar |
49-
| errorColor | string | #f30 | error color of loading bar |
50-
| disappearDuration | number | 300 | the visible duration after loading bar loading finished |
46+
| prop | type | default | description |
47+
| ----------------- | ------ | ------- | ----------------------------------------------------------- |
48+
| height | number | 3 | the height of loading bar |
49+
| color | string | #3B78E7 | the normal color of loading bar |
50+
| errorColor | string | #f30 | the error color of loading bar |
51+
| disappearDuration | number | 300 | the visible duration after the webview finishes the loading |
5152

5253
## License
5354

lib/loading-bar.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import React from 'react';
22
import { View, StyleSheet } from 'react-native';
33
import PropTypes from 'prop-types';
44

5-
const LoadingBar = ({ color, percent }) => {
5+
const LoadingBar = ({ color, percent, height }) => {
66
const style = {
77
backgroundColor: color,
8-
width: `${percent * 100}%`
8+
width: `${percent * 100}%`,
9+
height,
910
};
1011
return <View style={[styles.container, style]} />;
1112
};
@@ -17,7 +18,6 @@ LoadingBar.propTypes = {
1718
const styles = StyleSheet.create({
1819
container: {
1920
position: 'absolute',
20-
height: 3,
2121
zIndex: 10,
2222
top: 0,
2323
left: 0,

lib/webview.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import LoadingBar from "./loading-bar";
77
export default class ProgressBarWebView extends React.PureComponent {
88

99
static propTypes = {
10+
height: PropTypes.number,
1011
color: PropTypes.string,
1112
errorColor: PropTypes.string,
1213
disappearDuration: PropTypes.number,
@@ -17,6 +18,7 @@ export default class ProgressBarWebView extends React.PureComponent {
1718
};
1819

1920
static defaultProps = {
21+
height: 3,
2022
color: '#3B78E7',
2123
errorColor: '#f30',
2224
disappearDuration: 300,
@@ -59,10 +61,11 @@ export default class ProgressBarWebView extends React.PureComponent {
5961
}
6062

6163
render() {
64+
const { height } = this.props;
6265
const { percent, color, visible } = this.state;
6366
return (
6467
<View style={styles.container}>
65-
{visible && <LoadingBar color={color} percent={percent}/>}
68+
{visible && <LoadingBar height={height} color={color} percent={percent}/>}
6669
<WebView
6770
onLoadStart={this._onLoadStart}
6871
onLoadEnd={this._onLoadEnd}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-progress-webview",
3-
"version": "1.0.3",
3+
"version": "1.1.0",
44
"description": "React Native Progress WebView is a wrapper of React Native WebView to provide the loading status.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)