fix: home page is now using colorContext
continuous-integration/drone/push Build is passing Details

pull/20/head
Rémi REGNAULT 1 year ago
parent bd54ec2fa1
commit 1ab6ce5f9d

@ -1,50 +1,52 @@
import React from 'react'; import React, { useContext } from 'react';
import {StyleSheet,Pressable, Text, View, Image} from 'react-native'; import { StyleSheet,Pressable, Text, View } from 'react-native';
import Separator from '../components/Separator';
import ColorContext from '../theme/ColorContext';
interface foodElementImageProps { interface foodElementImageProps {
title : string title : string
} }
export default function FoodElementText(props : any) { export default function FoodElementText(props : any) {
return ( const {colors, toggleColors } = useContext(ColorContext)
<Pressable style={styles.button}>
<View style={styles.container}>
<View style={styles.view}>
<Text style={styles.text}>{props.title}</Text>
</View>
</View>
</Pressable>
);
}
const styles = StyleSheet.create({ const styles = StyleSheet.create({
button: { button: {
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
width: "80%", width: "80%",
borderRadius: 5, borderRadius: 5,
backgroundColor: '#E3DEC9', backgroundColor: colors.carrouselBackground,
}, },
text: { text: {
fontSize: 10, fontSize: 10,
fontWeight: 'bold', fontWeight: 'bold',
padding : "2%", padding : "2%",
color: 'black', color: colors.cardDetail,
}, },
view: { view: {
alignItems: 'flex-start', alignItems: 'flex-start',
justifyContent: 'center', justifyContent: 'center',
}, },
container: { container: {
width: "100%", width: "100%",
borderRadius: 5, borderRadius: 5,
borderWidth: 1, borderWidth: 1,
borderColor: '#3F3C42', borderColor: colors.cardDetail,
flexDirection: 'column', flexDirection: 'column',
justifyContent: 'center', justifyContent: 'center',
}, },
}); });
return (
<Pressable style={styles.button}>
<View style={styles.container}>
<View style={styles.view}>
<Text style={styles.text}>{props.title}</Text>
</View>
</View>
</Pressable>
);
}

