mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-20 22:16:26 +00:00
c5765bbf15
The apps ship only an address screen now. Once a server is picked, the native side points the WebView at it: TrekBridgeViewController on iOS and a config copy with server.url on Android. The UI then comes from that server, in the version it runs and on its own origin, so the session cookie, uploads, /ws and plugins work exactly as in a browser and no app release has to keep pace with the servers out there. The address screen (native-shell/, built into native-dist/) probes /api/health/features through native HTTP, tries https before http when no scheme was typed, and refuses servers without the nativeApp flag. It also serves as the error page when the remembered server does not load: retry, change server, or on iOS the stored copy of the server's start page. TrekShell is the app's own plugin for all of that: remember, change and reload the server, sign in through ASWebAuthenticationSession or a Custom Tab, and on iOS keep and open the offline copy of the start page, because WKWebView runs no service worker for a domain the app does not list. Plugins the frame does not use are gone (push, camera, geolocation, calendar, file transfer, in-app browser and more): the WebView covers the camera and location itself, and push needs a relay before it is worth shipping. With them go the push entitlement, the calendar usage strings and the Firebase bits. The iOS scheme falls back to capacitor://, since Capacitor drops an iosScheme of https, and the arm64 capability replaces armv7.
53 lines
2.4 KiB
TypeScript
53 lines
2.4 KiB
TypeScript
/// <reference types="@capacitor/splash-screen" />
|
|
/// <reference types="@capacitor/keyboard" />
|
|
import type { CapacitorConfig } from '@capacitor/cli';
|
|
import { KeyboardResize } from '@capacitor/keyboard';
|
|
|
|
const config: CapacitorConfig = {
|
|
appId: 'com.liketrek.trek',
|
|
appName: 'TREK - Plan your trips!',
|
|
// The app ships only the address screen. Once a server is picked, the native
|
|
// side points the WebView at it (TrekBridgeViewController.swift,
|
|
// MainActivity.java) and the UI comes from that server, always in the version
|
|
// the server runs. Session cookie, uploads, /ws and plugins work as they do in
|
|
// a browser, because the WebView is on the server's own origin.
|
|
webDir: 'native-dist',
|
|
server: {
|
|
// Android serves the address screen from https://localhost so it is a
|
|
// secure context. iOS keeps its default capacitor:// scheme: WKWebView
|
|
// handles https itself and Capacitor silently drops an iosScheme of https.
|
|
androidScheme: 'https',
|
|
// Shown, from the app bundle, whenever the server fails to load. The page
|
|
// knows a server is remembered and offers to retry or pick another one;
|
|
// on iOS it first tries the stored offline copy of the server's start page.
|
|
errorPath: 'index.html',
|
|
},
|
|
plugins: {
|
|
SplashScreen: {
|
|
// Matches <meta name="theme-color"> in index.html, so the launch image,
|
|
// the splash and the first painted frame are the same colour and there is
|
|
// no white flash between them.
|
|
backgroundColor: '#09090b',
|
|
// The server's UI hides it once React has mounted (native/nativeApp.ts),
|
|
// the address screen once it has rendered. Auto-hide stays on as the
|
|
// ceiling, so a page that never gets there cannot leave it up for good.
|
|
launchAutoHide: true,
|
|
launchShowDuration: 4000,
|
|
launchFadeOutDuration: 200,
|
|
showSpinner: false,
|
|
androidScaleType: 'CENTER_CROP',
|
|
},
|
|
Keyboard: {
|
|
// The mobile shell is built from bottom sheets (mobile/screens/**/M*Sheet).
|
|
// `body` resizes the webview itself, so a sheet's own scroll container
|
|
// keeps working; `native` resizes the whole view and fights the sheet.
|
|
resize: KeyboardResize.Body,
|
|
// Android-only workaround: with an edge-to-edge status bar the webview
|
|
// otherwise does not resize at all when the keyboard opens.
|
|
resizeOnFullScreen: true,
|
|
},
|
|
},
|
|
};
|
|
|
|
export default config;
|