/** * 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"}
)}
); } }