From cf22bf4eb580f541895d68392516ba8e3752020f Mon Sep 17 00:00:00 2001 From: arthur-lzrs <55158951+arthur-lzrs@users.noreply.github.com> Date: Fri, 27 Nov 2026 14:24:34 -0300 Subject: [PATCH] feat: open the menu with a swipe from the left On a phone the menu opens only from its button in the top bar, which is a stretch for a thumb on a large screen. A new device setting, Settings > General > This device > "Swipe from the edge for the menu", lets a swipe to the right that starts a little in from the left edge open the menu, and a swipe to the left on the menu or its backdrop close it. It is off by default, kept per device like keeping the screen on, and offered on a phone-sized screen with a touchscreen. The swipe starts 30 to 84 px in from the edge and never at it: a phone's own back gesture takes the very edge and a page cannot stop it, so starting clear of it means the two are never started by the same touch. It is not started on the map pages (a map pans on any touch), over a dialog, or on a map, a chart or anything that scrolls sideways. A finger that moves up or down first is a scroll and is left alone. The gesture listens on the window (pointer events, with touch events to follow the drag where a browser cancels the pointer to pan the page), so nothing sits over the page to catch taps. useDrawerSwipe holds it, App.vue wires it to the menu, and DeviceSettings has the toggle. The new edgeSwipeMenu setting is local to the device, so it is not synced to the account. Co-Authored-By: Claude Sonnet 5.5 --- README.md | 1 + frontend/src/App.vue | 17 + frontend/src/__tests__/App.spec.ts | 117 +++++ .../components/settings/DeviceSettings.vue | 19 +- .../settings/__tests__/SettingsModal.spec.ts | 49 ++ .../__tests__/useDrawerSwipe.spec.ts | 497 ++++++++++++++++++ frontend/src/composables/useDrawerSwipe.ts | 169 ++++++ frontend/src/locales/en.json | 4 + frontend/src/locales/es.json | 4 + frontend/src/locales/nl.json | 4 + frontend/src/locales/pt-PT.json | 4 + frontend/src/locales/pt.json | 4 + .../stores/__tests__/settingsStores.spec.ts | 21 + .../src/stores/__tests__/settingsSync.spec.ts | 15 + frontend/src/stores/settingsUi.ts | 9 +- 15 files changed, 929 insertions(+), 5 deletions(-) create mode 100644 frontend/src/composables/__tests__/useDrawerSwipe.spec.ts create mode 100644 frontend/src/composables/useDrawerSwipe.ts diff --git a/README.md b/README.md index e57d5279..f866bad1 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ The map behind the dashboard, the layout editor, the offline view, the HV batter - **Read-only API tokens** -- Make a token under Settings > Data & API > API tokens and let a script, a dashboard or a watch read what the app shows, without signing in. A token can only read: it cannot send commands or change anything, and the full data export, the logs and the diagnostics stay with a signed-in session. - **Home Assistant** -- Your car appears in Home Assistant automatically through MQTT discovery, sharing GarageStack's broker and MG session instead of needing a second integration. GarageStack adds sensors of its own to the car: the APK and its days left, open recalls, the maintenance due next and the last trip. See [`HOME_ASSISTANT.md`](documentation/HOME_ASSISTANT.md). - **Progressive Web App (PWA)** -- Installable on mobile or desktop for a native app-like experience, complete with a home screen icon and push notification support. Where the browser allows it, GarageStack offers to install itself, and the offer can be turned down for good. It also opens without a connection, in an underground car park or away from home without your VPN: every page then shows what that device last loaded (the dashboard, statistics, the map with its routes, the trip log, charge history, maintenance and climate schedules) and says so and from when, the buttons that need the server (commands, editing, the log viewer) are hidden until it can be reached again, and the directions dialog still offers the coordinates and a `geo:` link for a map app with offline maps. The maps keep their streets too: the app keeps the map tiles it has shown (up to about 150 raster tiles and 400 basemap files, for a month), so the areas you looked at with a signal are there offline. It never downloads areas you have not looked at, which OpenStreetMap's tile policy forbids. The saved pages and the kept tiles are forgotten on signing out. Installing and push need HTTPS, see [HTTPS](#https). +- **Swipe for the menu** -- On a phone, **Settings > General > This device** can switch on swiping the menu: a swipe to the right that starts a little in from the left edge of the screen opens it, and a swipe to the left closes it. It starts clear of the very edge, which a phone's own back gesture takes, so the two are never mixed up. It is off until a device switches it on, stays with that device, and is left out of the map pages and of anything that pans or scrolls sideways under the finger, such as a map, a chart or a row of chips. - **Charging stations** -- Overlay nearby EV charging stations on the map, sourced from the [Open Charge Map](https://openchargemap.org) database. Station data is cached in the database for 7 days; on page load the map immediately shows all stations within 100 km of your car that are already cached. Markers show operational status; clicking a marker displays the station name, operator, address, and available connector types with power ratings. Requires a free OCM API key (`OPENCHARGEMAP_API_KEY`). Unlike fuel stations and service areas, charging station tiles are loaded on demand as you browse the map and are not pre-populated by the background Worker. - **Fuel stations** -- Overlay nearby petrol and diesel stations on the map (HEV and PHEV only; not shown for BEV). Sourced from OpenStreetMap via the Overpass API -- no API key required. POI data is cached in the database for 7 days and pre-populated by the Worker for a 100 km radius around the car's last known position so the overlay is instant on first view. - **Motorway service areas** -- Overlay motorway service areas and rest stops on the map (all vehicle types). Same DB-backed cache and Worker pre-cache as fuel stations; useful for BEV drivers who often find fast chargers at service areas. diff --git a/frontend/src/App.vue b/frontend/src/App.vue index a7401706..c9bdc6c8 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -28,6 +28,8 @@ import { useScreenWakeLock } from '@/composables/useScreenWakeLock' import { usePhoneGpsRecorder } from '@/composables/usePhoneGpsRecorder' import { useRelativeTime } from '@/composables/useRelativeTime' import { useEscapeKey } from '@/composables/useEscapeKey' +import { useDrawerSwipe, useEdgeSwipeOffered } from '@/composables/useDrawerSwipe' +import { useUiSettingsStore } from '@/stores/settingsUi' import { formatDateTime, formatTime } from '@/utils/format' import { mayPlugIn } from '@/utils/vehicleType' @@ -227,6 +229,21 @@ function closeMenuOnLink(event: MouseEvent) { if (event.target instanceof Element && event.target.closest('a')) closeMenu() } +// A swipe from the left edge opens the mobile menu and a swipe to the left closes it, where this +// device has asked for that (Settings > General > This device). The two pages that are a map from +// edge to edge pan it on any touch, so there the swipe does not open the menu; an open menu +// still closes by swipe wherever it is. +const uiSettings = useUiSettingsStore() +const edgeSwipeOffered = useEdgeSwipeOffered() +useDrawerSwipe({ + enabled: () => uiSettings.edgeSwipeMenu && edgeSwipeOffered.value && !isLoginRoute.value, + blocksOpening: () => route.name === 'map' || route.name === 'tripEdit', + isOpen: () => menuOpen.value, + open: () => (menuOpen.value = true), + close: closeMenu, + closeFrom: '.sidebar, .sidebar-backdrop', +}) + // Escape closes the mobile menu and puts focus back on the button that opened it. const hamburger = ref(null) useEscapeKey( diff --git a/frontend/src/__tests__/App.spec.ts b/frontend/src/__tests__/App.spec.ts index 5131c2fc..d4929650 100644 --- a/frontend/src/__tests__/App.spec.ts +++ b/frontend/src/__tests__/App.spec.ts @@ -9,6 +9,11 @@ import { setBrowserOnline } from '@/composables/__tests__/connectionStub' const session = vi.hoisted(() => ({ authenticated: false })) +// Only what the app reads of this device's settings: whether swiping the menu is switched on. +const ui = vi.hoisted(() => ({ edgeSwipeMenu: false })) + +vi.mock('@/stores/settingsUi', () => ({ useUiSettingsStore: () => ui })) + vi.mock('@/stores/auth', () => ({ useAuthStore: () => ({ isAuthenticated: session.authenticated, @@ -174,6 +179,118 @@ describe('App mobile menu', () => { }) }) +describe('App menu swipe', () => { + // Phone-sized, with a touchscreen: what the swipe is offered on. + function onATouchPhone() { + vi.stubGlobal('matchMedia', (query: string) => ({ + matches: query === '(width <= 767px)' || query === '(any-pointer: coarse)', + media: query, + addEventListener: () => {}, + removeEventListener: () => {}, + })) + } + + async function mountClosed(path = '/') { + const router = createRouter({ + history: createMemoryHistory(), + routes: [ + { path: '/', component: Page }, + { path: '/map', name: 'map', component: Page }, + { path: '/login', name: 'login', component: Page }, + ], + }) + await router.push(path) + return mount(App, { + attachTo: document.body, + global: { + plugins: [i18n, router], + stubs: { + FontAwesomeIcon: true, + AppFooter: true, + NotificationPanel: true, + DemoBanner: true, + PwaInstallModal: true, + }, + }, + }) + } + + function swipe(target: Element, x: number, dx: number) { + const init = { bubbles: true, isPrimary: true, pointerType: 'touch', pointerId: 1 } + target.dispatchEvent(new PointerEvent('pointerdown', { ...init, clientX: x, clientY: 300 })) + target.dispatchEvent( + new PointerEvent('pointermove', { ...init, clientX: x + dx, clientY: 300 }), + ) + } + + afterEach(() => { + vi.unstubAllGlobals() + ui.edgeSwipeMenu = false + document.body.innerHTML = '' + }) + + it('opens the menu for a swipe from the left edge, and closes it for one back', async () => { + onATouchPhone() + ui.edgeSwipeMenu = true + const wrapper = await mountClosed() + expect(wrapper.find('.sidebar--open').exists()).toBe(false) + + swipe(wrapper.get('.app-body').element, 40, 100) + await flushPromises() + expect(wrapper.find('.sidebar--open').exists()).toBe(true) + expect(wrapper.get('.hamburger').attributes('aria-expanded')).toBe('true') + + swipe(wrapper.get('.sidebar').element, 200, -100) + await flushPromises() + expect(wrapper.find('.sidebar--open').exists()).toBe(false) + }) + + it('leaves the menu shut while this device has not asked for the swipe', async () => { + onATouchPhone() + const wrapper = await mountClosed() + + swipe(wrapper.get('.app-body').element, 40, 100) + await flushPromises() + + expect(wrapper.find('.sidebar--open').exists()).toBe(false) + }) + + it('leaves the menu shut on a screen without a touchscreen, whatever the setting says', async () => { + ui.edgeSwipeMenu = true + const wrapper = await mountClosed() + + swipe(wrapper.get('.app-body').element, 40, 100) + await flushPromises() + + expect(wrapper.find('.sidebar--open').exists()).toBe(false) + }) + + // The map pans on any touch, so on its page the swipe does not open the menu. + it('does not open the menu on the map page', async () => { + onATouchPhone() + ui.edgeSwipeMenu = true + const wrapper = await mountClosed('/map') + + swipe(wrapper.get('.app-body').element, 40, 100) + await flushPromises() + + expect(wrapper.find('.sidebar--open').exists()).toBe(false) + }) + + it('still closes a menu opened by its button on the map page', async () => { + onATouchPhone() + ui.edgeSwipeMenu = true + const wrapper = await mountClosed('/map') + await wrapper.get('.hamburger').trigger('click') + expect(wrapper.find('.sidebar--open').exists()).toBe(true) + + swipe(wrapper.get('.sidebar').element, 200, -100) + await flushPromises() + + expect(wrapper.find('.sidebar--open').exists()).toBe(false) + }) +}) + describe('App top bar', () => { // On a phone the page's own buttons and then Settings land in the slots; with the bell they form // one evenly spaced group, the slots coming first so the bell stays at the far end. diff --git a/frontend/src/components/settings/DeviceSettings.vue b/frontend/src/components/settings/DeviceSettings.vue index de61c6ab..04979a3e 100644 --- a/frontend/src/components/settings/DeviceSettings.vue +++ b/frontend/src/components/settings/DeviceSettings.vue @@ -3,6 +3,7 @@ import { useI18n } from 'vue-i18n' import { useUiSettingsStore } from '@/stores/settingsUi' import { useKeepScreenOnOffered } from '@/composables/useScreenWakeLock' import { usePhoneGpsOffered, usePhoneGpsStatus } from '@/composables/usePhoneGpsRecorder' +import { useEdgeSwipeOffered } from '@/composables/useDrawerSwipe' import SettingsToggle from '../SettingsToggle.vue' import SettingsSection from './SettingsSection.vue' @@ -10,22 +11,25 @@ const { t } = useI18n() const settings = useUiSettingsStore() const screenOffered = useKeepScreenOnOffered() const gpsOffered = usePhoneGpsOffered() +const edgeSwipeOffered = useEdgeSwipeOffered() const { denied, recording } = usePhoneGpsStatus() + diff --git a/frontend/src/components/settings/__tests__/SettingsModal.spec.ts b/frontend/src/components/settings/__tests__/SettingsModal.spec.ts index ed86ddf0..7fa6d4e6 100644 --- a/frontend/src/components/settings/__tests__/SettingsModal.spec.ts +++ b/frontend/src/components/settings/__tests__/SettingsModal.spec.ts @@ -425,6 +425,55 @@ describe('SettingsModal appearance', () => { expect(panel(wrapper, 'general').find('#footer-toggle-record-phone-gps').exists()).toBe(false) }) + // A phone-sized screen with a touchscreen, in the browser or in the installed app. + function runOnPhone(installed: boolean, touch = true) { + vi.stubGlobal('matchMedia', (query: string) => ({ + matches: + query === '(width <= 767px)' || + (touch && query === '(any-pointer: coarse)') || + (installed && query === '(display-mode: standalone)'), + addEventListener: () => {}, + removeEventListener: () => {}, + })) + } + + it('offers swiping the menu on a phone in a browser tab, where the installed-app settings are not', async () => { + runOnPhone(false) + const { wrapper } = await render() + const general = panel(wrapper, 'general') + const toggle = general.get('#footer-toggle-edge-swipe-menu') + expect(general.text()).toContain(en.settings.edgeSwipeMenu.label) + expect(general.text()).toContain(en.settings.device.title) + expect(general.find('#footer-toggle-keep-screen-on').exists()).toBe(false) + + expect((toggle.element as HTMLInputElement).checked).toBe(false) + await toggle.setValue(true) + expect(useUiSettingsStore(pinia).edgeSwipeMenu).toBe(true) + }) + + it('offers it next to the installed app settings on a phone', async () => { + runOnPhone(true) + Object.defineProperty(navigator, 'wakeLock', { + configurable: true, + value: { request: vi.fn<() => Promise>() }, + }) + const { wrapper } = await render() + const general = panel(wrapper, 'general') + + expect(general.find('#footer-toggle-edge-swipe-menu').exists()).toBe(true) + expect(general.find('#footer-toggle-keep-screen-on').exists()).toBe(true) + }) + + // A narrow desktop window has no finger to swipe with, and nothing else for this device either. + it('is not offered without a touchscreen', async () => { + runOnPhone(false, false) + const { wrapper } = await render() + const general = panel(wrapper, 'general') + + expect(general.find('#footer-toggle-edge-swipe-menu').exists()).toBe(false) + expect(general.text()).not.toContain(en.settings.device.title) + }) + it('offers recording GPS only once the screen is kept on', async () => { runAs(true) const { wrapper } = await render() diff --git a/frontend/src/composables/__tests__/useDrawerSwipe.spec.ts b/frontend/src/composables/__tests__/useDrawerSwipe.spec.ts new file mode 100644 index 00000000..163a72c9 --- /dev/null +++ b/frontend/src/composables/__tests__/useDrawerSwipe.spec.ts @@ -0,0 +1,497 @@ +import { afterEach, describe, expect, it, vi } from 'vitest' +import { defineComponent, h } from 'vue' +import { enableAutoUnmount, mount } from '@vue/test-utils' +import { + EDGE_START_MAX_PX, + EDGE_START_MIN_PX, + SCROLL_INTENT_PX, + SWIPE_DISTANCE_PX, + SWIPE_DIRECTION_RATIO, + useDrawerSwipe, + useEdgeSwipeOffered, +} from '../useDrawerSwipe' + +enableAutoUnmount(afterEach) + +// Where most swipes here start: inside the band, clear of the edge the phone keeps for itself. +const X0 = EDGE_START_MIN_PX + 10 + +const state = { enabled: true, blocksOpening: false, open: false } + +// A page with the drawer and its backdrop in it, the swipe's calls counted. The drawer is open +// when `state.open` says so, and a call to open or close flips it, as the real menu does. +function page() { + const open = vi.fn<() => void>(() => (state.open = true)) + const close = vi.fn<() => void>(() => (state.open = false)) + const wrapper = mount( + defineComponent({ + setup() { + useDrawerSwipe({ + enabled: () => state.enabled, + blocksOpening: () => state.blocksOpening, + isOpen: () => state.open, + open, + close, + closeFrom: '.sidebar, .sidebar-backdrop', + }) + return () => + h('div', [ + h('nav', { class: 'sidebar' }, [h('a', { class: 'link' })]), + h('div', { class: 'sidebar-backdrop' }), + h('main', { class: 'content' }), + ]) + }, + }), + { attachTo: document.body }, + ) + return { + wrapper, + open, + close, + content: wrapper.get('.content').element, + sidebar: wrapper.get('.sidebar').element, + link: wrapper.get('.link').element, + backdrop: wrapper.get('.sidebar-backdrop').element, + } +} + +/** A touch event's own report of the finger (jsdom has no Touch to build one from). */ +function touch(type: string, target: Element, fingers: { clientX: number; clientY: number }[]) { + const event = new Event(type, { bubbles: true, cancelable: true }) + Object.defineProperty(event, 'touches', { value: fingers }) + target.dispatchEvent(event) +} + +function pointer(type: string, target: Element, init: PointerEventInit = {}) { + target.dispatchEvent( + new PointerEvent(type, { + bubbles: true, + cancelable: true, + isPrimary: true, + pointerType: 'touch', + pointerId: 1, + ...init, + }), + ) +} + +/** A finger down at (x, y) that moves to (x + dx, y + dy) in a few steps. */ +function drag( + target: Element, + x: number, + y: number, + dx: number, + dy = 0, + init: PointerEventInit = {}, +) { + pointer('pointerdown', target, { clientX: x, clientY: y, ...init }) + for (const step of [0.25, 0.5, 0.75, 1]) + pointer('pointermove', target, { clientX: x + dx * step, clientY: y + dy * step, ...init }) +} + +afterEach(() => { + state.enabled = true + state.blocksOpening = false + state.open = false + document.body.innerHTML = '' +}) + +describe('useDrawerSwipe opening', () => { + it('opens the menu for a swipe that starts at the left edge and goes right', () => { + const { open, content } = page() + + drag(content, X0, 300, SWIPE_DISTANCE_PX) + + expect(open).toHaveBeenCalledOnce() + }) + + // The band is wide enough to hit with a thumb, and both of its ends count. + it.each([EDGE_START_MIN_PX, (EDGE_START_MIN_PX + EDGE_START_MAX_PX) / 2, EDGE_START_MAX_PX])( + 'opens the menu for a swipe that starts %s px in from the edge', + (x) => { + const { open, content } = page() + + drag(content, x, 300, SWIPE_DISTANCE_PX) + + expect(open).toHaveBeenCalledOnce() + }, + ) + + // The phone's own back gesture takes the very edge, so the swipe never starts there: the two are + // not mixed up, whichever the finger meant. + it.each([0, 5, EDGE_START_MIN_PX - 1])( + 'leaves a swipe that starts %s px from the edge to the phone', + (x) => { + const { open, content } = page() + + drag(content, x, 300, SWIPE_DISTANCE_PX * 2) + + expect(open).not.toHaveBeenCalled() + }, + ) + + it.each([EDGE_START_MAX_PX + 1, 200])( + 'leaves a swipe that starts as far in as %s px to the page', + (x) => { + const { open, content } = page() + + drag(content, x, 300, SWIPE_DISTANCE_PX * 2) + + expect(open).not.toHaveBeenCalled() + }, + ) + + it('leaves a map, a chart or anything else that pans under the finger alone', () => { + const { open, content } = page() + for (const own of ['canvas', 'div.maplibregl-map', 'div.leaflet-container']) { + const [tag, ...classes] = own.split('.') + const element = document.createElement(tag!) + element.classList.add(...classes) + content.append(element) + + drag(element, X0, 300, SWIPE_DISTANCE_PX * 2) + } + + expect(open).not.toHaveBeenCalled() + }) + + // A row of chips or a wide table scrolls sideways under the same finger, and gets it. + it('leaves a row that scrolls sideways alone, and opens over one that does not', () => { + const { open, content } = page() + const row = document.createElement('div') + row.style.overflowX = 'auto' + content.append(row) + + Object.defineProperty(row, 'scrollWidth', { value: 600, configurable: true }) + Object.defineProperty(row, 'clientWidth', { value: 300, configurable: true }) + drag(row, X0, 300, SWIPE_DISTANCE_PX * 2) + expect(open).not.toHaveBeenCalled() + + // The same row with nothing to scroll is just part of the page. + Object.defineProperty(row, 'scrollWidth', { value: 300, configurable: true }) + drag(row, X0, 300, SWIPE_DISTANCE_PX * 2) + expect(open).toHaveBeenCalledOnce() + }) + + it('opens over a row that overflows but does not scroll', () => { + const { open, content } = page() + const row = document.createElement('div') + row.style.overflowX = 'hidden' + Object.defineProperty(row, 'scrollWidth', { value: 600, configurable: true }) + Object.defineProperty(row, 'clientWidth', { value: 300, configurable: true }) + content.append(row) + + drag(row, X0, 300, SWIPE_DISTANCE_PX * 2) + + expect(open).toHaveBeenCalledOnce() + }) + + it('waits until the finger has gone far enough', () => { + const { open, content } = page() + + drag(content, X0, 300, SWIPE_DISTANCE_PX - 1) + + expect(open).not.toHaveBeenCalled() + }) + + it('does not open for a swipe to the left', () => { + const { open, content } = page() + + drag(content, X0, 300, -SWIPE_DISTANCE_PX * 2) + + expect(open).not.toHaveBeenCalled() + }) + + it('opens once, however far the finger goes on', () => { + const { open, content } = page() + + drag(content, X0, 300, SWIPE_DISTANCE_PX * 3) + pointer('pointermove', content, { clientX: 400, clientY: 300 }) + + expect(open).toHaveBeenCalledOnce() + }) + + it('takes a finger that moves up or down first for a scroll, whatever it does next', () => { + const { open, content } = page() + + pointer('pointerdown', content, { clientX: X0, clientY: 300 }) + pointer('pointermove', content, { clientX: X0 + 3, clientY: 300 + SCROLL_INTENT_PX + 1 }) + pointer('pointermove', content, { clientX: X0 + SWIPE_DISTANCE_PX * 2, clientY: 330 }) + + expect(open).not.toHaveBeenCalled() + }) + + it('does not take a slanting swipe for one', () => { + const { open, content } = page() + const dx = SWIPE_DISTANCE_PX + // Further sideways than up, but not by the margin a swipe needs. + drag(content, X0, 300, dx, dx / SWIPE_DIRECTION_RATIO + 1) + + expect(open).not.toHaveBeenCalled() + }) + + it('still opens for a swipe that wanders a little up or down', () => { + const { open, content } = page() + + drag(content, X0, 300, SWIPE_DISTANCE_PX * 2, SCROLL_INTENT_PX - 2) + + expect(open).toHaveBeenCalledOnce() + }) + + it('stops following a gesture the browser took over for good', () => { + const { open, content } = page() + + pointer('pointerdown', content, { clientX: X0, clientY: 300 }) + touch('touchcancel', content, []) + touch('touchmove', content, [{ clientX: X0 + SWIPE_DISTANCE_PX * 2, clientY: 300 }]) + + expect(open).not.toHaveBeenCalled() + }) + + // Chrome on Android cancels the pointer a few pixels into a sideways drag, to pan the page, and + // reports the rest of the drag as touch events only. + describe('where the browser cancels the pointer and only the touch goes on', () => { + it('opens the menu from the touch moves that follow', () => { + const { open, content } = page() + + pointer('pointerdown', content, { clientX: X0, clientY: 300 }) + pointer('pointermove', content, { clientX: X0 + 6, clientY: 300 }) + pointer('pointercancel', content, { clientX: X0 + 6, clientY: 300 }) + touch('touchmove', content, [{ clientX: X0 + 20, clientY: 300 }]) + expect(open).not.toHaveBeenCalled() + touch('touchmove', content, [{ clientX: X0 + SWIPE_DISTANCE_PX + 4, clientY: 300 }]) + + expect(open).toHaveBeenCalledOnce() + }) + + it('closes the menu the same way', () => { + state.open = true + const { close, sidebar } = page() + + pointer('pointerdown', sidebar, { clientX: 200, clientY: 300 }) + pointer('pointercancel', sidebar, { clientX: 200, clientY: 300 }) + touch('touchmove', sidebar, [{ clientX: 200 - SWIPE_DISTANCE_PX - 4, clientY: 300 }]) + + expect(close).toHaveBeenCalledOnce() + }) + + it('still takes a finger that goes up or down for a scroll', () => { + const { open, content } = page() + + pointer('pointerdown', content, { clientX: X0, clientY: 300 }) + pointer('pointercancel', content, { clientX: X0, clientY: 300 }) + touch('touchmove', content, [{ clientX: X0 + 3, clientY: 300 + SCROLL_INTENT_PX + 1 }]) + touch('touchmove', content, [{ clientX: X0 + SWIPE_DISTANCE_PX * 2, clientY: 330 }]) + + expect(open).not.toHaveBeenCalled() + }) + + it('gives up when a second finger lands', () => { + const { open, content } = page() + + pointer('pointerdown', content, { clientX: X0, clientY: 300 }) + touch('touchmove', content, [ + { clientX: X0 + SWIPE_DISTANCE_PX * 2, clientY: 300 }, + { clientX: 200, clientY: 300 }, + ]) + touch('touchmove', content, [{ clientX: X0 + SWIPE_DISTANCE_PX * 2, clientY: 300 }]) + + expect(open).not.toHaveBeenCalled() + }) + + it('does not start a swipe of its own: a touch that no pointerdown began is nothing', () => { + const { open, content } = page() + + touch('touchmove', content, [{ clientX: X0 + SWIPE_DISTANCE_PX * 2, clientY: 300 }]) + + expect(open).not.toHaveBeenCalled() + }) + }) + + it('forgets a finger that lifted before it went far enough', () => { + const { open, content } = page() + + drag(content, X0, 300, 10) + pointer('pointerup', content, { clientX: X0 + 10, clientY: 300 }) + pointer('pointermove', content, { clientX: X0 + SWIPE_DISTANCE_PX * 2, clientY: 300 }) + + expect(open).not.toHaveBeenCalled() + }) + + it('ignores a second finger, and follows only the one that landed first', () => { + const { open, content } = page() + + pointer('pointerdown', content, { clientX: X0, clientY: 300, pointerId: 1 }) + pointer('pointermove', content, { + clientX: X0 + SWIPE_DISTANCE_PX * 2, + clientY: 300, + pointerId: 2, + isPrimary: false, + }) + expect(open).not.toHaveBeenCalled() + + pointer('pointermove', content, { clientX: X0 + SWIPE_DISTANCE_PX, clientY: 300, pointerId: 1 }) + expect(open).toHaveBeenCalledOnce() + }) + + it.each(['mouse', 'pen'])('ignores a %s, which has no thumb to swipe with', (pointerType) => { + const { open, content } = page() + + drag(content, X0, 300, SWIPE_DISTANCE_PX * 2, 0, { pointerType }) + + expect(open).not.toHaveBeenCalled() + }) + + it('does nothing while swiping is off', () => { + state.enabled = false + const { open, close, content, sidebar } = page() + + drag(content, X0, 300, SWIPE_DISTANCE_PX * 2) + state.open = true + drag(sidebar, 200, 300, -SWIPE_DISTANCE_PX * 2) + + expect(open).not.toHaveBeenCalled() + expect(close).not.toHaveBeenCalled() + }) + + // A map pans on any touch, so on its page the edge swipe would fight it. + it('does not open on a page that blocks it', () => { + state.blocksOpening = true + const { open, content } = page() + + drag(content, X0, 300, SWIPE_DISTANCE_PX * 2) + + expect(open).not.toHaveBeenCalled() + }) + + it('does not open the menu under a dialog', () => { + const { open, content } = page() + const dialog = document.createElement('div') + dialog.setAttribute('role', 'dialog') + dialog.setAttribute('aria-modal', 'true') + document.body.append(dialog) + + drag(content, X0, 300, SWIPE_DISTANCE_PX * 2) + + expect(open).not.toHaveBeenCalled() + }) + + it('stops listening once the app is gone', () => { + const { open, wrapper } = page() + wrapper.unmount() + + drag(document.body, X0, 300, SWIPE_DISTANCE_PX * 2) + + expect(open).not.toHaveBeenCalled() + }) +}) + +describe('useDrawerSwipe closing', () => { + it('closes the open menu for a swipe to the left that starts on it', () => { + state.open = true + const { close, link } = page() + + drag(link, 200, 300, -SWIPE_DISTANCE_PX) + + expect(close).toHaveBeenCalledOnce() + }) + + it('closes it for a swipe that starts on the backdrop', () => { + state.open = true + const { close, backdrop } = page() + + drag(backdrop, 300, 300, -SWIPE_DISTANCE_PX) + + expect(close).toHaveBeenCalledOnce() + }) + + it('does not close it for a swipe that starts on the page behind', () => { + state.open = true + const { close, content } = page() + + drag(content, 300, 300, -SWIPE_DISTANCE_PX * 2) + + expect(close).not.toHaveBeenCalled() + }) + + it('does not close it for a swipe to the right', () => { + state.open = true + const { close, sidebar } = page() + + drag(sidebar, 50, 300, SWIPE_DISTANCE_PX * 2) + + expect(close).not.toHaveBeenCalled() + }) + + it('leaves a scroll of the open menu alone', () => { + state.open = true + const { close, sidebar } = page() + + pointer('pointerdown', sidebar, { clientX: 200, clientY: 300 }) + pointer('pointermove', sidebar, { clientX: 198, clientY: 300 + SCROLL_INTENT_PX + 1 }) + pointer('pointermove', sidebar, { clientX: 200 - SWIPE_DISTANCE_PX * 2, clientY: 330 }) + + expect(close).not.toHaveBeenCalled() + }) + + it('closes an open menu on a page that blocks opening it', () => { + state.open = true + state.blocksOpening = true + const { close, sidebar } = page() + + drag(sidebar, 200, 300, -SWIPE_DISTANCE_PX) + + expect(close).toHaveBeenCalledOnce() + }) + + it('starts from the edge no more once the menu is open, and a swipe there closes nothing', () => { + state.open = true + const { open, close, content } = page() + + drag(content, X0, 300, SWIPE_DISTANCE_PX * 2) + + expect(open).not.toHaveBeenCalled() + expect(close).not.toHaveBeenCalled() + }) +}) + +describe('useEdgeSwipeOffered', () => { + afterEach(() => vi.unstubAllGlobals()) + + function screen(matching: string[]) { + vi.stubGlobal('matchMedia', (query: string) => ({ + matches: matching.includes(query), + addEventListener: () => {}, + removeEventListener: () => {}, + })) + let offered = false + mount( + defineComponent({ + setup() { + const result = useEdgeSwipeOffered() + offered = result.value + return () => null + }, + }), + ) + return offered + } + + it('is offered on a phone-sized screen with a touchscreen', () => { + expect(screen(['(width <= 767px)', '(any-pointer: coarse)'])).toBe(true) + }) + + // A narrow desktop window has no finger to swipe with. + it('is not offered on a narrow screen without a touchscreen', () => { + expect(screen(['(width <= 767px)'])).toBe(false) + }) + + // A tablet or a touch laptop has the sidebar beside the page, not a drawer. + it('is not offered on a wide screen with a touchscreen', () => { + expect(screen(['(any-pointer: coarse)'])).toBe(false) + }) + + it('is not offered where matchMedia is missing', () => { + expect(screen([])).toBe(false) + }) +}) diff --git a/frontend/src/composables/useDrawerSwipe.ts b/frontend/src/composables/useDrawerSwipe.ts new file mode 100644 index 00000000..edfcbb57 --- /dev/null +++ b/frontend/src/composables/useDrawerSwipe.ts @@ -0,0 +1,169 @@ +import { computed, onMounted, onUnmounted, type ComputedRef } from 'vue' +import { PHONE_MEDIA_QUERY } from '@/utils/viewport' +import { useMediaQuery } from './useMediaQuery' + +/** A finger on the screen: the phone and tablet pointer, not a laptop's trackpad or a mouse. */ +const TOUCH_QUERY = '(any-pointer: coarse)' + +/** + * The nearest to the left edge a finger can land and still start the swipe. A phone's own back + * gesture takes the very edge, and the page cannot stop it, so the swipe starts clear of it: + * landing nearer than this is left to the system, and never both at once. + */ +export const EDGE_START_MIN_PX = 30 + +/** + * The farthest from the left edge a finger can land and still start the swipe. The band from the + * minimum to here is wide enough to hit with a thumb, without taking over the page. + */ +export const EDGE_START_MAX_PX = 84 + +/** + * What a finger that lands here is already using for a sideways movement of its own, so the swipe + * leaves it be: a map or a chart pans, and a row of chips scrolls (see {@link scrollsSideways}). + */ +const OWN_GESTURE_SELECTOR = 'canvas, .maplibregl-map, .leaflet-container' + +/** Whether `element`, or something around it, scrolls sideways under a finger. */ +function scrollsSideways(element: Element): boolean { + for ( + let el: Element | null = element; + el && el !== document.documentElement; + el = el.parentElement + ) { + if (el.scrollWidth <= el.clientWidth + 1) continue + const { overflowX } = getComputedStyle(el) + if (overflowX === 'auto' || overflowX === 'scroll') return true + } + return false +} + +/** How far the finger travels sideways for a swipe to count. */ +export const SWIPE_DISTANCE_PX = 56 + +/** The sideways travel is at least this many times the vertical one, or it is a scroll. */ +export const SWIPE_DIRECTION_RATIO = 1.5 + +/** Vertical travel past which the gesture is a scroll, whatever the finger does next. */ +export const SCROLL_INTENT_PX = 12 + +/** Every dialog and panel marks itself like this; none is swiped over. */ +const MODAL_SELECTOR = '[aria-modal="true"]' + +/** + * Whether swiping the menu open and shut is offered here: on a phone-sized screen with a + * touchscreen. A narrow desktop window has no finger to swipe with, and a tablet has a sidebar. + */ +export function useEdgeSwipeOffered(): ComputedRef { + const narrow = useMediaQuery(PHONE_MEDIA_QUERY) + const touch = useMediaQuery(TOUCH_QUERY) + return computed(() => narrow.value && touch.value) +} + +export interface DrawerSwipeOptions { + /** Whether swiping is on at all: the setting, and a screen that offers it. */ + enabled: () => boolean + /** Whether the page has a swipe of its own at the edge (a map pans on any touch). */ + blocksOpening: () => boolean + isOpen: () => boolean + open: () => void + close: () => void + /** What the open menu is made of, so a swipe that starts on it, or on its backdrop, closes it. */ + closeFrom: string +} + +type Direction = 'open' | 'close' + +/** + * Opens the mobile menu with a swipe that starts a little in from the left edge of the screen + * (EDGE_START_MIN_PX to EDGE_START_MAX_PX) and moves right, and closes it with a swipe to the left + * that starts on the menu or its backdrop. Listens on the window, so nothing sits over the page to + * catch taps meant for it, and mounted once, in App.vue. + * + * A swipe is a decision, not a drag: once the finger has gone far enough sideways, and not mostly + * up or down, the menu slides as it does for its button. Scrolling is left alone: a finger that + * moves up or down first is a scroll, and the browser taking the touch over (touchcancel) ends it. + * So is whatever already moves sideways under the finger, a map, a chart or a row that scrolls. + * + * The phone's own back gesture takes the very edge and the page cannot stop it, so the swipe + * starts clear of the edge rather than at it: the two never start from the same touch. + */ +export function useDrawerSwipe(options: DrawerSwipeOptions): void { + let swipe: { id: number; x: number; y: number; direction: Direction } | null = null + + function onPointerdown(event: PointerEvent) { + swipe = null + if (event.pointerType !== 'touch' || !event.isPrimary || !options.enabled()) return + + if (!options.isOpen()) { + if (event.clientX < EDGE_START_MIN_PX || event.clientX > EDGE_START_MAX_PX) return + if (options.blocksOpening() || document.querySelector(MODAL_SELECTOR)) return + const target = event.target + if ( + target instanceof Element && + (target.closest(OWN_GESTURE_SELECTOR) || scrollsSideways(target)) + ) + return + swipe = { id: event.pointerId, x: event.clientX, y: event.clientY, direction: 'open' } + } else if (event.target instanceof Element && event.target.closest(options.closeFrom)) { + swipe = { id: event.pointerId, x: event.clientX, y: event.clientY, direction: 'close' } + } + } + + /** Where the finger is now: the swipe's decision, whichever event reported it. */ + function follow(x: number, y: number) { + if (!swipe) return + const dx = x - swipe.x + const dy = y - swipe.y + + if (Math.abs(dy) > SCROLL_INTENT_PX && Math.abs(dy) > Math.abs(dx)) { + swipe = null + return + } + + const travelled = swipe.direction === 'open' ? dx : -dx + if (travelled < SWIPE_DISTANCE_PX || travelled <= SWIPE_DIRECTION_RATIO * Math.abs(dy)) return + + const { direction } = swipe + swipe = null + if (direction === 'open') options.open() + else options.close() + } + + function onPointermove(event: PointerEvent) { + if (swipe && event.pointerId === swipe.id) follow(event.clientX, event.clientY) + } + + // Some browsers (Chrome on Android) take a sideways drag for a pan of their own after a few + // pixels and cancel the pointer, which stops its pointermoves, but the touch events go on. So the + // touch follows the same swipe, and a cancelled pointer does not end it: a finger that goes + // vertical is a scroll by its own travel (see follow), and lifting it ends the gesture. + function onTouchmove(event: TouchEvent) { + const touch = event.touches[0] + if (event.touches.length > 1) swipe = null + else if (touch) follow(touch.clientX, touch.clientY) + } + + function onEnd() { + swipe = null + } + + // Capturing, so a page that stops the event on its way down (a map) is still heard to start. + const passive = { passive: true, capture: true } as const + onMounted(() => { + window.addEventListener('pointerdown', onPointerdown, passive) + window.addEventListener('pointermove', onPointermove, passive) + window.addEventListener('pointerup', onEnd, passive) + window.addEventListener('touchmove', onTouchmove, passive) + window.addEventListener('touchend', onEnd, passive) + window.addEventListener('touchcancel', onEnd, passive) + }) + onUnmounted(() => { + window.removeEventListener('pointerdown', onPointerdown, passive) + window.removeEventListener('pointermove', onPointermove, passive) + window.removeEventListener('pointerup', onEnd, passive) + window.removeEventListener('touchmove', onTouchmove, passive) + window.removeEventListener('touchend', onEnd, passive) + window.removeEventListener('touchcancel', onEnd, passive) + }) +} diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 63da8496..45c7ecd6 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -668,6 +668,10 @@ "label": "Keep the screen on", "desc": "Stops the screen from dimming or locking while the app is open, for a phone in a holder or a tablet on the wall. Uses more battery." }, + "edgeSwipeMenu": { + "label": "Swipe from the edge for the menu", + "desc": "Drag from the left of the screen, a little in from the very edge, to open the menu, and drag it back to close it. It starts clear of the edge itself, which a phone's own back gesture takes, so the two are never mixed up. Not on the map pages, where a swipe moves the map." + }, "dashboard": { "cardInfoIcons": "Show info icons", "cardInfoIconsDesc": "Adds a button beside each page's title, and to each dashboard and statistics card, that explains what it shows.", diff --git a/frontend/src/locales/es.json b/frontend/src/locales/es.json index a14e8a3f..83d1010f 100644 --- a/frontend/src/locales/es.json +++ b/frontend/src/locales/es.json @@ -668,6 +668,10 @@ "label": "Mantener la pantalla encendida", "desc": "Evita que la pantalla se atenúe o se bloquee mientras la aplicación está abierta, para un teléfono en un soporte o una tableta en la pared. Gasta más batería." }, + "edgeSwipeMenu": { + "label": "Deslizar desde el borde para el menú", + "desc": "Arrastrar desde la izquierda de la pantalla, un poco separado del borde mismo, abre el menú, y arrastrarlo de vuelta lo cierra. Empieza lejos del borde, que usa el gesto de volver del propio teléfono, para que los dos nunca se confundan. No en las páginas del mapa, donde deslizar mueve el mapa." + }, "dashboard": { "cardInfoIcons": "Mostrar iconos de información", "cardInfoIconsDesc": "Añade junto al título de cada página, y a cada tarjeta del panel y de las estadísticas, un botón que explica lo que muestra.", diff --git a/frontend/src/locales/nl.json b/frontend/src/locales/nl.json index bb54f4d7..6237eec2 100644 --- a/frontend/src/locales/nl.json +++ b/frontend/src/locales/nl.json @@ -668,6 +668,10 @@ "label": "Scherm aan houden", "desc": "Voorkomt dat het scherm dimt of vergrendelt zolang de app open is, voor een telefoon in een houder of een tablet aan de muur. Kost meer batterij." }, + "edgeSwipeMenu": { + "label": "Vanaf de rand vegen voor het menu", + "desc": "Sleep vanaf de linkerkant van het scherm, een stukje van de uiterste rand af, om het menu te openen en sleep het terug om het te sluiten. Het begint vrij van de rand zelf, die het terug-gebaar van een telefoon gebruikt, zodat de twee nooit door elkaar lopen. Niet op de kaartpagina's, waar een veegbeweging de kaart verschuift." + }, "dashboard": { "cardInfoIcons": "Info-iconen tonen", "cardInfoIconsDesc": "Voegt naast de titel van elke pagina, en aan elke kaart op het dashboard en bij de statistieken, een knop toe die uitlegt wat die toont.", diff --git a/frontend/src/locales/pt-PT.json b/frontend/src/locales/pt-PT.json index 6c373372..48785585 100644 --- a/frontend/src/locales/pt-PT.json +++ b/frontend/src/locales/pt-PT.json @@ -668,6 +668,10 @@ "label": "Manter o ecrã ligado", "desc": "Impede que o ecrã escureça ou bloqueie enquanto a aplicação estiver aberta, para um telemóvel num suporte ou um tablet na parede. Gasta mais bateria." }, + "edgeSwipeMenu": { + "label": "Deslizar a partir da margem para abrir o menu", + "desc": "Arraste a partir da esquerda do ecrã, um pouco afastado da margem extrema, para abrir o menu e arraste-o de volta para o fechar. O início fica longe da margem, que o gesto de voltar do telemóvel usa, para os dois nunca se confundirem. Não vale nas páginas do mapa, onde deslizar move o mapa." + }, "dashboard": { "cardInfoIcons": "Mostrar ícones de informação", "cardInfoIconsDesc": "Adiciona ao lado do título de cada página, e a cada cartão do painel e das estatísticas, um botão que explica o que mostra.", diff --git a/frontend/src/locales/pt.json b/frontend/src/locales/pt.json index 531e82dd..f25db028 100644 --- a/frontend/src/locales/pt.json +++ b/frontend/src/locales/pt.json @@ -668,6 +668,10 @@ "label": "Manter a tela ligada", "desc": "Impede que a tela escureça ou bloqueie enquanto o app estiver aberto, para um celular num suporte ou um tablet na parede. Gasta mais bateria." }, + "edgeSwipeMenu": { + "label": "Deslizar da borda para abrir o menu", + "desc": "Arraste da esquerda da tela, um pouco afastado da borda extrema, para abrir o menu e arraste de volta para fechá-lo. O início fica longe da borda, que o gesto de voltar do celular usa, para os dois nunca se confundirem. Não vale nas páginas do mapa, onde deslizar move o mapa." + }, "dashboard": { "cardInfoIcons": "Mostrar ícones de informação", "cardInfoIconsDesc": "Adiciona ao lado do título de cada página, e a cada cartão do painel e das estatísticas, um botão que explica o que ele mostra.", diff --git a/frontend/src/stores/__tests__/settingsStores.spec.ts b/frontend/src/stores/__tests__/settingsStores.spec.ts index 48392772..630b546b 100644 --- a/frontend/src/stores/__tests__/settingsStores.spec.ts +++ b/frontend/src/stores/__tests__/settingsStores.spec.ts @@ -504,6 +504,27 @@ describe('useUiSettingsStore', () => { expect(store.notificationTypeExclusions).toEqual(['charging-complete']) }) + it('leaves swiping the menu off until this device asks for it', () => { + expect(useUiSettingsStore().edgeSwipeMenu).toBe(false) + }) + + it('persists swiping the menu to its own localStorage key, and loads it again', async () => { + const store = useUiSettingsStore() + store.edgeSwipeMenu = true + await nextTick() + vi.advanceTimersByTime(SAVE_DEBOUNCE_MS) + expect(JSON.parse(localStorage.getItem(UI_KEY)!).edgeSwipeMenu).toBe(true) + + setActivePinia(createPinia()) + expect(useUiSettingsStore().edgeSwipeMenu).toBe(true) + }) + + // Anything but a plain true reads as off, so a hand-edited copy cannot switch it on by accident. + it.each(['true', 1, null, 'yes'])('reads %j as off', (stored) => { + localStorage.setItem(UI_KEY, JSON.stringify({ edgeSwipeMenu: stored })) + expect(useUiSettingsStore().edgeSwipeMenu).toBe(false) + }) + it('leaves the region, the clock and every unit on automatic until one is chosen', () => { localStorage.setItem(UI_KEY, JSON.stringify({ theme: 'light' })) const store = useUiSettingsStore() diff --git a/frontend/src/stores/__tests__/settingsSync.spec.ts b/frontend/src/stores/__tests__/settingsSync.spec.ts index 69a6217f..4265ec3e 100644 --- a/frontend/src/stores/__tests__/settingsSync.spec.ts +++ b/frontend/src/stores/__tests__/settingsSync.spec.ts @@ -136,6 +136,21 @@ describe('settings kept on the account', () => { expect(save).toHaveBeenCalledExactlyOnceWith('ui', { locale: 'nl' }) }) + it('keeps swiping the menu on this device, since it suits one phone and not every one', async () => { + localStorage.setItem(UI_KEY, JSON.stringify({ edgeSwipeMenu: true })) + load.mockResolvedValue({ ui: { theme: 'light', edgeSwipeMenu: false } }) + const ui = useUiSettingsStore() + await useSettingsSyncStore().start() + + expect(ui.edgeSwipeMenu).toBe(true) + + ui.edgeSwipeMenu = false + ui.locale = 'nl' + await settle() + + expect(save).toHaveBeenCalledExactlyOnceWith('ui', { locale: 'nl' }) + }) + it('keeps the screen and GPS settings on this device, since they suit one phone and not every one', async () => { localStorage.setItem(UI_KEY, JSON.stringify({ keepScreenOn: true, recordPhoneGps: true })) load.mockResolvedValue({ ui: { theme: 'light', keepScreenOn: false, recordPhoneGps: false } }) diff --git a/frontend/src/stores/settingsUi.ts b/frontend/src/stores/settingsUi.ts index 601b05c8..1e3b8faf 100644 --- a/frontend/src/stores/settingsUi.ts +++ b/frontend/src/stores/settingsUi.ts @@ -91,6 +91,8 @@ interface UiSettings { keepScreenOn: boolean /** Whether the installed app records the phone's GPS for the car's trips. This device only. */ recordPhoneGps: boolean + /** Whether a swipe from the left edge opens the phone menu, and a swipe back closes it. This device only. */ + edgeSwipeMenu: boolean carColorScheme: string /** The paints of the custom scheme, null until it is first chosen. */ carCustomColors: CarColors | null @@ -130,6 +132,7 @@ function defaultsFor(): UiSettings { colorfulMaps: false, keepScreenOn: false, recordPhoneGps: false, + edgeSwipeMenu: false, carColorScheme: DEFAULT_CAR_COLOR_SCHEME, carCustomColors: null, vehicleTypeOverride: 'auto', @@ -253,6 +256,7 @@ function parseUiFields(parsed: Record, fallback: UiSettings): U colorfulMaps: parsed.colorfulMaps === true, keepScreenOn: parsed.keepScreenOn === true, recordPhoneGps: parsed.recordPhoneGps === true, + edgeSwipeMenu: parsed.edgeSwipeMenu === true, ...carColor, vehicleTypeOverride: oneOf( parsed.vehicleTypeOverride, @@ -320,12 +324,15 @@ export const useUiSettingsStore = defineStore('settingsUi', () => { // (useNotificationPushSync), so it stays with the device: unticking everything on one // computer must not unsubscribe a phone, or subscribe it without a tap there. Keeping the // screen on suits a phone in a holder, not every computer the account signs in on, and only - // the phone that travels in the car should record GPS. + // the phone that travels in the car should record GPS. Swiping the menu open suits a phone and + // a thumb that likes it, and can clash with a phone's own back gesture, so it is each + // device's choice. localKeys: [ 'notificationTypeExclusions', 'notificationTypeInclusions', 'keepScreenOn', 'recordPhoneGps', + 'edgeSwipeMenu', ], })