Skip to content

Commit

Permalink
Added right side drawer with mock values and adjusted chat footer pad…
Browse files Browse the repository at this point in the history
…ding
  • Loading branch information
dyland88 committed Nov 19, 2024
1 parent ae880c1 commit 6e5a2ab
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 51 deletions.
2 changes: 1 addition & 1 deletion client/app/components/chat/ChatScreenFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const styles = StyleSheet.create({
borderWidth: 1,
borderRadius: Dimensions.get("window").width * 0.058,
marginHorizontal: Dimensions.get("window").width * 0.005,
marginBottom: Platform.OS === "ios" ? 0 : 5,
marginBottom: 5,
minHeight: Dimensions.get("window").width * 0.113,
maxHeight: Dimensions.get("window").width * 0.3,
},
Expand Down
18 changes: 12 additions & 6 deletions client/app/components/chat/NearbyHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@ import {
} from "react-native";
import { ChevronLeft } from "react-native-feather";

export const NearbyHeader: React.FC = () => {
interface NearbyHeaderProps {
onClick: () => void;
}

export const NearbyHeader: React.FC<NearbyHeaderProps> = ({ onClick }) => {
return (
<View style={styles.nearbyContainer}>
<Text style={styles.nearbyText}>Nearby</Text>
<View style={styles.iconContainer}>
<TouchableOpacity onPress={() => {}}>
<TouchableOpacity onPress={onClick}>
<View style={styles.iconContainer}>
<Image
style={styles.peopleIcon}
source={require("../../../assets/icons/misc/nearby_icon.png")}
/>
</TouchableOpacity>
<Text style={styles.countText}>{5}</Text>
</View>

<Text style={styles.countText}>{5}</Text>
</View>
</TouchableOpacity>
</View>
);
};
Expand All @@ -42,6 +47,7 @@ const styles = StyleSheet.create({
paddingRight: "5%",
paddingLeft: "10%",
gap: 10,
zIndex: 1,
},
nearbyText: {
fontFamily: "Quicksand",
Expand Down
117 changes: 90 additions & 27 deletions client/app/components/chat/NearbyUserDrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,99 @@
import * as React from "react";
import { Dimensions, Text, StyleSheet, View } from "react-native";
import { Drawer } from "react-native-drawer-layout";
import { Button } from "react-native";
import React, { useState } from "react";
import { View, Text, StyleSheet, FlatList, Dimensions } from "react-native";
import Animated, {
useSharedValue,
useAnimatedStyle,
withTiming,
Easing,
} from "react-native-reanimated";
import NearbyHeader from "./NearbyHeader";
import { Pressable } from "react-native";

export const NearbyUserDrawer = () => {
const [open, setOpen] = React.useState(true);
const SCREEN_WIDTH = Dimensions.get("window").width;

const NearbyUserDrawer = () => {
const [isOpen, setIsOpen] = useState(false);
const translateX = useSharedValue(SCREEN_WIDTH);

const toggleDrawer = () => {
translateX.value = isOpen
? withTiming(SCREEN_WIDTH, {
duration: 300, // Duration in milliseconds
easing: Easing.out(Easing.ease), // Smooth easing out
})
: withTiming(0, {
duration: 300,
easing: Easing.out(Easing.ease), // Smooth easing out
});
setIsOpen(!isOpen);
};

const animatedStyle = useAnimatedStyle(() => ({
transform: [{ translateX: translateX.value }],
}));

const nearbyUsers = ["Alice", "Bob", "Charlie", "Diana", "Eve"]; // Example names

return (
<Drawer
open={open}
onOpen={() => setOpen(true)}
onClose={() => setOpen(false)}
drawerType={"front"}
renderDrawerContent={() => {
return (
<View style={styles.drawerContent}>
<Text>Drawer content</Text>
</View>
);
}}>
<Button
onPress={() => setOpen((prevOpen) => !prevOpen)}
title={`${open ? "Close" : "Open"} drawer`}
/>
</Drawer>
<View style={styles.container}>
<NearbyHeader onClick={toggleDrawer} />
{/* Overlay and Drawer */}
{isOpen && <Pressable style={styles.overlay} onPress={toggleDrawer} />}
<Animated.View style={[styles.drawer, animatedStyle]}>
<Text style={styles.headerText}>Nearby Users</Text>
<FlatList
data={nearbyUsers}
keyExtractor={(item, index) => index.toString()}
renderItem={({ item }) => <Text style={styles.name}>{item}</Text>}
/>
</Animated.View>
</View>
);
};

const styles = StyleSheet.create({
drawerContent: {
height: Dimensions.get("window").height,
width: Dimensions.get("window").width,
backgroundColor: "white",
container: {
display: "flex",
height: Dimensions.get("screen").height,
flexDirection: "column",
alignItems: "center",
position: "absolute",
},
overlay: {
position: "absolute",
top: 0,
left: 0,
width: "100%",
height: "100%",
backgroundColor: "rgba(0, 0, 0, 0.15)",
zIndex: 1,
},
drawer: {
position: "absolute",
right: 0,
top: 0,
width: SCREEN_WIDTH * 0.6,
height: "100%",
backgroundColor: "#fff",
borderLeftWidth: 1,
borderLeftColor: "#ddd",
padding: 30,
shadowColor: "#000",
shadowOffset: { width: -2, height: 0 },
shadowOpacity: 0.3,
shadowRadius: 4,
zIndex: 2,
gap: 20,
},
headerText: {
fontFamily: "Quicksand",
fontSize: 24,
fontWeight: "bold",
},
name: {
fontSize: 18,
marginVertical: 10,
},
});

export default NearbyUserDrawer;
6 changes: 2 additions & 4 deletions client/app/screens/chat/ChatScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useState, useEffect } from "react";
import { useUser } from "@app/contexts/UserContext";
import NearbyHeader from "@app/components/chat/NearbyHeader";
import React from "react";
import { NearbyUserDrawer } from "@app/components/chat/NearbyUserDrawer";
import NearbyUserDrawer from "@app/components/chat/NearbyUserDrawer";

const ChatScreen = () => {
const settings = useSettings();
Expand Down Expand Up @@ -91,9 +91,8 @@ const ChatScreen = () => {
keyboardVerticalOffset={
Platform.OS === "ios" ? screenHeight * 0.055 : 0
}>
<NearbyUserDrawer />
<View style={styles.mainContainer}>
<NearbyHeader />
<NearbyUserDrawer />
<View style={styles.chatContainer}>
<MessageChannel messages={messages} />
</View>
Expand Down Expand Up @@ -137,7 +136,6 @@ const styles = StyleSheet.create({

footerContainer: {
width: "95%",

maxHeight: Dimensions.get("window").height * 0.15,
display: "flex",
flexDirection: "row",
Expand Down
14 changes: 1 addition & 13 deletions client/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 client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"react-native-drawer-layout": "^4.0.1",
"react-native-feather": "^1.1.2",
"react-native-gesture-handler": "~2.20.2",
"react-native-reanimated": "^3.16.1",
"react-native-safe-area-context": "4.12.0",
"react-native-screens": "~4.0.0",
"react-native-svg": "15.8.0",
Expand Down

0 comments on commit 6e5a2ab

Please sign in to comment.