import { StyleConstants } from '@utils/styles/constants' import React, { createRef, Dispatch, useCallback, useEffect } from 'react' import { Animated, StyleSheet, View } from 'react-native' import AccountInformationAvatar from './Information/Avatar' import AccountInformationName from './Information/Name' import AccountInformationAccount from './Information/Account' import AccountInformationCreated from './Information/Created' import AccountInformationStats from './Information/Stats' import AccountInformationActions from './Information/Actions' import AccountInformationFields from './Information/Fields' import AccountInformationNotes from './Information/Notes' import { AccountAction } from '../Account' export interface Props { accountDispatch?: Dispatch account: Mastodon.Account | undefined disableActions?: boolean } const AccountInformation: React.FC = ({ accountDispatch, account, disableActions = false }) => { const shimmerAvatarRef = createRef() const shimmerNameRef = createRef() const shimmerAccountRef = createRef() const shimmerCreatedRef = createRef() const shimmerStatsRef = createRef() useEffect(() => { const informationAnimated = Animated.stagger(400, [ Animated.parallel([ shimmerAvatarRef.current?.getAnimated(), shimmerNameRef.current?.getAnimated(), shimmerAccountRef.current?.getAnimated(), shimmerCreatedRef.current?.getAnimated(), shimmerStatsRef.current?.ref1.getAnimated(), shimmerStatsRef.current?.ref2.getAnimated(), shimmerStatsRef.current?.ref3.getAnimated() ]) ]) Animated.loop(informationAnimated).start() }, []) const onLayout = useCallback( ({ nativeEvent }) => accountDispatch && accountDispatch({ type: 'informationLayout', payload: { y: nativeEvent.layout.y, height: nativeEvent.layout.height } }), [] ) return ( {/* Moved or not: {account.moved} */} {!disableActions ? ( ) : null} {account?.fields && account.fields.length > 0 ? ( ) : null} {account?.note && account.note.length > 0 && account.note !== '

' ? ( // Empty notes might generate empty p tag ) : null}
) } const styles = StyleSheet.create({ base: { marginTop: -StyleConstants.Spacing.Global.PagePadding * 3, padding: StyleConstants.Spacing.Global.PagePadding }, avatarAndActions: { flexDirection: 'row', justifyContent: 'space-between' } }) export default AccountInformation