fixed darkmode issues on login and home

This commit is contained in:
Walcher 2023-12-08 17:19:30 +01:00
parent f62b49b5cf
commit 8437f474aa
3 changed files with 33 additions and 10 deletions

View file

@ -4,11 +4,17 @@ import { useAuth } from './contexts/AuthContext'
import { Redirect } from 'expo-router'; import { Redirect } from 'expo-router';
import { FontAwesome } from "@expo/vector-icons"; import { FontAwesome } from "@expo/vector-icons";
import { Input } from '../components'; import { Input } from '../components';
import { useThemeColor } from '../hooks/hooks';
export default function login() { export default function login() {
const [email, setEmail] = useState(""); const [email, setEmail] = useState("");
const [password, setPassword] = useState("") const [password, setPassword] = useState("")
const {authState, onLogin} = useAuth(); const {authState, onLogin} = useAuth()
const backgroundColor = useThemeColor("backgroundColor")
const textColor = useThemeColor("primaryText");
const elementDefaultColor = useThemeColor("elementDefaultColor")
// const {authState, onLogin} = useAuth(); // const {authState, onLogin} = useAuth();
// useEffect(() => { // useEffect(() => {
// login() // login()
@ -22,20 +28,24 @@ export default function login() {
return ( return (
<SafeAreaView style={{flex: 1, justifyContent: "center"}}> <SafeAreaView style={{flex: 1, justifyContent: "center", backgroundColor: backgroundColor}}>
{authState?.authenticated && {authState?.authenticated &&
<Redirect href={"/"}></Redirect>} <Redirect href={"/"}></Redirect>}
<Input <Input
placeholder={'Email'} placeholder={'Enter Email'}
label='Email or Username' label='Email or Username'
leftIcon={<FontAwesome name="user" size={20} />} labelColor={textColor}
leftIcon={<FontAwesome name="user" size={20} color={textColor} />}
onChangeHandler={setEmail} onChangeHandler={setEmail}
bgColor ={elementDefaultColor}
/> />
<Input <Input
placeholder={'Enter Password'} placeholder={'Enter Password'}
label='Password' label='Password'
leftIcon={<FontAwesome name="key" size={20} />} labelColor={textColor}
leftIcon={<FontAwesome name="key" size={20} color={textColor}/>}
onChangeHandler={setPassword} onChangeHandler={setPassword}
bgColor ={elementDefaultColor}
secure = {true} secure = {true}
/> />
<Button title='login' onPress={login}></Button> <Button title='login' onPress={login}></Button>

View file

@ -10,7 +10,8 @@ export default function SearchBar(props: SearchBarProps) {
const [isActive, setIsactive] = React.useState(false); const [isActive, setIsactive] = React.useState(false);
const textColor = useThemeColor("interactiveText") const textColor = useThemeColor("interactiveText")
const backgroundColor = useThemeColor("containerColor"); const backgroundColor = useThemeColor("elementDefaultColor");
const handleChange = (text:string) : void => { const handleChange = (text:string) : void => {
if(text !== ""){ if(text !== ""){
if(!isActive){ if(!isActive){
@ -23,9 +24,16 @@ export default function SearchBar(props: SearchBarProps) {
} }
} }
//TODO: Handle textCancel // cant apply the background color otherwise
const containerStyle = {
...styles.container,
backgroundColor: backgroundColor // apply dynamic background color
};
//TODO: Handle textCancel
// changed styles.container to containerStyle
return ( return (
<View style={styles.container}> <View style={containerStyle}>
<TextInput onChangeText = {handleChange} style={[{fontSize: SIZES.normal, height: "100%"}, styles.TextInput]} autoCorrect={false} keyboardType='web-search' placeholder={props.placeholder}></TextInput> <TextInput onChangeText = {handleChange} style={[{fontSize: SIZES.normal, height: "100%"}, styles.TextInput]} autoCorrect={false} keyboardType='web-search' placeholder={props.placeholder}></TextInput>
{isActive && {isActive &&
@ -45,7 +53,6 @@ const styles = StyleSheet.create({
justifyContent: "center", justifyContent: "center",
alignItems: "center", alignItems: "center",
height: 40, height: 40,
backgroundColor: backgroundColor,
borderRadius: 10, borderRadius: 10,
paddingHorizontal: 10 paddingHorizontal: 10
}, },

View file

@ -5,6 +5,7 @@ import { TextInputEndEditingEventData } from 'react-native/Libraries/Components/
interface InputProps { interface InputProps {
label? : string, label? : string,
labelColor?: string,
outlined? : boolean, outlined? : boolean,
placeholder?: string, placeholder?: string,
leftIcon?: any, leftIcon?: any,
@ -20,6 +21,7 @@ interface InputProps {
function Input({ function Input({
label, label,
labelColor,
outlined, outlined,
placeholder, placeholder,
leftIcon, leftIcon,
@ -32,13 +34,17 @@ function Input({
errorColor, errorColor,
bgColor bgColor
} : InputProps) { } : InputProps) {
const labelStyle = {
...styles.label,
color: labelColor ? labelColor : 'black',
};
const containerBorder = outlined ? styles.outlined : styles.standard const containerBorder = outlined ? styles.outlined : styles.standard
if(numLines == undefined){ if(numLines == undefined){
numLines = 1 numLines = 1
} }
return ( return (
<View style={{padding:10}}> <View style={{padding:10}}>
<Text style={styles.label}>{label}</Text> <Text style={labelStyle}>{label}</Text>
<View <View
style={[styles.container, containerBorder, {backgroundColor: bgColor ? bgColor : "white"}]}> style={[styles.container, containerBorder, {backgroundColor: bgColor ? bgColor : "white"}]}>
<View style={{paddingRight:10}}>{leftIcon}</View> <View style={{paddingRight:10}}>{leftIcon}</View>