xref: /MusicFree/src/components/base/playAllBar.tsx (revision c15039e228b46df3f5b7c5a9eb747a6097ad7be8)
19801b15cS猫头猫import React from 'react';
29801b15cS猫头猫import {Pressable, StyleSheet, View} from 'react-native';
39801b15cS猫头猫import rpx from '@/utils/rpx';
49801b15cS猫头猫import {iconSizeConst} from '@/constants/uiConst';
59801b15cS猫头猫import MusicQueue from '@/core/musicQueue';
69801b15cS猫头猫import {ROUTE_PATH, useNavigate} from '@/entry/router';
79801b15cS猫头猫import Color from 'color';
89801b15cS猫头猫import {IconButton} from 'react-native-paper';
99801b15cS猫头猫import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
109801b15cS猫头猫import ThemeText from './themeText';
119801b15cS猫头猫import useColors from '@/hooks/useColors';
12*c15039e2S猫头猫import {showPanel} from '../panels/usePanel';
139801b15cS猫头猫
149801b15cS猫头猫interface IProps {
159801b15cS猫头猫    musicList: IMusic.IMusicItem[] | null;
169801b15cS猫头猫    sheetName?: string;
179801b15cS猫头猫}
189801b15cS猫头猫export default function (props: IProps) {
199801b15cS猫头猫    const {musicList, sheetName} = props;
209801b15cS猫头猫    const colors = useColors();
219801b15cS猫头猫    const navigate = useNavigate();
229801b15cS猫头猫
239801b15cS猫头猫    return (
249801b15cS猫头猫        <View
259801b15cS猫头猫            style={[
269801b15cS猫头猫                style.topWrapper,
279801b15cS猫头猫                {
289801b15cS猫头猫                    backgroundColor: Color(colors.primary)
299801b15cS猫头猫                        .alpha(0.15)
309801b15cS猫头猫                        .toString(),
319801b15cS猫头猫                },
329801b15cS猫头猫            ]}>
339801b15cS猫头猫            <Pressable
349801b15cS猫头猫                style={style.playAll}
359801b15cS猫头猫                onPress={() => {
369801b15cS猫头猫                    if (musicList) {
379801b15cS猫头猫                        MusicQueue.playWithReplaceQueue(
389801b15cS猫头猫                            musicList[0],
399801b15cS猫头猫                            musicList,
409801b15cS猫头猫                        );
419801b15cS猫头猫                    }
429801b15cS猫头猫                }}>
439801b15cS猫头猫                <Icon
449801b15cS猫头猫                    name="play-circle-outline"
459801b15cS猫头猫                    style={style.playAllIcon}
469801b15cS猫头猫                    size={iconSizeConst.normal}
479801b15cS猫头猫                    color={colors.text}
489801b15cS猫头猫                />
499801b15cS猫头猫                <ThemeText fontWeight="bold">播放全部</ThemeText>
509801b15cS猫头猫            </Pressable>
519801b15cS猫头猫            <IconButton
529801b15cS猫头猫                icon={'plus-box-multiple-outline'}
539801b15cS猫头猫                size={rpx(48)}
549801b15cS猫头猫                onPress={async () => {
559801b15cS猫头猫                    showPanel('AddToMusicSheet', {
569801b15cS猫头猫                        musicItem: musicList ?? [],
579801b15cS猫头猫                        newSheetDefaultName: sheetName,
589801b15cS猫头猫                    });
599801b15cS猫头猫                }}
609801b15cS猫头猫            />
619801b15cS猫头猫            <IconButton
629801b15cS猫头猫                icon="playlist-edit"
639801b15cS猫头猫                size={rpx(48)}
649801b15cS猫头猫                onPress={async () => {
659801b15cS猫头猫                    navigate(ROUTE_PATH.MUSIC_LIST_EDITOR, {
669801b15cS猫头猫                        musicList: musicList,
679801b15cS猫头猫                        musicSheet: {
689801b15cS猫头猫                            title: sheetName,
699801b15cS猫头猫                        },
709801b15cS猫头猫                    });
719801b15cS猫头猫                }}
729801b15cS猫头猫            />
739801b15cS猫头猫        </View>
749801b15cS猫头猫    );
759801b15cS猫头猫}
769801b15cS猫头猫
779801b15cS猫头猫const style = StyleSheet.create({
789801b15cS猫头猫    /** playall */
799801b15cS猫头猫    topWrapper: {
809801b15cS猫头猫        height: rpx(72),
819801b15cS猫头猫        paddingHorizontal: rpx(24),
829801b15cS猫头猫        flexDirection: 'row',
839801b15cS猫头猫        alignItems: 'center',
849801b15cS猫头猫    },
859801b15cS猫头猫    playAll: {
869801b15cS猫头猫        flex: 1,
879801b15cS猫头猫        flexDirection: 'row',
889801b15cS猫头猫        alignItems: 'center',
899801b15cS猫头猫    },
909801b15cS猫头猫    playAllIcon: {
919801b15cS猫头猫        marginRight: rpx(12),
929801b15cS猫头猫    },
939801b15cS猫头猫});
94