113cebe63S猫头猫import React 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'; 1013cebe63S猫头猫import useOrientation from '@/hooks/useOrientation'; 1113cebe63S猫头猫import {showPanel} from '@/components/panels/usePanel'; 1213cebe63S猫头猫import TrackPlayer from '@/core/trackPlayer'; 1313cebe63S猫头猫import {iconSizeConst} from '@/constants/uiConst'; 1413cebe63S猫头猫import PersistStatus from '@/core/persistStatus'; 155b5a8d79S猫头猫import HeartIcon from '../heartIcon'; 165589cdf3S猫头猫import Icon from '@/components/base/icon.tsx'; 1713cebe63S猫头猫 1813cebe63S猫头猫export default function Operations() { 1913cebe63S猫头猫 //briefcase-download-outline briefcase-check-outline checkbox-marked-circle-outline 2013cebe63S猫头猫 const musicItem = TrackPlayer.useCurrentMusic(); 2113cebe63S猫头猫 const currentQuality = TrackPlayer.useCurrentQuality(); 2213cebe63S猫头猫 const isDownloaded = LocalMusicSheet.useIsLocal(musicItem); 2313cebe63S猫头猫 2413cebe63S猫头猫 const rate = PersistStatus.useValue('music.rate', 100); 2513cebe63S猫头猫 const orientation = useOrientation(); 2613cebe63S猫头猫 2713cebe63S猫头猫 return ( 2813cebe63S猫头猫 <View 2913cebe63S猫头猫 style={[ 3013cebe63S猫头猫 style.wrapper, 3113cebe63S猫头猫 orientation === 'horizonal' 3213cebe63S猫头猫 ? { 3313cebe63S猫头猫 marginBottom: 0, 3413cebe63S猫头猫 } 3513cebe63S猫头猫 : null, 3613cebe63S猫头猫 ]}> 375b5a8d79S猫头猫 <HeartIcon /> 3813cebe63S猫头猫 <Pressable 3913cebe63S猫头猫 onPress={() => { 4013cebe63S猫头猫 if (!musicItem) { 4113cebe63S猫头猫 return; 4213cebe63S猫头猫 } 4313cebe63S猫头猫 showPanel('MusicQuality', { 4413cebe63S猫头猫 musicItem, 4513cebe63S猫头猫 async onQualityPress(quality) { 4613cebe63S猫头猫 const changeResult = 4713cebe63S猫头猫 await TrackPlayer.changeQuality(quality); 4813cebe63S猫头猫 if (!changeResult) { 4913cebe63S猫头猫 Toast.warn('当前暂无此音质音乐'); 5013cebe63S猫头猫 } 5113cebe63S猫头猫 }, 5213cebe63S猫头猫 }); 5313cebe63S猫头猫 }}> 5413cebe63S猫头猫 <Image 5513cebe63S猫头猫 source={ImgAsset.quality[currentQuality]} 5613cebe63S猫头猫 style={style.quality} 5713cebe63S猫头猫 /> 5813cebe63S猫头猫 </Pressable> 5913cebe63S猫头猫 <Icon 605589cdf3S猫头猫 name={isDownloaded ? 'check-circle-outline' : 'arrow-down-tray'} 6113cebe63S猫头猫 size={iconSizeConst.normal} 6213cebe63S猫头猫 color="white" 6313cebe63S猫头猫 onPress={() => { 6413cebe63S猫头猫 if (musicItem && !isDownloaded) { 6513cebe63S猫头猫 showPanel('MusicQuality', { 66*756bc302S猫头猫 type: 'download', 6713cebe63S猫头猫 musicItem, 6813cebe63S猫头猫 async onQualityPress(quality) { 6913cebe63S猫头猫 Download.downloadMusic(musicItem, quality); 7013cebe63S猫头猫 }, 7113cebe63S猫头猫 }); 7213cebe63S猫头猫 } 7313cebe63S猫头猫 }} 7413cebe63S猫头猫 /> 7513cebe63S猫头猫 <Pressable 7613cebe63S猫头猫 onPress={() => { 7713cebe63S猫头猫 if (!musicItem) { 7813cebe63S猫头猫 return; 7913cebe63S猫头猫 } 8013cebe63S猫头猫 showPanel('PlayRate', { 8113cebe63S猫头猫 async onRatePress(newRate) { 8213cebe63S猫头猫 if (rate !== newRate) { 8313cebe63S猫头猫 try { 8413cebe63S猫头猫 await TrackPlayer.setRate(newRate / 100); 8513cebe63S猫头猫 PersistStatus.set('music.rate', newRate); 8613cebe63S猫头猫 } catch {} 8713cebe63S猫头猫 } 8813cebe63S猫头猫 }, 8913cebe63S猫头猫 }); 9013cebe63S猫头猫 }}> 9113cebe63S猫头猫 <Image source={ImgAsset.rate[rate!]} style={style.quality} /> 9213cebe63S猫头猫 </Pressable> 9313cebe63S猫头猫 <Icon 945589cdf3S猫头猫 name="ellipsis-vertical" 9513cebe63S猫头猫 size={iconSizeConst.normal} 9613cebe63S猫头猫 color="white" 9713cebe63S猫头猫 onPress={() => { 9813cebe63S猫头猫 if (musicItem) { 9913cebe63S猫头猫 showPanel('MusicItemOptions', { 10013cebe63S猫头猫 musicItem: musicItem, 10113cebe63S猫头猫 from: ROUTE_PATH.MUSIC_DETAIL, 10213cebe63S猫头猫 }); 10313cebe63S猫头猫 } 10413cebe63S猫头猫 }} 10513cebe63S猫头猫 /> 10613cebe63S猫头猫 </View> 10713cebe63S猫头猫 ); 10813cebe63S猫头猫} 10913cebe63S猫头猫 11013cebe63S猫头猫const style = StyleSheet.create({ 11113cebe63S猫头猫 wrapper: { 11213cebe63S猫头猫 width: '100%', 11313cebe63S猫头猫 height: rpx(80), 11413cebe63S猫头猫 marginBottom: rpx(24), 11513cebe63S猫头猫 flexDirection: 'row', 11613cebe63S猫头猫 alignItems: 'center', 11713cebe63S猫头猫 justifyContent: 'space-around', 11813cebe63S猫头猫 }, 11913cebe63S猫头猫 quality: { 12013cebe63S猫头猫 width: rpx(52), 12113cebe63S猫头猫 height: rpx(52), 12213cebe63S猫头猫 }, 12313cebe63S猫头猫}); 124