Created
February 9, 2024 03:55
-
-
Save Doko-Demo-Doa/4aafd423197660944a9472ac1b186460 to your computer and use it in GitHub Desktop.
Custom Component, simple version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { PropsWithChildren } from "react"; | |
import { StyleSheet } from "react-native"; | |
import { | |
TouchableOpacity, | |
TouchableOpacityProps, | |
} from "~/components/overrides"; | |
import { createStyleSheet, useStyles } from "~/utils/theme-utils"; | |
interface Props extends PropsWithChildren, TouchableOpacityProps { | |
variant?: "blue" | "purple" | "default"; | |
} | |
export const CustomButton: React.FC<Props> = ({ children, ...props }) => { | |
const { styles } = useStyles(styleSheet); | |
return ( | |
<TouchableOpacity | |
{...props} | |
style={StyleSheet.flatten([styles.default, props.style])} | |
> | |
{children} | |
</TouchableOpacity> | |
); | |
}; | |
const styleSheet = createStyleSheet((theme) => ({ | |
default: { | |
paddingHorizontal: 2, | |
paddingVertical: 2, | |
alignItems: "center", | |
justifyContent: "center", | |
borderRadius: 8, | |
backgroundColor: theme.colors.buttonSecondaryEnabled, | |
}, | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment