Skip to content

Commit

Permalink
fixed api requests
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorfrois committed Jun 24, 2024
1 parent c0f2c88 commit 4c6f614
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 9 deletions.
2 changes: 2 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ EX_DEV_CLIENT_NETWORK_INSPECTOR=true

# Use legacy packaging to compress native libraries in the resulting APK.
expo.useLegacyPackaging=false

VisionCamera_enableCodeScanner=true
4 changes: 3 additions & 1 deletion ios/app/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
<true/>
</dict>
<key>NSCameraUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to access your camera</string>
<string>$(PRODUCT_NAME) needs access to your Camera.</string>
<key>NSMotionUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to access your device motion</string>
<key>UILaunchStoryboardName</key>
<string>SplashScreen</string>
<key>UIRequiredDeviceCapabilities</key>
Expand Down
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"react-countup": "^6.5.3",
"react-native": "0.74.2",
"react-native-compass-heading": "^1.5.0",
"react-native-config": "^1.5.2",
"react-native-permissions": "^4.1.5",
"react-native-progress": "^5.0.1",
"react-native-safe-area-context": "4.10.1",
Expand Down
10 changes: 7 additions & 3 deletions src/screens/AtividadeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function AtividadeScreen({ route, navigation }) {
const [data, setData] = useState([]);
const [isLoading, setLoading] = useState(true);
const [degree, setDegree] = useState(0);
const TRAIL_API_BASE_URL = __DEV__ ? 'http://172.26.196.22:5000' : 'https://ALGUMACOISA.COM';

const item = route.params.item;

Expand All @@ -36,8 +37,10 @@ export default function AtividadeScreen({ route, navigation }) {

const getTrees = async () => {
try {
const response = await fetch('http://192.168.0.12:5000/trails/' + item.id + '/trees');
setLoading(true);
const response = await fetch(TRAIL_API_BASE_URL + '/trails/' + item.id + '/trees');
const trees = await response.json();
console.log(trees);
setData(trees);
} catch (error) {
console.error(error);
Expand All @@ -54,7 +57,8 @@ export default function AtividadeScreen({ route, navigation }) {
if (route.params?.sucess) {
if (route.params.sucess) {
setArvore(n => n + 1);
setDistancia(n => n + data[arvore].distance);
const distance = data[arvore + 1] != null && data[arvore + 1].distance != null? data[arvore + 1].distance : 0;
setDistancia(n => n + distance);
}
route.params.sucess = false;
}
Expand Down Expand Up @@ -82,7 +86,7 @@ export default function AtividadeScreen({ route, navigation }) {
return (
<View style={{ flex: 1, flexDirection: 'column' }}>
<View style={{ flex: 5, backgroundColor: 'whitesmoke' }}>
<ZoomableImage source={require('../assets/mapa.jpg')} />
<ZoomableImage source={{uri: item.map_img.replace('localhost', '172.26.196.22')}} />
</View>
<View style={{
flex: 2.5,
Expand Down
2 changes: 1 addition & 1 deletion src/screens/FinalScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function FinalScreen({ route, navigation }) {
<View style={{ flex: 5, backgroundColor: 'yellow' }}>
<Image style={{ height: '100%', width: 'undefined', resizeMode: 'cover' }}
// style={styles.roundImage}
source={require('../assets/flamboyant-laranja-esalq.jpg')}
source={{uri: item.thumb_img.replace('localhost', '172.26.196.22')}}
/>
</View>

Expand Down
2 changes: 1 addition & 1 deletion src/screens/IniciarScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function IniciarScreen({ route, navigation }) {
showsHorizontalScrollIndicator={false}>
<Image style={{ height: '100%', width: 'undefined', aspectRatio: 1, resizeMode: 'cover' }}
// style={styles.roundImage}
source={require('../assets/mapa.jpg')}
source={{uri: item.thumb_img.replace('localhost', '172.26.196.22')}}
/>
</ScrollView>
</View>
Expand Down
7 changes: 5 additions & 2 deletions src/screens/TrilhasScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function TrilhaCard({ item, navigation }) {
<View style={styles.cardHeader}>
<Image
style={styles.roundImage}
source={require('../assets/flamboyant-laranja-esalq.jpg')}
source={{uri: item.thumb_img.replace('localhost', '172.26.196.22')}}
/>
<View style={styles.subCard}>
<Text style={styles.cardTitle}>
Expand All @@ -41,10 +41,13 @@ function TrilhaCard({ item, navigation }) {
export default function TrilhasScreen({ navigation }) {
const [isLoading, setLoading] = useState(true);
const [data, setData] = useState([]);
const TRAIL_API_BASE_URL = __DEV__ ? 'http://172.26.196.22:5000' : 'google.com';


const getMovies = async () => {
try {
const response = await fetch('http://192.168.0.12:5000/trails/');
console.log(TRAIL_API_BASE_URL);
const response = await fetch(TRAIL_API_BASE_URL + '/trails/');
const json = await response.json();
console.log(json);
setData(json);
Expand Down
3 changes: 2 additions & 1 deletion src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export const styles = StyleSheet.create({
width: '25%',
height: 'undefined',
aspectRatio: 1,
borderRadius: 4
borderRadius: 4,
resizeMode: 'contain'
},
card : {
flex: 1,
Expand Down

0 comments on commit 4c6f614

Please sign in to comment.