2022-09-30 17:40:03 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
import { View, ImageBackground, TouchableOpacity, Text, Image } from 'react-native';
|
|
|
|
|
// Common Styles
|
|
|
|
|
import commonStyles from '../../Resources/CommonStyles';
|
2022-10-06 17:20:07 +02:00
|
|
|
// Redux
|
|
|
|
|
import { connect } from 'react-redux';
|
2022-12-28 16:32:30 +01:00
|
|
|
import { initDocuments } from '../Store/Actions/documents';
|
2022-09-30 17:40:03 +02:00
|
|
|
// Style
|
|
|
|
|
import styles from '../../Resources/Styles/HomeStyle';
|
|
|
|
|
// Translations
|
|
|
|
|
import i18n from "../../I18n";
|
|
|
|
|
// FileSytem
|
|
|
|
|
import * as FileSystem from 'expo-file-system';
|
2022-10-06 17:20:07 +02:00
|
|
|
|
|
|
|
|
function mapStateToProps(state) {
|
|
|
|
|
return {
|
|
|
|
|
directories: state.app.directories,
|
2022-12-28 13:27:14 +01:00
|
|
|
locale: state.locale.locale,
|
2022-10-06 17:20:07 +02:00
|
|
|
};
|
|
|
|
|
}
|
2022-09-30 17:40:03 +02:00
|
|
|
|
2022-12-28 16:32:30 +01:00
|
|
|
const mapDispatchToProps = dispatch => {
|
|
|
|
|
return {
|
|
|
|
|
init: (locale, directories) => {
|
|
|
|
|
dispatch({ type: 'INIT' })
|
|
|
|
|
dispatch(initDocuments(locale, directories))
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2022-09-30 17:40:03 +02:00
|
|
|
class HomeScreen extends React.Component {
|
2022-10-04 17:48:38 +02:00
|
|
|
|
2022-10-06 17:20:07 +02:00
|
|
|
componentDidMount() {
|
2022-12-28 16:32:30 +01:00
|
|
|
this.props.init(this.props.locale.value, this.props.directories);
|
2022-10-06 17:20:07 +02:00
|
|
|
}
|
|
|
|
|
|
2022-09-30 17:40:03 +02:00
|
|
|
render() {
|
2022-10-06 17:20:07 +02:00
|
|
|
i18n.locale = this.props.locale;
|
2022-09-30 17:40:03 +02:00
|
|
|
return (
|
|
|
|
|
<ImageBackground source={{ uri: FileSystem.documentDirectory + 'BackgroundImage.png' }} style={commonStyles.background}>
|
|
|
|
|
<View style={styles.container}>
|
2022-10-06 17:20:07 +02:00
|
|
|
<TouchableOpacity onPress={() => this.openFolder(2)} style={styles.button}>
|
2022-09-30 17:40:03 +02:00
|
|
|
<Image source={{ uri: FileSystem.documentDirectory + 'HomeButtonImage.png' }} style={styles.btnImg} />
|
2022-10-06 16:25:15 +02:00
|
|
|
<Text style={styles.btnTxt}>{i18n.t('global.videos')}</Text>
|
|
|
|
|
</TouchableOpacity>
|
2022-10-07 16:41:43 +02:00
|
|
|
<TouchableOpacity onPress={() => this.props.navigation.navigate('OnlyVideosScreen')} style={styles.button}>
|
2022-10-06 16:25:15 +02:00
|
|
|
<Image source={{ uri: FileSystem.documentDirectory + 'HomeButtonImage.png' }} style={styles.btnImg} />
|
2022-09-30 17:40:03 +02:00
|
|
|
<Text style={styles.btnTxt}>{i18n.t('global.videos')}</Text>
|
|
|
|
|
</TouchableOpacity>
|
2022-10-07 16:41:43 +02:00
|
|
|
<TouchableOpacity onPress={() => this.props.navigation.navigate('ContactScreen')} style={styles.button}>
|
2022-09-30 17:40:03 +02:00
|
|
|
<Image source={{ uri: FileSystem.documentDirectory + 'HomeButtonImage.png' }} style={styles.btnImg} />
|
|
|
|
|
<Text style={styles.btnTxt}>{i18n.t('global.contacts')}</Text>
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
</View>
|
|
|
|
|
</ImageBackground>
|
|
|
|
|
);
|
|
|
|
|
}
|
2022-10-04 17:48:38 +02:00
|
|
|
|
|
|
|
|
openFolder(id) {
|
2022-10-06 17:20:07 +02:00
|
|
|
const folder = this.props.directories.filter(tmp => tmp.id === id);
|
|
|
|
|
this.props.navigation.navigate('DirectoriesScreen', { folder: folder });
|
2022-10-04 17:48:38 +02:00
|
|
|
}
|
2022-09-30 17:40:03 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-28 16:32:30 +01:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(HomeScreen);
|