xref: /MusicFree/src/pages/sheetDetail/components/navBar.tsx (revision 4060c00a75883036bbd315fb25c90065209312b3)
1import React from 'react';
2import {useNavigation, useRoute} from '@react-navigation/native';
3import AppBarWithSearch from '@/components/base/appBarWithSearch';
4import MusicSheet from '@/core/musicSheet';
5import {ROUTE_PATH} from '@/entry/router';
6import useDialog from '@/components/dialogs/useDialog';
7
8export default function () {
9    const navigation = useNavigation<any>();
10    const route = useRoute<any>();
11    const id = route.params?.id ?? 'favorite';
12    const musicSheet = MusicSheet.useSheets(id);
13    const {showDialog} = useDialog();
14
15    return (
16        <AppBarWithSearch
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                                navigation.goBack();
35                            },
36                        });
37                    },
38                },
39            ]}
40        />
41    );
42}
43