-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
61 lines (59 loc) · 1.73 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import {ImageBackground, StyleSheet} from "react-native";
import {Provider} from "react-redux";
import store from "./BLL/store";
// @ts-ignore
import blueSky from "../weather-app/assets/blue-sky.jpg";
// @ts-ignore
import night from "../weather-app/assets/night.jpg";
// @ts-ignore
import sunset from "../weather-app/assets/sunset-sky.jpg";
import axios from "axios";
import {NavigationContainer} from "@react-navigation/native";
import React from "react";
import CurrentForecast from "./UI/Components/CurrentForecast";
import moment from "moment";
import config from "./config";
let {API_KEY} = config
export default function App() {
axios.interceptors.request.use((config) => {
config.baseURL = "https://api.openweathermap.org/data/2.5/";
config.params.appid = API_KEY
return config;
});
let imgBackground = blueSky;
if (
parseInt(moment(Date.now()).format("k")) >= 8 &&
parseInt(moment(Date.now()).format("k")) < 16
) {
imgBackground = blueSky;
} else if (
parseInt(moment(Date.now()).format("k")) >= 16 &&
parseInt(moment(Date.now()).format("k")) < 22
) {
imgBackground = sunset;
} else {
imgBackground = night;
}
//dd
return (
<Provider store={store}>
<NavigationContainer>
<ImageBackground
source={imgBackground}
style={styles.bg}
blurRadius={5}
>
<CurrentForecast/>
</ImageBackground>
</NavigationContainer>
</Provider>
);
}
const styles = StyleSheet.create({
bg: {
flex: 1,
width: "100%",
height: "100%",
resizeMode: "cover",
},
});