refactor(App, navigation): migrate to Expo Router and clean up navigation structure
All checks were successful
Frontend CI / build-and-push-web (push) Successful in 4m27s
Frontend CI / ota-android (push) Successful in 11m6s
Frontend CI / build-android-apk (push) Successful in 1h16m45s

- Updated App entry point to utilize Expo Router, simplifying the navigation setup.
- Removed legacy navigation components and services to streamline the codebase.
- Adjusted package.json to reflect the new entry point and updated dependencies for compatibility.
- Enhanced overall application structure by consolidating navigation logic and improving maintainability.
This commit is contained in:
lafay
2026-03-24 14:21:31 +08:00
parent b91e78c921
commit 2ddb9cadd8
111 changed files with 1829 additions and 3214 deletions

View File

@@ -19,8 +19,7 @@ import {
Modal,
} from 'react-native';
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
import { useNavigation } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { useRouter } from 'expo-router';
import { MaterialCommunityIcons } from '@expo/vector-icons';
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
import { colors, spacing, borderRadius, shadows } from '../../theme';
@@ -31,15 +30,12 @@ import { postService } from '../../services';
import { PostCard, TabBar, SearchBar } from '../../components/business';
import type { PostCardAction } from '../../components/business/PostCard';
import { Loading, EmptyState, Text, ImageGallery, ImageGridItem, ResponsiveGrid } from '../../components/common';
import { HomeStackParamList, RootStackParamList } from '../../navigation/types';
import { useResponsive, useResponsiveSpacing } from '../../hooks/useResponsive';
import { useDifferentialPosts } from '../../hooks/useDifferentialPosts';
import { processPostUseCase } from '../../core/usecases/ProcessPostUseCase';
import { SearchScreen } from './SearchScreen';
import { CreatePostScreen } from '../create/CreatePostScreen';
import { navigationService } from '../../infrastructure/navigation/navigationService';
type NavigationProp = NativeStackNavigationProp<HomeStackParamList, 'Home'> & NativeStackNavigationProp<RootStackParamList>;
import * as hrefs from '../../navigation/hrefs';
const TABS = ['最新', '关注', '热门'];
const TAB_ICONS = ['clock-outline', 'account-heart-outline', 'fire'];
@@ -54,7 +50,7 @@ type ViewMode = 'list' | 'grid';
type PostType = 'follow' | 'hot' | 'latest';
export const HomeScreen: React.FC = () => {
const navigation = useNavigation<NavigationProp>();
const router = useRouter();
const insets = useSafeAreaInsets();
const { posts: storePosts } = useUserStore();
const currentUser = useCurrentUser();
@@ -302,12 +298,12 @@ export const HomeScreen: React.FC = () => {
// 跳转到帖子详情
const handlePostPress = (postId: string, scrollToComments: boolean = false) => {
navigationService.navigate('PostDetail', { postId, scrollToComments });
router.push(hrefs.hrefPostDetail(postId, scrollToComments));
};
// 跳转到用户主页
const handleUserPress = (userId: string) => {
navigationService.navigate('UserProfile', { userId });
router.push(hrefs.hrefUserProfile(userId));
};
// 点赞帖子
@@ -563,10 +559,12 @@ export const HomeScreen: React.FC = () => {
/>
}
>
{distributePostsToColumns.map((column, index) => renderWaterfallColumn(column, index))}
{/* 加载更多指示器 */}
{isLoading && displayPosts.length > 0 && (
<View style={styles.loadingMore}>
<View style={styles.waterfallColumnsRow}>
{distributePostsToColumns.map((column, index) => renderWaterfallColumn(column, index))}
</View>
{/* 独立底部加载区:避免参与横向列布局导致列宽抖动 */}
{isLoadingMore && displayPosts.length > 0 && (
<View style={styles.loadingMoreFooter}>
<Loading size="sm" />
</View>
)}
@@ -808,8 +806,12 @@ const styles = StyleSheet.create({
flex: 1,
},
waterfallContainer: {
flexDirection: 'row',
width: '100%',
flexGrow: 1,
},
waterfallColumnsRow: {
width: '100%',
flexDirection: 'row',
alignItems: 'flex-start',
},
waterfallColumn: {
@@ -844,7 +846,7 @@ const styles = StyleSheet.create({
height: 72,
borderRadius: 36,
},
loadingMore: {
loadingMoreFooter: {
paddingVertical: 20,
alignItems: 'center',
justifyContent: 'center',