diff --git a/packages/desktop-client/src/components/FinancesApp.js b/packages/desktop-client/src/components/FinancesApp.js index e6f3dc6df8badcd0a7b3459c7630ef071798bfea..d8e44eb6d1851299fc9e9081f20aff38ed0e988d 100644 --- a/packages/desktop-client/src/components/FinancesApp.js +++ b/packages/desktop-client/src/components/FinancesApp.js @@ -203,7 +203,7 @@ function MobileNavTabs() { class FinancesApp extends React.Component { constructor(props) { super(props); - this.state = { isMobile: isMobile(window.innerWidth) }; + this.state = { isMobile: isMobile() }; this.history = createBrowserHistory(); let oldPush = this.history.push; @@ -232,7 +232,7 @@ class FinancesApp extends React.Component { handleWindowResize() { this.setState({ - isMobile: isMobile(window.innerWidth), + isMobile: isMobile(), windowWidth: window.innerWidth }); } diff --git a/packages/desktop-client/src/util.js b/packages/desktop-client/src/util.js index 2ed5cc5cfdca7a74b06442f650763db413b0fffd..bde05fce7d48b3cc9cef1c412aa94837b5eb5701 100644 --- a/packages/desktop-client/src/util.js +++ b/packages/desktop-client/src/util.js @@ -1,12 +1,10 @@ -import tokens from 'loot-design/src/tokens'; - export function getModalRoute(name) { let parts = name.split('/'); return [parts[0], parts.slice(1).join('/')]; } -export function isMobile(width) { - // Simple detection: if the screen width is too small - const containerWidth = width || window.innerWidth; - return containerWidth < parseInt(tokens.breakpoint_medium); +export function isMobile() { + let details = navigator.userAgent; + let regexp = /Mobi|android|iphone|kindle|ipad/i; + return regexp.test(details); }