u
This commit is contained in:
1 parent
295b3306a3
commit
c62c9d080b
8 files changed
+878
-136
No files matched your search
@@ -1,7 +1,10 @@
|
||||
import type { ViewStyle } from 'react-native'
|
||||
import { useRouter } from 'expo-router'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { Animated, Text, TouchableOpacity, View } from 'react-native'
|
||||
import { Animated, Image, Text, TouchableOpacity, View } from 'react-native'
|
||||
|
||||
import PagerView from 'react-native-pager-view'
|
||||
import { LucideIcon } from '../common/ao'
|
||||
|
||||
export interface PagerRoute {
|
||||
key: string
|
||||
@@ -16,6 +19,7 @@ interface PagerTabsProps {
|
||||
selectedIndex?: number // 外部控制选中页
|
||||
onChange?: (key: string) => void
|
||||
indicatorWidth?: number
|
||||
showCustomHeader?: boolean
|
||||
|
||||
className?: string
|
||||
style?: ViewStyle
|
||||
@@ -28,9 +32,12 @@ export default function PagerTabs({
|
||||
selectedIndex,
|
||||
onChange,
|
||||
indicatorWidth = 38,
|
||||
showCustomHeader,
|
||||
className,
|
||||
style,
|
||||
}: PagerTabsProps) {
|
||||
const router = useRouter()
|
||||
|
||||
const pagerRef = useRef<PagerView>(null)
|
||||
const [index, setIndex] = useState(selectedIndex ?? 0)
|
||||
const [tabWidth, setTabWidth] = useState(0)
|
||||
@@ -80,7 +87,15 @@ export default function PagerTabs({
|
||||
>
|
||||
{/* Header */}
|
||||
<View className="flex flex-row items-center">
|
||||
{left}
|
||||
{left || (showCustomHeader
|
||||
? (
|
||||
<View className="w-10 items-center justify-center">
|
||||
<TouchableOpacity onPress={() => router.back()}>
|
||||
<LucideIcon icon="ChevronLeft" size={28} clickable={false} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
)
|
||||
: null)}
|
||||
|
||||
{/* Tabs */}
|
||||
<View
|
||||
@@ -116,7 +131,16 @@ export default function PagerTabs({
|
||||
)}
|
||||
</View>
|
||||
|
||||
{right}
|
||||
{right || (showCustomHeader
|
||||
? (
|
||||
<View className="w-10 items-center justify-center">
|
||||
<Image
|
||||
source={require('@/static/images/logo.png')}
|
||||
style={{ width: 22, height: 22 }}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
: null)}
|
||||
</View>
|
||||
|
||||
{/* Pager */}
|
||||
|
||||
Reference in new issue
Block a user