1*16016ca7S猫头猫import React, {useState} from 'react'; 2be539549S猫头猫import {Pressable, StyleSheet, View} from 'react-native'; 3be539549S猫头猫import rpx from '@/utils/rpx'; 4be539549S猫头猫import LinearGradient from 'react-native-linear-gradient'; 5be539549S猫头猫import {Divider, IconButton, useTheme} from 'react-native-paper'; 6be539549S猫头猫import MusicQueue from '@/core/musicQueue'; 7be539549S猫头猫import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; 8be539549S猫头猫import usePanel from '@/components/panels/usePanel'; 9be539549S猫头猫import {iconSizeConst} from '@/constants/uiConst'; 10be539549S猫头猫import Color from 'color'; 11be539549S猫头猫import ThemeText from '@/components/base/themeText'; 12be539549S猫头猫import {ImgAsset} from '@/constants/assetsConst'; 13be539549S猫头猫import FastImage from '@/components/base/fastImage'; 14be539549S猫头猫import {ROUTE_PATH, useNavigate} from '@/entry/router'; 15be539549S猫头猫 16be539549S猫头猫interface IHeaderProps { 17be539549S猫头猫 topListDetail: IMusic.IMusicTopListItem | null; 18be539549S猫头猫 19be539549S猫头猫 musicList: IMusic.IMusicItem[] | null; 20be539549S猫头猫} 21be539549S猫头猫export default function Header(props: IHeaderProps) { 22be539549S猫头猫 const {topListDetail, musicList} = props; 23be539549S猫头猫 const {showPanel} = usePanel(); 24be539549S猫头猫 const {colors} = useTheme(); 25be539549S猫头猫 26*16016ca7S猫头猫 const [maxLines, setMaxLines] = useState<number | undefined>(6); 27*16016ca7S猫头猫 28*16016ca7S猫头猫 const toggleShowMore = () => { 29*16016ca7S猫头猫 if (maxLines) { 30*16016ca7S猫头猫 setMaxLines(undefined); 31*16016ca7S猫头猫 } else { 32*16016ca7S猫头猫 setMaxLines(6); 33*16016ca7S猫头猫 } 34*16016ca7S猫头猫 }; 35*16016ca7S猫头猫 36be539549S猫头猫 const navigate = useNavigate(); 37be539549S猫头猫 38be539549S猫头猫 return ( 39be539549S猫头猫 <> 40be539549S猫头猫 <LinearGradient 41be539549S猫头猫 colors={[ 42be539549S猫头猫 Color(colors.primary).alpha(0.8).toString(), 43be539549S猫头猫 Color(colors.primary).alpha(0.15).toString(), 44be539549S猫头猫 ]} 45be539549S猫头猫 style={style.wrapper}> 46be539549S猫头猫 <View style={style.content}> 47be539549S猫头猫 <FastImage 48be539549S猫头猫 style={style.coverImg} 49be539549S猫头猫 uri={topListDetail?.artwork ?? topListDetail?.coverImg} 50be539549S猫头猫 emptySrc={ImgAsset.albumDefault} 51be539549S猫头猫 /> 52be539549S猫头猫 <View style={style.details}> 53be539549S猫头猫 <ThemeText>{topListDetail?.title}</ThemeText> 54be539549S猫头猫 <ThemeText fontColor="secondary" fontSize="description"> 55be539549S猫头猫 共{musicList ? musicList.length ?? 0 : '-'}首{' '} 56be539549S猫头猫 </ThemeText> 57be539549S猫头猫 </View> 58be539549S猫头猫 </View> 59be539549S猫头猫 <Divider style={style.divider} /> 60*16016ca7S猫头猫 {topListDetail?.description ? ( 61*16016ca7S猫头猫 <Pressable onPress={toggleShowMore}> 62*16016ca7S猫头猫 <View 63*16016ca7S猫头猫 style={style.albumDesc} 64*16016ca7S猫头猫 onLayout={evt => { 65*16016ca7S猫头猫 console.log(evt.nativeEvent.layout); 66*16016ca7S猫头猫 }}> 67*16016ca7S猫头猫 <ThemeText 68*16016ca7S猫头猫 fontColor="secondary" 69*16016ca7S猫头猫 fontSize="description" 70*16016ca7S猫头猫 numberOfLines={maxLines}> 71*16016ca7S猫头猫 {topListDetail.description} 72be539549S猫头猫 </ThemeText> 73be539549S猫头猫 </View> 74*16016ca7S猫头猫 </Pressable> 75*16016ca7S猫头猫 ) : null} 76be539549S猫头猫 </LinearGradient> 77be539549S猫头猫 <View 78be539549S猫头猫 style={[ 79be539549S猫头猫 style.topWrapper, 80be539549S猫头猫 { 81be539549S猫头猫 backgroundColor: Color(colors.primary) 82be539549S猫头猫 .alpha(0.15) 83be539549S猫头猫 .toString(), 84be539549S猫头猫 }, 85be539549S猫头猫 ]}> 86be539549S猫头猫 <Pressable 87be539549S猫头猫 style={style.playAll} 88be539549S猫头猫 onPress={() => { 89be539549S猫头猫 if (musicList) { 90be539549S猫头猫 MusicQueue.playWithReplaceQueue( 91be539549S猫头猫 musicList[0], 92be539549S猫头猫 musicList, 93be539549S猫头猫 ); 94be539549S猫头猫 } 95be539549S猫头猫 }}> 96be539549S猫头猫 <Icon 97be539549S猫头猫 name="play-circle-outline" 98be539549S猫头猫 style={style.playAllIcon} 99be539549S猫头猫 size={iconSizeConst.normal} 100be539549S猫头猫 color={colors.text} 101be539549S猫头猫 /> 102be539549S猫头猫 <ThemeText fontWeight="bold">播放全部</ThemeText> 103be539549S猫头猫 </Pressable> 104be539549S猫头猫 <IconButton 105be539549S猫头猫 icon={'plus-box-multiple-outline'} 106be539549S猫头猫 size={rpx(48)} 107be539549S猫头猫 onPress={async () => { 108be539549S猫头猫 showPanel('AddToMusicSheet', { 109be539549S猫头猫 musicItem: musicList ?? [], 110be539549S猫头猫 }); 111be539549S猫头猫 }} 112be539549S猫头猫 /> 113be539549S猫头猫 <IconButton 114be539549S猫头猫 icon="playlist-edit" 115be539549S猫头猫 size={rpx(48)} 116be539549S猫头猫 onPress={async () => { 117be539549S猫头猫 navigate(ROUTE_PATH.MUSIC_LIST_EDITOR, { 118be539549S猫头猫 musicList: musicList, 119be539549S猫头猫 musicSheet: { 120be539549S猫头猫 title: topListDetail?.title, 121be539549S猫头猫 }, 122be539549S猫头猫 }); 123be539549S猫头猫 }} 124be539549S猫头猫 /> 125be539549S猫头猫 </View> 126be539549S猫头猫 </> 127be539549S猫头猫 ); 128be539549S猫头猫} 129be539549S猫头猫 130be539549S猫头猫const style = StyleSheet.create({ 131be539549S猫头猫 wrapper: { 132be539549S猫头猫 width: rpx(750), 133be539549S猫头猫 paddingVertical: rpx(24), 134be539549S猫头猫 justifyContent: 'center', 135be539549S猫头猫 alignItems: 'center', 136be539549S猫头猫 }, 137be539549S猫头猫 content: { 138be539549S猫头猫 width: rpx(702), 139be539549S猫头猫 flexDirection: 'row', 140be539549S猫头猫 justifyContent: 'space-between', 141be539549S猫头猫 alignItems: 'center', 142be539549S猫头猫 }, 143be539549S猫头猫 coverImg: { 144be539549S猫头猫 width: rpx(210), 145be539549S猫头猫 height: rpx(210), 146be539549S猫头猫 borderRadius: rpx(24), 147be539549S猫头猫 }, 148be539549S猫头猫 details: { 149be539549S猫头猫 width: rpx(456), 150be539549S猫头猫 height: rpx(140), 151be539549S猫头猫 justifyContent: 'space-between', 152be539549S猫头猫 }, 153be539549S猫头猫 divider: { 154be539549S猫头猫 marginVertical: rpx(18), 155be539549S猫头猫 }, 156be539549S猫头猫 157be539549S猫头猫 albumDesc: { 158be539549S猫头猫 width: rpx(702), 159be539549S猫头猫 }, 160be539549S猫头猫 /** playall */ 161be539549S猫头猫 topWrapper: { 162be539549S猫头猫 height: rpx(72), 163be539549S猫头猫 paddingHorizontal: rpx(24), 164be539549S猫头猫 flexDirection: 'row', 165be539549S猫头猫 alignItems: 'center', 166be539549S猫头猫 }, 167be539549S猫头猫 playAll: { 168be539549S猫头猫 flex: 1, 169be539549S猫头猫 flexDirection: 'row', 170be539549S猫头猫 alignItems: 'center', 171be539549S猫头猫 }, 172be539549S猫头猫 playAllIcon: { 173be539549S猫头猫 marginRight: rpx(12), 174be539549S猫头猫 }, 175be539549S猫头猫}); 176