No Description

CAVideoViewController.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**
  2. * Created by Sean on 2018/5/9.
  3. */
  4. import {
  5. View,
  6. Text,
  7. StyleSheet,
  8. TouchableOpacity,
  9. ScrollView,
  10. SectionList
  11. } from 'react-native'
  12. import React, {Component} from 'react'
  13. import {NavigationBarHeight, TabBarHeight, ScreenDimensions} from '../../../utils/DimensionsTools'
  14. import CAVideoBannerView from './CAVideoBannerView';
  15. import CAVideoListHeaderView from './CAVideoListHeaderView';
  16. import CAVideoListRow from './CAVideoListRow';
  17. import CAVideoDetailView from './CAVideoDetailView';
  18. import HttpTools from '../../../network/HttpTools';
  19. const sections = [
  20. { key: "推荐视频", image: require('../../../resources/Play/Video/video.png'), data: [{ title: "阿童木" }, { title: "阿玛尼" }, { title: "爱多多" }] },
  21. { key: "脱口秀", image: require('../../../resources/Play/Video/speak.png'), data: [{ title: "表哥" }, { title: "贝贝" }, { title: "表弟" }, { title: "表姐" }, { title: "表叔" }] },
  22. { key: "外教课", image: require('../../../resources/Play/Video/book.png'), data: [{ title: "成吉思汗" }, { title: "超市快递" }] },
  23. { key: "音乐", image: require('../../../resources/Play/Video/music.png'), data: [{ title: "王磊" }, { title: "王者荣耀" }, { title: "往事不能回味" },{ title: "王小磊" }, { title: "王中磊" }, { title: "王大磊" }] },
  24. ];
  25. export default class CAVideoViewController extends Component {
  26. constructor(props) {
  27. super(props)
  28. }
  29. componentDidMount() {
  30. }
  31. hideTabBar() {
  32. this.props.navigator.toggleTabs({
  33. to:'hidden',
  34. animated: true
  35. })
  36. }
  37. showTabBar() {
  38. this.props.navigator.toggleTabs({
  39. to:'shown',
  40. animated: true
  41. })
  42. }
  43. _jumpToBannerVideoPage = () => {
  44. console.log(this.props.onPressBannerBack)
  45. if(this.props.onPressBannerBack) {
  46. this.props.onPressBannerBack()
  47. }
  48. }
  49. _renderItem = (info) => {
  50. let txt = ' ' + info.item.title;
  51. return(
  52. <CAVideoListRow title={txt}/>
  53. );
  54. }
  55. _sectionComp = (info) => {
  56. let txt = info.section.key;
  57. let img = info.section.image
  58. return(
  59. <CAVideoListHeaderView title={txt} image={img}/>
  60. );
  61. }
  62. _renderHeaderComponent = () => {
  63. return (
  64. <CAVideoBannerView onBannerPress={this._jumpToBannerVideoPage}/>
  65. );
  66. }
  67. render() {
  68. return(
  69. <SectionList
  70. style={styles.ScrollView}
  71. renderSectionHeader={this._sectionComp}
  72. renderItem={this._renderItem}
  73. sections={sections}
  74. keyExtractor = {(item,index) =>{
  75. return 'key' + item.key + index
  76. }}
  77. ListHeaderComponent={this._renderHeaderComponent}
  78. />
  79. );
  80. }
  81. }
  82. const styles = StyleSheet.create({
  83. View: {
  84. flex: 1,
  85. flexDirection: 'column',
  86. width: ScreenDimensions.width,
  87. backgroundColor: 'white'
  88. },
  89. ScrollView: {
  90. width: ScreenDimensions.width,
  91. height: ScreenDimensions.height - NavigationBarHeight.height - TabBarHeight.height,
  92. backgroundColor: '#ffffff',
  93. },
  94. })