14060c00aS猫头猫import React, {useEffect} from 'react'; 24060c00aS猫头猫import {StyleSheet, View} from 'react-native'; 3be474dd8S猫头猫import rpx from '@/utils/rpx'; 420e2869eS猫头猫import Animated, { 520e2869eS猫头猫 useAnimatedStyle, 620e2869eS猫头猫 useSharedValue, 720e2869eS猫头猫 withTiming, 820e2869eS猫头猫} from 'react-native-reanimated'; 920e2869eS猫头猫import {useAtomValue} from 'jotai'; 1020e2869eS猫头猫import {scrollToTopAtom} from '../store/atoms'; 1120e2869eS猫头猫import {Avatar} from 'react-native-paper'; 1220e2869eS猫头猫import ThemeText from '@/components/base/themeText'; 1320e2869eS猫头猫import Tag from '@/components/base/tag'; 14e7fa3837S猫头猫import {useParams} from '@/entry/router'; 15be474dd8S猫头猫 1620e2869eS猫头猫const headerHeight = rpx(350); 174060c00aS猫头猫export default function Header() { 18e7fa3837S猫头猫 const {artistItem} = useParams<'artist-detail'>(); 1920e2869eS猫头猫 2020e2869eS猫头猫 const heightValue = useSharedValue(headerHeight); 2120e2869eS猫头猫 const opacityValue = useSharedValue(1); 2220e2869eS猫头猫 const scrollToTopState = useAtomValue(scrollToTopAtom); 2320e2869eS猫头猫 2420e2869eS猫头猫 const heightStyle = useAnimatedStyle(() => { 2520e2869eS猫头猫 return { 2620e2869eS猫头猫 height: heightValue.value, 2720e2869eS猫头猫 opacity: opacityValue.value, 2820e2869eS猫头猫 }; 2920e2869eS猫头猫 }); 3020e2869eS猫头猫 3120e2869eS猫头猫 const avatar = artistItem.avatar?.startsWith('//') 3220e2869eS猫头猫 ? `https:${artistItem.avatar}` 3320e2869eS猫头猫 : artistItem.avatar; 3420e2869eS猫头猫 3520e2869eS猫头猫 /** 折叠 */ 3620e2869eS猫头猫 useEffect(() => { 3720e2869eS猫头猫 if (scrollToTopState) { 3820e2869eS猫头猫 heightValue.value = withTiming(headerHeight); 3920e2869eS猫头猫 opacityValue.value = withTiming(1); 4020e2869eS猫头猫 } else { 4120e2869eS猫头猫 heightValue.value = withTiming(0); 4220e2869eS猫头猫 opacityValue.value = withTiming(0); 4320e2869eS猫头猫 } 4420e2869eS猫头猫 }, [scrollToTopState]); 4520e2869eS猫头猫 4620e2869eS猫头猫 return ( 4720e2869eS猫头猫 <Animated.View style={[style.wrapper, heightStyle]}> 4820e2869eS猫头猫 <View style={style.headerWrapper}> 494060c00aS猫头猫 <Avatar.Image size={rpx(144)} source={{uri: avatar}} /> 5020e2869eS猫头猫 <View style={style.info}> 5120e2869eS猫头猫 <View style={style.title}> 5220e2869eS猫头猫 <ThemeText 5320e2869eS猫头猫 fontSize="title" 5420e2869eS猫头猫 style={style.titleText} 5520e2869eS猫头猫 numberOfLines={1} 5620e2869eS猫头猫 ellipsizeMode="tail"> 57*c9fce3b5S猫头猫 {artistItem?.name ?? ''} 5820e2869eS猫头猫 </ThemeText> 59*c9fce3b5S猫头猫 {artistItem.platform ? ( 604060c00aS猫头猫 <Tag tagName={artistItem.platform} /> 61*c9fce3b5S猫头猫 ) : ( 62*c9fce3b5S猫头猫 <></> 634060c00aS猫头猫 )} 6420e2869eS猫头猫 </View> 6520e2869eS猫头猫 66*c9fce3b5S猫头猫 {artistItem.fans ? ( 6720e2869eS猫头猫 <ThemeText fontSize="subTitle" fontColor="secondary"> 6820e2869eS猫头猫 粉丝数: {artistItem.fans} 6920e2869eS猫头猫 </ThemeText> 70*c9fce3b5S猫头猫 ) : ( 71*c9fce3b5S猫头猫 <></> 7220e2869eS猫头猫 )} 7320e2869eS猫头猫 </View> 7420e2869eS猫头猫 </View> 7520e2869eS猫头猫 7620e2869eS猫头猫 <ThemeText 7720e2869eS猫头猫 style={style.description} 7820e2869eS猫头猫 numberOfLines={2} 7920e2869eS猫头猫 ellipsizeMode="tail" 8020e2869eS猫头猫 fontColor="secondary" 8120e2869eS猫头猫 fontSize="description"> 82*c9fce3b5S猫头猫 {artistItem?.description ?? ''} 8320e2869eS猫头猫 </ThemeText> 8420e2869eS猫头猫 </Animated.View> 8520e2869eS猫头猫 ); 86be474dd8S猫头猫} 87be474dd8S猫头猫 88be474dd8S猫头猫const style = StyleSheet.create({ 89be474dd8S猫头猫 wrapper: { 90be474dd8S猫头猫 width: rpx(750), 9120e2869eS猫头猫 height: headerHeight, 9220e2869eS猫头猫 backgroundColor: 'rgba(28, 28, 28, 0.1)', 9320e2869eS猫头猫 zIndex: 1, 9420e2869eS猫头猫 }, 9520e2869eS猫头猫 headerWrapper: { 9620e2869eS猫头猫 width: rpx(750), 9720e2869eS猫头猫 paddingTop: rpx(24), 9820e2869eS猫头猫 paddingHorizontal: rpx(24), 9920e2869eS猫头猫 height: rpx(240), 10020e2869eS猫头猫 flexDirection: 'row', 10120e2869eS猫头猫 alignItems: 'center', 10220e2869eS猫头猫 }, 10320e2869eS猫头猫 info: { 10420e2869eS猫头猫 marginLeft: rpx(24), 10520e2869eS猫头猫 justifyContent: 'space-around', 10620e2869eS猫头猫 height: rpx(144), 10720e2869eS猫头猫 }, 10820e2869eS猫头猫 title: { 10920e2869eS猫头猫 flexDirection: 'row', 11020e2869eS猫头猫 alignItems: 'center', 11120e2869eS猫头猫 }, 11220e2869eS猫头猫 titleText: { 11320e2869eS猫头猫 marginRight: rpx(18), 11420e2869eS猫头猫 maxWidth: rpx(400), 11520e2869eS猫头猫 }, 11620e2869eS猫头猫 description: { 11720e2869eS猫头猫 marginTop: rpx(24), 11820e2869eS猫头猫 width: rpx(750), 11920e2869eS猫头猫 paddingHorizontal: rpx(24), 120be474dd8S猫头猫 }, 121be474dd8S猫头猫}); 122