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