Skip to content

Commit

Permalink
ADD: Loading indicator for wallets
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosrdz committed May 25, 2020
1 parent d6d1673 commit bb2c3c1
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions BlueComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -1984,6 +1984,8 @@ const sliderHeight = 190;
export class WalletsCarousel extends Component {
walletsCarousel = React.createRef();

state = { isLoading: true };

_renderItem = ({ item, index }) => {
return <WalletCarouselItem item={item} index={index} handleLongPress={this.props.handleLongPress} onPress={this.props.onPress} />;
};
Expand All @@ -1992,20 +1994,34 @@ export class WalletsCarousel extends Component {
this.walletsCarousel.current.snapToItem(item);
};

onLayout = () => {
this.setState({ isLoading: false });
};

render() {
return (
<Carousel
{...this.props}
ref={this.walletsCarousel}
renderItem={this._renderItem}
sliderWidth={sliderWidth}
sliderHeight={sliderHeight}
itemWidth={itemWidth}
inactiveSlideScale={1}
inactiveSlideOpacity={0.7}
contentContainerCustomStyle={{ left: -20 }}
initialNumToRender={4}
/>
<>
{this.state.isLoading && (
<View
style={{ paddingVertical: sliderHeight / 2, paddingHorizontal: sliderWidth / 2, position: 'absolute', alignItems: 'center' }}
>
<ActivityIndicator />
</View>
)}
<Carousel
{...this.props}
ref={this.walletsCarousel}
renderItem={this._renderItem}
sliderWidth={sliderWidth}
sliderHeight={sliderHeight}
itemWidth={itemWidth}
inactiveSlideScale={1}
inactiveSlideOpacity={0.7}
contentContainerCustomStyle={{ left: -20 }}
initialNumToRender={4}
onLayout={this.onLayout}
/>
</>
);
}
}
Expand Down

0 comments on commit bb2c3c1

Please sign in to comment.