1d52aa40eS猫头猫import React, {memo} from 'react'; 2d52aa40eS猫头猫import {SectionList, SectionListProps, StyleSheet, View} from 'react-native'; 3d52aa40eS猫头猫import rpx from '@/utils/rpx'; 4d52aa40eS猫头猫import {IPluginTopListResult} from '../store/atoms'; 5d52aa40eS猫头猫import {RequestStateCode} from '@/constants/commonConst'; 6d52aa40eS猫头猫import Loading from '@/components/base/loading'; 7d52aa40eS猫头猫import Empty from '@/components/base/empty'; 8d52aa40eS猫头猫import TopListItem from '@/components/mediaItem/topListItem'; 9d52aa40eS猫头猫import ThemeText from '@/components/base/themeText'; 10d52aa40eS猫头猫 11d52aa40eS猫头猫interface IBoardPanelProps { 12cee6bc49S猫头猫 hash: string; 13d52aa40eS猫头猫 topListData: IPluginTopListResult; 14d52aa40eS猫头猫} 15d52aa40eS猫头猫function BoardPanel(props: IBoardPanelProps) { 16cee6bc49S猫头猫 const {hash, topListData} = props ?? {}; 17d52aa40eS猫头猫 18*5589cdf3S猫头猫 const renderItem: SectionListProps<IMusic.IMusicSheetItemBase>['renderItem'] = 19d52aa40eS猫头猫 ({item}) => { 20cee6bc49S猫头猫 return <TopListItem topListItem={item} pluginHash={hash} />; 21d52aa40eS猫头猫 }; 22d52aa40eS猫头猫 23*5589cdf3S猫头猫 const renderSectionHeader: SectionListProps<IMusic.IMusicSheetItemBase>['renderSectionHeader'] = 24d52aa40eS猫头猫 ({section: {title}}) => { 25d52aa40eS猫头猫 return ( 26d52aa40eS猫头猫 <View style={style.sectionHeader}> 27d52aa40eS猫头猫 <ThemeText fontWeight="bold" fontSize="title"> 28d52aa40eS猫头猫 {title} 29d52aa40eS猫头猫 </ThemeText> 30d52aa40eS猫头猫 </View> 31d52aa40eS猫头猫 ); 32d52aa40eS猫头猫 }; 33d52aa40eS猫头猫 34d52aa40eS猫头猫 return topListData?.state !== RequestStateCode.FINISHED ? ( 35d52aa40eS猫头猫 <Loading /> 36d52aa40eS猫头猫 ) : ( 37d52aa40eS猫头猫 <SectionList 38d52aa40eS猫头猫 renderItem={renderItem} 39d52aa40eS猫头猫 renderSectionHeader={renderSectionHeader} 40d52aa40eS猫头猫 ListEmptyComponent={<Empty />} 41*5589cdf3S猫头猫 sections={topListData?.data || []} 42d52aa40eS猫头猫 /> 43d52aa40eS猫头猫 ); 44d52aa40eS猫头猫} 45d52aa40eS猫头猫 46d52aa40eS猫头猫export default memo( 47d52aa40eS猫头猫 BoardPanel, 48d52aa40eS猫头猫 (prev, curr) => prev.topListData === curr.topListData, 49d52aa40eS猫头猫); 50d52aa40eS猫头猫 51d52aa40eS猫头猫const style = StyleSheet.create({ 52d52aa40eS猫头猫 wrapper: { 53d52aa40eS猫头猫 width: rpx(750), 54d52aa40eS猫头猫 }, 55d52aa40eS猫头猫 sectionHeader: { 56d52aa40eS猫头猫 marginTop: rpx(28), 57d52aa40eS猫头猫 marginBottom: rpx(24), 58d52aa40eS猫头猫 marginLeft: rpx(24), 59d52aa40eS猫头猫 }, 60d52aa40eS猫头猫}); 61