Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

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

Mauriceb16ac683cf9a
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<void> {
}
}
+/**
+ * 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<HTMLButtonElement>('.topbar .back');
+ if (back) back.click();
+ else void App.minimizeApp();
+ });
+ } catch {
+ /* web / unavailable: no system back gesture */
+ }
+}
+
async function start(): Promise<void> {
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 (
<div style={{ minHeight: '100vh', display: 'flex', fontFamily: 'var(--font-system)', position: 'relative' }}>
- {/* Language dropdown */}
- <div style={{ position: 'absolute', top: 16, insetInlineEnd: 16, zIndex: 10 }}>
+ {/* Language dropdown, below the status bar in the app and under a notch, not behind them */}
+ <div style={{ position: 'absolute', top: 'calc(env(safe-area-inset-top, 0px) + 16px)', insetInlineEnd: 16, zIndex: 10 }}>
<button type="button"
onClick={(e) => {
e.stopPropagation();