2021-01-30 01:29:15 +01:00
|
|
|
import ComponentInstance from '@components/Instance'
|
2021-01-03 02:00:26 +01:00
|
|
|
import { useScrollToTop } from '@react-navigation/native'
|
2021-01-30 01:29:15 +01:00
|
|
|
import Collections from '@screens/Tabs/Me/Root/Collections'
|
|
|
|
import Logout from '@screens/Tabs/Me/Root/Logout'
|
|
|
|
import MyInfo from '@screens/Tabs/Me/Root/MyInfo'
|
|
|
|
import Settings from '@screens/Tabs/Me/Root/Settings'
|
2021-05-09 21:59:03 +02:00
|
|
|
import AccountInformationSwitch from '@screens/Tabs/Me/Root/Switch'
|
2023-01-02 02:08:12 +01:00
|
|
|
import AccountContext from '@screens/Tabs/Shared/Account/Context'
|
2021-01-30 01:29:15 +01:00
|
|
|
import AccountNav from '@screens/Tabs/Shared/Account/Nav'
|
2021-05-09 21:59:03 +02:00
|
|
|
import { useProfileQuery } from '@utils/queryHooks/profile'
|
2022-12-28 23:41:36 +01:00
|
|
|
import { useGlobalStorage } from '@utils/storage/actions'
|
2023-05-15 22:30:18 +02:00
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
2023-01-02 02:08:12 +01:00
|
|
|
import React, { useRef } from 'react'
|
2023-05-15 22:30:18 +02:00
|
|
|
import { View } from 'react-native'
|
2022-12-21 14:42:44 +01:00
|
|
|
import Animated, { useAnimatedScrollHandler, useSharedValue } from 'react-native-reanimated'
|
2020-11-21 13:19:05 +01:00
|
|
|
|
2021-05-09 21:59:03 +02:00
|
|
|
const TabMeRoot: React.FC = () => {
|
2022-12-28 23:41:36 +01:00
|
|
|
const [accountActive] = useGlobalStorage.string('account.active')
|
2021-05-09 21:59:03 +02:00
|
|
|
|
|
|
|
const { data } = useProfileQuery({
|
2022-12-28 23:41:36 +01:00
|
|
|
options: { enabled: !!accountActive, keepPreviousData: false }
|
2021-04-24 15:03:17 +02:00
|
|
|
})
|
2020-11-21 13:19:05 +01:00
|
|
|
|
2021-01-04 10:50:24 +01:00
|
|
|
const scrollRef = useRef<Animated.ScrollView>(null)
|
2020-12-13 23:02:54 +01:00
|
|
|
useScrollToTop(scrollRef)
|
|
|
|
|
2021-01-04 10:50:24 +01:00
|
|
|
const scrollY = useSharedValue(0)
|
|
|
|
const onScroll = useAnimatedScrollHandler(event => {
|
|
|
|
scrollY.value = event.contentOffset.y
|
|
|
|
})
|
|
|
|
|
2020-11-22 00:46:23 +01:00
|
|
|
return (
|
2023-02-25 23:42:04 +01:00
|
|
|
<AccountContext.Provider value={{ account: data, pageMe: true, localInstance: true }}>
|
2023-01-02 02:08:12 +01:00
|
|
|
{accountActive && data ? <AccountNav scrollY={scrollY} /> : null}
|
2021-01-04 10:50:24 +01:00
|
|
|
<Animated.ScrollView
|
2020-12-18 00:00:45 +01:00
|
|
|
ref={scrollRef}
|
|
|
|
keyboardShouldPersistTaps='handled'
|
2021-01-04 10:50:24 +01:00
|
|
|
onScroll={onScroll}
|
|
|
|
scrollEventThrottle={16}
|
2020-12-18 00:00:45 +01:00
|
|
|
>
|
2023-01-02 02:08:12 +01:00
|
|
|
{accountActive ? <MyInfo /> : <ComponentInstance />}
|
2022-12-28 23:41:36 +01:00
|
|
|
{accountActive ? <Collections /> : null}
|
2020-12-18 00:00:45 +01:00
|
|
|
<Settings />
|
2023-05-15 22:30:18 +02:00
|
|
|
{accountActive ? (
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
flexDirection: 'row',
|
|
|
|
marginHorizontal: StyleConstants.Spacing.Global.PagePadding,
|
|
|
|
marginTop: StyleConstants.Spacing.S,
|
|
|
|
marginBottom: StyleConstants.Spacing.XL,
|
|
|
|
gap: StyleConstants.Spacing.M
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Logout />
|
|
|
|
<AccountInformationSwitch />
|
|
|
|
</View>
|
|
|
|
) : null}
|
2021-01-04 10:50:24 +01:00
|
|
|
</Animated.ScrollView>
|
2021-01-03 02:00:26 +01:00
|
|
|
</AccountContext.Provider>
|
2020-11-22 00:46:23 +01:00
|
|
|
)
|
2020-11-21 13:19:05 +01:00
|
|
|
}
|
|
|
|
|
2021-05-09 21:59:03 +02:00
|
|
|
export default TabMeRoot
|