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