Added onboarding + a lightweight install banner to both the mobile login screen and the settings screen, with Android/Chromium
install prompt support and iOS “Share → Add to Home Screen” guidance. Also added a small helper + tests to decide when/which banner variant should show, and shared copy in common.json.
This commit is contained in:
25
resources/js/admin/mobile/lib/installPrompt.ts
Normal file
25
resources/js/admin/mobile/lib/installPrompt.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
export type InstallOutcome = 'accepted' | 'dismissed' | 'unknown';
|
||||
|
||||
export type BeforeInstallPromptEvent = Event & {
|
||||
prompt: () => Promise<void>;
|
||||
userChoice: Promise<{ outcome: InstallOutcome; platform: string }>;
|
||||
};
|
||||
|
||||
export function isIosDevice(userAgent: string): boolean {
|
||||
return /iphone|ipad|ipod/i.test(userAgent);
|
||||
}
|
||||
|
||||
export function resolveStandaloneDisplayMode(matchMediaStandalone: boolean, navigatorStandalone?: boolean): boolean {
|
||||
return matchMediaStandalone || navigatorStandalone === true;
|
||||
}
|
||||
|
||||
export function getStandaloneStatus(): boolean {
|
||||
if (typeof window === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const matchMediaStandalone = window.matchMedia?.('(display-mode: standalone)')?.matches ?? false;
|
||||
const navigatorStandalone = typeof navigator !== 'undefined' ? (navigator as Navigator & { standalone?: boolean }).standalone : undefined;
|
||||
|
||||
return resolveStandaloneDisplayMode(matchMediaStandalone, navigatorStandalone);
|
||||
}
|
||||
Reference in New Issue
Block a user