import React, { useState } from 'react'; import { TouchableOpacity, Text, GestureResponderEvent, ColorValue, Switch, TextInput, View, StyleSheet, Platform } from 'react-native'; import { useColors } from './colors'; import { MaterialCommunityIcons } from '@expo/vector-icons'; type ThemeTextType = { style?: Object, children?: any, numberOfLines?: number, } export const ThemeText = ({ style, children, numberOfLines }: ThemeTextType) => { const colors = useColors(); return ( {children} ); }; type ThemeButtonType = { style?: Object, children?: React.ReactNode, onPress?: (event: GestureResponderEvent) => void, color?: ColorValue, disabled?: boolean, } export const ThemeButton = ({ style, children, onPress, color, disabled }: ThemeButtonType) => { const colors = useColors(); return ( {children} ); }; type ThemeSwitchType = { style?: Object, value?: boolean, disabled?: boolean, onValueChange?: (value: boolean) => void | Promise, } export const ThemeSwitch = ({ style, value, disabled, onValueChange }: ThemeSwitchType) => { const colors = useColors(); return ( ); }; type ThemeTextInputType = { style?: Object, value?: string, disabled?: boolean, onValueChange?: (value: string) => void | Promise, secureTextEntry?: boolean, placeholder?: string, } export const ThemeTextInput = ({ style, value, disabled, onValueChange, secureTextEntry, placeholder }: ThemeTextInputType) => { const colors = useColors(); const [showPassword, setShowPassword] = useState(!secureTextEntry); const styles = StyleSheet.create({ container: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', borderRadius: 8, paddingRight: 14, paddingLeft: 8, paddingVertical: 1, marginVertical: 5, borderColor: disabled ? colors.textDisabled : colors.text, borderWidth: 1, }, input: { flex: 1, paddingVertical: 10, paddingRight: 10, height: 45, ...(Platform.OS === 'web' ? { outlineStyle: 'none' } : {}), ...(Platform.OS === 'web' ? { outlineStyle: 'none' } : {}), backgroundColor: colors.backPrimary, color: disabled ? colors.textDisabled : colors.text, }, icon: { marginLeft: 10, }, }); return ( { secureTextEntry && setShowPassword(!showPassword)} /> } ); };