Skip to content

Commit

Permalink
Add default export to weather and wallpaper section imports
Browse files Browse the repository at this point in the history
  • Loading branch information
mgonzalezg9 committed Dec 14, 2024
1 parent 7227428 commit 7cc8aa3
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 47 deletions.
4 changes: 1 addition & 3 deletions src/screens/LocationDetails/WeatherSection.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { CurvedThemedView, View as ThemedView } from "@/components";
import CityTitle from "@/weather/components/CityTitle";
import ForecastRow from "@/weather/components/ForecastRow";
import WeatherDetails from "@/weather/components/WeatherDetails";
import { CityTitle, ForecastRow, WeatherDetails } from "@/weather/components";
import { Forecast, Weather } from "@/weather/interfaces";
import React from "react";
import { StyleSheet, View } from "react-native";
Expand Down
11 changes: 6 additions & 5 deletions src/screens/LocationRequest/LocationRequestBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ import Colors from "@/constants/Colors";
import { SweatherErrorCode } from "@/error/error-logic";
import { useDeviceLocales } from "@/hooks";
import useWallpaper from "@/wallpaper/hooks/useWallpaper";
import useWeatherForecast, {
LocationQuery,
} from "@/weather/hooks/useWeatherForecast";
import {
UseWeatherAndForecastProps,
useWeatherForecast,
} from "@/weather/hooks";
import { useNavigation } from "@react-navigation/native";
import React, { useEffect, useState } from "react";
import { ActivityIndicator, StyleSheet, View } from "react-native";
import ErrorSection from "./ErrorSection";
import SearchSection from "./SearchSection";

