Commit fbce9686 by Giang Tran

fix bug home

parent 9f568dc5
......@@ -8,7 +8,7 @@ def add_flipper_pods!(versions = {})
versions['Flipper-Glog'] ||= '0.3.6'
versions['Flipper-PeerTalk'] ||= '~> 0.0.4'
versions['Flipper-RSocket'] ||= '~> 1.0'
pod 'FlipperKit', versions['Flipper'], :configuration => 'Debug'
pod 'FlipperKit/FlipperKitLayoutPlugin', versions['Flipper'], :configuration => 'Debug'
pod 'FlipperKit/SKIOSNetworkPlugin', versions['Flipper'], :configuration => 'Debug'
......
import React, {useEffect, useState} from 'react';
import {Alert, Platform} from 'react-native';
import {Alert, Platform, View} from 'react-native';
import {connect} from 'react-redux';
import {getTransaction} from '../../apis/Functions/users';
import {getImagesHome} from '../../apis/Functions/General';
......@@ -180,24 +180,21 @@ const Home = (props) => {
};
return (
<>
<HomeView
data={data}
dataPrice={dataPriceFilter}
listImage={listImage}
filterId={filterId}
filters={filters}
setFilterId={changeFilter}
onSortByName={onSortByName}
onSortByPercent={onSortByPercent}
onSortByPriceOpenClose={onSortByPriceOpenClose}
onSortByPriceHighLow={onSortByPriceHighLow}
/>
<VersionChecker />
</>
<HomeView
data={data}
dataPrice={dataPriceFilter}
listImage={listImage}
filterId={filterId}
filters={filters}
setFilterId={changeFilter}
onSortByName={onSortByName}
onSortByPercent={onSortByPercent}
onSortByPriceOpenClose={onSortByPriceOpenClose}
onSortByPriceHighLow={onSortByPriceHighLow}
/>
);
};
<VersionChecker />;
const mapStateToProps = (state) => {
return {
user: state.userReducer,
......
......@@ -4,13 +4,15 @@ import {
ImageBackground,
StyleSheet,
ScrollView,
TouchableOpacity,
Text,
} from 'react-native';
import HeaderHome from '../../components/Header/HeaderHome';
import {getFontXD} from '../../Config/Functions';
import R from '../../assets/R';
import SwiperComponent from './SwiperComponent';
import PriceListView from './PriceListView';
import VersionChecker from '../VersionChecker';
const HomeView = (props) => {
return (
<ImageBackground
......@@ -34,6 +36,8 @@ const HomeView = (props) => {
onSortByPriceOpenClose={props.onSortByPriceOpenClose}
onSortByPriceHighLow={props.onSortByPriceHighLow}
/>
<VersionChecker />
</ScrollView>
</ImageBackground>
);
......
......@@ -28,160 +28,159 @@ import {getHeight, getWidth, logout} from '../Config/Functions';
const Tab = createBottomTabNavigator();
const PayScreenComponent = () => {
return null;
return null;
};
const TabNavigator = (props) => {
console.log(getHeight(), getWidth());
const navigate = useNavigation();
useEffect(() => {
setInitLanguage();
checkDeepking();
setTimeout(() => {
showPopUp();
}, 3000);
let logoutListener = DeviceEventEmitter.addListener('logout', (e) => {
console.log('run in to logout');
logout(navigate);
});
return () => {
logoutListener.remove();
};
}, []);
const checkDeepking = () => {
Linking.getInitialURL().then((url) => {
if (url) {
deeplinkScreen(url);
}
});
Linking.addEventListener('url', (url) => {
if (url) {
handleOpenURL(url);
}
});
};
const handleOpenURL = (event) => {
deeplinkScreen(event.url);
};
const deeplinkScreen = (url) => {
const route = url.replace(/.*?:\/\//g, '');
const id = route.match(/\/([^\/]+)\/?$/)[1];
const root = route.split('/')[0];
// const routeName = route.split('/')[1];
if (root == 'screen') {
navigate.navigate(DETAILNEW, {id});
}
};
useEffect(() => {
checkScreenInit();
}, [props.screenInit]);
const checkScreenInit = () => {
if (props.screenInit.screen) {
const {screen, id} = props.screenInit;
navigate.navigate(screen, {id: id});
}
console.log(getHeight(), getWidth());
const navigate = useNavigation();
useEffect(() => {
setInitLanguage();
checkDeepking();
setTimeout(() => {
showPopUp();
}, 3000);
let logoutListener = DeviceEventEmitter.addListener('logout', (e) => {
console.log('run in to logout');
logout(navigate);
});
return () => {
logoutListener.remove();
};
const setInitLanguage = async () => {
const laguage = await AsyncStorage.getItem(KEY.LANGUAGE);
if (laguage) {
props.changeLanguage(laguage);
}
setLocation(I18n, laguage);
};
const showPopUp = () => {
if (props.user.status == 1) {
return confirmAlert(I18n.t('PopupVerifyAccount'), () => {
navigate.navigate(AccountVerification);
});
} else if (props.user.status == 3 && !props.user.contract_code) {
return confirmAlert(I18n.t('PopupOpenCQG'), () => {
navigate.navigate(PACKETCQG);
});
}
};
return (
<View style={{flex: 1}}>
<Tab.Navigator
initialRouteName="Screen1"
tabBarOptions={{activeTintColor: R.colors.main}}>
<Tab.Screen
name="Screen1"
component={Home}
options={{
tabBarLabel: 'Overview',
tabBarIcon: ({color, size}) => (
<Icon name="landmark" size={size} color={color}/>
),
}}
/>
<Tab.Screen
name="Screen2"
component={Transaction}
options={{
tabBarLabel:
props.language.language == 'vi' ? 'Giao dịch' : 'Tradding',
tabBarIcon: ({color, size}) => (
<Image
source={R.images.iconTransaction2}
style={{width: size, height: size, tintColor: color}}
/>
),
}}
/>
<Tab.Screen
name="Pay"
component={PayScreenComponent}
options={{
tabBarButton: () => <PlussModal/>,
}}
/>
<Tab.Screen
name="Screen3"
component={Notification}
options={{
tabBarLabel:
props.language.language == 'vi' ? 'Thông báo' : 'Notification',
tabBarIcon: ({color, size}) => (
<Ionicons
name="ios-notifications-outline"
size={size}
color={color}
/>
),
}}
/>
<Tab.Screen
name="Screen4"
component={NewFeed}
options={{
tabBarLabel: props.language.language == 'vi' ? 'Tin tức' : 'News',
tabBarIcon: ({color, size}) => (
<Ionicons name="newspaper-outline" size={size} color={color}/>
),
}}
/>
</Tab.Navigator>
</View>
);
}, []);
const checkDeepking = () => {
Linking.getInitialURL().then((url) => {
if (url) {
deeplinkScreen(url);
}
});
Linking.addEventListener('url', (url) => {
if (url) {
handleOpenURL(url);
}
});
};
const handleOpenURL = (event) => {
deeplinkScreen(event.url);
};
const deeplinkScreen = (url) => {
const route = url.replace(/.*?:\/\//g, '');
const id = route.match(/\/([^\/]+)\/?$/)[1];
const root = route.split('/')[0];
// const routeName = route.split('/')[1];
if (root == 'screen') {
navigate.navigate(DETAILNEW, {id});
}
};
useEffect(() => {
checkScreenInit();
}, [props.screenInit]);
const checkScreenInit = () => {
if (props.screenInit.screen) {
const {screen, id} = props.screenInit;
navigate.navigate(screen, {id: id});
}
};
const setInitLanguage = async () => {
const laguage = await AsyncStorage.getItem(KEY.LANGUAGE);
if (laguage) {
props.changeLanguage(laguage);
}
setLocation(I18n, laguage);
};
const showPopUp = () => {
if (props.user.status == 1) {
return confirmAlert(I18n.t('PopupVerifyAccount'), () => {
navigate.navigate(AccountVerification);
});
} else if (props.user.status == 3 && !props.user.contract_code) {
return confirmAlert(I18n.t('PopupOpenCQG'), () => {
navigate.navigate(PACKETCQG);
});
}
};
return (
<View style={{flex: 1}}>
<Tab.Navigator
initialRouteName="Screen1"
tabBarOptions={{activeTintColor: R.colors.main}}>
<Tab.Screen
name="Screen1"
component={Home}
options={{
tabBarLabel: 'Overview',
tabBarIcon: ({color, size}) => (
<Icon name="landmark" size={size} color={color} />
),
}}
/>
<Tab.Screen
name="Screen2"
component={Transaction}
options={{
tabBarLabel:
props.language.language == 'vi' ? 'Giao dịch' : 'Tradding',
tabBarIcon: ({color, size}) => (
<Image
source={R.images.iconTransaction2}
style={{width: size, height: size, tintColor: color}}
/>
),
}}
/>
<Tab.Screen
name="Pay"
component={PayScreenComponent}
options={{
tabBarButton: () => <PlussModal />,
}}
/>
<Tab.Screen
name="Screen3"
component={Notification}
options={{
tabBarLabel:
props.language.language == 'vi' ? 'Thông báo' : 'Notification',
tabBarIcon: ({color, size}) => (
<Ionicons
name="ios-notifications-outline"
size={size}
color={color}
/>
),
}}
/>
<Tab.Screen
name="Screen4"
component={NewFeed}
options={{
tabBarLabel: props.language.language == 'vi' ? 'Tin tức' : 'News',
tabBarIcon: ({color, size}) => (
<Ionicons name="newspaper-outline" size={size} color={color} />
),
}}
/>
</Tab.Navigator>
</View>
);
};
const mapStateToProps = (state) => {
return {
user: state.userReducer,
notifi: state.CountNotificationReducer,
screenInit: state.ScreenInitReducer,
language: state.languageReducer,
};
return {
user: state.userReducer,
notifi: state.CountNotificationReducer,
screenInit: state.ScreenInitReducer,
language: state.languageReducer,
};
};
export default connect(mapStateToProps, {changeLanguage})(TabNavigator);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment