1da2a2959S猫头猫import React, {useMemo} from 'react'; 213cebe63S猫头猫import {Image, Pressable, StyleSheet, View} from 'react-native'; 313cebe63S猫头猫import rpx from '@/utils/rpx'; 413cebe63S猫头猫 513cebe63S猫头猫import Download from '@/core/download'; 613cebe63S猫头猫import LocalMusicSheet from '@/core/localMusicSheet'; 713cebe63S猫头猫import {ROUTE_PATH} from '@/entry/router'; 813cebe63S猫头猫import {ImgAsset} from '@/constants/assetsConst'; 913cebe63S猫头猫import Toast from '@/utils/toast'; 10da2a2959S猫头猫import toast from '@/utils/toast'; 1113cebe63S猫头猫import useOrientation from '@/hooks/useOrientation'; 1213cebe63S猫头猫import {showPanel} from '@/components/panels/usePanel'; 1313cebe63S猫头猫import TrackPlayer from '@/core/trackPlayer'; 1413cebe63S猫头猫import {iconSizeConst} from '@/constants/uiConst'; 1513cebe63S猫头猫import PersistStatus from '@/core/persistStatus'; 165b5a8d79S猫头猫import HeartIcon from '../heartIcon'; 175589cdf3S猫头猫import Icon from '@/components/base/icon.tsx'; 18da2a2959S猫头猫import PluginManager from '@/core/pluginManager.ts'; 1913cebe63S猫头猫 2013cebe63S猫头猫export default function Operations() { 2113cebe63S猫头猫 //briefcase-download-outline briefcase-check-outline checkbox-marked-circle-outline 2213cebe63S猫头猫 const musicItem = TrackPlayer.useCurrentMusic(); 2313cebe63S猫头猫 const currentQuality = TrackPlayer.useCurrentQuality(); 2413cebe63S猫头猫 const isDownloaded = LocalMusicSheet.useIsLocal(musicItem); 2513cebe63S猫头猫 2613cebe63S猫头猫 const rate = PersistStatus.useValue('music.rate', 100); 2713cebe63S猫头猫 const orientation = useOrientation(); 2813cebe63S猫头猫 29da2a2959S猫头猫 const supportComment = useMemo(() => { 30da2a2959S猫头猫 return !musicItem 31da2a2959S猫头猫 ? false 32da2a2959S猫头猫 : !!PluginManager.getByMedia(musicItem)?.instance?.getMusicComments; 33da2a2959S猫头猫 }, [musicItem]); 34da2a2959S猫头猫 3513cebe63S猫头猫 return ( 3613cebe63S猫头猫 <View 3713cebe63S猫头猫 style={[ 38da2a2959S猫头猫 styles.wrapper, 39*ab5f994aSmaotoumao orientation === 'horizontal' ? styles.horizontalWrapper : null, 4013cebe63S猫头猫 ]}> 415b5a8d79S猫头猫 <HeartIcon /> 4213cebe63S猫头猫 <Pressable 4313cebe63S猫头猫 onPress={() => { 4413cebe63S猫头猫 if (!musicItem) { 4513cebe63S猫头猫 return; 4613cebe63S猫头猫 } 4713cebe63S猫头猫 showPanel('MusicQuality', { 4813cebe63S猫头猫 musicItem, 4913cebe63S猫头猫 async onQualityPress(quality) { 5013cebe63S猫头猫 const changeResult = 5113cebe63S猫头猫 await TrackPlayer.changeQuality(quality); 5213cebe63S猫头猫 if (!changeResult) { 5313cebe63S猫头猫 Toast.warn('当前暂无此音质音乐'); 5413cebe63S猫头猫 } 5513cebe63S猫头猫 }, 5613cebe63S猫头猫 }); 5713cebe63S猫头猫 }}> 5813cebe63S猫头猫 <Image 5913cebe63S猫头猫 source={ImgAsset.quality[currentQuality]} 60da2a2959S猫头猫 style={styles.quality} 6113cebe63S猫头猫 /> 6213cebe63S猫头猫 </Pressable> 6313cebe63S猫头猫 <Icon 645589cdf3S猫头猫 name={isDownloaded ? 'check-circle-outline' : 'arrow-down-tray'} 6513cebe63S猫头猫 size={iconSizeConst.normal} 6613cebe63S猫头猫 color="white" 6713cebe63S猫头猫 onPress={() => { 6813cebe63S猫头猫 if (musicItem && !isDownloaded) { 6913cebe63S猫头猫 showPanel('MusicQuality', { 70756bc302S猫头猫 type: 'download', 7113cebe63S猫头猫 musicItem, 7213cebe63S猫头猫 async onQualityPress(quality) { 7313cebe63S猫头猫 Download.downloadMusic(musicItem, quality); 7413cebe63S猫头猫 }, 7513cebe63S猫头猫 }); 7613cebe63S猫头猫 } 7713cebe63S猫头猫 }} 7813cebe63S猫头猫 /> 7913cebe63S猫头猫 <Pressable 8013cebe63S猫头猫 onPress={() => { 8113cebe63S猫头猫 if (!musicItem) { 8213cebe63S猫头猫 return; 8313cebe63S猫头猫 } 8413cebe63S猫头猫 showPanel('PlayRate', { 8513cebe63S猫头猫 async onRatePress(newRate) { 8613cebe63S猫头猫 if (rate !== newRate) { 8713cebe63S猫头猫 try { 8813cebe63S猫头猫 await TrackPlayer.setRate(newRate / 100); 8913cebe63S猫头猫 PersistStatus.set('music.rate', newRate); 9013cebe63S猫头猫 } catch {} 9113cebe63S猫头猫 } 9213cebe63S猫头猫 }, 9313cebe63S猫头猫 }); 9413cebe63S猫头猫 }}> 95da2a2959S猫头猫 <Image source={ImgAsset.rate[rate!]} style={styles.quality} /> 9613cebe63S猫头猫 </Pressable> 9713cebe63S猫头猫 <Icon 98da2a2959S猫头猫 name="chat-bubble-oval-left-ellipsis" 99da2a2959S猫头猫 size={iconSizeConst.normal} 100da2a2959S猫头猫 color="white" 101a12c1865S猫头猫 opacity={supportComment ? 1 : 0.2} 102da2a2959S猫头猫 onPress={() => { 103da2a2959S猫头猫 if (!supportComment) { 104a12c1865S猫头猫 toast.warn('当前歌曲暂无评论'); 105da2a2959S猫头猫 return; 106da2a2959S猫头猫 } 107da2a2959S猫头猫 if (musicItem) { 108da2a2959S猫头猫 showPanel('MusicComment', { 109da2a2959S猫头猫 musicItem, 110da2a2959S猫头猫 }); 111da2a2959S猫头猫 } 112da2a2959S猫头猫 }} 113da2a2959S猫头猫 /> 114da2a2959S猫头猫 <Icon 1155589cdf3S猫头猫 name="ellipsis-vertical" 11613cebe63S猫头猫 size={iconSizeConst.normal} 11713cebe63S猫头猫 color="white" 11813cebe63S猫头猫 onPress={() => { 11913cebe63S猫头猫 if (musicItem) { 12013cebe63S猫头猫 showPanel('MusicItemOptions', { 12113cebe63S猫头猫 musicItem: musicItem, 12213cebe63S猫头猫 from: ROUTE_PATH.MUSIC_DETAIL, 12313cebe63S猫头猫 }); 12413cebe63S猫头猫 } 12513cebe63S猫头猫 }} 12613cebe63S猫头猫 /> 12713cebe63S猫头猫 </View> 12813cebe63S猫头猫 ); 12913cebe63S猫头猫} 13013cebe63S猫头猫 131da2a2959S猫头猫const styles = StyleSheet.create({ 13213cebe63S猫头猫 wrapper: { 13313cebe63S猫头猫 width: '100%', 13413cebe63S猫头猫 height: rpx(80), 13513cebe63S猫头猫 marginBottom: rpx(24), 13613cebe63S猫头猫 flexDirection: 'row', 13713cebe63S猫头猫 alignItems: 'center', 13813cebe63S猫头猫 justifyContent: 'space-around', 13913cebe63S猫头猫 }, 140da2a2959S猫头猫 horizontalWrapper: { 141da2a2959S猫头猫 marginBottom: 0, 142da2a2959S猫头猫 }, 14313cebe63S猫头猫 quality: { 14413cebe63S猫头猫 width: rpx(52), 14513cebe63S猫头猫 height: rpx(52), 14613cebe63S猫头猫 }, 14713cebe63S猫头猫}); 148