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: 'trash-outline', 23 title: '删除歌单', 24 show: id !== 'favorite', 25 onPress() { 26 showDialog('SimpleDialog', { 27 title: '删除歌单', 28 content: `确定删除歌单「${musicSheet.title}」吗?`, 29 onOk: async () => { 30 await MusicSheet.removeSheet(id); 31 Toast.success('已删除'); 32 navigation.goBack(); 33 }, 34 }); 35 }, 36 }, 37 { 38 icon: 'pencil-square', 39 title: '批量编辑', 40 onPress() { 41 navigation.navigate(ROUTE_PATH.MUSIC_LIST_EDITOR, { 42 musicList: musicSheet.musicList, 43 musicSheet: musicSheet, 44 }); 45 }, 46 }, 47 { 48 icon: 'pencil-outline', 49 title: '编辑歌单信息', 50 onPress() { 51 showPanel('EditMusicSheetInfo', { 52 musicSheet: musicSheet, 53 }); 54 }, 55 }, 56 { 57 icon: 'sort-outline', 58 title: '歌曲排序', 59 onPress() { 60 showDialog('RadioDialog', { 61 content: [ 62 { 63 value: SortType.Title, 64 label: '按歌曲名排序', 65 }, 66 { 67 value: SortType.Artist, 68 label: '按作者名排序', 69 }, 70 { 71 value: SortType.Album, 72 label: '按专辑名排序', 73 }, 74 { 75 value: SortType.Newest, 76 label: '按收藏时间从新到旧排序', 77 }, 78 { 79 value: SortType.Oldest, 80 label: '按收藏时间从旧到新排序', 81 }, 82 ], 83 defaultSelected: 84 MusicSheet.getSheetMeta(id, 'sort') || 85 SortType.None, 86 title: '歌曲排序', 87 async onOk(value) { 88 await MusicSheet.setSortType( 89 id, 90 value as SortType, 91 ); 92 toast.success('排序已更新'); 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