修复了课程表和发帖按钮

This commit is contained in:
2026-03-18 00:25:46 +08:00
parent b50bd9abb3
commit 71b4f8a679
6 changed files with 130 additions and 68 deletions

View File

@@ -17,6 +17,7 @@ import {
NativeSyntheticEvent,
Alert,
Clipboard,
Modal,
} from 'react-native';
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
import { useNavigation } from '@react-navigation/native';
@@ -33,6 +34,7 @@ import { Loading, EmptyState, Text, ImageGallery, ImageGridItem, ResponsiveGrid
import { HomeStackParamList, RootStackParamList } from '../../navigation/types';
import { useResponsive, useResponsiveSpacing } from '../../hooks/useResponsive';
import { SearchScreen } from './SearchScreen';
import { CreatePostScreen } from '../create/CreatePostScreen';
type NavigationProp = NativeStackNavigationProp<HomeStackParamList, 'Home'> & NativeStackNavigationProp<RootStackParamList>;
@@ -88,6 +90,9 @@ export const HomeScreen: React.FC = () => {
// 搜索显示状态(用于内嵌搜索页面)
const [showSearch, setShowSearch] = useState(false);
// 发帖弹窗状态
const [showCreatePost, setShowCreatePost] = useState(false);
// 用于跟踪当前页面显示的帖子 ID以便从 store 同步状态
const postIdsRef = React.useRef<Set<string>>(new Set());
const inFlightRequestKeysRef = React.useRef<Set<string>>(new Set());
@@ -144,7 +149,8 @@ export const HomeScreen: React.FC = () => {
if (!isMobile) {
return undefined;
}
return insets.bottom + MOBILE_TAB_BAR_HEIGHT + MOBILE_TAB_FLOATING_MARGIN + MOBILE_FAB_GAP;
// 往底部导航栏靠近一个按钮的位置
return insets.bottom + MOBILE_TAB_BAR_HEIGHT + MOBILE_TAB_FLOATING_MARGIN + MOBILE_FAB_GAP - MOBILE_TAB_BAR_HEIGHT;
}, [isMobile, insets.bottom]);
const appendUniquePosts = useCallback((prevPosts: Post[], incomingPosts: Post[]) => {
@@ -398,9 +404,9 @@ export const HomeScreen: React.FC = () => {
setShowImageViewer(true);
};
// 跳转到发帖页面
// 跳转到发帖页面(使用 Modal 方式)
const handleCreatePost = () => {
navigation.getParent()?.navigate('CreatePost');
setShowCreatePost(true);
};
// 渲染帖子卡片(列表模式)
@@ -733,6 +739,18 @@ export const HomeScreen: React.FC = () => {
onClose={() => setShowImageViewer(false)}
enableSave
/>
{/* 发帖弹窗 */}
<Modal
visible={showCreatePost}
animationType="slide"
presentationStyle="pageSheet"
onRequestClose={() => setShowCreatePost(false)}
>
<CreatePostScreen
onClose={() => setShowCreatePost(false)}
/>
</Modal>
</SafeAreaView>
);
};