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}
-
+