From 77cfa255274fdcdf822e836c7ea98e769bcb865d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 6 Oct 2021 15:27:31 +0200 Subject: mobile --- src/views/LandscapeWarning.js | 72 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/views/LandscapeWarning.js (limited to 'src/views/LandscapeWarning.js') diff --git a/src/views/LandscapeWarning.js b/src/views/LandscapeWarning.js new file mode 100644 index 0000000..389e8a6 --- /dev/null +++ b/src/views/LandscapeWarning.js @@ -0,0 +1,72 @@ +/** + * Instruction to rotate the phone to landscape + */ + +import React, { Component } from "react"; + +import { isMobile, isiPhone } from "../utils/index.js"; + +const PhoneIcon = ( + + + +); + +const RotateIcon = ( + + + +); + +export default class LandscapeWarning extends Component { + state = { + landscape: !isMobile || window.innerWidth > window.innerHeight, + }; + + constructor(props) { + super(props); + this.handleResize = this.handleResize.bind(this); + if (isMobile) { + window.addEventListener("resize", this.handleResize); + setTimeout(this.handleResize, 100); + } + } + + handleResize() { + const landscape = !isMobile || window.innerWidth > window.innerHeight; + if (landscape !== this.state.landscape) { + this.setState({ landscape }); + } + } + + render() { + const { landscape } = this.state; + if (landscape) return null; + return ( +
+ {RotateIcon} + {PhoneIcon} + {isiPhone && ( +
+ {"Please tap "} + A + {"A and Hide Toolbar"} +
+ {"then rotate your device."} +
+ )} + {!isiPhone && ( +
{"Please rotate your device"}
+ )} +
+ ); + } +} -- cgit v1.2.3-70-g09d2