import React, {useEffect} from 'react'; import {StyleSheet, View} from 'react-native'; import rpx from '@/utils/rpx'; import Animated, { useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated'; import {useAtomValue} from 'jotai'; import {scrollToTopAtom} from '../store/atoms'; import {Avatar} from 'react-native-paper'; import ThemeText from '@/components/base/themeText'; import Tag from '@/components/base/tag'; import {useRoute} from '@react-navigation/native'; const headerHeight = rpx(350); export default function Header() { const route = useRoute(); const artistItem: IArtist.IArtistItem = route.params?.artistItem ?? null; const heightValue = useSharedValue(headerHeight); const opacityValue = useSharedValue(1); const scrollToTopState = useAtomValue(scrollToTopAtom); const heightStyle = useAnimatedStyle(() => { return { height: heightValue.value, opacity: opacityValue.value, }; }); const avatar = artistItem.avatar?.startsWith('//') ? `https:${artistItem.avatar}` : artistItem.avatar; /** 折叠 */ useEffect(() => { if (scrollToTopState) { heightValue.value = withTiming(headerHeight); opacityValue.value = withTiming(1); } else { heightValue.value = withTiming(0); opacityValue.value = withTiming(0); } }, [scrollToTopState]); return ( {artistItem.name} {artistItem.platform && ( )} {artistItem.fans && ( 粉丝数: {artistItem.fans} )} {artistItem.description} ); } const style = StyleSheet.create({ wrapper: { width: rpx(750), height: headerHeight, backgroundColor: 'rgba(28, 28, 28, 0.1)', zIndex: 1, }, headerWrapper: { width: rpx(750), paddingTop: rpx(24), paddingHorizontal: rpx(24), height: rpx(240), flexDirection: 'row', alignItems: 'center', }, info: { marginLeft: rpx(24), justifyContent: 'space-around', height: rpx(144), }, title: { flexDirection: 'row', alignItems: 'center', }, titleText: { marginRight: rpx(18), maxWidth: rpx(400), }, description: { marginTop: rpx(24), width: rpx(750), paddingHorizontal: rpx(24), }, });