116016ca7S猫头猫import React, {useState} from 'react'; 2be539549S猫头猫import {Pressable, StyleSheet, View} from 'react-native'; 3be539549S猫头猫import rpx from '@/utils/rpx'; 4be539549S猫头猫import ThemeText from '@/components/base/themeText'; 5be539549S猫头猫import {ImgAsset} from '@/constants/assetsConst'; 6be539549S猫头猫import FastImage from '@/components/base/fastImage'; 79801b15cS猫头猫import PlayAllBar from '@/components/base/playAllBar'; 87a8d024eS猫头猫import useColors from '@/hooks/useColors'; 9be539549S猫头猫 10be539549S猫头猫interface IHeaderProps { 11bef6dda8S猫头猫 musicSheet: IMusic.IMusicSheetItem | null; 12be539549S猫头猫 musicList: IMusic.IMusicItem[] | null; 13bef6dda8S猫头猫 canStar?: boolean; 14be539549S猫头猫} 15be539549S猫头猫export default function Header(props: IHeaderProps) { 16bef6dda8S猫头猫 const {musicSheet, musicList, canStar} = props; 177a8d024eS猫头猫 const colors = useColors(); 18be539549S猫头猫 1916016ca7S猫头猫 const [maxLines, setMaxLines] = useState<number | undefined>(6); 2016016ca7S猫头猫 2116016ca7S猫头猫 const toggleShowMore = () => { 2216016ca7S猫头猫 if (maxLines) { 2316016ca7S猫头猫 setMaxLines(undefined); 2416016ca7S猫头猫 } else { 2516016ca7S猫头猫 setMaxLines(6); 2616016ca7S猫头猫 } 2716016ca7S猫头猫 }; 2816016ca7S猫头猫 29be539549S猫头猫 return ( 30277c5280S猫头猫 <View style={{backgroundColor: colors.card}}> 31277c5280S猫头猫 <View style={style.wrapper}> 32be539549S猫头猫 <View style={style.content}> 33be539549S猫头猫 <FastImage 34be539549S猫头猫 style={style.coverImg} 35bef6dda8S猫头猫 uri={musicSheet?.artwork ?? musicSheet?.coverImg} 36be539549S猫头猫 emptySrc={ImgAsset.albumDefault} 37be539549S猫头猫 /> 38be539549S猫头猫 <View style={style.details}> 39*e9c5e30eS猫头猫 <ThemeText numberOfLines={3}> 40*e9c5e30eS猫头猫 {musicSheet?.title} 41*e9c5e30eS猫头猫 </ThemeText> 42277c5280S猫头猫 <ThemeText 43277c5280S猫头猫 fontColor="textSecondary" 44277c5280S猫头猫 fontSize="description"> 4596744680S猫头猫 共 46bef6dda8S猫头猫 {musicSheet?.worksNum ?? 4796744680S猫头猫 (musicList ? musicList.length ?? 0 : '-')} 4896744680S猫头猫 首{' '} 49be539549S猫头猫 </ThemeText> 50be539549S猫头猫 </View> 51be539549S猫头猫 </View> 52bef6dda8S猫头猫 {musicSheet?.description ? ( 5316016ca7S猫头猫 <Pressable onPress={toggleShowMore}> 5416016ca7S猫头猫 <View 5516016ca7S猫头猫 style={style.albumDesc} 567cee35b5S猫头猫 // onLayout={evt => { 577cee35b5S猫头猫 // console.log(evt.nativeEvent.layout); 587cee35b5S猫头猫 // }} 597cee35b5S猫头猫 > 6016016ca7S猫头猫 <ThemeText 61277c5280S猫头猫 fontColor="textSecondary" 6216016ca7S猫头猫 fontSize="description" 6316016ca7S猫头猫 numberOfLines={maxLines}> 64bef6dda8S猫头猫 {musicSheet.description} 65be539549S猫头猫 </ThemeText> 66be539549S猫头猫 </View> 6716016ca7S猫头猫 </Pressable> 6816016ca7S猫头猫 ) : null} 69277c5280S猫头猫 </View> 709801b15cS猫头猫 <PlayAllBar 71bef6dda8S猫头猫 canStar={canStar} 729801b15cS猫头猫 musicList={musicList} 73bef6dda8S猫头猫 musicSheet={musicSheet} 74be539549S猫头猫 /> 75277c5280S猫头猫 </View> 76be539549S猫头猫 ); 77be539549S猫头猫} 78be539549S猫头猫 79be539549S猫头猫const style = StyleSheet.create({ 80be539549S猫头猫 wrapper: { 813b155a65S猫头猫 width: '100%', 823b155a65S猫头猫 padding: rpx(24), 83be539549S猫头猫 justifyContent: 'center', 847cee35b5S猫头猫 alignItems: 'flex-start', 85be539549S猫头猫 }, 86be539549S猫头猫 content: { 873b155a65S猫头猫 flex: 1, 88be539549S猫头猫 flexDirection: 'row', 893b155a65S猫头猫 justifyContent: 'flex-start', 90be539549S猫头猫 alignItems: 'center', 91be539549S猫头猫 }, 92be539549S猫头猫 coverImg: { 93be539549S猫头猫 width: rpx(210), 94be539549S猫头猫 height: rpx(210), 95be539549S猫头猫 borderRadius: rpx(24), 96be539549S猫头猫 }, 97be539549S猫头猫 details: { 983b155a65S猫头猫 flex: 1, 99be539549S猫头猫 height: rpx(140), 1003b155a65S猫头猫 paddingHorizontal: rpx(36), 101be539549S猫头猫 justifyContent: 'space-between', 102be539549S猫头猫 }, 103be539549S猫头猫 divider: { 104be539549S猫头猫 marginVertical: rpx(18), 105be539549S猫头猫 }, 106be539549S猫头猫 107be539549S猫头猫 albumDesc: { 1087cee35b5S猫头猫 width: '100%', 109277c5280S猫头猫 marginTop: rpx(28), 110be539549S猫头猫 }, 111be539549S猫头猫}); 112