import { FontAwesome } from "@expo/vector-icons";
import { GlyphMap } from "@expo/vector-icons/build/createIconSet";
import React from "react";
import { GestureResponderEvent, StyleProp, StyleSheet, Text, TouchableOpacity, ViewStyle } from "react-native";
import { IconProps } from "react-native-paper/lib/typescript/components/MaterialCommunityIcon";
import { colors } from "../utils/GlobalUtils";

interface ButtonProps {
    onPress: (event: GestureResponderEvent) => void,
    style?: StyleProp<ViewStyle>
}

interface TextButtonProps extends ButtonProps {
    text: string,
}

interface IconButtonProps extends ButtonProps {
    icon: string,
    color: string,
    size: number
}

/**
 * A general component that represents a primary button.
 * @component 
 */
export const PrimaryButton: React.FC<TextButtonProps> = ({text, onPress, style}) => {
    return(
    <TouchableOpacity style={[styles.btn, styles.primaryBtn, style]} onPress={onPress}>
        <Text style={{color: 'white'}}>{text}</Text>
    </TouchableOpacity>)
}

/**
 * A general component that represents a secondary button.
 * @component 
 */
export const SecondaryButton: React.FC<TextButtonProps> = ({text, onPress, style}) => {
    return(
    <TouchableOpacity style={[styles.btn, styles.secondaryBtn, style]} onPress={onPress}>
        <Text style={{color: 'white'}}>{text}</Text>
    </TouchableOpacity>)
}

export const IconButton: React.FC<IconButtonProps> = ({onPress, style, size, color, icon}) => {
    return(
        <TouchableOpacity style={style} onPress={onPress}>
            <FontAwesome size={size} color={color} name={icon as any}/>
        </TouchableOpacity>
    )
}

const styles = StyleSheet.create({
    btn: {
        borderRadius: 50,
        width: '100%',
        justifyContent: 'center',
        alignItems: 'center',
        height: 60,
        marginBottom: 20,
    },
    primaryBtn: {
        backgroundColor: colors.red,
    },
    secondaryBtn: {
        borderColor: 'white',
        borderWidth: 2,
        backgroundColor: 'transparent',
    }
})