xref: /MusicFree/src/pages/sheetDetail/components/navBar.tsx (revision 2aa881935ca35b8fb1abc4206e0dc35149231456)
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 useDialog from '@/components/dialogs/useDialog';
7import Toast from '@/utils/toast';
8
9export default function () {
10    const navigation = useNavigation<any>();
11    const {id = 'favorite'} = useParams<'sheet-detail'>();
12    const musicSheet = MusicSheet.useSheets(id);
13    const {showDialog} = useDialog();
14
15    return (
16        <ComplexAppBar
17            title="歌单"
18            onSearchPress={() => {
19                navigation.navigate(ROUTE_PATH.SEARCH_MUSIC_LIST, {
20                    musicList: musicSheet?.musicList,
21                });
22            }}
23            menuOptions={[
24                {
25                    icon: 'trash-can-outline',
26                    title: '删除歌单',
27                    show: id !== 'favorite',
28                    onPress() {
29                        showDialog('SimpleDialog', {
30                            title: '删除歌单',
31                            content: `确定删除歌单「${musicSheet.title}」吗?`,
32                            onOk: async () => {
33                                await MusicSheet.removeSheet(id);
34                                Toast.success('已删除');
35                                navigation.goBack();
36                            },
37                        });
38                    },
39                },
40                {
41                    icon: 'playlist-edit',
42                    title: '批量编辑',
43                    onPress() {
44                        navigation.navigate(ROUTE_PATH.MUSIC_LIST_EDITOR, {
45                            musicList: musicSheet.musicList,
46                            musicSheet: musicSheet,
47                        });
48                    },
49                },
50                {
51                    icon: 'square-edit-outline',
52                    title: '编辑歌单信息',
53                    onPress() {
54                        showDialog('EditSheetDetailDialog', {
55                            musicSheet: musicSheet,
56                        });
57                    },
58                },
59            ]}
60        />
61    );
62}
63