This commit is contained in:
oneao committed 2025-11-19 17:30:44 +08:00
1 parent 7419021927
commit 49285f1df2
16 files changed
+1184 -283

No files matched your search

@@ -1,125 +1,33 @@
import * as React from 'react'
import { Pressable, StyleSheet, Text, useWindowDimensions, View } from 'react-native'
import { SafeAreaView } from 'react-native-safe-area-context'
import { TabView } from 'react-native-tab-view'
import { Text, View } from 'react-native'
import PagerTabs from '@/components/custom/PagerTabs'
// 两个示例页面
function PageOne() {
export default function Demo() {
return (
<View style={styles.page}>
<Text style={{ fontSize: 18 }}>第一页内容</Text>
</View>
)
}
function PageTwo() {
return (
<View style={styles.page}>
<Text style={{ fontSize: 18 }}>第二页内容</Text>
</View>
)
}
export default function SimpleTabView() {
const layout = useWindowDimensions()
const [index, setIndex] = React.useState(0)
const routes = [
{ key: 'one', title: 'Tab 1' },
{ key: 'two', title: 'Tab 2' },
]
const renderScene = ({ route }: { route: { key: string } }) => {
switch (route.key) {
case 'one':
return <PageOne />
case 'two':
return <PageTwo />
default:
return null
}
}
return (
<SafeAreaView style={{ flex: 1, backgroundColor: '#fff' }}>
{/* Header + Tab */}
<View style={styles.header}>
<Pressable onPress={() => console.log('Left button clicked')}>
<Text style={styles.headerButton}>返回</Text>
</Pressable>
<View style={styles.tabContainer}>
{routes.map((r, i) => {
const focused = i === index
return (
<Pressable key={r.key} onPress={() => setIndex(i)} style={styles.tabButton}>
<Text style={[styles.tabText, focused && styles.tabTextActive]}>{r.title}</Text>
{focused && <View style={styles.underline} />}
</Pressable>
)
})}
</View>
<Pressable onPress={() => console.log('Right button clicked')}>
<Text style={styles.headerButton}>添加</Text>
</Pressable>
</View>
{/* TabView */}
<TabView
navigationState={{ index, routes }}
renderScene={renderScene}
onIndexChange={setIndex}
initialLayout={{ width: layout.width }}
renderTabBar={() => null} // 不使用默认 TabBar
<View className="flex-1">
<PagerTabs
left={(
<View className="w-[20%]">
<Text>Left</Text>
</View>
)}
right={(
<View className="w-[20%]">
<Text>right</Text>
</View>
)}
routes={[
{
key: 'tab1',
title: 'Tab 1',
element: <Text className="text-lg">第一个页面内容</Text>,
},
{
key: 'tab2',
title: 'Tab 2',
element: <Text className="text-lg">第二个页面内容</Text>,
},
]}
/>
<View><Text>123</Text></View>
</SafeAreaView>
</View>
)
}
const styles = StyleSheet.create({
header: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingHorizontal: 16,
paddingVertical: 8,
borderBottomWidth: 0.5,
borderColor: '#ddd',
},
headerButton: {
fontSize: 16,
color: '#007AFF',
},
tabContainer: {
flexDirection: 'row',
justifyContent: 'center',
flex: 1,
},
tabButton: {
marginHorizontal: 12,
alignItems: 'center',
paddingVertical: 4,
},
tabText: {
fontSize: 16,
color: '#666',
},
tabTextActive: {
color: '#007AFF',
fontWeight: 'bold',
},
underline: {
height: 2,
backgroundColor: '#007AFF',
width: '100%',
marginTop: 2,
},
page: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
})
@@ -110,7 +110,6 @@ export default function AddMoneyDrawer({
moneyCategoryStore.setCategories(res.data)
}
}
console.log(moneyCategoryStore.categories)
}
catch (err) {
console.error('获取分类失败', err)
@@ -1,4 +1,5 @@
import type { MoneyRecordGroup, MoneyRecordItem, QueryMoneyRecordsResult } from '@/types/money/record'
import { useRouter } from 'expo-router'
import React, { useEffect, useState } from 'react'
import { Text, TouchableOpacity, TouchableWithoutFeedback, View } from 'react-native'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
@@ -14,6 +15,7 @@ import AddMoneyDrawer from './components/AddDrawer'
import TransactionsList from './components/TransactionsList'
export default function Money() {
const router = useRouter()
const [showAddDrawer, setShowAddDrawer] = useState(false)
// 安全高度
const insets = useSafeAreaInsets()
@@ -386,7 +388,8 @@ export default function Money() {
<Fab
size="lg"
onPress={() => {
setShowAddDrawer(true)
// setShowAddDrawer(true)
router.navigate('/money/record/editor')
}}
>
<FabIcon as={AddIcon} size="xl" />