From 86c29780c70150771251fd13b532669be896582d Mon Sep 17 00:00:00 2001 From: FleetAdmiralJakob Date: Sun, 21 Jan 2024 18:43:57 +0100 Subject: [PATCH] fix(style): Added a change of the bottom menubar only for iOS devices --- apps/web/src/components/Layout.tsx | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/Layout.tsx b/apps/web/src/components/Layout.tsx index 3a97080c..c6799947 100644 --- a/apps/web/src/components/Layout.tsx +++ b/apps/web/src/components/Layout.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import Head from "next/head"; import Link from "next/link"; import { useTranslation } from "next-i18next"; @@ -18,6 +18,19 @@ interface LayoutProps { page?: "home" | "locationsettings" | "settings" | "contact"; } +declare global { + interface Window { + MSStream: any; + } +} + +function isIOS() { + if (typeof window !== "undefined") { + return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; + } + return false; +} + /* If you use this component, you have to add the i18n translation SSR stuff to the getStaticProps function of the page you use this component in. */ @@ -28,9 +41,14 @@ const Layout: React.FC = ({ page, }) => { const [navbarOpen, setNavbarOpen] = useState(false); + const [isIOS, setIsIOS] = useState(false); const { t: translation } = useTranslation("common"); + useEffect(() => { + setIsIOS(/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream); + }, []); + const handleShare = () => { const title = document.title; const url = window.location.href; @@ -141,7 +159,15 @@ const Layout: React.FC = ({ {translation("share button")}
{children}
-
+