mirror of
https://github.com/ecency/ecency-mobile.git
synced 2025-01-03 03:25:24 +03:00
removed splash screen && functions moved to applicationContainer
This commit is contained in:
parent
d10705e67d
commit
ca03cc7c42
@ -1,8 +1,5 @@
|
||||
import Logo from './logo/logo';
|
||||
// import Comment from './comment/comment';
|
||||
// import PostCard from "./postCard";
|
||||
import Reply from './reply/reply';
|
||||
// import Search from './search/search';
|
||||
import { FormInput } from './formInput';
|
||||
import { CircularButton, TextButton, IconButton } from './buttons';
|
||||
import { NumericKeyboard } from './numericKeyboard';
|
||||
@ -14,11 +11,8 @@ import UserListItem from './basicUIElements/view/userListItem/userListItem';
|
||||
|
||||
export {
|
||||
Logo,
|
||||
// Comment,
|
||||
// PostCard,
|
||||
UserListItem,
|
||||
Reply,
|
||||
// Search,
|
||||
FormInput,
|
||||
CircularButton,
|
||||
TextButton,
|
||||
|
@ -16,7 +16,6 @@ import {
|
||||
Profile,
|
||||
RootComponent,
|
||||
Settings,
|
||||
Splash,
|
||||
SteemConnect,
|
||||
Voters,
|
||||
} from '../screens';
|
||||
@ -81,10 +80,9 @@ const stackNavigatior = createStackNavigator(
|
||||
},
|
||||
},
|
||||
{
|
||||
cardStyle: {
|
||||
backgroundColor: 'white',
|
||||
// 1e2835
|
||||
},
|
||||
// cardStyle: {
|
||||
// backgroundColor: 'white',
|
||||
// },
|
||||
},
|
||||
);
|
||||
|
||||
@ -92,6 +90,5 @@ export default createSwitchNavigator({
|
||||
stackNavigatior,
|
||||
[ROUTES.SCREENS.LOGIN]: { screen: RootComponent()(Login) },
|
||||
[ROUTES.SCREENS.PINCODE]: { screen: RootComponent()(PinCode) },
|
||||
[ROUTES.SCREENS.SPLASH]: { screen: Splash },
|
||||
[ROUTES.SCREENS.STEEM_CONNECT]: { screen: RootComponent()(SteemConnect) },
|
||||
});
|
||||
|
@ -1,9 +1,27 @@
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import 'intl';
|
||||
import { addLocaleData } from 'react-intl';
|
||||
// Constants
|
||||
import en from 'react-intl/locale-data/en';
|
||||
import tr from 'react-intl/locale-data/tr';
|
||||
|
||||
import { getUserData, getAuthStatus, getSettings } from '../../../realm/realm';
|
||||
import { getUser } from '../../../providers/steem/dsteem';
|
||||
|
||||
// Actions
|
||||
import { addOtherAccount, updateCurrentAccount } from '../../../redux/actions/accountAction';
|
||||
import {
|
||||
activeApplication,
|
||||
login,
|
||||
openPinCodeModal,
|
||||
setLanguage,
|
||||
isNotificationOpen,
|
||||
setCurrency,
|
||||
setApi,
|
||||
isDarkTheme,
|
||||
} from '../../../redux/actions/applicationActions';
|
||||
|
||||
// Container
|
||||
import { ApplicationScreen } from '..';
|
||||
|
||||
addLocaleData([...en, ...tr]);
|
||||
@ -24,6 +42,11 @@ class ApplicationContainer extends Component {
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount = () => {
|
||||
this._getUserData();
|
||||
this._getSettings();
|
||||
};
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { isDarkTheme, selectedLanguage } = this.props;
|
||||
|
||||
@ -32,6 +55,54 @@ class ApplicationContainer extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
_getUserData = () => {
|
||||
const { dispatch } = this.props;
|
||||
getAuthStatus().then((res) => {
|
||||
if (res.isLoggedIn) {
|
||||
getUserData().then((response) => {
|
||||
if (response.length > 0) {
|
||||
response.forEach((accountData) => {
|
||||
dispatch(
|
||||
addOtherAccount({ username: accountData.username, avatar: accountData.avatar }),
|
||||
);
|
||||
});
|
||||
getUser(response[response.length - 1].username)
|
||||
.then((accountData) => {
|
||||
const realmObject = response[response.length - 1];
|
||||
accountData.realm_object = realmObject;
|
||||
|
||||
dispatch(updateCurrentAccount(accountData));
|
||||
dispatch(activeApplication());
|
||||
dispatch(login());
|
||||
if (__DEV__ === false) {
|
||||
dispatch(openPinCodeModal());
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
alert(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
dispatch(activeApplication());
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
_getSettings = () => {
|
||||
const { dispatch } = this.props;
|
||||
|
||||
getSettings().then((response) => {
|
||||
if (response) {
|
||||
response.isDarkTheme && dispatch(isDarkTheme(response.isDarkTheme));
|
||||
response.language && dispatch(setLanguage(response.language));
|
||||
response.currency && dispatch(setCurrency(response.currency));
|
||||
response.notification && dispatch(isNotificationOpen(response.currency));
|
||||
response.server && dispatch(setApi(response.currency));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
const { selectedLanguage } = this.props;
|
||||
const { isRenderRequire } = this.state;
|
||||
|
@ -1,6 +1,5 @@
|
||||
import PinCode from './pinCode';
|
||||
import RootComponent from './root';
|
||||
import Splash from './splash';
|
||||
import SteemConnect from './steem-connect/steemConnect';
|
||||
import { Application } from './application';
|
||||
import { Editor } from './editor';
|
||||
@ -27,7 +26,6 @@ export {
|
||||
Profile,
|
||||
RootComponent,
|
||||
Settings,
|
||||
Splash,
|
||||
SteemConnect,
|
||||
Voters,
|
||||
};
|
||||
|
@ -1,89 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { getUserData, getAuthStatus, getSettings } from '../../../realm/realm';
|
||||
import { getUser } from '../../../providers/steem/dsteem';
|
||||
|
||||
// Actions
|
||||
import { addOtherAccount, updateCurrentAccount } from '../../../redux/actions/accountAction';
|
||||
import {
|
||||
activeApplication,
|
||||
login,
|
||||
openPinCodeModal,
|
||||
setLanguage,
|
||||
isNotificationOpen,
|
||||
setCurrency,
|
||||
setApi,
|
||||
isDarkTheme,
|
||||
} from '../../../redux/actions/applicationActions';
|
||||
|
||||
// Constants
|
||||
import { default as ROUTES } from '../../../constants/routeNames';
|
||||
|
||||
import SplashScreen from '../screen/splashScreen';
|
||||
|
||||
class SplashContainer extends Component {
|
||||
componentDidMount = () => {
|
||||
this._getUserData();
|
||||
this._getSettings();
|
||||
};
|
||||
|
||||
_getUserData = () => {
|
||||
const { navigation, dispatch } = this.props;
|
||||
|
||||
getAuthStatus().then((res) => {
|
||||
if (res.isLoggedIn) {
|
||||
getUserData().then((response) => {
|
||||
if (response.length > 0) {
|
||||
response.forEach((accountData) => {
|
||||
dispatch(
|
||||
addOtherAccount({ username: accountData.username, avatar: accountData.avatar }),
|
||||
);
|
||||
});
|
||||
getUser(response[response.length - 1].username)
|
||||
.then((accountData) => {
|
||||
const realmObject = response[response.length - 1];
|
||||
accountData.realm_object = realmObject;
|
||||
|
||||
dispatch(updateCurrentAccount(accountData));
|
||||
dispatch(activeApplication());
|
||||
dispatch(login());
|
||||
if (__DEV__ === false) {
|
||||
dispatch(openPinCodeModal());
|
||||
}
|
||||
navigation.navigate(ROUTES.DRAWER.MAIN);
|
||||
})
|
||||
.catch((err) => {
|
||||
alert(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
dispatch(activeApplication());
|
||||
navigation.navigate(ROUTES.DRAWER.MAIN);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
_getSettings = () => {
|
||||
const { dispatch } = this.props;
|
||||
|
||||
getSettings().then((response) => {
|
||||
console.log(response.isDarkTheme);
|
||||
|
||||
if (response) {
|
||||
response.isDarkTheme && dispatch(isDarkTheme(response.isDarkTheme));
|
||||
response.language && dispatch(setLanguage(response.language));
|
||||
response.currency && dispatch(setCurrency(response.currency));
|
||||
response.notification && dispatch(isNotificationOpen(response.currency));
|
||||
response.server && dispatch(setApi(response.currency));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
return <SplashScreen />;
|
||||
}
|
||||
}
|
||||
|
||||
export default connect()(SplashContainer);
|
@ -1,3 +0,0 @@
|
||||
import Splash from './container/splashContainer';
|
||||
|
||||
export default Splash;
|
@ -1,37 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
import { Text, Animated } from 'react-native';
|
||||
// Components
|
||||
import { Logo } from '../../../components';
|
||||
|
||||
import styles from './splashStyles';
|
||||
|
||||
class SplashScreen extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
fadeAnim: new Animated.Value(0),
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount = () => {
|
||||
const { fadeAnim } = this.state;
|
||||
Animated.timing(fadeAnim, {
|
||||
toValue: 1,
|
||||
duration: 6000,
|
||||
}).start();
|
||||
};
|
||||
|
||||
render() {
|
||||
const { fadeAnim } = this.state;
|
||||
|
||||
return (
|
||||
<Animated.View style={[styles.container, { opacity: fadeAnim }]}>
|
||||
<Logo style={styles.logo} />
|
||||
<Text style={styles.title}>eSteem</Text>
|
||||
<Text style={styles.subTitle}>mobile</Text>
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default SplashScreen;
|
@ -1,24 +0,0 @@
|
||||
import EStyleSheet from 'react-native-extended-stylesheet';
|
||||
|
||||
export default EStyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
},
|
||||
title: {
|
||||
// fontFamily: 'Sansation_Bold',
|
||||
color: '$primaryDarkBlue',
|
||||
fontSize: 30,
|
||||
paddingBottom: 0,
|
||||
},
|
||||
subTitle: {
|
||||
// fontFamily: 'Sansation_Regular',
|
||||
color: '#00519c',
|
||||
fontSize: 24,
|
||||
},
|
||||
logo: {
|
||||
width: '$deviceWidth / 4',
|
||||
height: '$deviceWidth / 4',
|
||||
},
|
||||
});
|
Loading…
Reference in New Issue
Block a user