xref: /MusicFree/src/pages/sheetDetail/components/navBar.tsx (revision 428a07232c590a64f321e5de380e0b764e4a2b5e)
1import React from 'react';
2import {useNavigation} from '@react-navigation/native';
3import ComplexAppBar from '@/components/base/ComplexAppBar';
4import MusicSheet from '@/core/musicSheet';
5import {ROUTE_PATH, useParams} from '@/entry/router';
6import Toast from '@/utils/toast';
7import {showDialog} from '@/components/dialogs/useDialog';
8
9export default function () {
10    const navigation = useNavigation<any>();
11    const {id = 'favorite'} = useParams<'local-sheet-detail'>();
12    const musicSheet = MusicSheet.useSheets(id);
13
14    return (
15        <ComplexAppBar
16            title="歌单"
17            onSearchPress={() => {
18                navigation.navigate(ROUTE_PATH.SEARCH_MUSIC_LIST, {
19                    musicList: musicSheet?.musicList,
20                });
21            }}
22            menuOptions={[
23                {
24                    icon: 'trash-can-outline',
25                    title: '删除歌单',
26                    show: id !== 'favorite',
27                    onPress() {
28                        showDialog('SimpleDialog', {
29                            title: '删除歌单',
30                            content: `确定删除歌单「${musicSheet.title}」吗?`,
31                            onOk: async () => {
32                                await MusicSheet.removeSheet(id);
33                                Toast.success('已删除');
34                                navigation.goBack();
35                            },
36                        });
37                    },
38                },
39                {
40                    icon: 'playlist-edit',
41                    title: '批量编辑',
42                    onPress() {
43                        navigation.navigate(ROUTE_PATH.MUSIC_LIST_EDITOR, {
44                            musicList: musicSheet.musicList,
45                            musicSheet: musicSheet,
46                        });
47                    },
48                },
49                {
50                    icon: 'square-edit-outline',
51                    title: '编辑歌单信息',
52                    onPress() {
53                        showDialog('EditSheetDetailDialog', {
54                            musicSheet: musicSheet,
55                        });
56                    },
57                },
58                {
59                    icon: 'sort',
60                    title: '排序',
61                    onPress() {
62                        showDialog('RadioDialog', {
63                            content: [
64                                {
65                                    value: 'random',
66                                    key: '随机顺序',
67                                },
68                                {
69                                    value: 'a2z',
70                                    key: '歌曲名A-Z',
71                                },
72                                {
73                                    value: 'z2a',
74                                    key: '歌曲名Z-A',
75                                },
76                                {
77                                    value: 'arta2z',
78                                    key: '作者名A-Z',
79                                },
80                                {
81                                    value: 'artz2a',
82                                    key: '作者名Z-A',
83                                },
84                            ],
85                            title: '排序',
86                            async onOk(value) {
87                                MusicSheet.sortMusicList(
88                                    value as any,
89                                    musicSheet,
90                                );
91                            },
92                        });
93                    },
94                },
95            ]}
96        />
97    );
98}
99