import React from 'react';
import {
View,
ScrollView,
TouchableOpacity,
Text,
Image
} from 'react-native';
// Redux
import { connect } from 'react-redux';
import { initDocuments } from '../Store/Actions/documents';
// Treeview
import TreeView from 'react-native-animated-tree-view';
// Icon
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
// Assets
import arrowDown from '../../Resources/assets/img/arrow_down.png';
// Styles
import styles from '../../Resources/Styles/DirectoriesStyle';
function mapStateToProps(state) {
return {
documents: state.documents,
directories: state.directories,
locale: state.locale.locale,
mainColor: state.app.mainColor
};
}
class DirectoriesScreen extends React.Component {
state = {
documents: [],
};
render() {
const { folder } = this.props.route.params;
let documentList = this.state.documents.map(document => {
return (
this.openDocument(document)}>
{document.type === 'pdf' ? (
) : (
)}
{document.title}
);
});
return (
{
this.setState({
documents: this.props.documents.filter(
tmp => tmp.directory === folder.id,
)
});
}}
/>
{documentList}
);
}
openDocument(document) {
this.props.dispatch({ type: 'SET_CURRENT_OPENED_DOC', data: document });
if (document.type === 'pdf') {
this.props.navigation.navigate('PDFScreen', { uuid: document.uuid });
} else if (document.type === 'mp4') {
this.props.navigation.navigate('VideoScreen', { uuid: document.uuid });
} else {
console.log('Inconnu');
}
}
}
export default connect(mapStateToProps)(DirectoriesScreen);