diff --git a/app/(tabs)/index.tsx b/app/(tabs)/index.tsx index c6b099f..fdc5663 100644 --- a/app/(tabs)/index.tsx +++ b/app/(tabs)/index.tsx @@ -18,6 +18,8 @@ import { useLikesTemplates } from '@/hooks/data/use-likes-templates' import { userBalanceStore, userStore } from '@/stores' import { screenWidth, storage } from '@/utils' import { cn } from '@/utils/cn' +import ParallelogramButton from '@/components/ParallelogramButton' +import ParallelogramShape from '@/components/ParallelogramShape' const CATEGORY_ID = process.env.EXPO_PUBLIC_INDEX_GROUP_ID const ITEM_WIDTH = Math.floor((screenWidth - 24 - 12 * 2) / 3) @@ -38,8 +40,7 @@ type MediaItem = { authorName?: string isLiked?: boolean } -type ActiveTab = 'gen' | '' | 'new' | 'like' - +type ActiveTab = 'gen' | 'HOT' | 'NEW' | 'LIKE' /** ========================= * Entry page * ========================= */ @@ -53,7 +54,7 @@ const Index = observer(function Index() { /** ================= 状态 ================= */ - const [activeTab, setActiveTab] = useState('') + const [activeTab, setActiveTab] = useState('HOT') const [isSearchOpen, setIsSearchOpen] = useState(false) const [allItems, setAllItems] = useState([]) @@ -142,7 +143,7 @@ const Index = observer(function Index() { const { page, pageSize, search, tab } = queryRef.current let newItems: MediaItem[] = [] - if (tab === 'like') { + if (tab === 'LIKE') { console.log('加载收藏列表,isAuthenticated=', isLogin) if (!isLogin) { setHasMore(false) @@ -155,7 +156,7 @@ const Index = observer(function Index() { .map((f) => transformTemplateToMediaItem(f.template as TemplateData)) || [] } } else { - const sortBy = tab === 'new' ? 'createdAt' : 'likeCount' + const sortBy = tab === 'NEW' ? 'createdAt' : 'likeCount' const { data } = await loadTemplates({ page, limit: pageSize, @@ -357,7 +358,7 @@ const Index = observer(function Index() { } const renderListEmpty = () => { - if (activeTab === 'like' && !isLogin) { + if (activeTab === 'LIKE' && !isLogin) { return ( @@ -526,35 +527,54 @@ const SearchOverlay = memo(function SearchOverlay({ isOpen, onSearch('') onClose?.() }, [onClose, onSearch]) - + const searchHeight = 48 + const closeSize = 48 + const skewOffset = 8 // 统一所有平行四边形的倾斜角度 + const padding = 2 + const searchWidth = screenWidth - 40 - 8 - closeSize if (!isOpen) return null return ( - - - + + + + + + + - - + + {/* 关闭按钮平行四边形 */} + + + + + + ) @@ -569,26 +589,63 @@ const GooActions = observer(function GooActions({ gooPoints, on const { isPolling } = userBalanceStore const isDev = __DEV__ const isLogin = userStore.isLogin + + const width = 100 + const height = 32 + const skewOffset = 8 // 统一所有平行四边形的倾斜角度 + const padding = 2 + + const addWidth = 40 + const addHeight = height + const addSkewOffset = 8 // 统一所有平行四边形的倾斜角度 + return ( {!!isLogin && ( - - {gooPoints} - - {isDev && isPolling && } - - )} + + + + {isDev && isPolling && } + {gooPoints} + + + + + + + + + + + + )} - + - + ) }) @@ -656,29 +713,30 @@ type FilterSectionProps = { const FilterSection = memo(function FilterSection({ activeTab, onChange }) { const tabs = useMemo( () => [ - { label: '最热', state: '' as const }, - { label: '最新', state: 'new' as const }, - { label: '喜欢', state: 'like' as const }, + { label: '最热', state: 'HOT' as const }, + { label: '最新', state: 'NEW' as const }, + { label: '喜欢', state: 'LIKE' as const }, ], [], ) return ( - + {tabs.map(({ label, state }) => { const isActive = activeTab === state + const buttonWidth = Math.max(label.length * 13 + 12, 66) // 最小宽度 70,适应13px字体 + const buttonHeight = 30 // 稍微增加高度以适应13px字体 return ( - onChange(state)} - style={{ - transform: [{ skewX: '-6deg' }], - }} - > - {label} - + label={label} + state={state} + isActive={isActive} + onPress={() => onChange(state)} + width={buttonWidth} + height={buttonHeight} + /> ) })}