-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.tsx
51 lines (44 loc) · 1.85 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
import React, { useEffect, useState } from "react";
import Root from "./Navigators/Root";
import BootSplash from "react-native-bootsplash";
import { Alert, Linking, ToastAndroid } from "react-native";
import axios from "axios";
import SystemNavigationBar from "react-native-system-navigation-bar";
import { addTracks, setupPlayer } from "./Screens/trackplayer";
import TrackPlayer from "react-native-track-player";
const App=()=>{
const [latestVersion, setLatestVersion] = useState("");
const currentVersion = "1.4.1";
SystemNavigationBar.setNavigationColor('#3D3C49')
useEffect(() => {
const init = async () => {
await setupPlayer()
const queue = await TrackPlayer.getQueue();
if(queue.length <= 0) {
await addTracks();
}
await TrackPlayer.play()
axios.get("https://api.github.com/repos/Saboten758/Lemon_Player/releases/latest")
.then(response => {
const latestRelease = response.data;
setLatestVersion(latestRelease.tag_name);
if (latestRelease.tag_name !== currentVersion) {
Alert.alert("Your app is not up to date!",`Please update to the latest version from Github!\n\nCurrent Version: ${currentVersion}\nLatest Stable Version: ${latestRelease.tag_name}`,[{text:'Open Github',onPress: ()=>Linking.openURL("https:github.com/Saboten758/Lemon_Player/releases/latest")},{text:'Cancel'}]);
}
else{
ToastAndroid.showWithGravity("Your App is upto date!",1000,9)
}
})
.catch(error => {
Alert.alert("Error","New Version can't be fetched from GitHub! Check Your Internet Connection!");
});
};
init().finally(async () => {
await BootSplash.hide({ fade: true });
setTimeout(()=>{},1000)
ToastAndroid.show("Welcome to Lemon Player",ToastAndroid.SHORT)
});
}, []);
return<Root/>
}
export default App