xref: /MusicFree/src/pages/home/components/ActionButton.tsx (revision f90698e4f487034964a52e83e0bbca6e7a56aaa5)
1*f90698e4S猫头猫import ThemeText from '@/components/base/themeText';
2*f90698e4S猫头猫import useColors from '@/hooks/useColors';
3*f90698e4S猫头猫import rpx from '@/utils/rpx';
4*f90698e4S猫头猫import React from 'react';
5*f90698e4S猫头猫import {StyleProp, StyleSheet, ViewStyle} from 'react-native';
6*f90698e4S猫头猫import {TouchableOpacity} from 'react-native-gesture-handler';
7*f90698e4S猫头猫import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
8*f90698e4S猫头猫
9*f90698e4S猫头猫interface IActionButtonProps {
10*f90698e4S猫头猫    iconName: string;
11*f90698e4S猫头猫    iconColor?: string;
12*f90698e4S猫头猫    title: string;
13*f90698e4S猫头猫    action: () => void;
14*f90698e4S猫头猫    style?: StyleProp<ViewStyle>;
15*f90698e4S猫头猫}
16*f90698e4S猫头猫
17*f90698e4S猫头猫export default function ActionButton(props: IActionButtonProps) {
18*f90698e4S猫头猫    const {iconName, iconColor, title, action, style} = props;
19*f90698e4S猫头猫    const colors = useColors();
20*f90698e4S猫头猫    // rippleColor="rgba(0, 0, 0, .32)"
21*f90698e4S猫头猫    return (
22*f90698e4S猫头猫        <TouchableOpacity
23*f90698e4S猫头猫            onPress={action}
24*f90698e4S猫头猫            style={[
25*f90698e4S猫头猫                styles.wrapper,
26*f90698e4S猫头猫                {
27*f90698e4S猫头猫                    backgroundColor: colors.card,
28*f90698e4S猫头猫                },
29*f90698e4S猫头猫                style,
30*f90698e4S猫头猫            ]}>
31*f90698e4S猫头猫            <>
32*f90698e4S猫头猫                <Icon
33*f90698e4S猫头猫                    accessible={false}
34*f90698e4S猫头猫                    name={iconName}
35*f90698e4S猫头猫                    color={iconColor ?? colors.text}
36*f90698e4S猫头猫                    size={rpx(48)}
37*f90698e4S猫头猫                />
38*f90698e4S猫头猫                <ThemeText
39*f90698e4S猫头猫                    accessible={false}
40*f90698e4S猫头猫                    fontSize="subTitle"
41*f90698e4S猫头猫                    fontWeight="semibold"
42*f90698e4S猫头猫                    style={styles.text}>
43*f90698e4S猫头猫                    {title}
44*f90698e4S猫头猫                </ThemeText>
45*f90698e4S猫头猫            </>
46*f90698e4S猫头猫        </TouchableOpacity>
47*f90698e4S猫头猫    );
48*f90698e4S猫头猫}
49*f90698e4S猫头猫
50*f90698e4S猫头猫const styles = StyleSheet.create({
51*f90698e4S猫头猫    wrapper: {
52*f90698e4S猫头猫        width: rpx(140),
53*f90698e4S猫头猫        height: rpx(144),
54*f90698e4S猫头猫        borderRadius: rpx(12),
55*f90698e4S猫头猫        flexGrow: 1,
56*f90698e4S猫头猫        flexShrink: 0,
57*f90698e4S猫头猫        flexDirection: 'column',
58*f90698e4S猫头猫        alignItems: 'center',
59*f90698e4S猫头猫        justifyContent: 'center',
60*f90698e4S猫头猫    },
61*f90698e4S猫头猫    text: {
62*f90698e4S猫头猫        marginTop: rpx(12),
63*f90698e4S猫头猫    },
64*f90698e4S猫头猫});
65