xref: /MusicFree/src/components/base/button.tsx (revision 5589cdf32b2bb0f641e5ac7bf1f6152cd6b9b70e)
1import React from 'react';
2import {Pressable} from 'react-native';
3import ThemeText from './themeText';
4import rpx from '@/utils/rpx';
5import {CustomizedColors} from '@/hooks/useColors';
6
7interface IButtonProps {
8    withHorizontalPadding?: boolean;
9    style?: any;
10    hitSlop?: number;
11    children: string;
12    fontColor?: keyof CustomizedColors;
13    onPress?: () => void;
14}
15export default function (props: IButtonProps) {
16    const {children, onPress, fontColor, hitSlop, withHorizontalPadding} =
17        props;
18    return (
19        <Pressable
20            {...props}
21            style={[
22                withHorizontalPadding
23                    ? {
24                          paddingHorizontal: rpx(24),
25                      }
26                    : null,
27                props.style,
28            ]}
29            hitSlop={hitSlop ?? (withHorizontalPadding ? 0 : rpx(28))}
30            onPress={onPress}
31            accessible
32            accessibilityLabel={children}>
33            <ThemeText fontColor={fontColor}>{children}</ThemeText>
34        </Pressable>
35    );
36}
37