xref: /MusicFree/src/pages/sheetDetail/components/navBar.tsx (revision b4c389f44ac4dad056e7314478fadd2eca82a4b1)
1bf6e62f2S猫头猫import React from 'react';
2e7fa3837S猫头猫import {useNavigation} from '@react-navigation/native';
3*b4c389f4Smaotoumaoimport {ROUTE_PATH, useParams} from '@/core/router';
42a3194f5S猫头猫import Toast from '@/utils/toast';
5740e3947S猫头猫import toast from '@/utils/toast';
675d76114S猫头猫import {showDialog} from '@/components/dialogs/useDialog';
77a8d024eS猫头猫import AppBar from '@/components/base/appBar';
8740e3947S猫头猫import MusicSheet from '@/core/musicSheet';
9740e3947S猫头猫import {SortType} from '@/constants/commonConst.ts';
10da2a2959S猫头猫import {showPanel} from '@/components/panels/usePanel.ts';
11bf6e62f2S猫头猫
124060c00aS猫头猫export default function () {
1303f1f70cS猫头猫    const navigation = useNavigation<any>();
14ceb900cdS猫头猫    const {id = 'favorite'} = useParams<'local-sheet-detail'>();
15740e3947S猫头猫    const musicSheet = MusicSheet.useSheetItem(id);
16bf6e62f2S猫头猫
17bf6e62f2S猫头猫    return (
187a8d024eS猫头猫        <>
197a8d024eS猫头猫            <AppBar
207a8d024eS猫头猫                menu={[
21a3289929S猫头猫                    {
227fb90110S猫头猫                        icon: 'pencil-outline',
237fb90110S猫头猫                        title: '编辑歌单信息',
24a3289929S猫头猫                        onPress() {
257fb90110S猫头猫                            showPanel('EditMusicSheetInfo', {
26f970486eS猫头猫                                musicSheet: musicSheet,
27f970486eS猫头猫                            });
28f970486eS猫头猫                        },
29f970486eS猫头猫                    },
30e26be108S猫头猫                    {
317fb90110S猫头猫                        icon: 'pencil-square',
327fb90110S猫头猫                        title: '批量编辑歌曲',
33e26be108S猫头猫                        onPress() {
347fb90110S猫头猫                            navigation.navigate(ROUTE_PATH.MUSIC_LIST_EDITOR, {
357fb90110S猫头猫                                musicList: musicSheet.musicList,
36e26be108S猫头猫                                musicSheet: musicSheet,
37e26be108S猫头猫                            });
38e26be108S猫头猫                        },
39e26be108S猫头猫                    },
403499559fS猫头猫                    {
415589cdf3S猫头猫                        icon: 'sort-outline',
42740e3947S猫头猫                        title: '歌曲排序',
433499559fS猫头猫                        onPress() {
443499559fS猫头猫                            showDialog('RadioDialog', {
453499559fS猫头猫                                content: [
463499559fS猫头猫                                    {
47740e3947S猫头猫                                        value: SortType.Title,
48740e3947S猫头猫                                        label: '按歌曲名排序',
493499559fS猫头猫                                    },
503499559fS猫头猫                                    {
51740e3947S猫头猫                                        value: SortType.Artist,
52740e3947S猫头猫                                        label: '按作者名排序',
533499559fS猫头猫                                    },
543499559fS猫头猫                                    {
55740e3947S猫头猫                                        value: SortType.Album,
56740e3947S猫头猫                                        label: '按专辑名排序',
573499559fS猫头猫                                    },
583499559fS猫头猫                                    {
59740e3947S猫头猫                                        value: SortType.Newest,
60740e3947S猫头猫                                        label: '按收藏时间从新到旧排序',
613499559fS猫头猫                                    },
623499559fS猫头猫                                    {
63740e3947S猫头猫                                        value: SortType.Oldest,
64740e3947S猫头猫                                        label: '按收藏时间从旧到新排序',
65e43bbb40S猫头猫                                    },
663499559fS猫头猫                                ],
67740e3947S猫头猫                                defaultSelected:
68740e3947S猫头猫                                    MusicSheet.getSheetMeta(id, 'sort') ||
69740e3947S猫头猫                                    SortType.None,
70740e3947S猫头猫                                title: '歌曲排序',
713499559fS猫头猫                                async onOk(value) {
72740e3947S猫头猫                                    await MusicSheet.setSortType(
73740e3947S猫头猫                                        id,
74740e3947S猫头猫                                        value as SortType,
753499559fS猫头猫                                    );
76740e3947S猫头猫                                    toast.success('排序已更新');
773499559fS猫头猫                                },
783499559fS猫头猫                            });
793499559fS猫头猫                        },
803499559fS猫头猫                    },
817fb90110S猫头猫                    {
827fb90110S猫头猫                        icon: 'trash-outline',
837fb90110S猫头猫                        title: '删除歌单',
847fb90110S猫头猫                        show: id !== 'favorite',
857fb90110S猫头猫                        onPress() {
867fb90110S猫头猫                            showDialog('SimpleDialog', {
877fb90110S猫头猫                                title: '删除歌单',
887fb90110S猫头猫                                content: `确定删除歌单「${musicSheet.title}」吗?`,
897fb90110S猫头猫                                onOk: async () => {
907fb90110S猫头猫                                    await MusicSheet.removeSheet(id);
917fb90110S猫头猫                                    Toast.success('已删除');
927fb90110S猫头猫                                    navigation.goBack();
937fb90110S猫头猫                                },
947fb90110S猫头猫                            });
957fb90110S猫头猫                        },
967fb90110S猫头猫                    },
974060c00aS猫头猫                ]}
987a8d024eS猫头猫                actions={[
997a8d024eS猫头猫                    {
1005589cdf3S猫头猫                        icon: 'magnifying-glass',
1017a8d024eS猫头猫                        onPress() {
1027a8d024eS猫头猫                            navigation.navigate(ROUTE_PATH.SEARCH_MUSIC_LIST, {
1037a8d024eS猫头猫                                musicList: musicSheet?.musicList,
1047ce5c26cS猫头猫                                musicSheet: musicSheet,
1057a8d024eS猫头猫                            });
1067a8d024eS猫头猫                        },
1077a8d024eS猫头猫                    },
1087a8d024eS猫头猫                ]}>
1097a8d024eS猫头猫                歌单
1107a8d024eS猫头猫            </AppBar>
1117a8d024eS猫头猫        </>
112bf6e62f2S猫头猫    );
113bf6e62f2S猫头猫}
114