refactor(ui): implement custom header system and unify screen layouts
Refactor the navigation and header strategy by replacing native stack headers with a custom `SimpleHeader` component across most profile and detail screens. This provides a more consistent UI/UX and better control over layout behavior. - Implement `SimpleHeader` component in `src/components/common`. - Disable native header rendering in `app/(app)/(tabs)/profile/_layout.tsx` and `app/_layout.tsx`. - Update profile sub-screens to use `SimpleHeader` and `StatusBar` from `expo-status-bar`. - Refactor `PostDetailScreen` to use a custom header implementation for better integration with the post author information. - Update `UserScreen` to wrap content in `SafeAreaView` with the new header. - Adjust `AppBackButton` to support transparent backgrounds.
This commit is contained in:
@@ -5,22 +5,28 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { useLocalSearchParams } from 'expo-router';
|
||||
import { useLocalSearchParams, useRouter } from 'expo-router';
|
||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
import UserProfileScreen from './UserProfileScreen';
|
||||
import { useCurrentUser } from '../../stores/auth';
|
||||
import { SimpleHeader } from '../../components/common';
|
||||
|
||||
export const UserScreen: React.FC = () => {
|
||||
const { userId: userIdParam } = useLocalSearchParams<{ userId?: string }>();
|
||||
const router = useRouter();
|
||||
const userId = userIdParam || '';
|
||||
const currentUser = useCurrentUser();
|
||||
const isSelfProfile = !!currentUser?.id && currentUser.id === userId;
|
||||
|
||||
|
||||
return (
|
||||
<UserProfileScreen
|
||||
mode={isSelfProfile ? 'self' : 'other'}
|
||||
userId={isSelfProfile ? undefined : userId}
|
||||
hasHeader
|
||||
/>
|
||||
<SafeAreaView style={{ flex: 1 }} edges={['top', 'bottom']}>
|
||||
<SimpleHeader title="用户主页" onBack={() => router.back()} />
|
||||
<UserProfileScreen
|
||||
mode={isSelfProfile ? 'self' : 'other'}
|
||||
userId={isSelfProfile ? undefined : userId}
|
||||
hasHeader={false}
|
||||
/>
|
||||
</SafeAreaView>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user