2021-09-13 20:41:05 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { Text } from 'react-native';
|
|
|
|
|
|
|
|
import styles from './styles';
|
2022-04-07 14:10:03 +00:00
|
|
|
import { themes } from '../../../lib/constants';
|
2022-06-06 14:17:51 +00:00
|
|
|
import Touch from '../../../lib/methods/helpers/touch';
|
2022-05-02 19:21:15 +00:00
|
|
|
import { CustomIcon, TIconsName } from '../../CustomIcon';
|
2022-03-23 00:43:59 +00:00
|
|
|
import { useTheme } from '../../../theme';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
|
|
|
interface IPasscodeButton {
|
2022-01-12 12:54:04 +00:00
|
|
|
text?: string;
|
2022-05-02 19:21:15 +00:00
|
|
|
icon?: TIconsName;
|
2022-01-12 12:54:04 +00:00
|
|
|
disabled?: boolean;
|
|
|
|
onPress?: Function;
|
2021-09-13 20:41:05 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 00:43:59 +00:00
|
|
|
const Button = React.memo(({ text, disabled, onPress, icon }: IPasscodeButton) => {
|
|
|
|
const { theme } = useTheme();
|
|
|
|
|
2022-01-12 12:54:04 +00:00
|
|
|
const press = () => onPress && onPress(text);
|
2021-09-13 20:41:05 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Touch
|
|
|
|
style={[styles.buttonView, { backgroundColor: 'transparent' }]}
|
2022-01-12 12:54:04 +00:00
|
|
|
underlayColor={themes[theme].passcodeButtonActive}
|
|
|
|
rippleColor={themes[theme].passcodeButtonActive}
|
2021-09-13 20:41:05 +00:00
|
|
|
enabled={!disabled}
|
|
|
|
theme={theme}
|
2022-08-08 21:02:08 +00:00
|
|
|
onPress={press}
|
|
|
|
>
|
2021-09-13 20:41:05 +00:00
|
|
|
{icon ? (
|
2022-01-12 12:54:04 +00:00
|
|
|
<CustomIcon name={icon} size={36} color={themes[theme].passcodePrimary} />
|
2021-09-13 20:41:05 +00:00
|
|
|
) : (
|
2022-01-12 12:54:04 +00:00
|
|
|
<Text style={[styles.buttonText, { color: themes[theme].passcodePrimary }]}>{text}</Text>
|
2021-09-13 20:41:05 +00:00
|
|
|
)}
|
|
|
|
</Touch>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
export default Button;
|