Skip to content

Commit

Permalink
Creating nested screens
Browse files Browse the repository at this point in the history
  • Loading branch information
EuJinnLucaShow committed Aug 18, 2023
1 parent 99ac7a8 commit 9056766
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 71 deletions.
68 changes: 0 additions & 68 deletions src/screens/mainScreen/MapScreen.js

This file was deleted.

21 changes: 21 additions & 0 deletions src/screens/mainScreens/HomeScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import { moduleName } from 'react-native';
import { createStackNavigator } from '@react-navigation/stack';

import PostsScreen from '../nestedScreens/PostsScreen';
import CommentsScreen from '../nestedScreens/CommentsScreen';
import CreatePostsScreen from '../nestedScreens/CreatePostsScreen';

const NestedScreen = createStackNavigator();

const HomeScreen = () => {
return (
<NestedScreen.Navigator>
<NestedScreen.Screen name="Posts" component={PostsScreen} />
<NestedScreen.Screen name="Comments" component={CommentsScreen} />
<NestedScreen.Screen name="CreatePosts" component={CreatePostsScreen} />
</NestedScreen.Navigator>
);
};

export default NestedScreen;
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import {
View,
Text,
Expand All @@ -11,6 +11,7 @@ import {
Image,
} from 'react-native';
import { Camera } from 'expo-camera';
import * as Location from 'expo-location';
import { FontAwesome, Feather, SimpleLineIcons } from '@expo/vector-icons';

export default function CreatePostsScreen({ navigation }) {
Expand All @@ -24,6 +25,8 @@ export default function CreatePostsScreen({ navigation }) {
const takePhoto = async () => {
if (camera) {
const photo = await camera.takePictureAsync(null);
const location = await Location.getCurrentPositionAsync({});
console.log(location);
setPhoto(photo.uri);
}
};
Expand All @@ -33,6 +36,16 @@ export default function CreatePostsScreen({ navigation }) {
clearData();
};

useEffect(() => {
(async () => {
let { status } = await Location.requestForegroundPermissionsAsync();
if (status !== 'granted') {
setErrorMsg('Permission to access location was denied');
return;
}
})();
});

return (
<TouchableWithoutFeedback onPress={() => Keyboard.dismiss()}>
<KeyboardAvoidingView
Expand Down Expand Up @@ -173,7 +186,6 @@ const styles = StyleSheet.create({
borderRadius: 50,
},
photoMetaInput: {
width: '100%',
height: 50,
marginBottom: 16,
fontSize: 16,
Expand All @@ -187,7 +199,6 @@ const styles = StyleSheet.create({
top: 13,
},
publishButton: {
width: '100%',
height: 50,
marginBottom: 120,
padding: 16,
Expand Down
36 changes: 36 additions & 0 deletions src/screens/nestedScreens/MapScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React, { useState, useEffect } from 'react';
import { View, StyleSheet } from 'react-native';
import { useRoute } from '@react-navigation/native';
import MapView, { Marker } from 'react-native-maps';
import * as Location from 'expo-location';

export default function MapScreen() {
return (
<View style={styles.container}>
<MapView
style={{ flex: 1 }}
initialRegion={{
latitude: '',
longitude: '',
latitudeDelta: '',
longitudeDelta: '',
}}
>
<Marker
coordinate={{
latitude: '',
longitude: '',
}}
title={'title'}
description={'description'}
/>
</MapView>
</View>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
},
});

0 comments on commit 9056766

Please sign in to comment.