import React, { useState, useEffect } from 'react'; import { IonMenu, IonHeader, IonToolbar, IonTitle, IonContent, IonList, IonItem, IonLabel, IonIcon } from '@ionic/react'; import { list, search, heart, add, mic, documentText, time, trophy, people } from 'ionicons/icons'; import { useLocation, useNavigate } from 'react-router-dom'; const Navigation: React.FC = () => { const location = useLocation(); const navigate = useNavigate(); const [isLargeScreen, setIsLargeScreen] = useState(false); const navItems = [ { path: '/queue', label: 'Queue', icon: list }, { path: '/search', label: 'Search', icon: search }, { path: '/favorites', label: 'Favorites', icon: heart }, { path: '/new-songs', label: 'New Songs', icon: add }, { path: '/artists', label: 'Artists', icon: mic }, { path: '/song-lists', label: 'Song Lists', icon: documentText }, { path: '/history', label: 'History', icon: time }, { path: '/top-played', label: 'Top 100', icon: trophy }, { path: '/singers', label: 'Singers', icon: people }, ]; // Check screen size for responsive menu behavior useEffect(() => { const checkScreenSize = () => { const large = window.innerWidth >= 768; console.log('Screen width:', window.innerWidth, 'Is large screen:', large); setIsLargeScreen(large); }; checkScreenSize(); window.addEventListener('resize', checkScreenSize); return () => window.removeEventListener('resize', checkScreenSize); }, []); const handleNavigation = (path: string) => { navigate(path); // Close menu on mobile after navigation if (!isLargeScreen) { const menu = document.querySelector('ion-menu'); if (menu) { menu.close(); } } }; // For large screens, render a fixed sidebar instead of a menu if (isLargeScreen) { console.log('Rendering large screen sidebar'); return (

Karaoke

Singer: Matt

); } // For mobile screens, use the Ionic menu console.log('Rendering mobile menu'); return ( Menu {navItems.map((item) => ( handleNavigation(item.path)} className={location.pathname === item.path ? 'ion-activated' : ''} > {item.label} ))} ); }; export default Navigation;