Skip to content

Commit

Permalink
refactor: switch LoadingContainer to styled components (#785)
Browse files Browse the repository at this point in the history
  • Loading branch information
machour authored and Houssein Djirdeh committed Apr 25, 2018
1 parent 12078d8 commit 777ac29
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/components/loading-indicators/loading-container.component.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { StyleSheet, View, ActivityIndicator, Text } from 'react-native';
import { ActivityIndicator } from 'react-native';
import styled from 'styled-components';

import { colors, fonts } from 'config';

Expand All @@ -9,24 +10,21 @@ type Props = {
center: boolean,
};

const styles = StyleSheet.create({
loadingContainer: {
backgroundColor: colors.white,
flex: 1,
alignItems: 'center',
},
center: {
justifyContent: 'center',
},
text: {
paddingTop: 20,
...fonts.fontPrimary,
},
});
const Container = styled.View`
background-color: ${colors.white};
flex: 1;
align-items: center;
justify-content: ${props => (props.center ? 'center' : 'initial')};
`;

const Message = styled.Text`
padding-top: 20;
${fonts.fontPrimary};
`;

export const LoadingContainer = ({ animating, text, center }: Props) => (
<View style={[styles.loadingContainer, center && styles.center]}>
<Container center={center}>
<ActivityIndicator animating={animating} size="large" />
{text && <Text style={styles.text}>{text}</Text>}
</View>
{text && <Message>{text}</Message>}
</Container>
);

0 comments on commit 777ac29

Please sign in to comment.