From 8057e39e53f0f82a63a75d72c16411d2d70667c6 Mon Sep 17 00:00:00 2001 From: GamerBoss101 Date: Sun, 13 Apr 2025 08:25:18 -0400 Subject: [PATCH] jBAEJHBSrjb --- src/app/(app)/layout.tsx | 56 +++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/src/app/(app)/layout.tsx b/src/app/(app)/layout.tsx index 57b3653..08fee88 100644 --- a/src/app/(app)/layout.tsx +++ b/src/app/(app)/layout.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import MobileNav from "@/lib/components/MobileNav"; import NavBar from "@/lib/components/NavBar"; import { useDevice } from "@/lib/context/DeviceContext"; @@ -13,23 +13,50 @@ export default function RootLayout({ const { isMobile, isSafari } = useDevice(); const [isPlaying, setIsPlaying] = useState(false); - const handlePlayMusic = () => { + const handleToggleMusic = () => { const audioElement = document.getElementById("background-music") as HTMLAudioElement; if (audioElement) { - audioElement.play(); - setIsPlaying(true); + if (isPlaying) { + audioElement.pause(); + setIsPlaying(false); + } else { + audioElement.play(); + setIsPlaying(true); + } } }; + // Activate music when anything is clicked + useEffect(() => { + const handlePageClick = () => { + const audioElement = document.getElementById("background-music") as HTMLAudioElement; + if (audioElement && !isPlaying) { + audioElement.play(); + setIsPlaying(true); + } + }; + + document.addEventListener("click", handlePageClick); + + return () => { + document.removeEventListener("click", handlePageClick); + }; + }, [isPlaying]); + return (
+ {/* Navigation Bar */} {!isMobile && !isSafari ? : null} + + {/* Content Section */}
{children}
+ + {/* Mobile-Specific Features */} {isMobile && isSafari ? ( <> {/* Background Music */} @@ -38,17 +65,16 @@ export default function RootLayout({ Your browser does not support the audio element. - {/* Play Button */} - {!isPlaying && ( -
- -
- )} + {/* Music Toggle Button */} +
+ +
{/* Mobile Navigation */}