mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 21:11:14 +00:00
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
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user