const LocationRequestBody: React.FC = () => {
const LocationRequestBody = () => {
const navigation = useNavigation();
const [geoData, setGeoData] = useState<Omit<LocationQuery, "device">>(
const [geoData, setGeoData] = useState<Omit<UseWeatherAndForecastProps, "device">>(
{} as never
);
const [locationDenied, setLocationDenied] = useState(false);
Expand Down
9 changes: 9 additions & 0 deletions src/wallpaper/assets/images/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import bg1 from "./background_1.jpg";
import bg2 from "./background_2.jpg";
import bg3 from "./background_3.jpg";
import bg4 from "./background_4.jpg";
import bg5 from "./background_5.jpg";

export const BACKGROUND_LIST = [bg1, bg2, bg3, bg4, bg5];

export default BACKGROUND_LIST;
7 changes: 1 addition & 6 deletions src/wallpaper/services/wallpaper.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { wallpaperApi } from "../api";
import { WallpaperEndpoint } from "../api/endpoints";
import bg1 from "../assets/images/background_1.jpg";
import bg2 from "../assets/images/background_2.jpg";
import bg3 from "../assets/images/background_3.jpg";
import bg4 from "../assets/images/background_4.jpg";
import bg5 from "../assets/images/background_5.jpg";
import BACKGROUND_LIST from "../assets/images";
import { Wallpaper, WallpaperResponse } from "../interfaces";

const PER_PAGE = 3; // retrieves 3 wallpaper and choose one of them
const ORIENTATION = "portrait";
const BACKGROUND_LIST = [bg1, bg2, bg3, bg4, bg5];

type BackgroundQuery = {
query: string;
Expand Down
6 changes: 3 additions & 3 deletions src/weather/components/CityTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface CityTitleProps {
countryCode: string;
}

const CityTitle: React.FC<CityTitleProps> = ({ city, countryCode }) => {
const CityTitle = ({ city, countryCode }: CityTitleProps) => {
let regionName = "-";
if (countryCode) {
regionName = i18n.locale.includes("es")
Expand All @@ -33,8 +33,6 @@ const CityTitle: React.FC<CityTitleProps> = ({ city, countryCode }) => {
);
};

export default CityTitle;

const styles = StyleSheet.create({
cityText: {
fontSize: 36,
Expand All @@ -53,3 +51,5 @@ const styles = StyleSheet.create({
fontSize: 16,
},
});

export default CityTitle;
12 changes: 2 additions & 10 deletions src/weather/components/ConditionIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import Colors from "@/constants/Colors";
import { ICON_DEFAULT_PROPS } from "@/constants/Icon";
import ICON_DEFAULT_PROPS from "@/constants/Icon";
import { Icon } from "@/interfaces";
import React from "react";
import { Condition, Weather } from "../interfaces";
import { hasDaylight } from "../utils/time";
import Cloud from "./icons/Cloud";
import Fog from "./icons/Fog";
import Moon from "./icons/Moon";
import Rain from "./icons/Rain";
import Snow from "./icons/Snow";
import Storm from "./icons/Storm";
import Sun from "./icons/Sun";
import Tornado from "./icons/Tornado";
import Wind from "./icons/Wind";
import { Cloud, Fog, Moon, Rain, Snow, Storm, Sun, Tornado, Wind } from "./icons";

type ConditionIconProps = {
condition: Weather["condition"];
Expand Down
4 changes: 2 additions & 2 deletions src/weather/components/ConditionRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ const ConditionRow = ({
);
};

export default ConditionRow;

const styles = StyleSheet.create({
container: {
flexDirection: "row",
Expand All @@ -59,3 +57,5 @@ const styles = StyleSheet.create({
marginLeft: 5,
},
});

export default ConditionRow;
4 changes: 2 additions & 2 deletions src/weather/components/ForecastRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const ForecastRow = ({ hours, sunrise, sunset }: Forecast) => {
);
};

export default ForecastRow;

const styles = StyleSheet.create({
forecastRow: {
paddingHorizontal: 10,
},
});

export default ForecastRow;
4 changes: 2 additions & 2 deletions src/weather/components/TimeWeather.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ const TimeWeather = ({
);
};

export default TimeWeather;

const styles = StyleSheet.create({
container: {
flexDirection: "column",
Expand All @@ -57,3 +55,5 @@ const styles = StyleSheet.create({
fontSize: 16,
},
});

export default TimeWeather;
4 changes: 2 additions & 2 deletions src/weather/components/WeatherDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ const WeatherDetails = ({
);
};

export default WeatherDetails;

const styles = StyleSheet.create({
container: {
flexDirection: "row",
Expand All @@ -56,3 +54,5 @@ const styles = StyleSheet.create({
marginTop: 25,
},
});

export default WeatherDetails;
30 changes: 21 additions & 9 deletions src/weather/components/icons/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
export * from "./Cloud";
export * from "./Fog";
export * from "./Moon";
export * from "./Rain";
export * from "./Snow";
export * from "./Storm";
export * from "./Sun";
export * from "./Tornado";
export * from "./Wind";
import Cloud from "./Cloud";
import Fog from "./Fog";
import Moon from "./Moon";
import Rain from "./Rain";
import Snow from "./Snow";
import Storm from "./Storm";
import Sun from "./Sun";
import Tornado from "./Tornado";
import Wind from "./Wind";

export {
Cloud,
Fog,
Moon,
Rain,
Snow,
Storm,
Sun,
Tornado,
Wind
};
5 changes: 5 additions & 0 deletions src/weather/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import CityTitle from "./CityTitle";
import ForecastRow from "./ForecastRow";
import WeatherDetails from "./WeatherDetails";

export { CityTitle, ForecastRow, WeatherDetails };
3 changes: 3 additions & 0 deletions src/weather/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import useWeatherForecast, { UseWeatherAndForecastProps } from "./useWeatherForecast";

export { UseWeatherAndForecastProps, useWeatherForecast };
6 changes: 3 additions & 3 deletions src/weather/hooks/useWeatherForecast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { useEffect, useState } from "react";
import { Coordinates, Forecast, Weather } from "../interfaces";

export type LocationQuery = {
export type UseWeatherAndForecastProps = {
location: string;
coordinates: Coordinates;
device: {
Expand All @@ -18,7 +18,7 @@ const getWeatherAndForecast = async ({
location,
coordinates,
device,
}: LocationQuery) => {
}: UseWeatherAndForecastProps) => {
const [weather, forecast] = await Promise.all([
getCurrentWeather({
location,
Expand All @@ -39,7 +39,7 @@ export default function useWeatherForecast({
location,
coordinates,
device: { locale },
}: LocationQuery) {
}: UseWeatherAndForecastProps) {
const [weather, setWeather] = useState<Weather>();
const [forecast, setForecast] = useState<Forecast>();
const [isLoading, setLoading] = useState<boolean>(false);
Expand Down

0 comments on commit 7cc8aa3

Please sign in to comment.