Commit fbce9686 by Giang Tran

fix bug home

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