163c74e8eSmaotoumaoimport React from "react"; 263c74e8eSmaotoumaoimport { StyleSheet, View } from "react-native"; 363c74e8eSmaotoumaoimport rpx from "@/utils/rpx"; 463c74e8eSmaotoumaoimport { iconSizeConst } from "@/constants/uiConst"; 563c74e8eSmaotoumaoimport TranslationIcon from "@/assets/icons/translation.svg"; 663c74e8eSmaotoumaoimport Config from "@/core/config"; 763c74e8eSmaotoumaoimport useColors from "@/hooks/useColors"; 863c74e8eSmaotoumaoimport LyricManager from "@/core/lyricManager"; 963c74e8eSmaotoumaoimport Toast from "@/utils/toast"; 1063c74e8eSmaotoumaoimport { hidePanel, showPanel } from "@/components/panels/usePanel"; 1163c74e8eSmaotoumaoimport TrackPlayer from "@/core/trackPlayer"; 1263c74e8eSmaotoumaoimport MediaExtra from "@/core/mediaExtra"; 13*819a9075Smaotoumaoimport PersistStatus from "@/core/persistStatus.ts"; 1463c74e8eSmaotoumaoimport useOrientation from "@/hooks/useOrientation"; 1563c74e8eSmaotoumaoimport HeartIcon from "../heartIcon"; 1663c74e8eSmaotoumaoimport Icon from "@/components/base/icon.tsx"; 1713cebe63S猫头猫 1813cebe63S猫头猫interface ILyricOperationsProps { 1913cebe63S猫头猫 scrollToCurrentLrcItem: () => void; 2013cebe63S猫头猫} 2113cebe63S猫头猫 2213cebe63S猫头猫export default function LyricOperations(props: ILyricOperationsProps) { 2313cebe63S猫头猫 const {scrollToCurrentLrcItem} = props; 2413cebe63S猫头猫 2513cebe63S猫头猫 const lyricConfig = Config.useConfig('setting.lyric'); 2613cebe63S猫头猫 2713cebe63S猫头猫 const hasTranslation = LyricManager.useLyricState()?.hasTranslation; 28*819a9075Smaotoumao const showTranslation = PersistStatus.useValue( 2913cebe63S猫头猫 'lyric.showTranslation', 3013cebe63S猫头猫 false, 3113cebe63S猫头猫 ); 3213cebe63S猫头猫 const colors = useColors(); 335b5a8d79S猫头猫 const orientation = useOrientation(); 3413cebe63S猫头猫 3513cebe63S猫头猫 return ( 3613cebe63S猫头猫 <View style={styles.container}> 375b5a8d79S猫头猫 {orientation === 'vertical' ? <HeartIcon /> : null} 3813cebe63S猫头猫 <Icon 395589cdf3S猫头猫 name="font-size" 4013cebe63S猫头猫 size={iconSizeConst.normal} 4113cebe63S猫头猫 color="white" 4213cebe63S猫头猫 onPress={() => { 4313cebe63S猫头猫 showPanel('SetFontSize', { 4413cebe63S猫头猫 defaultSelect: lyricConfig?.detailFontSize ?? 1, 4513cebe63S猫头猫 onSelectChange(value) { 46*819a9075Smaotoumao PersistStatus.set('lyric.detailFontSize', value); 4713cebe63S猫头猫 scrollToCurrentLrcItem(); 4813cebe63S猫头猫 }, 4913cebe63S猫头猫 }); 5013cebe63S猫头猫 }} 5113cebe63S猫头猫 /> 5213cebe63S猫头猫 <Icon 535589cdf3S猫头猫 name="arrows-left-right" 5413cebe63S猫头猫 size={iconSizeConst.normal} 5513cebe63S猫头猫 color="white" 5613cebe63S猫头猫 onPress={() => { 5713cebe63S猫头猫 const currentMusicItem = TrackPlayer.getCurrentMusic(); 5813cebe63S猫头猫 5913cebe63S猫头猫 if (currentMusicItem) { 6013cebe63S猫头猫 showPanel('SetLyricOffset', { 6113cebe63S猫头猫 musicItem: currentMusicItem, 6213cebe63S猫头猫 onSubmit(offset) { 6313cebe63S猫头猫 MediaExtra.update(currentMusicItem, { 6413cebe63S猫头猫 lyricOffset: offset, 6513cebe63S猫头猫 }); 6613cebe63S猫头猫 LyricManager.refreshLyric(); 6713cebe63S猫头猫 scrollToCurrentLrcItem(); 6813cebe63S猫头猫 hidePanel(); 6913cebe63S猫头猫 }, 7013cebe63S猫头猫 }); 7113cebe63S猫头猫 } 7213cebe63S猫头猫 }} 7313cebe63S猫头猫 /> 7413cebe63S猫头猫 7513cebe63S猫头猫 <Icon 765589cdf3S猫头猫 name="magnifying-glass" 7713cebe63S猫头猫 size={iconSizeConst.normal} 7813cebe63S猫头猫 color="white" 7913cebe63S猫头猫 onPress={() => { 8013cebe63S猫头猫 const currentMusic = TrackPlayer.getCurrentMusic(); 8113cebe63S猫头猫 if (!currentMusic) { 8213cebe63S猫头猫 return; 8313cebe63S猫头猫 } 8413cebe63S猫头猫 // if ( 8513cebe63S猫头猫 // Config.get('setting.basic.associateLyricType') === 8613cebe63S猫头猫 // 'input' 8713cebe63S猫头猫 // ) { 8813cebe63S猫头猫 // showPanel('AssociateLrc', { 8913cebe63S猫头猫 // musicItem: currentMusic, 9013cebe63S猫头猫 // }); 9113cebe63S猫头猫 // } else { 9213cebe63S猫头猫 showPanel('SearchLrc', { 9313cebe63S猫头猫 musicItem: currentMusic, 9413cebe63S猫头猫 }); 9513cebe63S猫头猫 // } 9613cebe63S猫头猫 }} 9713cebe63S猫头猫 /> 9813cebe63S猫头猫 <TranslationIcon 9913cebe63S猫头猫 width={iconSizeConst.normal} 10013cebe63S猫头猫 height={iconSizeConst.normal} 10113cebe63S猫头猫 opacity={!hasTranslation ? 0.2 : showTranslation ? 1 : 0.5} 10213cebe63S猫头猫 color={ 10313cebe63S猫头猫 showTranslation && hasTranslation ? colors.primary : 'white' 10413cebe63S猫头猫 } 10513cebe63S猫头猫 // style={} 10613cebe63S猫头猫 onPress={() => { 10713cebe63S猫头猫 if (!hasTranslation) { 10813cebe63S猫头猫 Toast.warn('当前歌曲无翻译'); 10913cebe63S猫头猫 return; 11013cebe63S猫头猫 } 11113cebe63S猫头猫 112*819a9075Smaotoumao PersistStatus.set( 11313cebe63S猫头猫 'lyric.showTranslation', 11413cebe63S猫头猫 !showTranslation, 11513cebe63S猫头猫 ); 11613cebe63S猫头猫 scrollToCurrentLrcItem(); 11713cebe63S猫头猫 }} 11813cebe63S猫头猫 /> 11926f32636S猫头猫 <Icon 12026f32636S猫头猫 name="ellipsis-vertical" 12126f32636S猫头猫 size={iconSizeConst.normal} 12226f32636S猫头猫 color={'white'} 12326f32636S猫头猫 onPress={() => { 12426f32636S猫头猫 const currentMusic = TrackPlayer.getCurrentMusic(); 12526f32636S猫头猫 if (currentMusic) { 12626f32636S猫头猫 showPanel('MusicItemLyricOptions', { 12726f32636S猫头猫 musicItem: currentMusic, 12826f32636S猫头猫 }); 12926f32636S猫头猫 } 13026f32636S猫头猫 }} 13126f32636S猫头猫 /> 13213cebe63S猫头猫 </View> 13313cebe63S猫头猫 ); 13413cebe63S猫头猫} 13513cebe63S猫头猫 13613cebe63S猫头猫const styles = StyleSheet.create({ 13713cebe63S猫头猫 container: { 13813cebe63S猫头猫 height: rpx(80), 13913cebe63S猫头猫 marginBottom: rpx(24), 14013cebe63S猫头猫 width: '100%', 14113cebe63S猫头猫 flexDirection: 'row', 14213cebe63S猫头猫 alignItems: 'center', 14313cebe63S猫头猫 justifyContent: 'space-around', 14413cebe63S猫头猫 }, 14513cebe63S猫头猫}); 146