save tmp clean + HomeBtns, Directories + PDF OK
This commit is contained in:
parent
4f415e5cd2
commit
5879b502ce
10 changed files with 57 additions and 36 deletions
|
|
@ -18,23 +18,18 @@ import SyncController from './App/Controllers/SyncController';
|
|||
// Views
|
||||
import InstallScreen from './App/Views/InstallScreen';
|
||||
import LoginScreen from './App/Views/LoginScreen';
|
||||
|
||||
import SyncScreen from './App/Views/SyncScreen';
|
||||
import HomeScreen from './App/Views/HomeScreen';
|
||||
import DirectoriesScreen from './App/Views/DirectoriesScreen';
|
||||
import PDFScreen from './App/Views/PDFScreen';
|
||||
import OnlyVideosScreen from './App/Views/OnlyVideosScreen';
|
||||
import ContactScreen from './App/Views/ContactScreen';
|
||||
import ContactDetailsScreen from './App/Views/ContactDetailsScreen';
|
||||
import SearchScreen from "./App/Views/SearchScreen";
|
||||
import MySpaceScreen from './App/Views/MySpaceScreen';
|
||||
// END V2
|
||||
|
||||
import SyncScreen from './App/Views/SyncScreen';
|
||||
import HomeScreen from './App/Views/HomeScreen';
|
||||
|
||||
|
||||
import DirectoriesScreen from './Views/Directories';
|
||||
import VideoScreen from './Views/Video';
|
||||
import PDFScreen from './Views/PDF';
|
||||
|
||||
|
||||
import SearchScreen from "./Views/Search";
|
||||
import MySpaceScreen from './Views/MySpace';
|
||||
|
||||
// V2
|
||||
//SplashScreen.preventAutoHideAsync(); //Keep
|
||||
|
|
@ -252,7 +247,7 @@ class App extends React.Component {
|
|||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
const folder = store.getState().directories.filter(tmp => tmp.id === 1);
|
||||
const folder = store.getState().directories.treeview.filter(tmp => tmp.id === 1);
|
||||
navigation.navigation.navigate('DirectoriesScreen', { folder: folder })
|
||||
}}
|
||||
style={{ marginRight: 15 }}>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ const initialState = {
|
|||
syncVersion: 0,
|
||||
currentOpenedDoc: {},
|
||||
ShowIsActive: 0,
|
||||
HomeBtns: {},
|
||||
};
|
||||
|
||||
const reducer = (state = initialState, action) => {
|
||||
|
|
@ -23,6 +24,14 @@ const reducer = (state = initialState, action) => {
|
|||
isSetup: saved === undefined ? false : saved.value === "true" ? true : false,
|
||||
ShowIsActive: ShowIsActive === undefined ? false : ShowIsActive.value
|
||||
};
|
||||
case 'INIT_HOME_BTNS': {
|
||||
let HomeFolders = Setting.get('HomeFolders');
|
||||
let Btns = JSON.parse(HomeFolders.value);
|
||||
return {
|
||||
...state,
|
||||
HomeBtns: Btns
|
||||
}
|
||||
}
|
||||
case 'SET_ISSETUP':
|
||||
Setting.upsert({ key: 'isSetup', value: "true" });
|
||||
saved = Setting.get('isSetup');
|
||||
|
|
|
|||
|
|
@ -7,15 +7,21 @@ const initialState = [];
|
|||
const reducer = (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case INIT_DIRECTORIES: {
|
||||
return [
|
||||
return {
|
||||
...state,
|
||||
Directory.getAll(
|
||||
global: Directory.getAll(
|
||||
action.user.role,
|
||||
action.user.authorizedFolders,
|
||||
false,
|
||||
action.lang
|
||||
),
|
||||
treeview: Directory.getAll(
|
||||
action.user.role,
|
||||
action.user.authorizedFolders,
|
||||
true,
|
||||
action.lang
|
||||
)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
default: {
|
||||
|
|
|
|||
|
|
@ -11,10 +11,7 @@ const reducer = (state = initialState, action) => {
|
|||
if (docs.length === 0) {
|
||||
return state
|
||||
}
|
||||
return [
|
||||
...state,
|
||||
docs.filter(item => item.lang === action.lang)
|
||||
];
|
||||
return docs.filter(item => item.lang === action.lang);
|
||||
}
|
||||
|
||||
default: {
|
||||
|
|
|
|||
|
|
@ -213,7 +213,6 @@ class ContactScreen extends React.Component {
|
|||
}
|
||||
}
|
||||
this.setState({ contacts: this.state.contacts.sort(Helpers.compareValues(field, sort)), sortType: sort, sortField: field });
|
||||
//console.log(this.state.contacts[0].name)
|
||||
}
|
||||
|
||||
HeaderItem() {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import {
|
|||
} 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
|
||||
|
|
@ -19,7 +20,9 @@ import styles from '../../Resources/Styles/DirectoriesStyle';
|
|||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
documents: state.app.documents,
|
||||
documents: state.documents,
|
||||
directories: state.directories,
|
||||
locale: state.locale.locale,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -56,6 +59,7 @@ class DirectoriesScreen extends React.Component {
|
|||
rightImage={{ uri: Image.resolveAssetSource(arrowDown).uri }}
|
||||
containerStyle={styles.treeviewContainer}
|
||||
onClick={folder => {
|
||||
console.log(folder, this.props.documents)
|
||||
this.setState({
|
||||
documents: this.props.documents.filter(
|
||||
tmp => tmp.directory === folder.id,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import * as FileSystem from 'expo-file-system';
|
|||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
btns: state.app.HomeBtns,
|
||||
directories: state.directories,
|
||||
locale: state.locale.locale,
|
||||
currentUser: state.app.currentUser
|
||||
|
|
@ -25,6 +26,7 @@ function mapStateToProps(state) {
|
|||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
init: () => dispatch({ type: 'INIT' }),
|
||||
initBtns: () => dispatch({ type: 'INIT_HOME_BTNS' }),
|
||||
initDirectories: (lang, user) => dispatch(initDirectories(lang, user)),
|
||||
initDocuments: (lang, directories) => dispatch(initDocuments(lang, directories)),
|
||||
initContact: currentUser => dispatch(initContact(currentUser)),
|
||||
|
|
@ -35,8 +37,8 @@ class HomeScreen extends React.Component {
|
|||
|
||||
componentDidMount() {
|
||||
this.props.init();
|
||||
this.props.initBtns();
|
||||
this.props.initDirectories(this.props.locale.value, this.props.currentUser);
|
||||
this.props.initDocuments(this.props.locale.value, this.props.directories);
|
||||
this.props.initContact(this.props.currentUser);
|
||||
}
|
||||
|
||||
|
|
@ -45,10 +47,7 @@ class HomeScreen extends React.Component {
|
|||
return (
|
||||
<ImageBackground source={{ uri: FileSystem.documentDirectory + 'BackgroundImage.png' }} style={commonStyles.background}>
|
||||
<View style={styles.container}>
|
||||
<TouchableOpacity onPress={() => this.openFolder(2)} style={styles.button}>
|
||||
<Image source={{ uri: FileSystem.documentDirectory + 'HomeButtonImage.png' }} style={styles.btnImg} />
|
||||
<Text style={styles.btnTxt}>{i18n.t('global.videos')}</Text>
|
||||
</TouchableOpacity>
|
||||
{this.renderBtns()}
|
||||
<TouchableOpacity onPress={() => this.props.navigation.navigate('OnlyVideosScreen')} style={styles.button}>
|
||||
<Image source={{ uri: FileSystem.documentDirectory + 'HomeButtonImage.png' }} style={styles.btnImg} />
|
||||
<Text style={styles.btnTxt}>{i18n.t('global.videos')}</Text>
|
||||
|
|
@ -62,8 +61,25 @@ class HomeScreen extends React.Component {
|
|||
);
|
||||
}
|
||||
|
||||
renderBtns() {
|
||||
let locale = this.props.locale;
|
||||
let objBtns = this.props.btns;
|
||||
let array = Object.keys(objBtns).map(function (key) { return objBtns[key]; });
|
||||
return array.map((item, index) => {
|
||||
let names = JSON.parse(item.name);
|
||||
let name = (locale in names) ? names[locale] : names.fr;
|
||||
return (
|
||||
<TouchableOpacity onPress={() => this.openFolder(item.id)} style={styles.button}>
|
||||
<Image source={{ uri: FileSystem.documentDirectory + 'HomeButtonImage.png' }} style={styles.btnImg} />
|
||||
<Text style={styles.btnTxt}>{name}</Text>
|
||||
</TouchableOpacity>
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
openFolder(id) {
|
||||
const folder = this.props.directories.filter(tmp => tmp.id === id);
|
||||
const folder = this.props.directories.treeview.filter(tmp => tmp.id === id);
|
||||
this.props.initDocuments(this.props.locale, this.props.directories.global);
|
||||
this.props.navigation.navigate('DirectoriesScreen', { folder: folder });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,16 +19,16 @@ class PDFScreen extends React.Component {
|
|||
<Pdf
|
||||
source={source}
|
||||
onLoadComplete={(numberOfPages, filePath) => {
|
||||
console.log(`number of pages: ${numberOfPages}`);
|
||||
//console.log(`number of pages: ${numberOfPages}`);
|
||||
}}
|
||||
onPageChanged={(page, numberOfPages) => {
|
||||
console.log(`current page: ${page}`);
|
||||
//console.log(`current page: ${page}`);
|
||||
}}
|
||||
onError={error => {
|
||||
console.log(error);
|
||||
}}
|
||||
onPressLink={uri => {
|
||||
console.log(`Link presse: ${uri}`);
|
||||
//console.log(`Link presse: ${uri}`);
|
||||
}}
|
||||
style={styles.pdf}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import styles from '../../Resources/Styles/SearchStyle';
|
|||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
documents: state.app.documents,
|
||||
documents: state.documents,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { View, Button, Alert, Text } from 'react-native';
|
|||
// Redux
|
||||
import { connect } from 'react-redux';
|
||||
import { initDirectories } from '../Store/Actions/directories';
|
||||
import { initDocuments } from '../Store/Actions/documents';
|
||||
import { initContact } from '../Store/Actions/contacts';
|
||||
// Style
|
||||
import styles from '../../Resources/Styles/SyncStyle';
|
||||
|
|
@ -20,10 +19,8 @@ import * as FileSystem from 'expo-file-system';
|
|||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
documents: state.documents,
|
||||
syncVersion: state.app.syncVersion,
|
||||
currentUser: state.app.currentUser,
|
||||
directories: state.directories,
|
||||
locale: state.locale.locale,
|
||||
};
|
||||
}
|
||||
|
|
@ -32,7 +29,6 @@ const mapDispatchToProps = dispatch => {
|
|||
return {
|
||||
init: () => dispatch({ type: 'INIT' }),
|
||||
initDirectories: (lang, user) => dispatch(initDirectories(lang, user)),
|
||||
initDocuments: (lang, directories) => dispatch(initDocuments(lang, directories)),
|
||||
initContact: currentUser => dispatch(initContact(currentUser)),
|
||||
updateVersion: version => dispatch({
|
||||
type: 'UPDATE_VERSION',
|
||||
|
|
@ -298,7 +294,6 @@ class SyncScreen extends React.Component {
|
|||
finishSync(version) {
|
||||
this.props.init();
|
||||
this.props.initDirectories(this.props.locale.value, this.props.currentUser);
|
||||
this.props.initDocuments(this.props.locale.value, this.props.directories);
|
||||
this.props.initContact(this.props.currentUser);
|
||||
|
||||
SyncController.updateVersion(version);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue