|
| 1 | +import Exponent from 'exponent'; |
| 2 | +import React, { Component } from 'react'; |
| 3 | +import { |
| 4 | + StyleSheet, |
| 5 | + Text, |
| 6 | + View, |
| 7 | + Image, |
| 8 | + Dimensions, |
| 9 | + StatusBar, |
| 10 | +} from 'react-native'; |
| 11 | +import * as Animatable from 'react-native-animatable'; |
| 12 | +import { NavigationBar } from '@exponent/ex-navigation'; |
| 13 | + |
| 14 | + |
| 15 | +// import HeaderImageScrollView, { TriggeringView } from 'react-native-image-header-scroll-view'; |
| 16 | +import HeaderImageScrollView, { TriggeringView } from '../ImageHeaderScrollView'; |
| 17 | +import tvShowContent from '../assets/tvShowContent'; |
| 18 | + |
| 19 | +const MIN_HEIGHT = NavigationBar.DEFAULT_HEIGHT; |
| 20 | +const MAX_HEIGHT = 250; |
| 21 | + |
| 22 | +const styles = StyleSheet.create({ |
| 23 | + image: { |
| 24 | + height: MAX_HEIGHT, |
| 25 | + width: Dimensions.get('window').width, |
| 26 | + alignSelf: 'stretch', |
| 27 | + resizeMode: 'cover', |
| 28 | + }, |
| 29 | + title: { |
| 30 | + fontSize: 20, |
| 31 | + }, |
| 32 | + name: { |
| 33 | + fontWeight: 'bold', |
| 34 | + }, |
| 35 | + section: { |
| 36 | + padding: 20, |
| 37 | + borderBottomWidth: 1, |
| 38 | + borderBottomColor: '#cccccc', |
| 39 | + backgroundColor: 'white', |
| 40 | + }, |
| 41 | + sectionTitle: { |
| 42 | + fontSize: 18, |
| 43 | + fontWeight: 'bold', |
| 44 | + }, |
| 45 | + sectionContent: { |
| 46 | + fontSize: 16, |
| 47 | + textAlign: 'justify', |
| 48 | + }, |
| 49 | + keywords: { |
| 50 | + flexDirection: 'row', |
| 51 | + justifyContent: 'flex-start', |
| 52 | + alignItems: 'flex-start', |
| 53 | + flexWrap: 'wrap', |
| 54 | + }, |
| 55 | + keywordContainer: { |
| 56 | + backgroundColor: '#999999', |
| 57 | + borderRadius: 10, |
| 58 | + margin: 10, |
| 59 | + padding: 10, |
| 60 | + }, |
| 61 | + keyword: { |
| 62 | + fontSize: 16, |
| 63 | + color: 'white', |
| 64 | + }, |
| 65 | + titleContainer: { |
| 66 | + flex: 1, |
| 67 | + alignSelf: 'stretch', |
| 68 | + justifyContent: 'center', |
| 69 | + alignItems: 'center', |
| 70 | + }, |
| 71 | + imageTitle: { |
| 72 | + color: 'white', |
| 73 | + backgroundColor: 'transparent', |
| 74 | + fontSize: 24, |
| 75 | + }, |
| 76 | + navTitleView: { |
| 77 | + height: MIN_HEIGHT, |
| 78 | + justifyContent: 'center', |
| 79 | + alignItems: 'center', |
| 80 | + paddingTop: 16, |
| 81 | + opacity: 0, |
| 82 | + }, |
| 83 | + navTitle: { |
| 84 | + color: 'white', |
| 85 | + fontSize: 18, |
| 86 | + backgroundColor: 'transparent', |
| 87 | + }, |
| 88 | +}); |
| 89 | + |
| 90 | +class TvShow extends Component { |
| 91 | + constructor() { |
| 92 | + super(); |
| 93 | + this.state = { showNavTitle: false }; |
| 94 | + } |
| 95 | + |
| 96 | + render() { |
| 97 | + return ( |
| 98 | + <View style={{ flex: 1, marginTop: -MIN_HEIGHT }}> |
| 99 | + <StatusBar barStyle="light-content" /> |
| 100 | + <HeaderImageScrollView |
| 101 | + maxHeight={MAX_HEIGHT} |
| 102 | + minHeight={MIN_HEIGHT} |
| 103 | + maxOverlayOpacity={0.6} |
| 104 | + minOverlayOpacity={0.3} |
| 105 | + fadeOutForeground |
| 106 | + renderHeader={() => ( |
| 107 | + <Image source={tvShowContent.image} style={styles.image} /> |
| 108 | + )} |
| 109 | + renderFixedForeground={() => ( |
| 110 | + <Animatable.View |
| 111 | + style={styles.navTitleView} |
| 112 | + ref={(navTitleView) => { this.navTitleView = navTitleView; }} |
| 113 | + > |
| 114 | + <Text style={styles.navTitle}>{tvShowContent.title}, ({tvShowContent.year})</Text> |
| 115 | + </Animatable.View> |
| 116 | + )} |
| 117 | + renderForeground={() => ( |
| 118 | + <View style={styles.titleContainer}> |
| 119 | + <Text style={styles.imageTitle}>{tvShowContent.title}</Text> |
| 120 | + </View> |
| 121 | + )} |
| 122 | + > |
| 123 | + <TriggeringView |
| 124 | + style={styles.section} |
| 125 | + onHide={() => this.navTitleView.fadeInUp(200)} |
| 126 | + onDisplay={() => this.navTitleView.fadeOut(100)} |
| 127 | + > |
| 128 | + <Text style={styles.title}> |
| 129 | + <Text style={styles.name}>{tvShowContent.title}</Text>, ({tvShowContent.year}) |
| 130 | + </Text> |
| 131 | + </TriggeringView> |
| 132 | + <View style={styles.section}> |
| 133 | + <Text style={styles.sectionTitle}>Overview</Text> |
| 134 | + <Text style={styles.sectionContent}>{tvShowContent.overview}</Text> |
| 135 | + </View> |
| 136 | + <View style={styles.section}> |
| 137 | + <Text style={styles.sectionTitle}>Keywords</Text> |
| 138 | + <View style={styles.keywords}> |
| 139 | + {tvShowContent.keywords.map(keyword => ( |
| 140 | + <View style={styles.keywordContainer} key={keyword}> |
| 141 | + <Text style={styles.keyword}>{keyword}</Text> |
| 142 | + </View> |
| 143 | + ))} |
| 144 | + </View> |
| 145 | + </View> |
| 146 | + </HeaderImageScrollView> |
| 147 | + </View> |
| 148 | + ); |
| 149 | + } |
| 150 | +} |
| 151 | + |
| 152 | +TvShow.route = { |
| 153 | + navigationBar: { |
| 154 | + tintColor: 'white', |
| 155 | + backgroundColor: 'transparent', |
| 156 | + borderBottomWidth: 0, |
| 157 | + statusBarHeight: 0, |
| 158 | + elevation: 0, |
| 159 | + }, |
| 160 | +}; |
| 161 | + |
| 162 | +export default TvShow; |
0 commit comments