xref: /MusicFree/src/pages/home/components/operations/index.tsx (revision b4c389f44ac4dad056e7314478fadd2eca82a4b1)
14060c00aS猫头猫import React from 'react';
2e0caea6eS猫头猫import {StyleSheet} from 'react-native';
3bf6e62f2S猫头猫import rpx from '@/utils/rpx';
4f90698e4S猫头猫import ActionButton from '../ActionButton';
5*b4c389f4Smaotoumaoimport {ROUTE_PATH, useNavigate} from '@/core/router';
6e0caea6eS猫头猫import {ScrollView} from 'react-native-gesture-handler';
75589cdf3S猫头猫import {IIconName} from '@/components/base/icon.tsx';
8bf6e62f2S猫头猫
9e0caea6eS猫头猫interface IOperationsProps {
10ab5f994aSmaotoumao    orientation?: 'horizontal' | 'vertical';
11e0caea6eS猫头猫}
12e0caea6eS猫头猫
135589cdf3S猫头猫interface IActionOption {
145589cdf3S猫头猫    iconName: IIconName;
155589cdf3S猫头猫    iconColor?: string;
165589cdf3S猫头猫    title: string;
175589cdf3S猫头猫    action?: () => void;
185589cdf3S猫头猫}
195589cdf3S猫头猫
20e0caea6eS猫头猫export default function Operations(props: IOperationsProps) {
21e7fa3837S猫头猫    const navigate = useNavigate();
22e0caea6eS猫头猫    const {orientation} = props;
23bf6e62f2S猫头猫
245589cdf3S猫头猫    const actionButtons: IActionOption[] = [
2508a8e62cS猫头猫        {
26bf6e62f2S猫头猫            iconName: 'heart',
27bf6e62f2S猫头猫            iconColor: 'red',
287aed04d4S猫头猫            title: '我喜欢',
29bf6e62f2S猫头猫            action() {
30ceb900cdS猫头猫                navigate(ROUTE_PATH.LOCAL_SHEET_DETAIL, {
3108a8e62cS猫头猫                    id: 'favorite',
3208a8e62cS猫头猫                });
3308a8e62cS猫头猫            },
3408a8e62cS猫头猫        },
3508a8e62cS猫头猫        {
36233cafa6S猫头猫            iconName: 'folder-music-outline',
37bf6e62f2S猫头猫            title: '本地音乐',
38bf6e62f2S猫头猫            action() {
39e7fa3837S猫头猫                navigate(ROUTE_PATH.LOCAL);
4008a8e62cS猫头猫            },
4108a8e62cS猫头猫        },
4208a8e62cS猫头猫        {
43ceb900cdS猫头猫            iconName: 'fire',
44ceb900cdS猫头猫            title: '推荐歌单',
45bf6e62f2S猫头猫            action() {
46ceb900cdS猫头猫                navigate(ROUTE_PATH.RECOMMEND_SHEETS);
4708a8e62cS猫头猫            },
4808a8e62cS猫头猫        },
49f326d0eeS猫头猫        {
505589cdf3S猫头猫            iconName: 'trophy',
51f326d0eeS猫头猫            title: '榜单',
52f326d0eeS猫头猫            action() {
53d52aa40eS猫头猫                navigate(ROUTE_PATH.TOP_LIST);
54f326d0eeS猫头猫            },
55f326d0eeS猫头猫        },
560412c91bS猫头猫        {
575589cdf3S猫头猫            iconName: 'clock-outline',
580412c91bS猫头猫            title: '播放记录',
590412c91bS猫头猫            action() {
600412c91bS猫头猫                navigate(ROUTE_PATH.HISTORY);
610412c91bS猫头猫            },
620412c91bS猫头猫        },
6308a8e62cS猫头猫    ];
64bf6e62f2S猫头猫
65bf6e62f2S猫头猫    return (
66e0caea6eS猫头猫        <ScrollView
670412c91bS猫头猫            style={
680412c91bS猫头猫                orientation === 'vertical'
690412c91bS猫头猫                    ? style.wrapper
70ab5f994aSmaotoumao                    : style.horizontalWrapper
710412c91bS猫头猫            }
72ab5f994aSmaotoumao            scrollEnabled={orientation === 'horizontal'}
73e650bfb3S猫头猫            showsHorizontalScrollIndicator={false}
74e0caea6eS猫头猫            horizontal={orientation === 'vertical'}
75e0caea6eS猫头猫            contentContainerStyle={
76e0caea6eS猫头猫                orientation === 'vertical'
77e0caea6eS猫头猫                    ? style.contentWrapper
78ab5f994aSmaotoumao                    : style.horizontalContentWrapper
79e0caea6eS猫头猫            }>
8008a8e62cS猫头猫            {actionButtons.map(action => (
814060c00aS猫头猫                <ActionButton key={action.title} {...action} />
8208a8e62cS猫头猫            ))}
83e0caea6eS猫头猫        </ScrollView>
84bf6e62f2S猫头猫    );
85bf6e62f2S猫头猫}
86bf6e62f2S猫头猫
87bf6e62f2S猫头猫const style = StyleSheet.create({
88bf6e62f2S猫头猫    wrapper: {
89e1fceebdS猫头猫        marginTop: rpx(20),
90e1fceebdS猫头猫        marginBottom: rpx(20),
91e0caea6eS猫头猫        flexGrow: 0,
92e0caea6eS猫头猫        flexShrink: 0,
930412c91bS猫头猫    },
94ab5f994aSmaotoumao    horizontalWrapper: {
950412c91bS猫头猫        marginTop: rpx(20),
960412c91bS猫头猫        marginBottom: rpx(20),
970412c91bS猫头猫        flexGrow: 0,
980412c91bS猫头猫        flexShrink: 0,
99e0caea6eS猫头猫    },
100e0caea6eS猫头猫    contentWrapper: {
101e0caea6eS猫头猫        flexDirection: 'row',
102e0caea6eS猫头猫        height: rpx(144),
103e0caea6eS猫头猫        paddingHorizontal: rpx(24),
104e0caea6eS猫头猫    },
105ab5f994aSmaotoumao    horizontalContentWrapper: {
106e0caea6eS猫头猫        width: rpx(170),
107e0caea6eS猫头猫        flexDirection: 'column',
108e0caea6eS猫头猫        paddingVertical: rpx(24),
1097bd66ef7S猫头猫        paddingLeft: rpx(15),
110bf6e62f2S猫头猫    },
111bf6e62f2S猫头猫});
112