Commit 03cfc11f by tungnq

TODO: Đã tối ưu hoá lại phần màn hình home và thêm chức năng tìm kiếm cho màn hình home

parent 9fe8ccd6
...@@ -4,3 +4,4 @@ const fonts = { ...@@ -4,3 +4,4 @@ const fonts = {
InterSemiBold:'Inter_18pt-SemiBold', InterSemiBold:'Inter_18pt-SemiBold',
}; };
export default fonts; export default fonts;
import { Image, SafeAreaView, StatusBar, StyleSheet, TextInput, View } from "react-native"; import {
import React from "react"; Image,
import R from "../../assets/R"; SafeAreaView,
const customHeader = (props) => { StatusBar,
StyleSheet,
TextInput,
View,
} from 'react-native';
import React from 'react';
import R from '../../assets/R';
import styles from './style';
const customHeader = props => {
const { const {
pathLogo, pathLogo,
width, width,
...@@ -13,24 +21,17 @@ const customHeader = (props) => { ...@@ -13,24 +21,17 @@ const customHeader = (props) => {
} = props; } = props;
const SearchIcon = R.images.icSearch; const SearchIcon = R.images.icSearch;
return ( return (
<View style={[styles.container_header, styles.spacing_header]}>
<View style={[styles.container ,{justifyContent: 'center',marginTop:20}]}> <Image source={pathLogo} style={{width: width, height: height}} />
<Image
source={pathLogo}
style={{ width: width, height: height }}
/>
<View style={styles.size_box}></View> <View style={styles.size_box}></View>
<View <View style={styles.search_box}>
style={styles.search_box}
>
<SearchIcon <SearchIcon
width={25} width={20}
height={25} height={20}
stroke={R.colors.white} stroke={R.colors.white}
stroke-width={2} stroke-width={2}
/> />
<View style={styles.size_box_2}></View> <View style={styles.size_box_2}></View>
<TextInput <TextInput
value={value} value={value}
onChangeText={onChangeText} onChangeText={onChangeText}
...@@ -44,37 +45,3 @@ const customHeader = (props) => { ...@@ -44,37 +45,3 @@ const customHeader = (props) => {
}; };
export default customHeader; export default customHeader;
const styles = StyleSheet.create({
container: {
flexDirection: "row",
marginHorizontal: 15,
},
size_box:{
width: '20%',
},
size_box_2:{
width: '2.5%',
},
search_box: {
flex: 3,
flexDirection: "row",
backgroundColor: R.colors.black250,
alignItems: "center",
borderColor: R.colors.gray280,
borderRadius: 100,
borderWidth: 1,
maxHeight:40,
paddingHorizontal: 14,
paddingVertical: 5
},
input: {
fontSize: R.fontsize.fontsSize12,
color: R.colors.white,
margin:0,
padding:0,
fontFamily: R.fonts.InterRegular,
fontWeight: '400',
},
});
...@@ -72,17 +72,25 @@ const Home = (props) => { ...@@ -72,17 +72,25 @@ const Home = (props) => {
const handleSearchChange = (text) => { const handleSearchChange = (text) => {
setSearchText(text); setSearchText(text);
}; };
const handleNavigationProfile = () => {
navigation.navigate(SCREENNAME.PROFILE);
};
const filterMenuData = (menuData) =>{
return menuData.filter(item => item.title.toLowerCase().includes(searchText.toLowerCase()));
}
return ( return (
<Homeview <Homeview
menuDataStudy={menuDataStudy} menuDataStudy={filterMenuData(menuDataStudy) || menuDataStudy}
menuDataIndividual={menuDataIndividual} menuDataIndividual={filterMenuData(menuDataIndividual) || menuDataIndividual}
menuDataOnlineSer={menuDataOnlineSer} menuDataOnlineSer={filterMenuData(menuDataOnlineSer) || menuDataOnlineSer}
selectedMenuItem={selectedMenuItem} selectedMenuItem={selectedMenuItem}
searchText={searchText} searchText={searchText}
userProfile={userProfile} userProfile={userProfile}
onMenuItemPress={handleMenuItemPress} onMenuItemPress={handleMenuItemPress}
onSearchChange={handleSearchChange} onSearchChange={handleSearchChange}
onNavigationProfile={handleNavigationProfile}
/> />
); );
}; };
......
import React from "react"; import React from "react";
import { View, Text, StyleSheet, Image, TouchableOpacity } from "react-native"; import { View, Text, StyleSheet, Image, TouchableOpacity } from "react-native";
import R from "../../assets/R"; import styles from "./style";
const ItemGrid = ({ item ,onPress }) => { const ItemGrid = ({ item ,onPress }) => {
const IconComponent = item.icon; const IconComponent = item.icon;
return ( return (
...@@ -21,27 +21,3 @@ const ItemGrid = ({ item ,onPress }) => { ...@@ -21,27 +21,3 @@ const ItemGrid = ({ item ,onPress }) => {
export default ItemGrid; export default ItemGrid;
const styles = StyleSheet.create({
menu_item: {
alignItems: "center",
paddingVertical: 10,
paddingHorizontal: 5,
marginHorizontal: 5,
marginVertical: 5,
flex: 1,
maxWidth: "30%",
minHeight:"30%"
},
icon_container: {
width: 35,
height: 35,
backgroundColor:R.colors.white,
},
menu_text: {
fontSize: R.fontsize.fontsSize12,
fontWeight: "600",
color: R.colors.black,
fontFamily: R.fonts.InterMedium,
textAlign: "center",
},
});
import { StyleSheet } from "react-native"; import {StyleSheet} from 'react-native';
import R from "../../assets/R"; import R from '../../assets/R';
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container_header: {
flexDirection: 'row',
marginHorizontal: 15,
},
spacing_header: {
justifyContent: 'center',
marginTop: 20,
},
size_box: {
width: '20%',
},
size_box_2: {
width: '2.5%',
},
search_box: {
flex: 3,
flexDirection: 'row',
backgroundColor: R.colors.black250,
alignItems: 'center',
borderColor: R.colors.gray280,
borderRadius: 100,
height:35,
paddingHorizontal: 10,
paddingVertical: 5,
},
input: {
fontSize: R.fontsize.fontsSize12,
color: R.colors.white,
margin: 0,
padding: 0,
fontFamily: R.fonts.InterRegular,
fontWeight: '400',
},
/* -------------------------------------------------------------------------- */
/* Body */
/* -------------------------------------------------------------------------- */
container_body: { container_body: {
flex: 1, flex: 1,
backgroundColor: R.colors.white, backgroundColor: R.colors.white,
...@@ -13,22 +50,22 @@ const styles = StyleSheet.create({ ...@@ -13,22 +50,22 @@ const styles = StyleSheet.create({
profile_card: { profile_card: {
position: 'absolute', position: 'absolute',
bottom: -30, bottom: -30,
flexDirection: "row", flexDirection: 'row',
alignItems: "center", alignItems: 'center',
backgroundColor: R.colors.white, backgroundColor: R.colors.white,
paddingVertical: 10, paddingVertical: 10,
paddingHorizontal: 15, paddingHorizontal: 15,
marginHorizontal: 15, marginHorizontal: 15,
borderRadius: 15, borderRadius: 15,
shadowColor: R.colors.black, shadowColor: R.colors.black,
shadowOffset: { width: 0, height: 2 }, shadowOffset: {width: 0, height: 2},
shadowOpacity: 0.22, shadowOpacity: 0.22,
shadowRadius: 2.22, shadowRadius: 2.22,
elevation: 3, elevation: 3,
}, },
profile_left: { profile_left: {
flexDirection: "row", flexDirection: 'row',
alignItems: "center", alignItems: 'center',
flex: 3, flex: 3,
}, },
...@@ -48,7 +85,7 @@ const styles = StyleSheet.create({ ...@@ -48,7 +85,7 @@ const styles = StyleSheet.create({
height: '100%', height: '100%',
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
backgroundColor: R.colors.grey, backgroundColor: R.colors.blue500,
}, },
avatar_text: { avatar_text: {
fontSize: R.fontsize.fontsSize16, fontSize: R.fontsize.fontsSize16,
...@@ -62,11 +99,11 @@ const styles = StyleSheet.create({ ...@@ -62,11 +99,11 @@ const styles = StyleSheet.create({
}, },
text_card_info: { text_card_info: {
fontSize: R.fontsize.fontsSize12, fontSize: R.fontsize.fontsSize12,
fontWeight: "400", fontWeight: '600',
color: R.colors.black, color: R.colors.black,
fontFamily: R.fonts.InterRegular, fontFamily: R.fonts.InterMedium,
numberOfLines: 1, numberOfLines: 1,
ellipsizeMode: "tail", ellipsizeMode: 'tail',
}, },
profile_btn: { profile_btn: {
paddingVertical: 5, paddingVertical: 5,
...@@ -75,16 +112,15 @@ const styles = StyleSheet.create({ ...@@ -75,16 +112,15 @@ const styles = StyleSheet.create({
minHeight: 21, minHeight: 21,
maxWidth: 108, maxWidth: 108,
borderRadius: 15, borderRadius: 15,
flexDirection: "row", flexDirection: 'row',
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
}, },
btn_text: { btn_text: {
fontSize: R.fontsize.fontsSize10, fontSize: R.fontsize.fontsSize10,
fontWeight: "400", fontWeight: '400',
color: R.colors.black, color: R.colors.black,
fontFamily: R.fonts.InterRegular, fontFamily: R.fonts.InterRegular,
}, },
icon: { icon: {
marginLeft: 5, marginLeft: 5,
...@@ -95,13 +131,37 @@ const styles = StyleSheet.create({ ...@@ -95,13 +131,37 @@ const styles = StyleSheet.create({
menu_title: { menu_title: {
color: R.colors.txtMain, color: R.colors.txtMain,
fontSize: R.fontsize.fontsSize14, fontSize: R.fontsize.fontsSize14,
fontWeight: "600", fontWeight: '600',
color: R.colors.black, color: R.colors.black,
fontFamily: R.fonts.InterMedium, fontFamily: R.fonts.InterMedium,
}, },
scroll: { scroll: {
flex: 1, flex: 1,
marginTop: 35, marginTop: 35,
} },
});
export default styles; /* ---------------------------------- ITEM ---------------------------------- */
\ No newline at end of file menu_item: {
alignItems: 'center',
paddingVertical: 10,
paddingHorizontal: 5,
marginHorizontal: 5,
marginVertical: 5,
flex: 1,
maxWidth: '30%',
minHeight: '30%',
},
icon_container: {
width: 35,
height: 35,
backgroundColor: R.colors.white,
},
menu_text: {
fontSize: R.fontsize.fontsSize12,
fontWeight: '600',
color: R.colors.black,
fontFamily: R.fonts.InterMedium,
textAlign: 'center',
},
});
export default styles;
...@@ -20,6 +20,7 @@ import ItemGrid from './item'; ...@@ -20,6 +20,7 @@ import ItemGrid from './item';
import styles from './style'; import styles from './style';
import {useNavigation} from '@react-navigation/native'; import {useNavigation} from '@react-navigation/native';
import * as SCREENNAME from '../../routers/ScreenNames'; import * as SCREENNAME from '../../routers/ScreenNames';
import TextSearchView from '../../components/Input/TextSearch/TextSearch';
const HomeView = props => { const HomeView = props => {
const { const {
...@@ -31,6 +32,7 @@ const HomeView = props => { ...@@ -31,6 +32,7 @@ const HomeView = props => {
userProfile, userProfile,
onMenuItemPress, onMenuItemPress,
onSearchChange, onSearchChange,
onNavigationProfile,
} = props; } = props;
const ArrowRightIcon = R.images.icArrowRight; const ArrowRightIcon = R.images.icArrowRight;
...@@ -80,8 +82,7 @@ const HomeView = props => { ...@@ -80,8 +82,7 @@ const HomeView = props => {
<TouchableOpacity <TouchableOpacity
style={styles.profile_btn} style={styles.profile_btn}
onPress={() => navigate.navigate(SCREENNAME.PROFILE)} onPress={() => onNavigationProfile()}>
activeOpacity={0.7}>
<Text style={styles.btn_text}>H s cá nhân</Text> <Text style={styles.btn_text}>H s cá nhân</Text>
<ArrowRightIcon <ArrowRightIcon
width={5} width={5}
...@@ -110,13 +111,9 @@ const HomeView = props => { ...@@ -110,13 +111,9 @@ const HomeView = props => {
</View> </View>
); );
const renderBodyView1 = () => {
return ( return (
<SafeAreaView style={styles.container_body}> <>
<StatusBar barStyle="light-content" translucent={false} />
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
<View style={[{flex: 1}]}>
<View style={styles.container_body}>
<ImageBackground <ImageBackground
source={R.images.igBackgroundSlider} source={R.images.igBackgroundSlider}
style={[styles.background_header]}> style={[styles.background_header]}>
...@@ -128,10 +125,22 @@ const HomeView = props => { ...@@ -128,10 +125,22 @@ const HomeView = props => {
backgroundInput={R.colors.backgroundInputSearch} backgroundInput={R.colors.backgroundInputSearch}
textLabel={I18n.t('Search')} textLabel={I18n.t('Search')}
textColorLabel={R.colors.white} textColorLabel={R.colors.white}
value={searchText}
onChangeText={onSearchChange}
/> />
{renderProfileCard()} {renderProfileCard()}
</ImageBackground> </ImageBackground>
</>
);
};
const renderBody = () => {
return (
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
<View style={[{flex: 1}]}>
<View style={styles.container_body}>
{renderBodyView1()}
<ScrollView <ScrollView
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
...@@ -145,6 +154,13 @@ const HomeView = props => { ...@@ -145,6 +154,13 @@ const HomeView = props => {
</View> </View>
</View> </View>
</TouchableWithoutFeedback> </TouchableWithoutFeedback>
);
};
return (
<SafeAreaView style={styles.container_body}>
<StatusBar barStyle="light-content" translucent={false} />
{renderBody()}
</SafeAreaView> </SafeAreaView>
); );
}; };
......
import { StyleSheet, Dimensions } from 'react-native'
const { width, height } = Dimensions.get('window')
const styles = StyleSheet.create({
container:{
flex: 1,
backgroundColor:'white'
},
body:{
flex: 1,
marginHorizontal: 15
}
})
export default styles
\ No newline at end of file
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