Skip to content

Commit d567b14

Browse files
committed
👍 User Experience: added flatlist horizontal, for search
1 parent f0c2066 commit d567b14

File tree

4 files changed

+95
-10
lines changed

4 files changed

+95
-10
lines changed

app/_layout.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
import { Stack } from 'expo-router'
2+
import { useCallback } from 'react'
3+
import { useFonts } from 'expo-font'
4+
import * as SplashScreen from 'expo-splash-screen';
5+
6+
SplashScreen.preventAutoHideAsync()
27

38
const Layout = () => {
4-
return <Stack />;
9+
const [fontLoaded] = useFonts({
10+
DMBold: require('../assets/fonts/DMSans-Bold.ttf'),
11+
DMMedium: require('../assets/fonts/DMSans-Medium.ttf'),
12+
DMRegular: require('../assets/fonts/DMSans-Regular.ttf')
13+
})
14+
15+
const onLayoutRootView = useCallback(async () => {
16+
if (fontLoaded) {
17+
await SplashScreen.hideAsync()
18+
}
19+
}, [fontLoaded])
20+
if (!fontLoaded) return null;
21+
return <Stack onLayout={onLayoutRootView}/>;
522
}
623

724
export default Layout;

app/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const Home = () => {
2222
<ScrollView showsVerticalScrollIndicator={false}>
2323
<View style={{
2424
flex: 1,
25-
padding: SIZES.medium
25+
padding: SIZES.medium,
2626
}}>
2727
<Welcome />
2828
<Popularjobs />
Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,36 @@
1-
import React from 'react'
2-
import { View, Text } from 'react-native'
1+
import React, { useState } from 'react'
2+
import { View, Text, ActivityIndicator, FlatList } from 'react-native'
3+
import { COLORS, SIZES } from '../../../constants'
4+
import PopularJobCard from '../../common/cards/popular/PopularJobCard'
35

46
import styles from './popularjobs.style'
7+
import { useRouter } from 'expo-router'
8+
import { TouchableOpacity } from 'react-native-gesture-handler'
59

610
const Popularjobs = () => {
11+
const router = useRouter();
12+
const isLoading = false
13+
const error = false
14+
15+
16+
717
return (
8-
<View>
9-
<Text>Popularjobs</Text>
18+
<View style={styles.container}>
19+
<View style={styles.header}>
20+
<Text style={styles.headerTitle}>Popular Jobs</Text>
21+
<TouchableOpacity><Text style={styles.headerBtn}>Show all</Text></TouchableOpacity>
22+
</View>
23+
<View style={styles.cardsContainer}>
24+
{isLoading ? (
25+
<ActivityIndicator size="large" color={COLORS.primary} />
26+
) : error ? (
27+
<Text>Something went worng</Text>
28+
) : (
29+
<FlatList />
30+
)}
31+
</View>
1032
</View>
1133
)
1234
}
1335

14-
export default Popularjobs
36+
export default Popularjobs

components/home/welcome/Welcome.jsx

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,59 @@
1-
import React from 'react'
1+
import React, { useState } from 'react'
22
import { View, Text, TextInput, TouchableOpacity, Image, FlatList } from 'react-native'
3-
import {icons, SIZES} from '../../../constants'
3+
import { icons, SIZES } from '../../../constants'
44

55
import styles from './welcome.style'
66

7+
const jobType = ["Full-Time", "Part-Time", "Contractor"]
8+
79
const Welcome = () => {
10+
const [activeJobType, setActiveJobType] = useState('Full-Time')
11+
812
return (
913
<View>
10-
<Text>Welcome</Text>
14+
<View style={styles.container}>
15+
<Text style={styles.userName}>Hello, Daniel Park</Text>
16+
<Text style={styles.welcomeMessage}>Find Your Dream Job</Text>
17+
</View>
18+
<View style={styles.searchContainer}>
19+
<View style={styles.searchWrapper}>
20+
<TextInput
21+
style={styles.searchInput}
22+
value=""
23+
onChange={() => { }}
24+
placeholder='What are you looking for?'
25+
/>
26+
</View>
27+
<TouchableOpacity
28+
style={styles.searchBtn}
29+
onPress={() => { }}
30+
>
31+
<Image source={icons.search}
32+
resizeMode='contain'
33+
style={styles.searchBtnImage}
34+
/>
35+
</TouchableOpacity>
36+
</View>
37+
<View style={styles.tabsContainer}>
38+
<FlatList
39+
data={jobType}
40+
horizontal
41+
ListHeaderComponent={() => null}
42+
renderItem={({ item }) => (
43+
<TouchableOpacity
44+
style={styles.tab(activeJobType, item)}
45+
onPress={() => {
46+
setActiveJobType(item);
47+
// router.push(`/search/\${item}`);
48+
}}
49+
>
50+
<Text style={styles.tabText(activeJobType, item)}>{item}</Text>
51+
</TouchableOpacity>
52+
)}
53+
keyExtractor={item => item}
54+
contentContainerStyle={{ columnGap: SIZES.small }}
55+
/>
56+
</View>
1157
</View>
1258
)
1359
}

0 commit comments

Comments
 (0)