No Description

PicAndTextNavigationBar.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /**
  2. * Created by zack on 2018/5/22.
  3. */
  4. import {
  5. View,
  6. Text,
  7. StyleSheet,
  8. FlatList,
  9. Platform,
  10. TouchableOpacity,
  11. Image,
  12. ImageBackground
  13. } from 'react-native'
  14. import React, {Component} from 'react'
  15. import {NavigationBarHeight, TabBarHeight, ScreenDimensions} from '../../../../utils/DimensionsTools'
  16. export default class FollowPageViewNavigationBar extends Component {
  17. constructor(props) {
  18. super(props)
  19. this.state = {
  20. userName: props.userName,
  21. userIcon: props.userIcon
  22. }
  23. }
  24. componentWillReceiveProps(props) {
  25. this.setState({
  26. userName: props.userName,
  27. userIcon: props.userIcon
  28. })
  29. }
  30. shouldComponentUpdate(nextProps) {
  31. if (nextProps.userName !== this.state.userName ||
  32. nextProps.userIcon !== this.state.userIcon
  33. ) {
  34. return true
  35. }
  36. return false
  37. }
  38. renderUserIcon(userIcon) {
  39. if (userIcon && userIcon.length) {
  40. return(
  41. <View>
  42. <ImageBackground imageStyle = {{borderRadius: 18,}} source={{uri: userIcon}} style={[styles.TitleHeaderImageView, {flexDirection: 'column-reverse', alignItems: 'flex-end'}]}>
  43. <Image source={require('../../../../resources/images/TabBar/PicAndText/follow.png')}/>
  44. </ImageBackground>
  45. </View>
  46. )
  47. }else {
  48. return <View />
  49. }
  50. }
  51. render() {
  52. return (
  53. <View style={styles.View}>
  54. <View style={styles.NavigationBarView}>
  55. <TouchableOpacity onPress={() => {
  56. this.props.didClickLeftButton()
  57. }} style={styles.LeftView}>
  58. <Image source={require("../../../../resources/images/TabBar/Community/Follow/left.png")}/>
  59. <Text style={styles.LeftText}>{this.state.leftTitle}</Text>
  60. </TouchableOpacity>
  61. <View style={styles.TitleHeaderBgView}>
  62. {this.renderUserIcon(this.state.userIcon)}
  63. <Text style={styles.TitleHeaderUserName}>{this.state.userName}</Text>
  64. </View>
  65. <TouchableOpacity style={styles.RightButton}>
  66. <Image source={require('../../../../resources/images/TabBar/PicAndText/more.png')}/>
  67. </TouchableOpacity>
  68. </View>
  69. <View style={styles.BottomLineView} />
  70. </View>
  71. );
  72. }
  73. }
  74. const styles = StyleSheet.create({
  75. View: {
  76. position: 'absolute',
  77. left: 0,
  78. top: 0,
  79. height: NavigationBarHeight.height,
  80. width: ScreenDimensions.width,
  81. backgroundColor: "#ffffff",
  82. shadowColor: "#eeeeee",
  83. shadowOffset: {
  84. width: 0,
  85. height: -1
  86. },
  87. shadowRadius: 0,
  88. shadowOpacity: 1,
  89. flexDirection: 'row',
  90. alignItems: 'center',
  91. justifyContent: 'space-between',
  92. elevation: 5, //only for android
  93. },
  94. NavigationBarView: {
  95. marginTop: Platform.OS === 'ios' ? 20 : 0,
  96. width: ScreenDimensions.width,
  97. height: Platform.OS === 'ios' ? (NavigationBarHeight.height - 20) : NavigationBarHeight.height,
  98. flexDirection: 'row',
  99. justifyContent: 'center',
  100. alignItems: 'center',
  101. },
  102. LeftView: {
  103. left: 15,
  104. justifyContent: 'center',
  105. flexDirection: 'row',
  106. alignItems: 'center',
  107. position: 'absolute',
  108. },
  109. LeftText: {
  110. fontSize: 14,
  111. color: '#999999',
  112. marginLeft: 5,
  113. },
  114. BottomLineView: {
  115. width: ScreenDimensions.width,
  116. height: 0.5,
  117. backgroundColor: '#cacaca',
  118. position: 'absolute',
  119. left: 0,
  120. bottom: 0,
  121. },
  122. TitleHeaderBgView: {
  123. flexDirection: 'row',
  124. alignItems: 'center',
  125. justifyContent: 'center'
  126. },
  127. TitleHeaderImageView: {
  128. width: 36,
  129. height: 36,
  130. borderRadius: 16,
  131. },
  132. TitleHeaderUserName: {
  133. fontSize: 15,
  134. color: '#000000',
  135. marginLeft: 12
  136. },
  137. RightButton: {
  138. height: 30,
  139. width: 44,
  140. right: 20,
  141. flexDirection: 'row-reverse',
  142. position: 'absolute',
  143. alignItems: 'center'
  144. }
  145. })