diff --git a/src/App.css b/src/App.css index f270304..57d64b9 100644 --- a/src/App.css +++ b/src/App.css @@ -8,11 +8,3 @@ flex: 1; padding-bottom: 56px; /* Space for the bottom navigation */ } - -.bottom-nav { - position: fixed; - bottom: 0; - left: 0; - right: 0; - z-index: 10; /* Ensure it's above other elements */ -} diff --git a/src/App.jsx b/src/App.jsx index d8b15b9..aa854a6 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,29 +1,24 @@ -import { useState } from 'react'; -import { Link, Route, BrowserRouter as Router, Routes } from 'react-router-dom'; +import { Route, BrowserRouter as Router, Routes } from 'react-router-dom'; -import FlagIcon from '@mui/icons-material/Flag'; -import HomeIcon from '@mui/icons-material/Home'; -import BottomNavigation from '@mui/material/BottomNavigation'; -import BottomNavigationAction from '@mui/material/BottomNavigationAction'; import { ThemeProvider } from '@mui/material/styles'; import { theme } from '@utils/theme'; -import Home from './pages/Home'; +import Home from '@pages/Home'; +import Streak from '@pages/Streak'; +import Footer from '@components/common/Footer'; import Header from '@components/common/Header'; import { UserProvider } from '@contexts/UserContext'; import './App.css'; const App = () => { - const [value, setValue] = useState(0); - return (
+
-
{/* Main content area where pages will render */} } /> @@ -32,22 +27,7 @@ const App = () => {
{/* Bottom Navigation with React Router links */} - { - setValue(newValue); - }} - showLabels - > - } component={Link} to="/" /> - } - component={Link} - to="/streak" - /> - +
@@ -56,5 +36,3 @@ const App = () => { }; export default App; - -const Streak = () =>

Streak

; diff --git a/src/components/common/ConfirmSignOutDialog.jsx b/src/components/common/ConfirmSignOutDialog.jsx new file mode 100644 index 0000000..244e618 --- /dev/null +++ b/src/components/common/ConfirmSignOutDialog.jsx @@ -0,0 +1,26 @@ +import { useUser } from '@contexts/UserContext'; +import { Button, Dialog, DialogActions, DialogTitle } from '@mui/material'; + +const ConfirmSignOutDialog = ({ open, onClose }) => { + const { handleSignOut } = useUser(); + + // Function to confirm sign out + const confirmSignOut = async () => { + await handleSignOut(); + onClose(); + }; + + return ( + + Confirm Sign Out + + + + + + ); +}; + +export default ConfirmSignOutDialog; diff --git a/src/components/common/Footer.jsx b/src/components/common/Footer.jsx new file mode 100644 index 0000000..2b12b84 --- /dev/null +++ b/src/components/common/Footer.jsx @@ -0,0 +1,39 @@ +import FlagIcon from '@mui/icons-material/Flag'; +import HomeIcon from '@mui/icons-material/Home'; +import { BottomNavigation, BottomNavigationAction } from '@mui/material'; +import { Link, useLocation } from 'react-router-dom'; + +export default function Footer() { + const location = useLocation(); + + // Get the index of the page based on the path + const getPageIndex = (path) => { + switch (path) { + case '/': + return 0; + case '/streak': + return 1; + default: + return 0; + } + }; + + return ( + + } component={Link} to="/" /> + } component={Link} to="/streak" /> + + ); +} diff --git a/src/components/common/Header.jsx b/src/components/common/Header.jsx index 60a7c8c..e2d4735 100644 --- a/src/components/common/Header.jsx +++ b/src/components/common/Header.jsx @@ -1,23 +1,34 @@ import { useUser } from '@contexts/UserContext'; +import ArrowBackIcon from '@mui/icons-material/ArrowBack'; import { AppBar, Avatar, Box, Button, IconButton, Toolbar, Typography } from '@mui/material'; +import { useState } from 'react'; +import { useLocation, useNavigate } from 'react-router-dom'; +import ConfirmSignOutDialog from './ConfirmSignOutDialog'; const Header = () => { - const { user, handleSignIn, handleSignOut } = useUser(); + const { user, handleSignIn } = useUser(); + const location = useLocation(); + const navigate = useNavigate(); - const handleAuthClick = async () => { - if (user) { - await handleSignOut(); - } else { - await handleSignIn(); - } - }; + // State for Dialog visibility + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + + // Show back button only on pages other than Home and Streak + const showBackButton = location.pathname !== '/' && location.pathname !== '/streak'; return ( - + - {/* Placeholder Box for back button if needed in the future */} - + {showBackButton && ( + navigate(-1)} // Back button + > + + + )} { position: 'absolute', left: '50%', transform: 'translateX(-50%)', - fontWeight: '600', + fontWeight: 600, fontSize: '1.4rem', }} > @@ -35,11 +46,19 @@ const Header = () => { {user ? ( - - - + <> + setOpenConfirmDialog(true)}> + + + + {/* Dialog for Confirm Sign Out */} + setOpenConfirmDialog(false)} + /> + ) : ( - )} diff --git a/src/pages/Streak.jsx b/src/pages/Streak.jsx new file mode 100644 index 0000000..e61349f --- /dev/null +++ b/src/pages/Streak.jsx @@ -0,0 +1,11 @@ +import { Box } from '@mui/material'; + +const Streak = () => { + return ( + +

Streak

+
+ ); +}; + +export default Streak;