From 3b4213c78cebfa960115cadef3fd1edbddba3e47 Mon Sep 17 00:00:00 2001 From: Maxence Lanone Date: Sat, 4 Mar 2023 19:13:13 +0100 Subject: [PATCH] ajout switch settings page + option component :hammer: --- src/components/CityListItem.tsx | 66 ++++++++++++++++-------------- src/components/OptionComponent.tsx | 54 ++++++++++++++++++++++++ src/components/WidgetMeteo.tsx | 1 - src/navigator/Navigator.tsx | 3 +- src/screen/AddCity.tsx | 43 ++++++++++--------- src/screen/Settings.tsx | 29 +++++++++++++ 6 files changed, 141 insertions(+), 55 deletions(-) create mode 100644 src/components/OptionComponent.tsx create mode 100644 src/screen/Settings.tsx diff --git a/src/components/CityListItem.tsx b/src/components/CityListItem.tsx index d4ca4e0..7dde64c 100644 --- a/src/components/CityListItem.tsx +++ b/src/components/CityListItem.tsx @@ -8,39 +8,43 @@ import { useNavigation } from '@react-navigation/native'; type CityListItemProps = { item: City; } - + export default function CityListItem(props: CityListItemProps) { -return ( - - - - {props.item.name} - {props.item.name} - {props.item.longitude} - {props.item.latitude} - - - - -) + return ( + <> + + + {props.item.name} + + + + + ) } const styles = StyleSheet.create({ -container: { - flex: 1, - flexDirection: "row", - marginHorizontal: "30%" -}, -separator: { - marginVertical: 4, - backgroundColor: "rgba(255,255,255,0.3)", - height: 1, - width: '90%', -}, -teaserImage: { - width: 50, - height: 50, -} + container: { + flex: 0, + flexDirection: 'row', + justifyContent: 'space-between', + alignItems: 'center', + width: '100%', + }, + separator: { + marginVertical: 4, + backgroundColor: "rgba(223,223,223,1)", + height: 1, + width: '90%', + }, + teaserImage: { + width: 50, + height: 50, + }, + text: { + fontWeight: "bold", + color: "black", + margin: 10, + width: '100%', + }, }); - - \ No newline at end of file + diff --git a/src/components/OptionComponent.tsx b/src/components/OptionComponent.tsx new file mode 100644 index 0000000..6f69816 --- /dev/null +++ b/src/components/OptionComponent.tsx @@ -0,0 +1,54 @@ +//item for meteo in list + +import React from 'react'; +import { StyleSheet, Text, View, Image, TouchableOpacity, Switch } from 'react-native'; +import { City, Weather, CITIES_DATA, FAVORITE_CITY_DATA, getCurrentWeather } from '../../data/stub'; +import { useNavigation } from '@react-navigation/native'; +import { useState } from 'react'; + +type OptionComponentProps = { + nameOption: String; +} + +export default function OptionComponent(props: OptionComponentProps) { + const [isEnabled, setIsEnabled] = useState(false); + const toggleSwitch = () => setIsEnabled(previousState => !previousState); + return ( + <> + + {props.nameOption} + + + + + ) +} + +const styles = StyleSheet.create({ + container: { + flex: 0, + flexDirection: 'row', + justifyContent: 'space-evenly', + alignItems: 'center', + width: '80%', + }, + separator: { + marginVertical: 4, + backgroundColor: "rgba(223,223,223,1)", + height: 1, + width: '90%', + }, + teaserImage: { + width: 50, + height: 50, + }, + text: { + fontWeight: "bold", + color: "black", + margin: 10, + width: '100%', + }, +}); + diff --git a/src/components/WidgetMeteo.tsx b/src/components/WidgetMeteo.tsx index e7d5625..55b8e48 100644 --- a/src/components/WidgetMeteo.tsx +++ b/src/components/WidgetMeteo.tsx @@ -29,7 +29,6 @@ const styles = StyleSheet.create({ flex: 0, justifyContent: 'center', alignItems: 'center', - backgroundColor: '#F5FCFF', margin: 10, padding: 10, shadowColor: "#000", diff --git a/src/navigator/Navigator.tsx b/src/navigator/Navigator.tsx index fcbf45f..017f9ea 100644 --- a/src/navigator/Navigator.tsx +++ b/src/navigator/Navigator.tsx @@ -6,6 +6,7 @@ import { FontAwesome } from "@expo/vector-icons"; import DetailMeteo from "../screen/DetailMeteo"; import Meteo from "../screen/Meteo"; import AddCity from "../screen/AddCity"; +import Settings from "../screen/Settings"; const Tab = createBottomTabNavigator(); export default function MainTab() { @@ -29,7 +30,7 @@ export default function MainTab() { title: 'Add', tabBarIcon: ({ color }) => , }} /> - diff --git a/src/screen/AddCity.tsx b/src/screen/AddCity.tsx index 5d230f7..7ccbf5a 100644 --- a/src/screen/AddCity.tsx +++ b/src/screen/AddCity.tsx @@ -13,14 +13,14 @@ export default function AddCity() { return ( - + - + item.name}/> + keyExtractor={(item: City) => item.name} /> ); @@ -29,31 +29,30 @@ export default function AddCity() { const styles = StyleSheet.create({ container: { flex: 1, - backgroundColor: 'rgba(223,223,223,0.3)', - alignItems: 'center', justifyContent: 'center', + alignItems: 'center', + margin: 10, }, textInput: { - height: 40, - borderColor: 'gray', - borderRadius: 10, - borderWidth: 1, - width: "90%", - margin: 10 - + width: "90%" + }, searchBar: { - flexDirection: "row", - justifyContent: "center", - alignItems: "center", - width: "100%", - height: 50, - backgroundColor: "rgba(255,255,255,0.3)", + flexDirection: 'row', + justifyContent: 'center', + alignItems: 'center', + borderWidth: 0.5, + borderColor: '#000', + height: 40, + borderRadius: 10, + margin: 10, }, imageLoupe: { - width: 20, - height: 20, - margin: 10 + padding: 10, + margin: 5, + height: 15, + width: 15, + resizeMode: 'stretch', + alignItems: 'center', } }); - \ No newline at end of file diff --git a/src/screen/Settings.tsx b/src/screen/Settings.tsx new file mode 100644 index 0000000..12aea3c --- /dev/null +++ b/src/screen/Settings.tsx @@ -0,0 +1,29 @@ +import { useState } from 'react'; +import { Button, StyleSheet, Text, View, SafeAreaView, FlatList, ListViewBase } from 'react-native'; +import { City, Weather, CITIES_DATA, FAVORITE_CITY_DATA, getCurrentWeather } from '../../data/stub'; +import CityListItem from '../components/CityListItem'; +import OptionComponent from '../components/OptionComponent'; + +export default function Settings() { + + const [meteo, setMeteo] = useState("Meteo"); + const [city, setCity] = useState(new City("Paris", 48.856614, 2.3522219)); + + + return ( + + + + + ); +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor: '#fff', + alignItems: 'center', + justifyContent: 'flex-start', + paddingTop: 20, + }, +}); \ No newline at end of file