No Description

VideoDetailsViewContorller.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /**
  2. * Created by zack on 2018/4/19.
  3. */
  4. import {
  5. View,
  6. Text,
  7. Image,
  8. StyleSheet,
  9. TouchableHighlight,
  10. ImageBackground,
  11. } from 'react-native'
  12. import React, { Component } from 'react'
  13. import ScreenDimensions from '../../../utils/ScreenDimensions'
  14. import ScreenDimensionsClientHeight from '../../../utils/ScreenDimensions'
  15. import NavigationBarHeight from '../../../utils/NavigationBarHeight'
  16. import TabBarHeight from '../../../utils/TabBarHeight'
  17. import RefreshInfiniteListView from '../../../utils/RefreshInfiniteListView'
  18. import VideoDetailsCellViewContorller from "./VideoDetailsCellViewContorller"
  19. //ScreenDimensions.clientHeight
  20. export default class VideoDetailsViewContorller extends Component {
  21. constructor(props) {
  22. super(props)
  23. this.state = {
  24. rate: 1,
  25. showMp: true,
  26. selectedPages: 0
  27. }
  28. }
  29. componentWillMount(){
  30. // StatusBar.setHidden(true);
  31. }
  32. componentWillUnmount(){
  33. // StatusBar.setHidden(false);
  34. this.showTabBar();
  35. this.props.navigator.setStyle({
  36. statusBarHidden: false,
  37. })
  38. }
  39. hideTabBar() {
  40. this.props.navigator.toggleTabs({
  41. to:'hidden',
  42. animated: true
  43. })
  44. }
  45. showTabBar() {
  46. this.props.navigator.toggleTabs({
  47. to:'shown',
  48. animated: true
  49. })
  50. }
  51. componentDidMount() {
  52. this.props.navigator.setStyle({
  53. statusBarHidden: true,
  54. })
  55. this.hideTabBar();
  56. let data = []
  57. for (var i = 1; i < 5; i++) {
  58. data.push({ key: i - 1, index: i - 1 });
  59. }
  60. this.list.setData(data)
  61. }
  62. render() {
  63. return (
  64. <View
  65. style={styles.View}>
  66. <RefreshInfiniteListView
  67. style={styles.View}
  68. numColumns={1}
  69. pagingEnabled={true}
  70. horizontal={true}
  71. showsHorizontalScrollIndicator={true}
  72. ref={this.listRef.bind(this)}
  73. onScroll={this._onScroll.bind(this)}
  74. renderItem={this.renderRow.bind(this)}
  75. onRefresh={this.onRefresh.bind(this)}
  76. onEndReached={this.onInfinite.bind(this)}>
  77. </RefreshInfiniteListView>
  78. <View style={styles.topStyle}>
  79. <TouchableHighlight
  80. underlayColor={"rgba(255,255,255,0)"}
  81. onPress={() => {
  82. this.props.navigator.pop({
  83. animated: true,
  84. animationType: 'slide-horizontal',
  85. });
  86. }}>
  87. <View style={styles.cellLeftStyle}>
  88. <Image source={require('../../../resources/images/TabBar/Community/SmallVideo/VideoDetails/left.png')} style={styles.btn_backStyle} />
  89. </View>
  90. </TouchableHighlight>
  91. <TouchableHighlight
  92. underlayColor={"rgba(255,255,255,0)"}
  93. onPress={this.onPressMore.bind(this)}>
  94. <View style={styles.cellRightStyle}>
  95. <Image source={require('../../../resources/images/TabBar/Community/SmallVideo/VideoDetails/more.png')} style={styles.cellRightStyle} />
  96. </View>
  97. </TouchableHighlight>
  98. </View>
  99. </View>
  100. );
  101. }
  102. onPress() {
  103. //返回
  104. console.log("返回")
  105. this.props.navigator.pop({
  106. animated: true,
  107. animationType: 'slide-horizontal',
  108. });
  109. }
  110. listRef(node) {
  111. this.list = node;
  112. }
  113. onRefresh() {
  114. //下拉刷新
  115. this.list.setRefreshing(true);
  116. this.requestData(false)
  117. }
  118. onInfinite() {
  119. //上拉加载
  120. this.requestData(true)
  121. }
  122. requestData(isLoadMore) {
  123. this.list.setRefreshing(false);
  124. if (isLoadMore) {
  125. console.log("上啦中=======")
  126. } else {
  127. console.log("下啦中=======")
  128. }
  129. }
  130. renderRow({ item, index }) {
  131. return (
  132. <VideoDetailsCellViewContorller selectedPages={index === this.state.selectedPages} style={styles.View} />
  133. )
  134. }
  135. _onScroll(e) {
  136. if (e % ScreenDimensions.width === 0) {
  137. this.setState({
  138. selectedPages: e / ScreenDimensions.width
  139. })
  140. }
  141. }
  142. onPressMore(){
  143. }
  144. }
  145. const styles = StyleSheet.create({
  146. View: {
  147. width: ScreenDimensions.width,
  148. height: ScreenDimensions.height,
  149. },
  150. btn_backStyle: {
  151. width: 25 / 2,
  152. height: 49 / 2,
  153. marginLeft: 21,
  154. marginTop: 22
  155. },
  156. topStyle: {
  157. position: 'absolute',
  158. top: 0,
  159. left: 0,
  160. right: 0,
  161. height: 88,
  162. backgroundColor: 'rgba(255,255,255,.1)',
  163. justifyContent: "space-between",
  164. flexDirection: "row",
  165. },
  166. cellLeftStyle: {
  167. },
  168. cellRightStyle: {
  169. width:47/2,
  170. height:4,
  171. marginRight:21,
  172. marginTop:15,
  173. }
  174. })