From b16ac683cf9af1627f1acb260099475fd1aff71b Mon Sep 17 00:00:00 2001 From: Maurice Date: Sun, 8 Nov 2026 16:51:28 +0100 Subject: [PATCH] fix(native): Android's back gesture steps back through the first screens, the login's language picker clears the status bar, and a slow trip open shows its splash sooner --- client/native-shell/main.ts | 18 ++++++++++++++++++ client/src/mobile/routeTransition.ts | 4 +++- .../mobile/screens/trip/MTripLoadingSplash.tsx | 8 ++++---- client/src/pages/LoginPage.tsx | 4 ++-- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/client/native-shell/main.ts b/client/native-shell/main.ts index 11fec72bd..3640602e3 100644 --- a/client/native-shell/main.ts +++ b/client/native-shell/main.ts @@ -1,3 +1,4 @@ +import { App } from '@capacitor/app'; import { Capacitor, CapacitorHttp } from '@capacitor/core'; import { Haptics, ImpactStyle, NotificationType } from '@capacitor/haptics'; import { SplashScreen } from '@capacitor/splash-screen'; @@ -1013,8 +1014,25 @@ async function paintStatusBar(): Promise { } } +/** + * Android's back gesture steps back through the first screens as their own + * back button does, and only leaves the app from a screen that has none. + */ +function followBackGesture(): void { + try { + void App.addListener('backButton', () => { + const back = current?.querySelector('.topbar .back'); + if (back) back.click(); + else void App.minimizeApp(); + }); + } catch { + /* web / unavailable: no system back gesture */ + } +} + async function start(): Promise { void paintStatusBar(); + followBackGesture(); let url: string | null; try { ({ url } = await TrekShell.getServer()); diff --git a/client/src/mobile/routeTransition.ts b/client/src/mobile/routeTransition.ts index 12a31732c..456f07759 100644 --- a/client/src/mobile/routeTransition.ts +++ b/client/src/mobile/routeTransition.ts @@ -18,7 +18,9 @@ import type { Location, NavigationType } from 'react-router'; */ export type RouteTransitionKind = 'forward' | 'back' | 'tab'; -const SETTLE_MS = 800; +// Short on purpose: while it waits the browser shows a frozen snapshot of the old +// page, so on a slow connection a longer wait reads as the app hanging. +const SETTLE_MS = 350; let skipNext = false; let current: ViewTransition | null = null; diff --git a/client/src/mobile/screens/trip/MTripLoadingSplash.tsx b/client/src/mobile/screens/trip/MTripLoadingSplash.tsx index ca0c4b286..9acb3f4c2 100644 --- a/client/src/mobile/screens/trip/MTripLoadingSplash.tsx +++ b/client/src/mobile/screens/trip/MTripLoadingSplash.tsx @@ -13,12 +13,12 @@ import { useTripSplashBeats } from '../../../components/shared/useTripSplashBeat */ /** * How long a trip may take to open before the splash comes up. The page - * transition holds the page the trip was opened from for up to 800ms + * transition holds the page the trip was opened from for up to 350ms * (mobile/routeTransition.ts), so a trip that loads in that time slides in - * whole, the way the dashboard slides back in on the way out, and the splash is - * only for a slow connection. + * whole, the way the dashboard slides back in on the way out. A slower one gets + * the splash right after, so a slow connection never sees the app stand still. */ -export const TRIP_SPLASH_AFTER_MS = 1000 +export const TRIP_SPLASH_AFTER_MS = 400 /** * While a trip opens. At first nothing but the screen's own background, marked diff --git a/client/src/pages/LoginPage.tsx b/client/src/pages/LoginPage.tsx index 5e0d8eae7..d9f59878c 100644 --- a/client/src/pages/LoginPage.tsx +++ b/client/src/pages/LoginPage.tsx @@ -228,8 +228,8 @@ export default function LoginPage(): React.ReactElement { return (
- {/* Language dropdown */} -
+ {/* Language dropdown, below the status bar in the app and under a notch, not behind them */} +