TabBar.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import React from 'react'
  2. import {
  3. StyleSheet,
  4. Text,
  5. View,
  6. TouchableOpacity,
  7. Dimensions,
  8. PixelRatio,
  9. } from 'react-native'
  10. import Icon from '../../../components/Iconfont/Iconfont'
  11. import { NavigationActions } from '../../../utils'
  12. import { isIphoneX } from '../../common/theme/config'
  13. const { width, height } = Dimensions.get('window')
  14. class DetailTabBar extends React.Component {
  15. constructor(props) {
  16. super(props)
  17. }
  18. render() {
  19. return (
  20. <View
  21. style={{
  22. flexDirection: 'row',
  23. paddingLeft: 10,
  24. paddingTop: isIphoneX() ? HEADERSTYLE.paddingTop : 0,
  25. borderBottomColor: '#DDD',
  26. borderBottomWidth: 1 / PixelRatio.get(),
  27. }}
  28. >
  29. <TouchableOpacity
  30. style={{ alignSelf: 'flex-end' }}
  31. onPress={() => this.props.dispatch(NavigationActions.back())}
  32. >
  33. <Icon name="icon-icon-fanhui" size={26} color={'#666'} />
  34. </TouchableOpacity>
  35. <View style={[styles.tabs, this.props.style, { width: width * 0.6 }]}>
  36. {this.props.tabs.map((tab, i) => {
  37. return (
  38. <TouchableOpacity
  39. key={tab}
  40. onPress={() => this.props.goToPage(i)}
  41. style={styles.tab}
  42. >
  43. <View
  44. style={{
  45. height: 40,
  46. borderBottomColor:
  47. this.props.activeTab === i ? '#666' : 'transparent',
  48. borderBottomWidth: 2,
  49. paddingTop: 10,
  50. }}
  51. >
  52. <Text
  53. style={{
  54. fontSize: 14,
  55. lineHeight: 20,
  56. color: '#333',
  57. //color: this.props.activeTab === i ? "#333" : "rgb(204,204,204)"
  58. }}
  59. >
  60. {tab}
  61. </Text>
  62. </View>
  63. </TouchableOpacity>
  64. )
  65. })}
  66. </View>
  67. </View>
  68. )
  69. }
  70. }
  71. const styles = StyleSheet.create({
  72. tab: {
  73. flex: 1,
  74. alignItems: 'center',
  75. justifyContent: 'center',
  76. paddingBottom: 10,
  77. },
  78. tabs: {
  79. marginLeft: 40,
  80. height: 40,
  81. flexDirection: 'row',
  82. paddingTop: 10,
  83. },
  84. })
  85. export default DetailTabBar