@ -1,124 +1,127 @@
import React, { useState } from 'react'; import React, { useContext, useState } from 'react';
import {StyleSheet,Pressable, Text, View, Image} from 'react-native'; import {StyleSheet,Pressable, Text, View, Image} from 'react-native';
import ColorContext from '../theme/ColorContext';
type Profile = { type Profile = {
name: string name: string
avatar: string avatar: string
isActive: string isActive: string
disableSelection: boolean disableSelection: boolean
} }
export default function ProfileElement(props : Profile) { export default function ProfileElement(props : Profile) {
const [waiting, setWaiting] = useState("none") const { colors, toggleColors } = useContext(ColorContext)
const [separator, setSeparator] = useState("none")
const changeStatus = () => {
if (props.disableSelection){
setWaiting("none")
}
else if (waiting == "flex"){
setWaiting("none")
}
else{
setWaiting("flex")
}
if (props.disableSelection){
setSeparator("none")
}
else if (props.isActive == "flex" && waiting == "none"){
setSeparator("flex")
}
else{
setSeparator("none")
}
console.log(waiting, separator, props.name)
}
let imageSource const [waiting, setWaiting] = useState("none")
if (props.avatar == "plus.png"){ const [separator, setSeparator] = useState("none")
imageSource = require('../assets/images/plus.png') const changeStatus = () => {
} if (props.disableSelection){
else if (props.avatar == "plus_small.png"){ setWaiting("none")
imageSource = require('../assets/images/plus_small.png') }
} else if (waiting == "flex"){
else{ setWaiting("none")
imageSource = require('../assets/images/logo.png') }
} else{
setWaiting("flex")
}
if (props.disableSelection){
setSeparator("none")
}
else if (props.isActive == "flex" && waiting == "none"){
setSeparator("flex")
}
else{
setSeparator("none")
}
console.log(waiting, separator, props.name)
}
return ( let imageSource
<Pressable onPress={changeStatus} style={styles.button}> if (props.avatar == "plus.png"){
<View> imageSource = require('../assets/images/plus.png')
<View style={styles.pseudoBar}> }
<Image source={imageSource} style={styles.avatar}></Image> else if (props.avatar == "plus_small.png"){
<Text style={styles.text}>{props.name}</Text> imageSource = require('../assets/images/plus_small.png')
</View> }
<View style={styles.pseudoBar}> else{
<View style={[styles.active, {display: props.isActive}]}> imageSource = require('../assets/images/logo.png')
<Text style={styles.textActive}>Activated</Text> }
</View>
<View style={{flex: 0.3, display: separator}}/>
<View style={[styles.waiting, {display: waiting}]}>
<Text style={styles.textWaiting}>Waiting...</Text>
</View>
</View>
</View>
</Pressable>
);
}
const styles = StyleSheet.create({
button: {
alignItems: 'center',
justifyContent: 'flex-start',
height: "80%",
width: "78%",
marginVertical: "3%",
},
pseudoBar: {
flexDirection: "row",
alignItems: "center",
justifyContent: "center",
width: "100%",
marginHorizontal: "3%",
marginBottom: "3%",
},
avatar: {
padding: "5%",
resizeMode: 'contain',
borderWidth: 2,
borderColor: "#ACA279",
borderRadius: 45,
height: "100%",
flex: 0.01,
},
text: {
fontSize: 15,
color: '#ACA279',
alignItems: 'center',
textAlign: 'left',
flex: 0.9,
marginLeft: "10%",
padding: "2%",
},
active: { const styles = StyleSheet.create({
borderWidth: 1, button: {
borderRadius: 20, alignItems: 'center',
borderColor: "#59BDCD", justifyContent: 'flex-start',
padding: "1%", height: "80%",
}, width: "78%",
textActive: { marginVertical: "3%",
fontSize: 10, },
color: "#59BDCD", pseudoBar: {
}, flexDirection: "row",
alignItems: "center",
justifyContent: "center",
width: "100%",
marginHorizontal: "3%",
marginBottom: "3%",
},
avatar: {
padding: "5%",
resizeMode: 'contain',
borderWidth: 2,
borderColor: colors.carrouselText,
borderRadius: 45,
height: "100%",
flex: 0.01,
},
text: {
fontSize: 15,
color: colors.carrouselText,
alignItems: 'center',
textAlign: 'left',
flex: 0.9,
marginLeft: "10%",
padding: "2%",
},
active: {
borderWidth: 1,
borderRadius: 20,
borderColor: colors.carrouselDetail,
padding: "1%",
},
textActive: {
fontSize: 10,
color: colors.carrouselDetail,
},
waiting: {
borderWidth: 1,
borderRadius: 20,
borderColor: "#ACA279",
padding: "1%",
},
textWaiting: {
fontSize: 10,
color: "#ACA279",
},
});
waiting: { return (
borderWidth: 1, <Pressable onPress={changeStatus} style={styles.button}>
borderRadius: 20, <View>
borderColor: "#ACA279", <View style={styles.pseudoBar}>
padding: "1%", <Image source={imageSource} style={styles.avatar}></Image>
}, <Text style={styles.text}>{props.name}</Text>
textWaiting: { </View>
fontSize: 10, <View style={styles.pseudoBar}>
color: "#ACA279", <View style={[styles.active, {display: props.isActive}]}>
}, <Text style={styles.textActive}>Activated</Text>
}); </View>
<View style={{flex: 0.3, display: separator}}/>
<View style={[styles.waiting, {display: waiting}]}>
<Text style={styles.textWaiting}>Waiting...</Text>
</View>
</View>
</View>
</Pressable>
);
}

