You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Navbar.jsx 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import React from 'react';
  2. import { View, StyleSheet, Pressable, Text } from 'react-native';
  3. import Icon from 'react-native-vector-icons/MaterialIcons';
  4. import { usePathname } from 'expo-router';
  5. import { Link } from 'expo-router';
  6. const navItems = [
  7. {
  8. href: '/',
  9. icon: 'home',
  10. label: 'Home',
  11. onPress: () => console.log("home"),
  12. },
  13. {
  14. href: '/notify',
  15. icon: 'edit-document',
  16. label: 'Notify',
  17. onPress: () => console.log("notify"),
  18. },
  19. {
  20. href: '/explore',
  21. icon: 'person',
  22. label: 'Profile',
  23. onPress: () => console.log("profile"),
  24. },
  25. ];
  26. const NavItem = ({ href, icon, label, onPress, isActive }) => (
  27. <Link href={href}>
  28. <Pressable onPress={onPress} style={[styles.navItem]}>
  29. <Icon name={icon} size={30} style={[styles.icon, {opacity: isActive ? 1 : 0.5}]} />
  30. <Text style={[styles.textLink, {opacity: isActive ? 1 : 0.5}]}>{label}</Text>
  31. </Pressable>
  32. </Link>
  33. );
  34. export function Navbar() {
  35. const pathName = usePathname();
  36. return (
  37. <View style={styles.navContainer}>
  38. {navItems.map((item, index) => (
  39. <NavItem key={index} {...item} isActive={pathName == item.href} />
  40. ))}
  41. </View>
  42. );
  43. }
  44. const styles = StyleSheet.create({
  45. navContainer: {
  46. backgroundColor: "#396868",
  47. paddingVertical: 10,
  48. width: "100%",
  49. flexDirection: "row",
  50. justifyContent: "space-evenly",
  51. },
  52. navItem: {
  53. alignItems: 'center',
  54. },
  55. icon: {
  56. color: "#FFF",
  57. active:{
  58. color:"#"
  59. }
  60. },
  61. textLink: {
  62. color: "#FFF",
  63. },
  64. });