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
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 { useHistory } from '../src/hooks';
|
|
import { JobCard } from '../src/components/JobCard';
|
|
import { LoadingState, ErrorState, EmptyState } from '../src/components/StateView';
|
|
import { colors , spacing } from '../src/theme';
|
|
|
|
/**
|
|
* 浏览历史页(职位)
|
|
*/
|
|
export default function HistoryScreen() {
|
|
const router = useRouter();
|
|
const { items, loading, error, refresh, isEmpty } = useHistory();
|
|
|
|
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="time-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: spacing.card,
|
|
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: spacing.card,
|
|
paddingTop: 12,
|
|
paddingBottom: 24,
|
|
},
|
|
});
|
|
|