@ -1,12 +1,15 @@
import {React, useState} from 'react'; import React, { useContext, useState } from 'react';
import {View, StyleSheet, Pressable, Image, Text} from 'react-native'; import {View, StyleSheet, Pressable, Image} from 'react-native';
import ProfileElement from './ProfileElement'
import ColorContext from '../theme/ColorContext';
import bracketLeft from '../assets/images/angle_bracket_left.png'; import bracketLeft from '../assets/images/angle_bracket_left.png';
import bracketRight from '../assets/images/angle_bracket_right.png'; import bracketRight from '../assets/images/angle_bracket_right.png';
import ProfileElement from './ProfileElement'
type ProfileSelectionProps = { type ProfileSelectionProps = {
listProfile: Profile[] listProfile: Profile[]
disableSelection: boolean disableSelection: boolean
} }
type Profile = { type Profile = {
@ -16,47 +19,49 @@ type Profile = {
} }
export default function ProfileSelection(props: ProfileSelectionProps) { export default function ProfileSelection(props: ProfileSelectionProps) {
const [cpt, setCpt] = useState(0); const { colors, toggleColors } = useContext(ColorContext);
const decreaseCounter = () => {
if (cpt > 0) { const [cpt, setCpt] = useState(0);
setCpt(cpt - 1); const decreaseCounter = () => {
} if (cpt > 0) {
else { setCpt(cpt - 1);
setCpt(props.listProfile.length - 1); }
} else {
}; setCpt(props.listProfile.length - 1);
const increaseCounter = () => { }
if (cpt < props.listProfile.length - 1) { };
setCpt(cpt + 1); const increaseCounter = () => {
} if (cpt < props.listProfile.length - 1) {
else { setCpt(cpt + 1);
setCpt(0); }
} else {
}; setCpt(0);
}
return ( };
<View style={styles.background}>
<Pressable onPress={decreaseCounter}> const styles = StyleSheet.create({
<Image source={bracketLeft} style={{width: 40, height: 40, resizeMode: "contain"}}/> background: {
</Pressable> width: "92%",
<ProfileElement name={props.listProfile[cpt].name} avatar={props.listProfile[cpt].avatar} isActive={props.listProfile[cpt].isActive} disableSelection={props.disableSelection}/> height: 80,
<Pressable onPress={increaseCounter}> borderRadius: 20,
<Image source={bracketRight} style={{width: 40, height: 40, resizeMode: "contain"}}/> borderWidth: 2,
</Pressable> borderColor: colors.carrouselText,
</View> backgroundColor: colors.carrouselBackground,
); flexDirection: 'row',
} justifyContent: 'center',
alignItems: 'center',
},
});
const styles = StyleSheet.create({ return (
background: { <View style={styles.background}>
width: "92%", <Pressable onPress={decreaseCounter}>
height: 80, <Image source={bracketLeft} style={{width: 40, height: 40, resizeMode: "contain"}} tintColor={colors.carrouselText}/>
borderRadius: 20, </Pressable>
borderWidth: 2, <ProfileElement name={props.listProfile[cpt].name} avatar={props.listProfile[cpt].avatar} isActive={props.listProfile[cpt].isActive} disableSelection={props.disableSelection}/>
borderColor: '#ACA279', <Pressable onPress={increaseCounter}>
backgroundColor: '#E3DEC9', <Image source={bracketRight} style={{width: 40, height: 40, resizeMode: "contain"}} tintColor={colors.carrouselText}/>
flexDirection: 'row', </Pressable>
justifyContent: 'center', </View>
alignItems: 'center', );
}, }
});

@ -112,9 +112,9 @@ export default function HomePage({ navigation, props }) {
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
borderRadius: 20, borderRadius: 20,
backgroundColor: '#E3DEC9', backgroundColor: colors.carrouselBackground,
borderWidth: 2, borderWidth: 2,
borderColor: "#ACA279", borderColor: colors.carrouselText,
padding: "2%" padding: "2%"
} }
}); });
@ -143,7 +143,7 @@ export default function HomePage({ navigation, props }) {
<View style={{marginTop: "3%"}}/> <View style={{marginTop: "3%"}}/>
<ProfileSelection listProfile={profiles} disableSelection={true}/> <ProfileSelection listProfile={profiles} disableSelection={true}/>
<View style={{marginTop: "4%"}}/> <View style={{marginTop: "4%"}}/>
<ValidateButton title="Modify Profiles" image="parameter.png" colour="#59BDCD" backColour="#E3DEC9" todo={() => navigation.navigate('Profiles')}/> <ValidateButton title="Modify Profiles" image="parameter.png" colour={colors.buttonDetail} backColour={colors.buttonBackground} todo={() => navigation.navigate('Profiles')}/>
</View> </View>
<View style={styles.separator}/> <View style={styles.separator}/>
<View style={styles.profilesSelection}> <View style={styles.profilesSelection}>
@ -151,7 +151,7 @@ export default function HomePage({ navigation, props }) {
<Text style={styles.filters}>Ingredient Stocks</Text> <Text style={styles.filters}>Ingredient Stocks</Text>
</View> </View>
<View style={{marginTop: "4%"}}/> <View style={{marginTop: "4%"}}/>
<ValidateButton title="Manage Stocks" image="warehouse.png" colour="#59BDCD" backColour="#E3DEC9" todo={() => console.log('ManageStocks')}/> <ValidateButton title="Manage Stocks" image="warehouse.png" colour={colors.buttonDetail} backColour={colors.buttonBackground} todo={() => console.log('ManageStocks')}/>
</View> </View>
<View style={styles.separator}/> <View style={styles.separator}/>
<View style={styles.profilesSelection}> <View style={styles.profilesSelection}>
@ -160,21 +160,21 @@ export default function HomePage({ navigation, props }) {
</View> </View>
<View style={{marginTop: "3%"}}/> <View style={{marginTop: "3%"}}/>
<View style={styles.ingredientSelection}> <View style={styles.ingredientSelection}>
<Text style={{fontSize: 15, color: "#3F3C42"}}>Selected Ingredient</Text> <Text style={{fontSize: 15, color: colors.carrouselText}}>Selected Ingredient</Text>
<View style={{flexDirection: "row", padding: "4%", justifyContent: "center", alignItems: "center"}}> <View style={{flexDirection: "row", padding: "4%", justifyContent: "center", alignItems: "center"}}>
<Pressable onPress={decreaseCounter}> <Pressable onPress={decreaseCounter}>
<Image source={bracketLeft} style={{width: 40, height: 40, resizeMode: "contain"}} /> <Image source={bracketLeft} style={{width: 40, height: 40, resizeMode: "contain"}} tintColor={colors.carrouselText}/>
</Pressable> </Pressable>
<FoodElementText title={ingredientList[cpt].title}/> <FoodElementText title={ingredientList[cpt].title}/>
<Pressable onPress={increaseCounter}> <Pressable onPress={increaseCounter}>
<Image source={bracketRight} style={{width: 40, height: 40, resizeMode: "contain"}} /> <Image source={bracketRight} style={{width: 40, height: 40, resizeMode: "contain"}} tintColor={colors.carrouselText} />
</Pressable> </Pressable>
</View> </View>
</View> </View>
<View style={{marginTop: "4%"}}/> <View style={{marginTop: "4%"}}/>
<ValidateButton title="Change Selected Ingredients" image="cook.png" colour="#59BDCD" backColour="#E3DEC9" todo={ () => console.log('Chnge Selected Ingredient')}/> <ValidateButton title="Change Selected Ingredients" image="cook.png" colour={colors.buttonDetail} backColour={colors.buttonBackground} todo={ () => console.log('Chnge Selected Ingredient')}/>
<View style={{marginTop: "3%"}}/> <View style={{marginTop: "3%"}}/>
<ValidateButton title="Search Recipes" image="search.png" colour="#59BDCD" backColour="#E3DEC9" todo={ () => console.log('Go and search for recipe')}/> <ValidateButton title="Search Recipes" image="search.png" colour={colors.buttonDetail} backColour={colors.buttonBackground} todo={ () => console.log('Go and search for recipe')}/>
</View> </View>
<View style={{marginBottom: "20%"}}/> <View style={{marginBottom: "20%"}}/>
</LinearGradient> </LinearGradient>

@ -27,6 +27,9 @@ export interface Theme {
buttonDetail: string, buttonDetail: string,
welcomeText: string, welcomeText: string,
welcomeName: string, welcomeName: string,
carrouselBackground: string,
carrouselText: string,
carrouselDetail: string
} }
export const LightTheme : Theme = { export const LightTheme : Theme = {
@ -45,7 +48,10 @@ export const LightTheme : Theme = {
buttonBackground: Pearl, buttonBackground: Pearl,
buttonDetail: Moonstone, buttonDetail: Moonstone,
welcomeText: Ecru, welcomeText: Ecru,
welcomeName: Moonstone welcomeName: Moonstone,
carrouselBackground: Pearl,
carrouselText: Ecru,
carrouselDetail: Moonstone
} }
export const DarkTheme : Theme = { export const DarkTheme : Theme = {
@ -64,6 +70,9 @@ export const DarkTheme : Theme = {
buttonBackground: Jet, buttonBackground: Jet,
buttonDetail: CarolinaBlue, buttonDetail: CarolinaBlue,
welcomeText: SteelBlue, welcomeText: SteelBlue,
welcomeName:Alabaster welcomeName:Alabaster,
carrouselBackground: CarolinaBlue,
carrouselText: SteelBlue,
carrouselDetail: Alabaster
} }

Loading…
Cancel
Save