Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. const HEADER_EXPANDED_VIEW = 200
  2. const HEADER_COLLAPSED_VIEW = 80
  3.  
  4. export default class HomeActivity extends Component {
  5. constructor(props) {
  6. super(props)
  7. this.state = {
  8. scrollY: new Animated.Value(0)
  9. }
  10. }
  11.  
  12. static navigationOptions = {
  13. title: "HomeActivity",
  14. header: null
  15. }
  16.  
  17. render() {
  18. const headerHeight = this.state.scrollY.interpolate({
  19. inputRange: [0, HEADER_EXPANDED_VIEW - HEADER_COLLAPSED_VIEW],
  20. outputRange: [HEADER_EXPANDED_VIEW, HEADER_COLLAPSED_VIEW],
  21. extrapolate: "clamp"
  22. })
  23.  
  24. // console.log(headerHeight)
  25.  
  26. return (
  27. <View style={styles.container}>
  28. <ScrollView
  29. contentContainerStyle={{
  30. padding: 16,
  31. paddingTop: HEADER_EXPANDED_VIEW,
  32. color: "#FFFFFF"
  33. }}
  34. onScroll={Animated.event([
  35. {
  36. nativeEvent: {
  37. contentOffset: {
  38. y: this.state.scrollY
  39. }
  40. }
  41. }
  42. ])}
  43. >
  44. <Text style={styles.title}>This is Title</Text>
  45. <Text style={styles.content}>
  46. .....
  47. </Text>
  48. </ScrollView>
  49. <CollapsingHeader headerHeight={headerHeight} />
  50. </View>
  51. )
  52. }
  53. }
  54.  
  55. const styles = StyleSheet.create({
  56. container: {
  57. flex: 1
  58. },
  59. scrollContainer: {
  60. padding: 16
  61. },
  62. title: {
  63. fontSize: 24,
  64. marginVertical: 16
  65. }
  66. })
  67.  
  68. export default class CollapsingHeader extends Component {
  69. render() {
  70. return (
  71. <Animated.View
  72. style={{
  73. height: this.props.headerHeight,
  74. width: Dimensions.get("screen").width,
  75. position: "absolute",
  76. top: 0,
  77. left: 0,
  78. borderWidth: 2,
  79. borderColor: "#FF0000",
  80. backgroundColor: "#212121"
  81. }}
  82. >
  83. <View
  84. style={{
  85. borderWidth: 2,
  86. borderColor: "#00FF00"
  87. }}
  88. >
  89. <MenuButton />
  90. </View>
  91.  
  92. <View
  93. style={{
  94. flexDirection: "row",
  95. borderWidth: 2,
  96. borderColor: "#0000FF"
  97. }}
  98. >
  99. <View
  100. style={{
  101. flexGrow: 1
  102. }}
  103. >
  104. <Text
  105. style={{
  106. fontFamily: "NunitoSans-Bold",
  107. fontSize: 40,
  108. color: "#FFFFFF"
  109. }}
  110. >
  111. Home
  112. </Text>
  113. </View>
  114.  
  115. <SortButton />
  116.  
  117. <SearchButton />
  118. </View>
  119. </Animated.View>
  120. )
  121. }
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement