Skip to content

Commit

Permalink
feat: Add navigation to the Profile screens
Browse files Browse the repository at this point in the history
  • Loading branch information
VGeorgiev committed Sep 17, 2022
1 parent 42d2335 commit 5803b35
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/components/FeedPost.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StyleSheet, Text, View, Image } from "react-native";
import { StyleSheet, Text, View, Image, TouchableOpacity } from "react-native";
import like from "../../assets/images/like.png";
import {
Entypo,
Expand All @@ -7,16 +7,22 @@ import {
MaterialCommunityIcons,
} from "@expo/vector-icons";
import IconButton from "./IconButton";
import { useNavigation } from "@react-navigation/native";

interface FeedPostProps {
post: Post;
}

const FeedPost: React.FC<FeedPostProps> = ({ post }) => {
const navigation = useNavigation();
const navigateToProfile = () => {
// @ts-ignore
navigation.navigate("Profile");
};
return (
<View style={styles.post}>
{/* Header */}
<View style={styles.header}>
<TouchableOpacity onPress={navigateToProfile} style={styles.header}>
<Image source={{ uri: post.User.image }} style={styles.profileImage} />
<View>
<Text style={styles.name}>{post.User.name}</Text>
Expand All @@ -28,7 +34,7 @@ const FeedPost: React.FC<FeedPostProps> = ({ post }) => {
color="gray"
style={styles.icon}
/>
</View>
</TouchableOpacity>
{/* Body */}
{post.description && (
<Text style={styles.description}>{post.description}</Text>
Expand Down
4 changes: 4 additions & 0 deletions src/navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import FeedScreen from "../screens/FeedScreen";
import CreatePostScreen from "../screens/CreatePostScreen";
import ProfileScreen from "../screens/ProfileScreen";
import UpdateProfileScreen from "../screens/UpdateProfileScreen";

const Stack = createNativeStackNavigator();

Expand All @@ -15,6 +17,8 @@ const Navigator = () => {
options={{ headerShown: false }}
/>
<Stack.Screen name="Create Post" component={CreatePostScreen} />
<Stack.Screen name="Profile" component={ProfileScreen} />
<Stack.Screen name="Edit Profile" component={UpdateProfileScreen} />
</Stack.Navigator>
</NavigationContainer>
);
Expand Down
6 changes: 5 additions & 1 deletion src/screens/ProfileScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const ProfileScreenHeader = ({
if (!user) {
return <ActivityIndicator />;
}
const editProfile = () => {
// @ts-ignore
navigation.navigate("Edit Profile");
};

return (
<View style={styles.container}>
Expand All @@ -60,7 +64,7 @@ const ProfileScreenHeader = ({
Add to Story
</Text>
</Pressable>
<Pressable style={styles.button}>
<Pressable style={styles.button} onPress={editProfile}>
<MaterialCommunityIcons name="pencil" size={16} color="black" />
<Text style={styles.buttonText}>Edit Profile</Text>
</Pressable>
Expand Down

0 comments on commit 5803b35

Please sign in to comment.