1import React from 'react'; 2import {useNavigation} from '@react-navigation/native'; 3import {ROUTE_PATH, useParams} from '@/entry/router'; 4import Toast from '@/utils/toast'; 5import toast from '@/utils/toast'; 6import {showDialog} from '@/components/dialogs/useDialog'; 7import AppBar from '@/components/base/appBar'; 8import MusicSheet from '@/core/musicSheet'; 9import {SortType} from '@/constants/commonConst.ts'; 10import {showPanel} from '@/components/panels/usePanel.ts'; 11 12export default function () { 13 const navigation = useNavigation<any>(); 14 const {id = 'favorite'} = useParams<'local-sheet-detail'>(); 15 const musicSheet = MusicSheet.useSheetItem(id); 16 17 return ( 18 <> 19 <AppBar 20 menu={[ 21 { 22 icon: 'pencil-outline', 23 title: '编辑歌单信息', 24 onPress() { 25 showPanel('EditMusicSheetInfo', { 26 musicSheet: musicSheet, 27 }); 28 }, 29 }, 30 { 31 icon: 'pencil-square', 32 title: '批量编辑歌曲', 33 onPress() { 34 navigation.navigate(ROUTE_PATH.MUSIC_LIST_EDITOR, { 35 musicList: musicSheet.musicList, 36 musicSheet: musicSheet, 37 }); 38 }, 39 }, 40 { 41 icon: 'sort-outline', 42 title: '歌曲排序', 43 onPress() { 44 showDialog('RadioDialog', { 45 content: [ 46 { 47 value: SortType.Title, 48 label: '按歌曲名排序', 49 }, 50 { 51 value: SortType.Artist, 52 label: '按作者名排序', 53 }, 54 { 55 value: SortType.Album, 56 label: '按专辑名排序', 57 }, 58 { 59 value: SortType.Newest, 60 label: '按收藏时间从新到旧排序', 61 }, 62 { 63 value: SortType.Oldest, 64 label: '按收藏时间从旧到新排序', 65 }, 66 ], 67 defaultSelected: 68 MusicSheet.getSheetMeta(id, 'sort') || 69 SortType.None, 70 title: '歌曲排序', 71 async onOk(value) { 72 await MusicSheet.setSortType( 73 id, 74 value as SortType, 75 ); 76 toast.success('排序已更新'); 77 }, 78 }); 79 }, 80 }, 81 { 82 icon: 'trash-outline', 83 title: '删除歌单', 84 show: id !== 'favorite', 85 onPress() { 86 showDialog('SimpleDialog', { 87 title: '删除歌单', 88 content: `确定删除歌单「${musicSheet.title}」吗?`, 89 onOk: async () => { 90 await MusicSheet.removeSheet(id); 91 Toast.success('已删除'); 92 navigation.goBack(); 93 }, 94 }); 95 }, 96 }, 97 ]} 98 actions={[ 99 { 100 icon: 'magnifying-glass', 101 onPress() { 102 navigation.navigate(ROUTE_PATH.SEARCH_MUSIC_LIST, { 103 musicList: musicSheet?.musicList, 104 musicSheet: musicSheet, 105 }); 106 }, 107 }, 108 ]}> 109 歌单 110 </AppBar> 111 </> 112 ); 113} 114