Skip to content

Commit 6e0f6b2

Browse files
Chandrasekar-Ghousseindjirdeh
authored andcommitted
refactor: switch LoadingRepositoryProfile to styled components (#837)
* Migrated LoadingRepositoryProfile to styled-components * Modified Icon to follow styled components
1 parent f851b76 commit 6e0f6b2

1 file changed

Lines changed: 56 additions & 69 deletions

File tree

Lines changed: 56 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,54 @@
11
// @flow
22

33
import React, { Component } from 'react';
4-
import { StyleSheet, Text, View, Animated } from 'react-native';
4+
import { View, Animated } from 'react-native';
55
import { Icon } from 'react-native-elements';
6+
import styled from 'styled-components';
67

78
import { colors, fonts, normalize } from 'config';
89
import { loadingAnimation, t } from 'utils';
910

10-
const styles = StyleSheet.create({
11-
container: {
12-
flex: 1,
13-
alignItems: 'center',
14-
justifyContent: 'center',
15-
},
16-
darkenContainer: {
17-
backgroundColor: 'rgba(0,0,0,.6)',
18-
},
19-
profile: {
20-
flex: 2,
21-
marginTop: 50,
22-
alignItems: 'center',
23-
justifyContent: 'center',
24-
},
25-
title: {
26-
color: colors.white,
27-
...fonts.fontPrimaryBold,
28-
fontSize: normalize(16),
29-
marginBottom: 2,
30-
backgroundColor: 'transparent',
31-
},
32-
subtitle: {
33-
color: colors.white,
34-
...fonts.fontPrimary,
35-
fontSize: normalize(12),
36-
paddingLeft: 15,
37-
paddingRight: 15,
38-
backgroundColor: 'transparent',
39-
},
40-
details: {
41-
flex: 1,
42-
flexDirection: 'row',
43-
justifyContent: 'space-around',
44-
minWidth: 300,
45-
},
46-
unit: {
47-
flex: 1,
48-
},
49-
unitText: {
50-
textAlign: 'center',
51-
color: colors.white,
52-
fontSize: normalize(10),
53-
...fonts.fontPrimary,
54-
},
55-
icon: {
11+
const Container = styled.View`
12+
flex: 1;
13+
align-items: center;
14+
justify-content: center;
15+
`;
16+
17+
const Profile = styled.View`
18+
flex: 2;
19+
margin-top: 50;
20+
align-items: center;
21+
justify-content: center;
22+
`;
23+
24+
const OctIcon = styled(Icon).attrs({
25+
name: 'repo',
26+
type: 'octicon',
27+
size: 45,
28+
color: colors.greyLight,
29+
containerStyle: {
30+
marginLeft: 10,
5631
paddingBottom: 20,
5732
},
58-
});
33+
})``;
34+
35+
const Details = styled.View`
36+
flex: 1;
37+
flex-direction: row;
38+
justify-content: space-around;
39+
min-width: 300;
40+
`;
41+
42+
const Unit = styled.View`
43+
flex: 1;
44+
`;
45+
46+
const UnitText = styled.Text`
47+
text-align: center;
48+
color: ${colors.white};
49+
font-size: ${normalize(10)};
50+
${fonts.fontPrimary};
51+
`;
5952

6053
export class LoadingRepositoryProfile extends Component {
6154
props: {
@@ -81,29 +74,23 @@ export class LoadingRepositoryProfile extends Component {
8174
const { locale } = this.props;
8275

8376
return (
84-
<View style={styles.container}>
77+
<Container>
8578
<View>
86-
<View style={styles.profile}>
87-
<Icon
88-
containerStyle={[styles.icon, { marginLeft: 10 }]}
89-
name={'repo'}
90-
type="octicon"
91-
size={45}
92-
color={colors.greyLight}
93-
/>
94-
</View>
95-
96-
<View style={styles.details}>
97-
<View style={styles.unit}>
98-
<Text style={styles.unitText}>{t('Stars', locale)}</Text>
99-
</View>
100-
101-
<View style={styles.unit}>
102-
<Text style={styles.unitText}>{t('Forks', locale)}</Text>
103-
</View>
104-
</View>
79+
<Profile>
80+
<OctIcon />
81+
</Profile>
82+
83+
<Details>
84+
<Unit>
85+
<UnitText>{t('Stars', locale)}</UnitText>
86+
</Unit>
87+
88+
<Unit>
89+
<UnitText>{t('Forks', locale)}</UnitText>
90+
</Unit>
91+
</Details>
10592
</View>
106-
</View>
93+
</Container>
10794
);
10895
}
10996
}

0 commit comments

Comments
 (0)