2022-09-28 18:08:39 +02:00
|
|
|
/**
|
|
|
|
|
* Sample React Native App
|
|
|
|
|
* https://github.com/facebook/react-native
|
|
|
|
|
*
|
|
|
|
|
* @format
|
|
|
|
|
* @flow strict-local
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import React from 'react';
|
2022-10-05 18:03:52 +02:00
|
|
|
import { View, Image, TextInput, TouchableOpacity } from 'react-native';
|
2022-10-04 19:02:39 +02:00
|
|
|
// Redux
|
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
|
// Store
|
|
|
|
|
import { store } from './App/Store/ConfigureStore';
|
|
|
|
|
// Navigation
|
|
|
|
|
import { NavigationContainer } from '@react-navigation/native';
|
|
|
|
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
|
|
|
import CustomNavigation from './Navigation';
|
2022-10-05 18:03:52 +02:00
|
|
|
// Icons
|
|
|
|
|
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
|
2022-10-04 19:02:39 +02:00
|
|
|
// Translations
|
|
|
|
|
import i18n from "./I18n";
|
|
|
|
|
// Navigations style
|
|
|
|
|
import styles from './Resources/Styles/NavigationStyle';
|
|
|
|
|
// Database
|
|
|
|
|
import { Setting } from "./Database";
|
2022-09-28 18:08:39 +02:00
|
|
|
// Views
|
|
|
|
|
import InstallScreen from './App/Views/InstallScreen';
|
2022-09-30 17:40:03 +02:00
|
|
|
import HomeScreen from './App/Views/HomeScreen';
|
2022-10-05 18:03:52 +02:00
|
|
|
import LoginScreen from './App/Views/LoginScreen';
|
|
|
|
|
import SyncScreen from './App/Views/SyncScreen';
|
2022-10-04 19:02:39 +02:00
|
|
|
// Lang Flags
|
|
|
|
|
import flagFR from './Resources/assets/img/flags/fr.png';
|
|
|
|
|
import flagEN from './Resources/assets/img/flags/en.png';
|
|
|
|
|
import flagDE from './Resources/assets/img/flags/de.png';
|
|
|
|
|
import flagES from './Resources/assets/img/flags/es.png';
|
|
|
|
|
|
|
|
|
|
const Stack = createNativeStackNavigator();
|
|
|
|
|
|
|
|
|
|
const App = () => {
|
|
|
|
|
state = {
|
|
|
|
|
logged: false,
|
|
|
|
|
searchTxt: '',
|
|
|
|
|
sendEmail: '',
|
|
|
|
|
ShowIsActive: '0'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const savedLocale = Setting.get('locale');
|
|
|
|
|
let locale;
|
|
|
|
|
if (savedLocale !== undefined) {
|
|
|
|
|
locale = savedLocale.value;
|
|
|
|
|
} else {
|
2022-10-05 18:03:52 +02:00
|
|
|
locale = store.getState().app.locale;
|
2022-10-04 19:02:39 +02:00
|
|
|
}
|
2022-09-28 18:08:39 +02:00
|
|
|
|
2022-10-04 19:02:39 +02:00
|
|
|
let flag;
|
|
|
|
|
switch (locale) {
|
|
|
|
|
case "fr":
|
|
|
|
|
flag = { uri: Image.resolveAssetSource(flagFR).uri }
|
|
|
|
|
break;
|
|
|
|
|
case "en":
|
|
|
|
|
flag = { uri: Image.resolveAssetSource(flagEN).uri }
|
|
|
|
|
break;
|
|
|
|
|
case "de":
|
|
|
|
|
flag = { uri: Image.resolveAssetSource(flagDE).uri }
|
|
|
|
|
break;
|
|
|
|
|
case "es":
|
|
|
|
|
flag = { uri: Image.resolveAssetSource(flagES).uri }
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-09-28 18:08:39 +02:00
|
|
|
|
|
|
|
|
return (
|
2022-10-04 19:02:39 +02:00
|
|
|
<Provider store={store}>
|
|
|
|
|
<NavigationContainer>
|
|
|
|
|
<Stack.Navigator>
|
2022-10-05 18:03:52 +02:00
|
|
|
<Stack.Screen
|
|
|
|
|
name="SyncScreen"
|
|
|
|
|
component={SyncScreen}
|
|
|
|
|
options={{ headerTitle: () => CustomNavigation.LogoTitle(i18n.t('global.synchronization')) }}
|
|
|
|
|
/>
|
|
|
|
|
<Stack.Screen
|
|
|
|
|
name="LoginScreen"
|
|
|
|
|
component={LoginScreen}
|
|
|
|
|
options={(navigation, route) => ({
|
|
|
|
|
headerTitle: () => CustomNavigation.LogoTitle(i18n.t('global.login')),
|
|
|
|
|
headerRight: () => (
|
|
|
|
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
onPress={() => {
|
|
|
|
|
store.dispatch({ type: 'UPDATE_LOCALE' });
|
|
|
|
|
this.setState({ state: this.state }); // to force re-rendering
|
|
|
|
|
}}
|
|
|
|
|
style={{ marginRight: 15 }}>
|
|
|
|
|
<Image source={flag} style={{ width: 25, height: 25 }} />
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
</View>
|
|
|
|
|
),
|
|
|
|
|
})}
|
|
|
|
|
/>
|
2022-10-04 19:02:39 +02:00
|
|
|
<Stack.Screen
|
|
|
|
|
name="HomeScreen"
|
|
|
|
|
component={HomeScreen}
|
|
|
|
|
options={(navigation, route) => ({
|
|
|
|
|
headerTitle: () => CustomNavigation.LogoTitle(i18n.t('global.home')),
|
|
|
|
|
headerRight: () => (
|
|
|
|
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
|
|
|
<View style={{ flexDirection: 'row', marginRight: 50 }}>
|
|
|
|
|
<TextInput style={styles.searchInput} placeholder={i18n.t('global.search')} value={this.state.searchTxt} onChangeText={(text) => this.setState({ searchTxt: text })} />
|
|
|
|
|
<TouchableOpacity style={styles.btnSearch} onPress={() => {
|
|
|
|
|
if (this.state.searchTxt.length > 0) {
|
|
|
|
|
navigation.navigation.navigate('SearchScreen', {
|
|
|
|
|
needle: this.state.searchTxt,
|
|
|
|
|
onlyVideos: false,
|
|
|
|
|
});
|
|
|
|
|
this.setState({ searchTxt: '' });
|
|
|
|
|
}
|
|
|
|
|
}}>
|
2022-10-05 18:03:52 +02:00
|
|
|
<FontAwesome5 name={'search'} size={20} color={'white'} />
|
2022-10-04 19:02:39 +02:00
|
|
|
</TouchableOpacity>
|
|
|
|
|
</View>
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
onPress={() => {
|
|
|
|
|
store.dispatch({ type: 'UPDATE_LOCALE' });
|
|
|
|
|
}}
|
|
|
|
|
style={{ marginRight: 15 }}>
|
|
|
|
|
<Image source={flag} style={{ width: 25, height: 25 }} />
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
{this.state.ShowIsActive === '1' && (
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
onPress={() => navigation.navigation.navigate('MySpaceScreen')}
|
|
|
|
|
style={{ marginRight: 15 }}>
|
2022-10-05 18:03:52 +02:00
|
|
|
<FontAwesome5 name="user-circle" size={25} />
|
2022-10-04 19:02:39 +02:00
|
|
|
</TouchableOpacity>
|
|
|
|
|
)}
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
onPress={() =>
|
|
|
|
|
navigation.navigation.navigate('SyncScreen', {
|
|
|
|
|
isInstalled: true,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
style={{ marginRight: 15 }}>
|
2022-10-05 18:03:52 +02:00
|
|
|
<FontAwesome5 name="sync-alt" size={20} />
|
2022-10-04 19:02:39 +02:00
|
|
|
</TouchableOpacity>
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
onPress={() => {
|
|
|
|
|
store.dispatch({ type: 'SET_LOGGED', data: false });
|
|
|
|
|
}}
|
|
|
|
|
style={{ marginRight: 15 }}>
|
2022-10-05 18:03:52 +02:00
|
|
|
<FontAwesome5 name="sign-out-alt" size={20} />
|
2022-10-04 19:02:39 +02:00
|
|
|
</TouchableOpacity>
|
|
|
|
|
</View>
|
|
|
|
|
)
|
|
|
|
|
})}
|
|
|
|
|
/>
|
|
|
|
|
</Stack.Navigator>
|
|
|
|
|
</NavigationContainer>
|
|
|
|
|
</Provider>
|
2022-09-28 18:08:39 +02:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default App;
|