1import { useCallback } from 'react';
2import { View, TouchableOpacity, Text, StyleSheet } from 'react-native';
3
4import { ActionFunction } from './index.types';
5import Colors from '../../constants/Colors';
6
7export default function ActionButton({
8  name,
9  action,
10  onPress,
11}: {
12  name: string;
13  action: ActionFunction;
14  onPress: (action: ActionFunction) => void;
15}) {
16  const handlePress = useCallback(() => onPress(action), [onPress, action]);
17
18  return (
19    <View style={styles.button}>
20      <TouchableOpacity onPress={handlePress}>
21        <Text style={styles.buttonText}>{name}</Text>
22      </TouchableOpacity>
23    </View>
24  );
25}
26
27const styles = StyleSheet.create({
28  button: {
29    paddingVertical: 3,
30    paddingHorizontal: 6,
31    marginLeft: 5,
32    backgroundColor: Colors.tintColor,
33    borderRadius: 5,
34  },
35  buttonText: {
36    fontSize: 10,
37    padding: 2,
38    fontWeight: '500',
39    color: 'white',
40  },
41});
42