轻松聘
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

86 lines
2.4 KiB

import { Ionicons } from '@expo/vector-icons';
import { useRouter } from 'expo-router';
import { Pressable, ScrollView, StyleSheet, Text, View } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { useFavorites } from '../src/hooks';
import { JobCard } from '../src/components/JobCard';
import { LoadingState, ErrorState, EmptyState } from '../src/components/StateView';
import { colors } from '../src/theme';
/**
* 我的收藏页(职位)
*/
export default function FavoritesScreen() {
const router = useRouter();
const { items, loading, error, refresh, isEmpty } = useFavorites();
return (
<SafeAreaView style={styles.safeArea} edges={['top']}>
<View style={styles.header}>
<Pressable style={styles.headerBtn} onPress={() => router.back()} hitSlop={8}>
<Ionicons name="chevron-back" size={24} color={colors.textPrimary} />
</Pressable>
<Text style={styles.headerTitle}>我的收藏</Text>
<View style={styles.headerBtn} />
</View>
{loading ? (
<LoadingState text="加载收藏中…" />
) : error ? (
<ErrorState message="收藏加载失败,请重试" onRetry={refresh} />
) : isEmpty ? (
<EmptyState
icon="heart-outline"
title="还没有收藏"
subtitle="浏览职位时点击收藏,会在这里出现"
/>
) : (
<ScrollView
style={styles.scroll}
contentContainerStyle={styles.content}
showsVerticalScrollIndicator={false}
>
{items.map((job) => (
<JobCard key={job.id} job={job} onPress={() => router.push(`/jobs/${job.id}`)} />
))}
</ScrollView>
)}
</SafeAreaView>
);
}
const styles = StyleSheet.create({
safeArea: {
flex: 1,
backgroundColor: colors.pageBg,
},
header: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingHorizontal: 8,
height: 48,
backgroundColor: colors.white,
borderBottomWidth: 1,
borderBottomColor: colors.borderLight,
},
headerBtn: {
width: 40,
height: 40,
alignItems: 'center',
justifyContent: 'center',
},
headerTitle: {
fontSize: 17,
fontWeight: '700',
color: colors.textPrimary,
},
scroll: {
flex: 1,
},
content: {
paddingHorizontal: 8,
paddingTop: 12,
paddingBottom: 24,
},
});