Skip to content

Commit

Permalink
Move tabview to a separate component
Browse files Browse the repository at this point in the history
  • Loading branch information
cheng-tan committed May 6, 2020
1 parent 5480dde commit 8928b86
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 22 deletions.
36 changes: 14 additions & 22 deletions ContactLog/ContactLog.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Image,
TouchableOpacity,
} from 'react-native';
import ScrollableTabView, {DefaultTabBar} from 'react-native-scrollable-tab-view';
import colors from '../assets/colors';
import Locations from './Locations';
import People from './People';
Expand All @@ -17,6 +16,7 @@ import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import PropTypes from 'prop-types';
import Calendar from '../views/Calendar';
import TabView from '../views/TabView';

class ContactLog extends Component {
constructor() {
Expand Down Expand Up @@ -61,29 +61,10 @@ class ContactLog extends Component {
value: new Date(day.dateString.replace(/-/g, '/')),
});
}}>
<ScrollableTabView
initialPage={1}
renderTabBar={() => {
return (
<DefaultTabBar
backgroundColor={'white'}
activeTextColor={colors.section_title}
inactiveTextColor={colors.gray_icon}
textStyle={{
fontWeight: '500',
textTransform: 'uppercase'
}}
underlineStyle={{
height: 2,
backgroundColor: colors.primary_theme
}}
tabStyle={{paddingTop: 10}}
/>
);
}}>
<TabView>
<Locations tabLabel={'locations'} />
<People tabLabel={'people'} />
</ScrollableTabView>
</TabView>
</Calendar>
</>
);
Expand Down Expand Up @@ -116,6 +97,17 @@ const styles = StyleSheet.create({
color: colors.section_title,
fontWeight: '500',
},
tabBarText: {
fontWeight: '500',
textTransform: 'uppercase',
},
tabBarUnderline: {
height: 2,
backgroundColor: colors.primary_theme,
},
tabBar: {
paddingTop: 10,
},
});

ContactLog.propTypes = {
Expand Down
43 changes: 43 additions & 0 deletions views/TabView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, {Component} from 'react';
import {StyleSheet} from 'react-native';
import ScrollableTabView, {DefaultTabBar} from 'react-native-scrollable-tab-view';
import colors from '../assets/colors';

class TabView extends Component {
render() {
return (
<ScrollableTabView
initialPage={0}
renderTabBar={() => {
return (
<DefaultTabBar
backgroundColor={'white'}
activeTextColor={colors.section_title}
inactiveTextColor={colors.gray_icon}
textStyle={styles.tabBarText}
underlineStyle={styles.tabBarUnderline}
tabStyle={styles.tabBar}
/>
);
}}>
{this.props.children}
</ScrollableTabView>
);
}
}

const styles = StyleSheet.create({
tabBarText: {
fontWeight: '500',
textTransform: 'uppercase',
},
tabBarUnderline: {
height: 2,
backgroundColor: colors.primary_theme,
},
tabBar: {
paddingTop: 10,
},
});

export default TabView;

0 comments on commit 8928b86

Please sign in to comment.