{"ast":null,"code":"import _asyncToGenerator from \"@babel/runtime/helpers/asyncToGenerator\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport View from \"react-native-web/dist/exports/View\";\nimport StyleSheet from \"react-native-web/dist/exports/StyleSheet\";\nimport TouchableHighlight from \"react-native-web/dist/exports/TouchableHighlight\";\nimport { FlatList } from \"react-native-gesture-handler\";\nimport { VilleCompopo } from \"../components/VilleCompopo\";\nimport { TopBar } from \"../components/TopBar\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { useEffect, useState } from \"react\";\nimport { getWeatherList } from \"../redux/actions/getWeatherList\";\nimport { SearchBar } from '@rneui/themed';\nimport { setWeatherSearched } from \"../redux/actions/setWeatherSearched\";\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nimport { jsxs as _jsxs } from \"react/jsx-runtime\";\nexport default function CityList(_ref) {\n var navigation = _ref.navigation;\n var weatherList = useSelector(function (state) {\n return state.appReducer.weatherList;\n });\n var weatherListSearched = useSelector(function (state) {\n return state.appReducer.weatherListSearched;\n });\n var favoriteCity = useSelector(function (state) {\n return state.appReducer.favoriteCity;\n });\n var dispatch = useDispatch();\n var _useState = useState(''),\n _useState2 = _slicedToArray(_useState, 2),\n cityName = _useState2[0],\n setCityName = _useState2[1];\n useEffect(function () {\n var loadWeather = function () {\n var _ref2 = _asyncToGenerator(function* () {\n dispatch(getWeatherList());\n });\n return function loadWeather() {\n return _ref2.apply(this, arguments);\n };\n }();\n loadWeather();\n }, [dispatch]);\n function updateSearch(newVal) {\n if (newVal == \"\") {\n dispatch(setWeatherSearched(weatherList));\n } else {\n dispatch(setWeatherSearched(weatherList.filter(function (arg) {\n return arg.city.name.toLowerCase().startsWith(newVal.toLowerCase());\n })));\n }\n }\n return _jsxs(View, {\n style: {\n flex: 1,\n width: \"100%\",\n alignItems: \"center\"\n },\n children: [_jsx(TopBar, {}), _jsx(SearchBar, {\n platform: \"default\",\n containerStyle: {\n width: \"100%\",\n backgroundColor: \"darksalmon\"\n },\n inputContainerStyle: {\n backgroundColor: \"powderblue\"\n },\n inputStyle: {},\n leftIconContainerStyle: {},\n rightIconContainerStyle: {},\n loadingProps: {},\n onChangeText: function onChangeText(newVal) {\n setCityName(newVal);\n updateSearch(newVal);\n },\n placeholder: \"Type query here...\",\n placeholderTextColor: \"#888\",\n round: true,\n value: cityName\n }), _jsx(FlatList, {\n data: weatherListSearched,\n keyExtractor: function keyExtractor(item) {\n return item.city.name;\n },\n renderItem: function renderItem(_ref3) {\n var item = _ref3.item;\n return _jsx(TouchableHighlight, {\n onPress: function onPress() {\n return navigation.navigate(\"CityDetails\", {\n \"weather\": item\n });\n },\n children: _jsx(VilleCompopo, {\n weather: item,\n fav: favoriteCity\n })\n });\n },\n style: leStyle.container\n })]\n });\n}\nvar leStyle = StyleSheet.create({\n container: {\n flex: 1,\n alignContent: 'center',\n width: '100%'\n },\n searchBar: {\n width: \"90%\",\n margin: 20,\n height: 30,\n backgroundColor: \"powderblue\",\n borderRadius: 10,\n textAlign: \"center\"\n }\n});","map":{"version":3,"names":["FlatList","VilleCompopo","TopBar","useDispatch","useSelector","useEffect","useState","getWeatherList","SearchBar","setWeatherSearched","CityList","navigation","weatherList","state","appReducer","weatherListSearched","favoriteCity","dispatch","cityName","setCityName","loadWeather","updateSearch","newVal","filter","arg","city","name","toLowerCase","startsWith","flex","width","alignItems","backgroundColor","item","navigate","leStyle","container","StyleSheet","create","alignContent","searchBar","margin","height","borderRadius","textAlign"],"sources":["/Users/thomaschazot/Documents/But2A/LaSuperMeteo/iut-expo-starter/screens/CityList.tsx"],"sourcesContent":["import { View, Text, StyleSheet, TouchableHighlight, Image } from \"react-native\"\nimport { FlatList, TextInput } from \"react-native-gesture-handler\"\nimport { CITIES_DATA, City, getCurrentWeather, FAVORITE_CITY_DATA, Weather } from \"../data/stub\"\nimport { VilleCompopo } from \"../components/VilleCompopo\";\nimport { TopBar } from \"../components/TopBar\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { useEffect, useState } from \"react\";\nimport { getWeatherList } from \"../redux/actions/getWeatherList\";\nimport { SearchBar } from '@rneui/themed';\nimport { setWeatherSearched } from \"../redux/actions/setWeatherSearched\";\n\n\nexport default function CityList({navigation}){\n\n const weatherList: Weather[] = useSelector(state => state.appReducer.weatherList);\n const weatherListSearched: Weather[] = useSelector(state => state.appReducer.weatherListSearched);\n\n\n const favoriteCity = useSelector(state => state.appReducer.favoriteCity)\n\n // Create a const that will hold the react-redux events dispatcher\n const dispatch = useDispatch();\n \n const [cityName, setCityName] = useState('');\n\n\n \n // Let's define a hook that will be used to update the rendered state after the return will be called\n // You cannot perform side-effects outside of a useEffect hook\n useEffect(() => {\n const loadWeather = async () => {\n dispatch(getWeatherList());\n };\n loadWeather();\n }, [dispatch]);\n \n\n function updateSearch(newVal: string){\n if (newVal == \"\"){\n dispatch(setWeatherSearched(weatherList))\n }\n else{\n dispatch(setWeatherSearched(weatherList.filter((arg) => arg.city.name.toLowerCase().startsWith(newVal.toLowerCase()))))\n }\n }\n\n return (\n \n \n {setCityName(newVal); updateSearch(newVal)}}\n placeholder=\"Type query here...\"\n placeholderTextColor=\"#888\"\n round\n value={cityName}\n /> \n\n item.city.name}\n renderItem={({item}) => navigation.navigate(\"CityDetails\", {\"weather\": item})}>}\n style={leStyle.container} \n />\n \n )\n}\n\nconst leStyle = StyleSheet.create({\n container: {\n flex: 1,\n alignContent: 'center',\n width: '100%'\n },\n searchBar: {\n width: \"90%\",\n margin: 20,\n height: 30,\n backgroundColor: \"powderblue\",\n borderRadius: 10,\n textAlign: \"center\"\n }\n});"],"mappings":";;;;;AACA,SAASA,QAAQ,QAAmB,8BAA8B;AAElE,SAASC,YAAY;AACrB,SAASC,MAAM;AACf,SAASC,WAAW,EAAEC,WAAW,QAAQ,aAAa;AACtD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,cAAc;AACvB,SAASC,SAAS,QAAQ,eAAe;AACzC,SAASC,kBAAkB;AAA8C;AAA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