-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix: env variables in github * Fix: Env variables in release * Feat: Update page check (#37)
- Loading branch information
Showing
6 changed files
with
66 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,49 @@ | ||
import React from 'react'; | ||
import React, {useEffect, useState} from 'react'; | ||
import {NavigationContainer} from '@react-navigation/native'; | ||
import RootStackNavigation from './src/Navigation/RootStackNavigator'; | ||
import updateApp from './src/services/updateApp.service'; | ||
import {Button, Linking, StyleSheet, Text, View} from 'react-native'; | ||
|
||
const App = (): JSX.Element => { | ||
const [version, setVersion] = useState(false); | ||
useEffect(() => { | ||
updateApp(setVersion); | ||
}, []); | ||
return ( | ||
<NavigationContainer> | ||
<RootStackNavigation /> | ||
</NavigationContainer> | ||
<> | ||
{version ? ( | ||
<View style={styles.updateContainer}> | ||
<Text style={styles.text}> | ||
Il semblerait que votre application ne soit pas à jour ! | ||
</Text> | ||
<Button | ||
title="Mettre à jour" | ||
onPress={() => { | ||
Linking.openURL('market://details?id=com.opticarbu'); | ||
}} | ||
/> | ||
</View> | ||
) : ( | ||
<NavigationContainer> | ||
<RootStackNavigation /> | ||
</NavigationContainer> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
updateContainer: { | ||
height: '100%', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
text: { | ||
width: '80%', | ||
textAlign: 'center', | ||
marginBottom: 10, | ||
fontSize: 18, | ||
}, | ||
}); | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {HOST} from '@env'; | ||
|
||
const updateApp = async (setVersion: (value: any) => void) => { | ||
const pj = require('../../package.json'); | ||
const body = {version: pj.version}; | ||
const res = await fetch(`${HOST}/update`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(body), | ||
}); | ||
if (!res.ok) throw Error('Error on osrm services'); | ||
const resolve = await res.json(); | ||
setVersion(resolve); | ||
}; | ||
|
||
export default updateApp; |