xref: /MusicFree/src/pages/sheetDetail/components/navBar.tsx (revision a3289929bc041a9f0caf6abb271346bf5f23949e)
1bf6e62f2S猫头猫import React from 'react';
2bf6e62f2S猫头猫import {Appbar} from 'react-native-paper';
31c06c799S猫头猫import {StyleSheet, View} from 'react-native';
4bf6e62f2S猫头猫import rpx from '@/utils/rpx';
503f1f70cS猫头猫import {useNavigation, useRoute} from '@react-navigation/native';
6bf6e62f2S猫头猫import usePrimaryColor from '@/hooks/usePrimaryColor';
703f1f70cS猫头猫import AppBarWithSearch from '@/components/base/appBarWithSearch';
803f1f70cS猫头猫import MusicSheet from '@/common/musicSheetManager';
903f1f70cS猫头猫import {ROUTE_PATH} from '@/entry/router';
10*a3289929S猫头猫import useDialog from '@/components/dialogs/useDialog';
11bf6e62f2S猫头猫
12bf6e62f2S猫头猫interface IProps {}
13bf6e62f2S猫头猫export default function (props: IProps) {
1403f1f70cS猫头猫  const navigation = useNavigation<any>();
1503f1f70cS猫头猫  const route = useRoute<any>();
1603f1f70cS猫头猫  const id = route.params?.id ?? 'favorite';
1703f1f70cS猫头猫  const musicSheet = MusicSheet.useSheets(id);
18*a3289929S猫头猫  const {showDialog} = useDialog();
19bf6e62f2S猫头猫
20bf6e62f2S猫头猫  return (
2103f1f70cS猫头猫    <AppBarWithSearch
2203f1f70cS猫头猫      title="歌单"
2303f1f70cS猫头猫      onSearchPress={() => {
2403f1f70cS猫头猫        navigation.navigate(ROUTE_PATH.SEARCH_MUSIC_LIST, {
25*a3289929S猫头猫          musicList: musicSheet?.musicList,
2603f1f70cS猫头猫        });
27*a3289929S猫头猫      }}
28*a3289929S猫头猫      menuOptions={[
29*a3289929S猫头猫        {
30*a3289929S猫头猫          icon: 'trash-can-outline',
31*a3289929S猫头猫          title: '删除歌单',
32*a3289929S猫头猫          show: id !== 'favorite',
33*a3289929S猫头猫          onPress() {
34*a3289929S猫头猫            showDialog('SimpleDialog', {
35*a3289929S猫头猫              title: '删除歌单',
36*a3289929S猫头猫              content: `确定删除歌单${musicSheet.title}吗?`,
37*a3289929S猫头猫              onOk: async () => {
38*a3289929S猫头猫                await MusicSheet.removeSheet(id);
39*a3289929S猫头猫                navigation.goBack();
40*a3289929S猫头猫              },
41*a3289929S猫头猫            });
42*a3289929S猫头猫          },
43*a3289929S猫头猫        },
44*a3289929S猫头猫      ]}></AppBarWithSearch>
45bf6e62f2S猫头猫  );
46bf6e62f2S猫头猫}
47bf6e62f2S猫头猫
48bf6e62f2S猫头猫const style = StyleSheet.create({
49bf6e62f2S猫头猫  appbar: {
50bf6e62f2S猫头猫    shadowColor: 'transparent',
51bf6e62f2S猫头猫    flexDirection: 'row',
52bf6e62f2S猫头猫    width: rpx(750),
53bf6e62f2S猫头猫  },
54bf6e62f2S猫头猫});
55