wavelength_app/components/theme/buttons/DefaultButton.tsx

57 lines
1.3 KiB
TypeScript
Raw Normal View History

import { StyleSheet, Pressable } from "react-native";
import { ThemedView } from "@/components/theme/Theme";
import { Colors } from '@/constants/Colors';
import { useColorScheme } from '@/hooks/useColorScheme';
2024-10-29 11:23:29 -05:00
import { StyleProp, ViewStyle } from 'react-native';
const DEFAULT_WIDTH = 320;
const DEFAULT_HEIGHT = 68;
type Props = {
width?: number;
height?: number;
onPress?: () => void;
};
const Button = ({ width, height, children, onPress }: Props & React.ComponentProps<typeof Pressable>) => {
const scheme = useColorScheme() ?? 'dark';
return (
<ThemedView
style={[
styles.buttonContainer,
{
width: (width ?? DEFAULT_WIDTH),
height: (height ?? DEFAULT_HEIGHT),
},
]}
>
<Pressable
style={[
styles.button,
{backgroundColor: Colors[scheme].text}
]}
onPress={onPress}
>
{children}
</Pressable>
</ThemedView>
);
};
export default Button;
const styles = StyleSheet.create({
buttonContainer: {
alignItems: 'center',
justifyContent: 'center',
padding: 3,
},
button: {
borderRadius: 10,
width: '100%',
height: '100%',
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'row',
},
});