Skip to content

Commit 8fd9809

Browse files
Add customLoader and remove animatable (#1152)
* Add customLoader and remove animatable * remove redundent view Co-authored-by: Ethan Sharabi <[email protected]>
1 parent e0247b7 commit 8fd9809

File tree

2 files changed

+29
-33
lines changed

2 files changed

+29
-33
lines changed

demo/src/screens/componentScreens/LoadingScreen.js

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,22 @@
11
import React, {Component} from 'react';
2-
import {View as AnimatableView} from 'react-native-animatable';
3-
import {View, Text, LoaderScreen, Colors} from 'react-native-ui-lib';//eslint-disable-line
4-
2+
import {View, Text, LoaderScreen, Colors} from 'react-native-ui-lib';
53
export default class LoadingScreen extends Component {
6-
74
state = {
8-
loading: true,
5+
loading: true
96
};
107

118
componentDidMount() {
129
setTimeout(() => {
13-
this.setState({
14-
animationConfig: {
15-
animation: 'fadeOut',
16-
onAnimationEnd: () => this.setState({loading: false}),
17-
},
18-
});
10+
this.setState({loading: false});
1911
}, 2500);
2012
}
2113

2214
render() {
23-
const {loading, animationConfig} = this.state;
15+
const {loading} = this.state;
2416
return (
2517
<View flex bg-orange70 center>
26-
<Text text10>
27-
Content Content Content
28-
</Text>
29-
{loading &&
30-
<AnimatableView {...animationConfig}>
31-
<LoaderScreen
32-
color={Colors.blue30}
33-
message="Loading..."
34-
overlay
35-
/>
36-
</AnimatableView>
37-
}
18+
<Text text10>Content Content Content</Text>
19+
{loading && <LoaderScreen color={Colors.blue30} message="Loading..." overlay/>}
3820
</View>
3921
);
4022
}

src/components/loaderScreen/index.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {BaseComponent} from '../../commons';
77
import View from '../../components/view';
88
import Text from '../../components/text';
99

10-
1110
/**
1211
* @description: Component that shows a full screen with an activity indicator
1312
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/LoadingScreen.js
@@ -22,6 +21,10 @@ export default class LoaderScreen extends BaseComponent {
2221
* Color of the loading indicator
2322
*/
2423
loaderColor: PropTypes.string,
24+
/**
25+
* Custom loader
26+
*/
27+
customLoader: PropTypes.element,
2528
/**
2629
* Color of the loader background (only when passing 'overlay')
2730
*/
@@ -44,18 +47,29 @@ export default class LoaderScreen extends BaseComponent {
4447
};
4548

4649
render() {
47-
const {message, messageStyle, loaderColor, overlay, backgroundColor, containerStyle, ...others} = this.props;
50+
const {
51+
message,
52+
messageStyle,
53+
loaderColor,
54+
overlay,
55+
backgroundColor,
56+
customLoader,
57+
containerStyle,
58+
...others
59+
} = this.props;
4860

4961
return (
5062
<View style={[overlay ? [styles.overlayContainer, {backgroundColor}] : styles.container, containerStyle]}>
5163
<View flex center>
52-
<ActivityIndicator
53-
size={'large'}
54-
animating
55-
color={loaderColor || (Constants.isIOS ? Colors.dark60 : Colors.primary)}
56-
{...others}
57-
/>
58-
{!overlay && message && <Text style={[styles.message, messageStyle]}>{message}</Text>}
64+
{customLoader || (
65+
<ActivityIndicator
66+
size={'large'}
67+
animating
68+
color={loaderColor || (Constants.isIOS ? Colors.dark60 : Colors.primary)}
69+
{...others}
70+
/>
71+
)}
72+
{message && <Text style={[styles.message, messageStyle]}>{message}</Text>}
5973
</View>
6074
</View>
6175
);

0 commit comments

Comments
 (0)