u
This commit is contained in:
1 parent
46106d0c76
commit
34240d2e16
36 files changed
+2853
-165
No files matched your search
@@ -3,7 +3,6 @@ import type { NavItem } from '@/store/navigation'
|
||||
import { Slot, usePathname, useRouter } from 'expo-router'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { Text, TouchableOpacity, View } from 'react-native'
|
||||
import { KeyboardAvoidingView } from 'react-native-keyboard-controller'
|
||||
import Animated, { useAnimatedRef } from 'react-native-reanimated'
|
||||
import Sortable from 'react-native-sortables'
|
||||
import { ADrawer, LucideIcon } from '@/components/common/ao'
|
||||
@@ -72,14 +71,13 @@ export default function TabsLayout() {
|
||||
return (
|
||||
<View className="flex-1 bg-gray-100">
|
||||
<View className="flex-1 bg-white">
|
||||
<KeyboardAvoidingView
|
||||
behavior="padding"
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
}}
|
||||
>
|
||||
<Slot />
|
||||
</KeyboardAvoidingView>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useNavigation } from 'expo-router'
|
||||
import React, { useState } from 'react'
|
||||
import { Text, View } from 'react-native'
|
||||
import { AButton, AModal } from '@/components/common/ao'
|
||||
@@ -7,6 +8,9 @@ import { useSpaceStore } from '@/store/space'
|
||||
export default function TestScreen() {
|
||||
const [showDissolve, setShowDissolve] = useState(false)
|
||||
const spaceStore = useSpaceStore()
|
||||
const navigation = useNavigation()
|
||||
|
||||
console.log(navigation.getState()?.routes)
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
||||
|
||||
+8
-8
@@ -1,4 +1,4 @@
|
||||
import type { MoneyCategoryItem } from '@/types/money/category'
|
||||
import type { FinanceCategory } from '@/types/finance/category'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { AInput, LucideIcon } from '@/components/common/ao'
|
||||
import EmptyState from '@/components/common/EmptyStatus'
|
||||
@@ -16,15 +16,15 @@ import {
|
||||
|
||||
interface CategorySection {
|
||||
title: string
|
||||
data: MoneyCategoryItem[]
|
||||
data: FinanceCategory[]
|
||||
}
|
||||
|
||||
interface CategorySheetProps {
|
||||
open?: boolean
|
||||
moneyCategories?: MoneyCategoryItem[]
|
||||
moneyCategories?: FinanceCategory[]
|
||||
value?: number | null
|
||||
onClose?: () => void
|
||||
onSelect?: (category: MoneyCategoryItem) => void
|
||||
onSelect?: (category: FinanceCategory) => void
|
||||
}
|
||||
|
||||
export default function CategorySheet({
|
||||
@@ -45,7 +45,7 @@ export default function CategorySheet({
|
||||
} | null>(null)
|
||||
|
||||
const handleSelect = useCallback(
|
||||
(item: MoneyCategoryItem) => {
|
||||
(item: FinanceCategory) => {
|
||||
onSelect?.(item)
|
||||
onClose?.()
|
||||
},
|
||||
@@ -56,7 +56,7 @@ export default function CategorySheet({
|
||||
id: number,
|
||||
name: string,
|
||||
type: number,
|
||||
): MoneyCategoryItem {
|
||||
): FinanceCategory {
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
@@ -188,9 +188,9 @@ export default function CategorySheet({
|
||||
}, 0)
|
||||
}}
|
||||
keyExtractor={(item, index) =>
|
||||
String((item as MoneyCategoryItem).id ?? index)}
|
||||
String((item as FinanceCategory).id ?? index)}
|
||||
renderItem={({ item }) => {
|
||||
const category = item as MoneyCategoryItem
|
||||
const category = item as FinanceCategory
|
||||
const selected = value === category.id
|
||||
|
||||
return (
|
||||
+6
-7
@@ -1,7 +1,6 @@
|
||||
import type { MoneyRecord, MoneyRecordGroup } from '@/types/money/record'
|
||||
import type { FinanceRecord, FinanceRecordGroup } from '@/types/finance/record'
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import { Pressable, RefreshControl, SectionList, Text, Vibration, View } from 'react-native'
|
||||
|
||||
import { LucideIcon } from '@/components/common/ao'
|
||||
import EmptyState from '@/components/common/EmptyStatus'
|
||||
import MoneyCategoryIcon from '@/components/common/MoneyCategoryIcon'
|
||||
@@ -11,8 +10,8 @@ import { useUserStore } from '@/store/user'
|
||||
import { MoneyCategoryEnum } from '@/types/money/category'
|
||||
|
||||
interface StaticTransactionsProps {
|
||||
records: MoneyRecordGroup[]
|
||||
onUpdate?: (data: MoneyRecord) => void
|
||||
records: FinanceRecordGroup[]
|
||||
onUpdate?: (data: FinanceRecord) => void
|
||||
onDelete?: (id: number) => void
|
||||
onDetail?: (id: number) => void
|
||||
onRefreshData?: () => void
|
||||
@@ -163,9 +162,9 @@ export default function StaticTransactions({
|
||||
{item.remark ? item.remark : category?.name}
|
||||
</Text>
|
||||
{
|
||||
item.user_id !== userID && (
|
||||
item.member_id !== userID && (
|
||||
<Text className="text-gray-500 text-xs italic">
|
||||
{item.username}
|
||||
{item.member_name}
|
||||
</Text>
|
||||
)
|
||||
}
|
||||
@@ -186,7 +185,7 @@ export default function StaticTransactions({
|
||||
}}
|
||||
>
|
||||
{
|
||||
userID === item.user_id && (
|
||||
userID === item.member_id && (
|
||||
<>
|
||||
<MenuItem
|
||||
key="update"
|
||||
+26
-23
@@ -1,24 +1,25 @@
|
||||
import type { DateMorePickerMode } from '@/components/common/ao/DateMorePicker'
|
||||
import { useFocusEffect, useRouter } from 'expo-router'
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import React, { useCallback, useEffect, useState } from 'react'
|
||||
import { Image, Text, TouchableOpacity, View } from 'react-native'
|
||||
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||
import { ADateMorePicker, ADatePicker, ADrawer, AListItem, LucideIcon } from '@/components/common/ao'
|
||||
import { resolveDateRange } from '@/components/common/ao/DateMorePicker'
|
||||
import { Fab, FabIcon } from '@/components/ui/fab'
|
||||
import { AddIcon } from '@/components/ui/icon'
|
||||
import { listFinanceRecordsApi } from '@/request/api/finance/record'
|
||||
import { deleteMoneyRecordApi, listMoneyRecordsApi } from '@/request/api/money/record'
|
||||
import { useMoneyCategoryStore } from '@/store/moneyCategory'
|
||||
import { useMoneyRecordStore } from '@/store/moneyRecord'
|
||||
import { useFinanceStore } from '@/store/finance'
|
||||
import { getCurrentYearMonth, normalizeDateTime } from '@/utils/time'
|
||||
import { toast } from '@/utils/toast'
|
||||
import CategorySheet from './components/CategorySheet'
|
||||
import TransactionsList from './components/TransactionsList'
|
||||
|
||||
export default function Money() {
|
||||
const moneyRecordStore = useMoneyRecordStore()
|
||||
const moneyCategoryStore = useMoneyCategoryStore()
|
||||
const router = useRouter()
|
||||
|
||||
const financeStore = useFinanceStore()
|
||||
|
||||
// 安全高度
|
||||
const insets = useSafeAreaInsets()
|
||||
|
||||
@@ -37,17 +38,16 @@ export default function Money() {
|
||||
// 操作菜单
|
||||
const [showActionsMenu, setShowActionsMenu] = useState(false)
|
||||
|
||||
function fetchMoneyRecords() {
|
||||
console.log(searchParams)
|
||||
|
||||
function fetchFinanceRecords() {
|
||||
const resolveDate = resolveDateRange(dateMode, searchParams.startTime)
|
||||
|
||||
listMoneyRecordsApi({
|
||||
listFinanceRecordsApi({
|
||||
start_time: resolveDate.startTime,
|
||||
end_time: resolveDate.endTime,
|
||||
category_id: 0,
|
||||
}).then((res) => {
|
||||
if (res.isSuccess) {
|
||||
moneyRecordStore.setRecords(res.data.records || [])
|
||||
financeStore.setRecords(res.data.records || [])
|
||||
}
|
||||
else {
|
||||
toast.show({
|
||||
@@ -58,9 +58,11 @@ export default function Money() {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
fetchMoneyRecords()
|
||||
financeStore.ensureCategoriesLoaded()
|
||||
fetchFinanceRecords()
|
||||
}, [searchParams.startTime, searchParams.endTime]),
|
||||
)
|
||||
|
||||
@@ -69,7 +71,7 @@ export default function Money() {
|
||||
id,
|
||||
})
|
||||
|
||||
fetchMoneyRecords()
|
||||
fetchFinanceRecords()
|
||||
}
|
||||
|
||||
function timeModeTip() {
|
||||
@@ -147,7 +149,7 @@ export default function Money() {
|
||||
numberOfLines={1}
|
||||
ellipsizeMode="tail"
|
||||
>
|
||||
{moneyRecordStore.getTotalIncome()}
|
||||
{financeStore.getTotalIncome()}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
@@ -158,7 +160,7 @@ export default function Money() {
|
||||
numberOfLines={1}
|
||||
ellipsizeMode="tail"
|
||||
>
|
||||
{moneyRecordStore.getTotalExpense()}
|
||||
{financeStore.getTotalExpense()}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
@@ -169,7 +171,7 @@ export default function Money() {
|
||||
numberOfLines={1}
|
||||
ellipsizeMode="tail"
|
||||
>
|
||||
{moneyRecordStore.getTotalBalance()}
|
||||
{financeStore.getTotalBalance()}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
@@ -178,16 +180,16 @@ export default function Money() {
|
||||
|
||||
<View className="flex-1 mt-2">
|
||||
<TransactionsList
|
||||
records={moneyRecordStore.records}
|
||||
records={financeStore.records}
|
||||
onUpdate={(data) => {
|
||||
router.navigate({
|
||||
pathname: '/money/record/editor',
|
||||
router.push({
|
||||
pathname: '/finance/record/editor',
|
||||
params: { id: data.id },
|
||||
})
|
||||
}}
|
||||
onDetail={(id) => {
|
||||
router.navigate({
|
||||
pathname: '/money/record/detail',
|
||||
pathname: '/finance/record/detail',
|
||||
params: { id },
|
||||
})
|
||||
}}
|
||||
@@ -195,7 +197,7 @@ export default function Money() {
|
||||
handleDeleteRecord(id)
|
||||
}}
|
||||
onRefreshData={() => {
|
||||
fetchMoneyRecords()
|
||||
fetchFinanceRecords()
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
@@ -203,7 +205,7 @@ export default function Money() {
|
||||
<Fab
|
||||
size="lg"
|
||||
onPress={() => {
|
||||
router.navigate('/money/record/editor')
|
||||
router.navigate('/finance/record/editor')
|
||||
}}
|
||||
>
|
||||
<FabIcon as={AddIcon} size="xl" />
|
||||
@@ -247,7 +249,7 @@ export default function Money() {
|
||||
<CategorySheet
|
||||
open={showCategorySheet}
|
||||
value={searchParams.category}
|
||||
moneyCategories={moneyCategoryStore.categories}
|
||||
moneyCategories={financeStore.categories}
|
||||
onClose={() => {
|
||||
setShowCategorySheet(false)
|
||||
}}
|
||||
@@ -283,7 +285,8 @@ export default function Money() {
|
||||
icon="LayoutGrid"
|
||||
text="类别设置"
|
||||
onPress={() => {
|
||||
router.navigate('/money/category/setting')
|
||||
// router.navigate('/money/category/setting')
|
||||
router.push('/finance/category')
|
||||
setShowActionsMenu(false)
|
||||
}}
|
||||
/>
|
||||
@@ -26,21 +26,21 @@ export default function Index() {
|
||||
|
||||
{/* <AButton
|
||||
className="w-full"
|
||||
onPress={() => ('/money')}
|
||||
onPress={() => ('/finance')}
|
||||
>
|
||||
开始使用
|
||||
</AButton> */}
|
||||
<View className="flex flex-row gap-3 mt-4">
|
||||
<AButton
|
||||
className="flex-1"
|
||||
onPress={() => ('/money')}
|
||||
onPress={() => ('/finance')}
|
||||
>
|
||||
创建空间
|
||||
</AButton>
|
||||
<AButton
|
||||
className="flex-1"
|
||||
variant="outline"
|
||||
onPress={() => ('/money')}
|
||||
onPress={() => ('/finance')}
|
||||
>
|
||||
加入空间
|
||||
</AButton>
|
||||
|
||||
Reference in new issue
Block a user