From 510aaf525ec4f321b6222a4f682db293f6f27443 Mon Sep 17 00:00:00 2001 From: Remi REGNAULT Date: Tue, 28 Nov 2023 15:16:23 +0100 Subject: [PATCH] fix: Profile creation page uses color context --- LeftOvers/components/ListSelect.tsx | 174 ++++++++-------- LeftOvers/components/ListWithoutSelect.tsx | 4 +- LeftOvers/components/ProfileModification.tsx | 207 ++++++++++--------- LeftOvers/screens/CreateProfile.tsx | 62 +++--- 4 files changed, 223 insertions(+), 224 deletions(-) diff --git a/LeftOvers/components/ListSelect.tsx b/LeftOvers/components/ListSelect.tsx index e4fc101..a4ff431 100644 --- a/LeftOvers/components/ListSelect.tsx +++ b/LeftOvers/components/ListSelect.tsx @@ -1,8 +1,9 @@ -import React from 'react'; +import React, { useContext } from 'react'; import {StyleSheet, Text, TextInput, View, Image, FlatList} from 'react-native'; import ValidateButton from './ValidateButton'; import HeaderFlatList from './HeaderFlatList'; import { MultipleSelectList, SelectList } from 'react-native-dropdown-select-list' +import ColorContext from '../theme/ColorContext'; type ListProps = { title: string @@ -10,91 +11,92 @@ type ListProps = { } export default function ListSelect(props: ListProps) { - const [selected, setSelected] = React.useState([]); - return ( - setSelected(val)} - data={props.content} - save="value" - search={false} - arrowicon={} - boxStyles={styles.titleBar} - inputStyles={styles.title} - dropdownStyles={styles.itemList} - dropdownItemStyles={styles.itemCell} - dropdownTextStyles={styles.itemText} - badgeStyles={styles.badges} - badgeTextStyles={styles.badgesText} - notFoundText="All Diets Already Selected" - placeholder={props.title} - label={props.title}/> - ); -} + const [selected, setSelected] = React.useState([]); + const { colors, toggleColors } = useContext(ColorContext); -const styles = StyleSheet.create({ - titleBar: { - flexDirection: "row", - alignItems: "center", - justifyContent: "stretch", - backgroundColor: "#F2F0E4", - borderTopRightRadius: 15, - borderTopLeftRadius: 15, - borderBottomRightRadius: 0, - borderBottomLeftRadius: 0, - borderWidth: 2, - borderColor: "#ACA279", - minWidth: "92%", - maxWidth: "92%", - marginBottom: 0, - overflow: "hidden", - }, - arrow: { - resizeMode: 'contain', - tintColor: "#3F3C42", - flex: 0.1, - }, - title: { - fontSize: 15, - color: '#3F3C42', - alignItems: 'center', - textAlign: "left", - flex: 0.9, - }, + const styles = StyleSheet.create({ + titleBar: { + flexDirection: "row", + alignItems: "center", + backgroundColor: colors.cardElementTitleBackground, + borderTopRightRadius: 15, + borderTopLeftRadius: 15, + borderBottomRightRadius: 0, + borderBottomLeftRadius: 0, + borderWidth: 2, + borderColor: colors.cardElementBorder, + minWidth: "92%", + maxWidth: "92%", + marginBottom: 0, + overflow: "hidden", + }, + arrow: { + resizeMode: 'contain', + tintColor: colors.cardElementTitle, + flex: 0.1, + }, + title: { + fontSize: 15, + color: colors.cardElementTitle, + alignItems: 'center', + textAlign: "left", + flex: 0.9, + }, + + itemList: { + flexDirection: "row", + alignItems: "flex-start", + borderWidth: 0, + borderTopRightRadius: 0, + borderTopLeftRadius: 0, + borderBottomRightRadius: 15, + borderBottomLeftRadius: 15, + backgroundColor: colors.cardElementBackground, + minWidth: "92%", + maxWidth: "92%", + }, + itemCell: { + padding: 0, + paddingTop: "5%", + width: "100%", + minWidth: 250, + maxWidth: 250, + }, + itemText: { + fontSize: 13, + textAlign: "left", + flex: 1, + padding: "1%", + paddingLeft: "3%", + color: colors.cardElementText, + }, + + badges: { + backgroundColor: colors.cardElementBackground, + }, + badgesText: { + fontSize: 15, + color: colors.cardElementText, + }, + }); - itemList: { - flexDirection: "row", - alignItems: "flex-start", - justifyContent: "stretch", - borderWidth: 0, - borderTopRightRadius: 0, - borderTopLeftRadius: 0, - borderBottomRightRadius: 15, - borderBottomLeftRadius: 15, - backgroundColor: "#E3DEC9", - minWidth: "92%", - maxWidth: "92%", - }, - itemCell: { - padding: 0, - paddingTop: "5%", - width: "100%", - minWidth: 250, - maxWidth: 250, - }, - itemText: { - fontSize: 13, - textAlign: "left", - flex: 1, - padding: "1%", - paddingLeft: "3%", - color: "#3F3C42", - }, + return ( + setSelected(val)} + data={props.content} + save="value" + search={false} + arrowicon={} + boxStyles={styles.titleBar} + inputStyles={styles.title} + dropdownStyles={styles.itemList} + dropdownItemStyles={styles.itemCell} + dropdownTextStyles={styles.itemText} + badgeStyles={styles.badges} + badgeTextStyles={styles.badgesText} + notFoundText="All Diets Already Selected" + placeholder={props.title} + label={props.title}/> + ); +} - badges: { - backgroundColor: "#59BDCD", - }, - badgesText: { - fontSize: 15, - color: "#F2F0E4", - }, -}); \ No newline at end of file diff --git a/LeftOvers/components/ListWithoutSelect.tsx b/LeftOvers/components/ListWithoutSelect.tsx index 804f65a..758c0ff 100644 --- a/LeftOvers/components/ListWithoutSelect.tsx +++ b/LeftOvers/components/ListWithoutSelect.tsx @@ -7,7 +7,7 @@ import ColorContext from '../theme/ColorContext'; type ListProps = { title: string - content: list + content: string[] } export default function ListWithoutSelect(props: ListProps) { @@ -18,7 +18,6 @@ export default function ListWithoutSelect(props: ListProps) { titleBar: { flexDirection: "row", alignItems: "center", - justifyContent: "stretch", backgroundColor: colors.cardElementTitleBackground, borderTopRightRadius: 15, borderTopLeftRadius: 15, @@ -47,7 +46,6 @@ export default function ListWithoutSelect(props: ListProps) { itemList: { flexDirection: "row", alignItems: "flex-start", - justifyContent: "stretch", borderWidth: 0, borderTopRightRadius: 0, borderTopLeftRadius: 0, diff --git a/LeftOvers/components/ProfileModification.tsx b/LeftOvers/components/ProfileModification.tsx index ebf9cf4..52dbc0e 100644 --- a/LeftOvers/components/ProfileModification.tsx +++ b/LeftOvers/components/ProfileModification.tsx @@ -1,116 +1,119 @@ -import React from 'react'; -import { useState } from 'react'; +import React, { useContext, useState } from 'react'; import {StyleSheet, Text, TextInput, View, Image} from 'react-native'; + import ValidateButton from './ValidateButton'; import ListSelect from './ListSelect'; import ListWithoutSelect from './ListWithoutSelect'; +import ColorContext from '../theme/ColorContext'; type ProfileProps = { - name: string - avatar: string - diets: list - allergies: list + name: string + avatar: string + diets: string[] + allergies: string[] } export default function ProfileModification(props: ProfileProps) { - const [name, onChangeName] = useState(props.name); + const [name, onChangeName] = useState(props.name); + const { colors, toggleColors } = useContext(ColorContext); - let imageSource - if (props.avatar == "plus.png"){ - imageSource = require('../assets/images/plus.png') - } - else if (props.avatar == "plus_small.png"){ - imageSource = require('../assets/images/plus_small.png') - } - else{ - imageSource = require('../assets/images/logo.png') - } + let imageSource + if (props.avatar == "plus.png"){ + imageSource = require('../assets/images/plus.png') + } + else if (props.avatar == "plus_small.png"){ + imageSource = require('../assets/images/plus_small.png') + } + else{ + imageSource = require('../assets/images/logo.png') + } - return ( - - - - - - - - Filters - 3 selected + const styles = StyleSheet.create({ + background: { + flexDirection: 'column', + alignItems: 'center', + justifyContent: 'center', + borderRadius: 15, + backgroundColor: colors.cardBackground, + padding: "3%", + marginHorizontal: "3%", + }, + + pseudoBar: { + flexDirection: "row", + alignItems: "center", + justifyContent: "center", + width: "100%", + marginHorizontal: "3%", + marginBottom: "3%", + }, + avatar: { + padding: "5%", + resizeMode: 'contain', + borderWidth: 2, + borderColor: colors.cardTitle, + borderRadius: 45, + height: "100%", + flex: 0.04, + }, + textInput: { + fontSize: 15, + color: colors.cardTitle, + borderRadius: 10, + borderWidth: 2, + borderStyle: 'dashed', + borderColor: colors.cardTitle, + alignItems: 'center', + textAlign: 'left', + flex: 0.8, + marginLeft: "7%", + padding: "2%", + }, + modify: { + height: "100%", + tintColor: colors.cardTitle, + resizeMode: 'contain', + flex: 0.1, + marginLeft: "3%", + }, + + filterBar: { + flexDirection: "row", + width: "85%", + paddingTop: "3%", + paddingBottom: "2%", + alignItems: "flex-end", + justifyContent: "center", + }, + filters: { + fontSize: 20, + color: colors.cardTitle, + flex: 1, + }, + nbSelected: { + fontSize: 11, + color: colors.cardDetail, + textAlign: "right", + } + }); + + return ( + + + + + + + + Filters + 3 selected + + + + + + console.log("Create Profile...")}/> - - - - - - - ); + ); } -const styles = StyleSheet.create({ - background: { - flexDirection: 'column', - alignItems: 'center', - justifyContent: 'center', - borderRadius: 15, - backgroundColor: '#F2F0E4', - padding: "3%", - marginHorizontal: "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.04, - }, - textInput: { - fontSize: 15, - color: '#ACA279', - borderRadius: 10, - borderWidth: 2, - borderStyle: 'dashed', - borderColor: '#ACA279', - alignItems: 'center', - textAlign: 'left', - flex: 0.8, - marginLeft: "7%", - padding: "2%", - }, - modify: { - height: "100%", - tintColor: "#ACA279", - resizeMode: 'contain', - flex: 0.1, - marginLeft: "3%", - }, - - filterBar: { - flexDirection: "row", - width: "85%", - paddingTop: "3%", - paddingBottom: "2%", - alignItems: "flex-end", - justifyContent: "center", - }, - filters: { - fontSize: 20, - color: '#ACA279', - flex: 1, - }, - nbSelected: { - fontSize: 11, - color: "#3F3C42", - textAlign: "right", - } -}); \ No newline at end of file diff --git a/LeftOvers/screens/CreateProfile.tsx b/LeftOvers/screens/CreateProfile.tsx index d77b825..a8fe93d 100644 --- a/LeftOvers/screens/CreateProfile.tsx +++ b/LeftOvers/screens/CreateProfile.tsx @@ -1,43 +1,39 @@ -import React from 'react'; +import React, { useContext } from 'react'; import {StyleSheet, View, ScrollView, useWindowDimensions} from 'react-native'; import { LinearGradient } from 'expo-linear-gradient'; import { SafeAreaProvider } from 'react-native-safe-area-context'; import ProfileModification from '../components/ProfileModification'; import ValidateButton from '../components/ValidateButton'; +import ColorContext from '../theme/ColorContext'; export default function CreateProfile(props) { - const all = [] - const die = [{value: "Dairy free"}, {value: "Gluten free"}, {value: "Porkless"}, {value: "Vegan"}, {value: "Vegetarian"}, {value: "Pescatarian"}] - return ( - - - - - - - (console.log("Profile Created"))}> - - - - - ); + const { colors, toggleColors } = useContext(ColorContext) + const all = [] + const die = [{value: "Dairy free"}, {value: "Gluten free"}, {value: "Porkless"}, {value: "Vegan"}, {value: "Vegetarian"}, {value: "Pescatarian"}] + + const styles = StyleSheet.create({ + linearGradient: { + height: "100%", + width: "100%", + flex: 1, + padding: "2%", + paddingTop: 0, + }, + }); + + return ( + + + + + + + (console.log("Profile Created"))}> + + + + + ); } -const styles = StyleSheet.create({ - container: { - height: "100%", - width: "100%", - flex: 1, - backgroundColor: '#3F3C42', - alignItems: 'center', - justifyContent: 'center', - }, - linearGradient: { - height: "100%", - width: "100%", - flex: 1, - padding: "2%", - paddingTop: 0, - }, -}); \ No newline at end of file