diff --git a/src/app/screens/ForecastScreen.js b/src/app/screens/ForecastScreen.js index 062be2e..0f30666 100644 --- a/src/app/screens/ForecastScreen.js +++ b/src/app/screens/ForecastScreen.js @@ -1,4 +1,4 @@ -import React, { useState, useContext } from "react"; +import React, { useState, useContext, useEffect } from "react"; import Screen from "../components/Screen"; import { StyleSheet, View, Text, TouchableNativeFeedback } from "react-native"; import { dimensions, screen_width } from "../config/dimensions"; @@ -6,6 +6,7 @@ import colors from "../config/colors"; import getWeatherForecast from "../api/weather_forecast"; import assets from "../config/assets"; import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view"; +import Swipeable from "react-native-gesture-handler/Swipeable"; function forecastDay(day, setDay) { return ( @@ -83,7 +84,7 @@ function renderTodayForecast(forecast) { {WeatherInput(forecast.today_forecast.morning_weather_index, "Manhã")} { + if (swipePosition ) { + day == 0 ? swipePosition.openLeft() : swipePosition.openRight(); + } + }, [day]); return ( @@ -212,15 +220,20 @@ function renderScreen(forecast) { {currentLocationAndDate(forecast, day)} - setSwipePosition(ref)} + renderRightActions={() => renderWeekForecast(forecast)} + onSwipeableOpen={() => {setDay(1)}} + onSwipeableClose={() => {setDay(0)}} > - {day == 0 - ? renderTodayForecast(forecast) - : renderWeekForecast(forecast)} - + + {renderTodayForecast(forecast)} + + ); } @@ -253,6 +266,7 @@ const styles = StyleSheet.create({ padding: dimensions.spacing.normal_padding, }, centered: { + backgroundColor: "white", flexDirection: "column", alignItems: "center", }, diff --git a/src/package.json b/src/package.json index 8ca88b6..89a31a9 100644 --- a/src/package.json +++ b/src/package.json @@ -21,6 +21,7 @@ "@react-navigation/bottom-tabs": "^5.11.2", "@react-navigation/native": "^5.8.10", "@react-navigation/stack": "^5.12.8", + "apisauce": "^2.1.1", "expo": "^39.0.5", "expo-asset": "~8.2.0", "expo-file-system": "~9.2.0",