cleaned up application screen class

This commit is contained in:
noumantahir 2022-06-17 18:29:25 +05:00
parent 418c1c9ae9
commit 7b87d111eb

View File

@ -1,10 +1,9 @@
import React, { Component, Fragment } from 'react';
import { StatusBar, Platform, View, Alert, Text, Modal, TouchableHighlight } from 'react-native';
import { StatusBar, Platform, View, Alert } from 'react-native';
import EStyleSheet from 'react-native-extended-stylesheet';
import { connect } from 'react-redux';
import { createAppContainer } from 'react-navigation';
import { injectIntl } from 'react-intl';
import VersionNumber from 'react-native-version-number';
import AppNavitation from '../../../navigation/routes';
import { setTopLevelNavigator, navigate } from '../../../navigation/service';
@ -14,7 +13,6 @@ import {
toastNotification as toastNotificationAction,
setRcOffer,
} from '../../../redux/actions/uiAction';
import { getVersionForWelcomeModal } from '../../../realm/realm';
import ROUTES from '../../../constants/routeNames';
@ -32,7 +30,6 @@ import {
// Themes (Styles)
import darkTheme from '../../../themes/darkTheme';
import lightTheme from '../../../themes/lightTheme';
import parseVersionNumber from '../../../utils/parseVersionNumber';
const Navigation = createAppContainer(AppNavitation);
@ -41,20 +38,9 @@ class ApplicationScreen extends Component {
super(props);
this.state = {
isShowToastNotification: false,
showWelcomeModal: false,
};
}
componentDidMount() {
const { appVersion } = VersionNumber;
getVersionForWelcomeModal().then((version) => {
if (version < parseVersionNumber(appVersion)) {
this.setState({ showWelcomeModal: true });
}
});
}
componentDidUpdate(prevProps) {
const { rcOffer, dispatch, intl } = this.props;
const { rcOffer: rcOfferPrev } = prevProps;
@ -117,7 +103,7 @@ class ApplicationScreen extends Component {
foregroundNotificationData,
navigation,
} = this.props;
const { isShowToastNotification, showWelcomeModal } = this.state;
const { isShowToastNotification } = this.state;
const barStyle = isDarkTheme ? 'light-content' : 'dark-content';
const barColor = isDarkTheme ? '#1e2835' : '#fff';
@ -128,6 +114,7 @@ class ApplicationScreen extends Component {
) : (
<StatusBar barStyle={barStyle} backgroundColor={barColor} />
)}
<Fragment>
{!isConnected && <NoInternetConnection />}
<Navigation
@ -135,32 +122,6 @@ class ApplicationScreen extends Component {
setTopLevelNavigator(navigatorRef);
}}
/>
<Modal
animationType="slide"
visible={false}
presentationStyle="pageSheet"
onRequestClose={() => {
Alert.alert('Modal has been closed.');
}}
>
<View
style={{
backgroundColor: 'white',
flex: 1,
justifyContent: 'center',
alignItems: 'center',
}}
>
<Text>Hello World!</Text>
<TouchableHighlight
onPress={() => {
this.setState({ showWelcomeModal: !showWelcomeModal });
}}
>
<Text>Hide Modal</Text>
</TouchableHighlight>
</View>
</Modal>
</Fragment>
{isShowToastNotification && (