Intl moved

This commit is contained in:
Mustafa Buyukcelebi 2019-07-18 11:10:34 +03:00
parent a77c4f4e65
commit 0fcbdcdbad
2 changed files with 37 additions and 32 deletions

View File

@ -1,14 +1,32 @@
import React from 'react';
import { Provider } from 'react-redux';
import { Provider, connect } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';
import { IntlProvider } from 'react-intl';
import { flattenMessages } from './utils/flattenMessages';
import messages from './config/locales';
import Application from './screens/application';
import { store, persistor } from './redux/store/store';
export default () => (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
const _renderApp = ({ locale }) => (
<PersistGate loading={null} persistor={persistor}>
<IntlProvider locale={locale} messages={flattenMessages(messages[locale])}>
<Application />
</PersistGate>
</Provider>
</IntlProvider>
</PersistGate>
);
const mapStateToProps = state => ({
locale: state.application.language,
});
const App = connect(mapStateToProps)(_renderApp);
export default () => {
return (
<Provider store={store}>
<App />
</Provider>
);
};

View File

@ -1,10 +1,7 @@
import React, { Component, Fragment } from 'react';
import { IntlProvider } from 'react-intl';
import { StatusBar, Platform, View } from 'react-native';
import EStyleSheet from 'react-native-extended-stylesheet';
import { ReduxNavigation } from '../../../navigation/reduxNavigation';
import { flattenMessages } from '../../../utils/flattenMessages';
import messages from '../../../config/locales';
// Services
import { toastNotification as toastNotificationAction } from '../../../redux/actions/uiAction';
@ -47,14 +44,7 @@ class ApplicationScreen extends Component {
};
render() {
const {
isConnected,
isDarkTheme,
locale,
toastNotification,
isReady,
isPinCodeReqiure,
} = this.props;
const { isConnected, isDarkTheme, toastNotification, isReady, isPinCodeReqiure } = this.props;
const { isShowToastNotification } = this.state;
const barStyle = isDarkTheme ? 'light-content' : 'dark-content';
const barColor = isDarkTheme ? '#1e2835' : '#fff';
@ -66,21 +56,18 @@ class ApplicationScreen extends Component {
) : (
<StatusBar barStyle={barStyle} backgroundColor={barColor} />
)}
<IntlProvider locale={locale} messages={flattenMessages(messages[locale])}>
<Fragment>
{!isConnected && <NoInternetConnection />}
<ReduxNavigation />
<Modal
isOpen={isPinCodeReqiure}
isFullScreen
swipeToClose={false}
backButtonClose={false}
>
<PinCode setWrappedComponentState={this._setWrappedComponentState} />
</Modal>
</Fragment>
</IntlProvider>
<Fragment>
{!isConnected && <NoInternetConnection />}
<ReduxNavigation />
<Modal
isOpen={isPinCodeReqiure}
isFullScreen
swipeToClose={false}
backButtonClose={false}
>
<PinCode setWrappedComponentState={this._setWrappedComponentState} />
</Modal>
</Fragment>
{Platform.OS === 'android' && <PostButtonForAndroid />}
{isShowToastNotification && (