Videos.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import React, { Component } from 'react';
  2. import { Text, ListView, View } from 'react-native';
  3. import { Card, CardSection, Button } from '../../components/common';
  4. import { Actions } from 'react-native-router-flux';
  5. import Header from './Header';
  6. //import VideoPlayer from 'react-native-video-controls';
  7. class Videos extends Component {
  8. componentWillMount() {
  9. this.createDataSource(this.props);
  10. }
  11. componentWillReceiveProps(nextProps) {
  12. this.createDataSource(nextProps);
  13. }
  14. createDataSource({ videos }) {
  15. const ds = new ListView.DataSource({
  16. rowHasChanged: (r1, r2) => r1 !== r2
  17. });
  18. console.log(videos);
  19. this.dataSource = ds.cloneWithRows(videos);
  20. }
  21. renderHeader() {
  22. return <Header titulo={this.props.titulo} profesor={this.props.profesor} fecha={this.props.fecha} />;
  23. }
  24. playVideo(id) {
  25. Actions.ViewVideo({ id:id });
  26. }
  27. renderVideo({ video, titulo }) {
  28. return ( <Button onPress={this.playVideo.bind(this, video) }>{titulo}</Button> );
  29. }
  30. render() {
  31. return (
  32. <View>
  33. <ListView
  34. dataSource={this.dataSource}
  35. renderRow={this.renderVideo.bind(this)}
  36. />
  37. </View>
  38. );
  39. }
  40. }
  41. const styles = {
  42. texto: {
  43. fontSize: 12,
  44. }
  45. }
  46. export default Videos;