No Description

FollowPageViewNavigationBar.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /**
  2. * Created by zack on 2018/5/2.
  3. */
  4. import {
  5. View,
  6. Text,
  7. StyleSheet,
  8. FlatList,
  9. Platform,
  10. TouchableOpacity,
  11. Image
  12. } from 'react-native'
  13. import React, {Component} from 'react'
  14. import {NavigationBarHeight, TabBarHeight, ScreenDimensions} from '../../../../utils/DimensionsTools'
  15. export default class FollowPageViewNavigationBar extends Component {
  16. constructor(props) {
  17. super(props)
  18. this.state = {
  19. selectedTagIndex: props.selectedTagIndex
  20. }
  21. }
  22. componentWillReceiveProps(props) {
  23. this.setState({
  24. selectedTagIndex: props.selectedTagIndex
  25. })
  26. }
  27. shouldComponentUpdate(nextProps) {
  28. if (nextProps.selectedTagIndex !== this.state.selectedTagIndex) {
  29. return true
  30. }
  31. return false
  32. }
  33. didSelectedTagIndex(index) {
  34. this.setState({selectedTagIndex: index})
  35. this.props.didSelectedTagIndex(index)
  36. }
  37. render() {
  38. return (
  39. <View style={styles.View}>
  40. <View style={styles.NavigationBarView}>
  41. <TouchableOpacity onPress={() => {
  42. this.props.didClickLeftButton()
  43. }} style={styles.LeftView}>
  44. <Image source={require("../../../../resources/images/TabBar/Community/Follow/left.png")}/>
  45. <Text style={styles.LeftText}>{this.state.leftTitle}</Text>
  46. </TouchableOpacity>
  47. <TouchableOpacity onPress={() => this.didSelectedTagIndex(0)} style={[styles.TagButtonView, {marginRight: 55,}]}>
  48. <Text style={[styles.TagButtonText, {color: this.state.selectedTagIndex === 0 ? '#fc4747' : '#000000'}]}>{"推荐"}</Text>
  49. </TouchableOpacity>
  50. <TouchableOpacity onPress={() => this.didSelectedTagIndex(1)} style={styles.TagButtonView}>
  51. <Text style={[styles.TagButtonText, {color: this.state.selectedTagIndex === 1 ? '#fc4747' : '#000000'}]}>{"名人"}</Text>
  52. </TouchableOpacity>
  53. </View>
  54. <View style={styles.BottomLineView} />
  55. </View>
  56. );
  57. }
  58. }
  59. const styles = StyleSheet.create({
  60. View: {
  61. position: 'absolute',
  62. left: 0,
  63. top: 0,
  64. height: NavigationBarHeight.height,
  65. width: ScreenDimensions.width,
  66. backgroundColor: "#ffffff",
  67. shadowColor: "#eeeeee",
  68. shadowOffset: {
  69. width: 0,
  70. height: -1
  71. },
  72. shadowRadius: 0,
  73. shadowOpacity: 1,
  74. flexDirection: 'row',
  75. alignItems: 'center',
  76. justifyContent: 'center',
  77. elevation: 5, //only for android
  78. },
  79. NavigationBarView: {
  80. marginTop: Platform.OS === 'ios' ? 20 : 0,
  81. width: ScreenDimensions.width,
  82. height: Platform.OS === 'ios' ? (NavigationBarHeight.height - 20) : NavigationBarHeight.height,
  83. flexDirection: 'row',
  84. justifyContent: 'center',
  85. alignItems: 'center',
  86. },
  87. LeftView: {
  88. left: 15,
  89. justifyContent: 'center',
  90. flexDirection: 'row',
  91. alignItems: 'center',
  92. position: 'absolute',
  93. },
  94. LeftText: {
  95. fontSize: 14,
  96. color: '#999999',
  97. marginLeft: 5,
  98. },
  99. TagButtonView: {
  100. justifyContent: 'center',
  101. alignItems: 'center',
  102. height: 44,
  103. },
  104. TagButtonText: {
  105. fontSize: 18,
  106. },
  107. BottomLineView: {
  108. width: ScreenDimensions.width,
  109. height: 0.5,
  110. backgroundColor: '#cacaca',
  111. position: 'absolute',
  112. left: 0,
  113. bottom: 0,
  114. }
  115. })