xref: /MusicFree/src/pages/musicDetail/components/navBar.tsx (revision b882a19d884fffa32f7c8cef31652b909dceaa0f)
1import React from 'react';
2import {StyleSheet, Text, View} from 'react-native';
3import rpx from '@/utils/rpx';
4import {IconButton} from 'react-native-paper';
5import MusicQueue from '@/core/musicQueue';
6import {useNavigation} from '@react-navigation/native';
7import Tag from '@/components/base/tag';
8import {fontSizeConst, fontWeightConst} from '@/constants/uiConst';
9// import useShare from '@/components/share/useShare';
10import Toast from '@/utils/toast';
11
12export default function NavBar() {
13    const navigation = useNavigation();
14    const musicItem = MusicQueue.useCurrentMusicItem();
15    // const {showShare} = useShare();
16
17    return (
18        <View style={style.wrapper}>
19            <IconButton
20                icon="arrow-left"
21                size={rpx(48)}
22                color="white"
23                onPress={() => {
24                    navigation.goBack();
25                }}
26            />
27            <View style={style.headerContent}>
28                <Text numberOfLines={1} style={style.headerTitleText}>
29                    {musicItem?.title ?? ''}
30                </Text>
31                <View style={style.headerDesc}>
32                    <Text style={style.headerArtistText}>
33                        {musicItem?.artist}
34                    </Text>
35                    <Tag tagName={musicItem?.platform ?? ''} />
36                </View>
37            </View>
38            <IconButton
39                icon="share"
40                color="white"
41                size={rpx(48)}
42                onPress={() => {
43                    Toast.warn('还没做好...再等等吧');
44                    // showShare({
45                    //     content: {
46                    //         type: 'ShareMusic',
47                    //         track: {
48                    //             id: musicItem?.id,
49                    //             platform: musicItem?.platform,
50                    //         },
51                    //     },
52                    //     title: musicItem?.title,
53                    //     desc: musicItem?.artist,
54                    // });
55                }}
56            />
57        </View>
58    );
59}
60
61const style = StyleSheet.create({
62    wrapper: {
63        width: rpx(750),
64        height: rpx(150),
65        flexDirection: 'row',
66        alignItems: 'center',
67        justifyContent: 'space-between',
68    },
69    headerContent: {
70        flex: 1,
71        height: rpx(150),
72        justifyContent: 'center',
73        alignItems: 'center',
74        maxWidth: rpx(640),
75    },
76    headerTitleText: {
77        color: 'white',
78        fontWeight: fontWeightConst.semibold,
79        fontSize: fontSizeConst.title,
80        marginBottom: rpx(12),
81        includeFontPadding: false,
82    },
83    headerDesc: {
84        height: rpx(32),
85        flexDirection: 'row',
86        alignItems: 'center',
87    },
88    headerArtistText: {
89        color: 'white',
90        fontSize: fontSizeConst.subTitle,
91        includeFontPadding: false,
92    },
93});
94