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