index.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import BottomNavigation from '@mui/material/BottomNavigation';
  2. import BottomNavigationAction from '@mui/material/BottomNavigationAction';
  3. import React, { useState } from 'react';
  4. import { makeStyles } from '@material-ui/core'
  5. import ChatListRecent from './ChatListRecent'
  6. const useStyles = makeStyles({
  7. bottomNavigation: {
  8. boxShadow: '0px 1px 1px 1px rgba(120,120,120,0.63)',
  9. marginBottom: 20
  10. },
  11. icon: {
  12. marginBottom:0,
  13. },
  14. underline: {
  15. fontSize: 30,
  16. lineHeight:0
  17. },
  18. })
  19. const SearchBar = () => {
  20. const [isActive, setIsActive] = useState<number>(0)
  21. const handleIsActive = (_e: React.SyntheticEvent<Element, Event>, newValue: number): void => setIsActive(newValue)
  22. const classes = useStyles()
  23. const Icon = ({ name }: { name: string }) => <span className={classes.icon}>{name}</span>
  24. const Label = () => <span className={classes.underline}>__</span>
  25. return (
  26. <>
  27. <BottomNavigation
  28. showLabels
  29. value={isActive}
  30. onChange={handleIsActive}
  31. className={classes.bottomNavigation}
  32. >
  33. <BottomNavigationAction label={<Label/>} icon={<Icon name='Chats' />} />
  34. <BottomNavigationAction label={<Label/>} icon={<Icon name='Media' />} />
  35. <BottomNavigationAction label={<Label/>} icon={<Icon name='Links' />} />
  36. <BottomNavigationAction label={<Label/>} icon={<Icon name='Files' />} />
  37. <BottomNavigationAction label={<Label/>} icon={<Icon name='Music' />} />
  38. <BottomNavigationAction label={<Label/>} icon={<Icon name='Voice' />} />
  39. </BottomNavigation>
  40. {isActive === 0&&<ChatListRecent/>}
  41. </>
  42. )
  43. }
  44. export default SearchBar