50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { supabase } from '@/lib/supabase';
|
|
import { ThemedTextButton } from '@/components/theme';
|
|
import { Alert, StyleSheet } from 'react-native';
|
|
import React from 'react';
|
|
import { TextStyle, PressableProps, DimensionValue } from 'react-native';
|
|
|
|
// Extend ThemedButton props (which already extends PressableProps)
|
|
type ThemedTextButtonProps = Omit<PressableProps, 'children'> & {
|
|
width?: DimensionValue;
|
|
height?: DimensionValue;
|
|
fontSize?: number;
|
|
fontWeight?: 'normal' | 'semibold' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
|
|
textStyle?: TextStyle;
|
|
containerStyle?: object;
|
|
buttonStyle?: object;
|
|
};
|
|
|
|
const Logout_Button: React.FC<ThemedTextButtonProps> = ({
|
|
width,
|
|
height,
|
|
fontSize = 16,
|
|
fontWeight = 'normal',
|
|
textStyle,
|
|
containerStyle,
|
|
buttonStyle,
|
|
...restProps
|
|
}) => {
|
|
const signOut = async () => {
|
|
const { error } = await supabase.auth.signOut();
|
|
if (error) Alert.alert(error.message);
|
|
};
|
|
|
|
return (
|
|
<ThemedTextButton
|
|
text='Logout'
|
|
width={width}
|
|
height={height}
|
|
textColor='white'
|
|
backgroundColor='red'
|
|
fontSize={fontSize}
|
|
fontWeight={fontWeight}
|
|
containerStyle={containerStyle}
|
|
buttonStyle={buttonStyle}
|
|
onPress={() => signOut()}
|
|
{...restProps}
|
|
/>
|
|
);
|
|
};
|
|
export default Logout_Button;
|