From 9e768921beec3026d9e81dd226b104fccf2e3358 Mon Sep 17 00:00:00 2001 From: Daniel Shleifman Date: Sun, 26 Jun 2022 13:37:08 +0300 Subject: [PATCH] PWAInstallationGuide added --- .../App/PWAInstallationGuide/IOSShareIcon.jsx | 21 +++++++ .../App/PWAInstallationGuide/index.jsx | 44 ++++++++++++++ .../App/PWAInstallationGuide/style.jsx | 59 +++++++++++++++++++ web/src/components/App/index.jsx | 8 ++- web/src/utils/checkIsIOS.jsx | 5 ++ 5 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 web/src/components/App/PWAInstallationGuide/IOSShareIcon.jsx create mode 100644 web/src/components/App/PWAInstallationGuide/index.jsx create mode 100644 web/src/components/App/PWAInstallationGuide/style.jsx create mode 100644 web/src/utils/checkIsIOS.jsx diff --git a/web/src/components/App/PWAInstallationGuide/IOSShareIcon.jsx b/web/src/components/App/PWAInstallationGuide/IOSShareIcon.jsx new file mode 100644 index 0000000..aa02156 --- /dev/null +++ b/web/src/components/App/PWAInstallationGuide/IOSShareIcon.jsx @@ -0,0 +1,21 @@ +export default function IOSShareIcon() { + return ( + + Svg Vector Icons : http://www.onlinewebfonts.com/icon + + + + + ) +} diff --git a/web/src/components/App/PWAInstallationGuide/index.jsx b/web/src/components/App/PWAInstallationGuide/index.jsx new file mode 100644 index 0000000..1cb4217 --- /dev/null +++ b/web/src/components/App/PWAInstallationGuide/index.jsx @@ -0,0 +1,44 @@ +import IconButton from '@material-ui/core/IconButton' +import CloseIcon from '@material-ui/icons/Close' +import { useState } from 'react' + +import IOSShareIcon from './IOSShareIcon' +import { StyledWrapper, StyledHeader, StyledContent } from './style' + +export function PWAInstallationGuide() { + const [isOpen, setIsOpen] = useState(!JSON.parse(localStorage.getItem('pwaNotificationIsClosed'))) + + return ( + + + ts-icon + Install application + { + setIsOpen(false) + localStorage.setItem('pwaNotificationIsClosed', true) + }} + > + + + + + +

Install the app on your device to easily access it anytime. No app store. No download.

+ +

VLC button will be added to open video instantly on the phone

+ +

+ 1. Tap on +

+ +

+ 2. Select Add to Home Screen +

+
+
+ ) +} diff --git a/web/src/components/App/PWAInstallationGuide/style.jsx b/web/src/components/App/PWAInstallationGuide/style.jsx new file mode 100644 index 0000000..1c9b730 --- /dev/null +++ b/web/src/components/App/PWAInstallationGuide/style.jsx @@ -0,0 +1,59 @@ +import styled, { css } from 'styled-components' + +export const StyledWrapper = styled.div` + ${({ isOpen }) => css` + position: absolute; + bottom: 10px; + left: 50%; + background: #eeeef0; + width: calc(100% - 20px); + z-index: 9999; + border-radius: 10px; + transition: all 0.3s; + color: #000; + + ${isOpen + ? css` + opacity: 1; + transform: translate(-50%, 0); + ` + : css` + transform: translate(-50%, 150%); + opacity: 0; + pointer-events: none; + `} + + > :not(:last-child) { + border-bottom: 1px solid #dadadc; + } + + > * { + padding: 20px; + } + `} +` + +export const StyledHeader = styled.div` + display: grid; + grid-auto-flow: column; + grid-template-columns: min-content 1fr; + gap: 20px; + align-items: center; + font-weight: 700; + + img { + border-radius: 5px; + } +` + +export const StyledContent = styled.div` + > :not(:last-child) { + margin-bottom: 25px; + } + + span { + background: #fefcfd; + padding: 5px; + border-radius: 5px; + } +` diff --git a/web/src/components/App/index.jsx b/web/src/components/App/index.jsx index 9e913dc..83dbd7d 100644 --- a/web/src/components/App/index.jsx +++ b/web/src/components/App/index.jsx @@ -18,14 +18,18 @@ import useChangeLanguage from 'utils/useChangeLanguage' import { ThemeProvider as MuiThemeProvider } from '@material-ui/core/styles' import { ThemeProvider as StyledComponentsThemeProvider } from 'styled-components' import { useQuery } from 'react-query' -import { getTorrents } from 'utils/Utils' +import { getTorrents, isStandaloneApp } from 'utils/Utils' import GlobalStyle from 'style/GlobalStyle' import { lightTheme, THEME_MODES, useMaterialUITheme } from 'style/materialUISetup' import getStyledComponentsTheme from 'style/getStyledComponentsTheme' +import checkIsIOS from 'utils/checkIsIOS' import { AppWrapper, AppHeader, HeaderToggle, StyledIconButton } from './style' import Sidebar from './Sidebar' import PWAFooter from './PWAFooter' +import { PWAInstallationGuide } from './PWAInstallationGuide' + +const snackbarIsClosed = JSON.parse(localStorage.getItem('snackbarIsClosed')) export const DarkModeContext = createContext() @@ -123,7 +127,7 @@ export default function App() { {isDonationDialogOpen && setIsDonationDialogOpen(false)} />} - {!JSON.parse(localStorage.getItem('snackbarIsClosed')) && } + {snackbarIsClosed ? checkIsIOS() && !isStandaloneApp && : } diff --git a/web/src/utils/checkIsIOS.jsx b/web/src/utils/checkIsIOS.jsx new file mode 100644 index 0000000..27b55c0 --- /dev/null +++ b/web/src/utils/checkIsIOS.jsx @@ -0,0 +1,5 @@ +export default () => { + if (typeof window === `undefined` || typeof navigator === `undefined`) return false + + return /iPhone|iPad|iPod/i.test(navigator.userAgent || navigator.vendor) +}