werkstaetten-app/src/routes/(app)/+layout.svelte
Friederich Loheide 856559f830 Native Apps für iOS und Android (Capacitor) mit Push über Firebase
Apps (mobile/):
- Capacitor-8-Hülle, lädt die Web-App von APP_URL – Inhalte ohne App-Update
- Android- und iOS-Projekt (Swift Package Manager) mit Firebase Messaging,
  nativer Sprachausgabe, Teilen, App, Statusleiste, Startbildschirm
- `npm run sync` überträgt APP_ID, Name, Adresse und Farbe aus mobile/.env
  in beide Projekte und richtet ein: App-Links (Android intent-filter,
  iOS Associated Domains), Push (Entitlements, Background Mode,
  AppDelegate, Benachrichtigungssymbol/-farbe), Offline-Seite;
  idempotent, prüft Eingaben, warnt bei fehlenden Firebase-Dateien
- `npm run assets` erzeugt Symbole und Startbildschirme aus Logo und
  Markenfarbe der Redaktion, dazu das Android-Benachrichtigungssymbol
- Schritt-für-Schritt-Anleitung für den Mac (mobile/README.md)

Server:
- Versand an App-Geräte über FCM HTTP v1 (signiertes JWT, ohne
  firebase-admin), eingebunden in alle Benachrichtigungen; abgemeldete
  Geräte werden entfernt (nur bei UNREGISTERED, nicht bei anderen Fehlern)
- Firebase-Dienstkonto in den Einstellungen hochladen (verschlüsselt),
  App-ID, Team-ID, SHA-256, Store-Links; /.well-known/apple-app-site-
  association und assetlinks.json; Smart-App-Banner, Store-Hinweis
- Server erkennt die App am User-Agent (kein Aufblitzen von
  „Als App installieren“); Datenschutz-Vorlage um Firebase ergänzt

Web-App in der App: Push über Firebase statt Web-Push, Vorlesen nativ,
Teilen nativ, Zurück-Taste (schließt erst Dialoge), Antippen einer
Benachrichtigung und App-Links öffnen die Seite (nur eigene Adressen).

Getestet mit nachgebauter Capacitor-Brücke und nachgebautem Firebase-Dienst.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-03 07:03:26 +00:00

146 lines
5.6 KiB
Svelte
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script lang="ts">
import { page } from '$app/state';
import { onMount } from 'svelte';
import House from '@lucide/svelte/icons/house';
import Newspaper from '@lucide/svelte/icons/newspaper';
import CalendarDays from '@lucide/svelte/icons/calendar-days';
import Bookmark from '@lucide/svelte/icons/bookmark';
import Menu from '@lucide/svelte/icons/menu';
import Search from '@lucide/svelte/icons/search';
import Volume2 from '@lucide/svelte/icons/volume-2';
import ReadAloudBar from '$lib/components/ReadAloudBar.svelte';
import { speech } from '$lib/speech.svelte';
import MenuSheet from '$lib/components/MenuSheet.svelte';
import { favorites } from '$lib/favorites.svelte';
import { goto } from '$app/navigation';
import { initNative } from '$lib/native';
let { data, children } = $props();
let menuOpen = $state(false);
onMount(() => {
favorites.load();
initNative((path) => goto(path));
});
const nav = [
{ href: '/', label: 'Start', icon: House },
{ href: '/meldungen', label: 'Aktuelles', icon: Newspaper },
{ href: '/termine', label: 'Termine', icon: CalendarDays },
{ href: '/merkliste', label: 'Merkliste', icon: Bookmark }
];
const isActive = (href: string) =>
href === '/' ? page.url.pathname === '/' : page.url.pathname.startsWith(href);
// Menü bei Navigation schließen
$effect(() => {
page.url.pathname;
menuOpen = false;
});
</script>
<a href="#inhalt" class="sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-50 btn btn-primary">
Zum Inhalt springen
</a>
<div class="min-h-dvh flex flex-col">
<header class="sticky top-0 z-30 safe-top bg-bg/95 backdrop-blur-md border-b border-line">
<div class="mx-auto max-w-6xl px-4 h-16 lg:h-20 flex items-center gap-2">
<a href="/" class="flex items-center gap-3 min-w-0 mr-auto" aria-label="{data.brand.appName} – Startseite">
{#if data.brand.logo}
<img src={data.brand.logo.thumb} alt="" class="h-10 lg:h-12 w-auto max-w-40 object-contain" />
{:else}
<span class="grid place-items-center size-10 rounded-full bg-brand text-on-brand font-bold text-lg">
{data.brand.appName.slice(0, 1)}
</span>
{/if}
<span class="min-w-0 leading-tight">
<span class="block font-bold text-[1.05rem] text-brand-ink truncate">{data.brand.appName}</span>
<span class="block text-xs text-ink-3 truncate">{data.brand.orgName}</span>
</span>
</a>
<nav class="hidden lg:flex items-center mr-4" aria-label="Hauptnavigation">
{#each nav as item, i (item.href)}
{#if i > 0}<span aria-hidden="true" class="size-1.5 rounded-full bg-accent mx-3"></span>{/if}
<a
href={item.href}
class="relative py-2 font-bold text-[0.95rem] {isActive(item.href) ? 'text-brand-ink' : 'text-ink-2 hover:text-brand-ink'}"
aria-current={isActive(item.href) ? 'page' : undefined}
>
{item.label}
{#if isActive(item.href)}<span class="absolute inset-x-0 -bottom-0.5 h-0.5 rounded-full bg-accent"></span>{/if}
</a>
{/each}
</nav>
{#if speech.supported}
<button
type="button"
class="btn btn-icon {speech.active ? 'btn-primary' : 'btn-ghost text-brand-ink'}"
aria-label={speech.active ? 'Vorlesen beenden' : 'Seite vorlesen'}
aria-pressed={speech.active}
onclick={() => (speech.active ? speech.stop() : speech.start('inhalt'))}
>
<Volume2 class="size-6" strokeWidth={2.25} />
</button>
{/if}
<a href="/suche" class="btn btn-ghost btn-icon text-brand-ink" aria-label="Suche">
<Search class="size-6" strokeWidth={2.25} />
</a>
<button class="btn btn-ghost btn-icon text-brand-ink" aria-label="Menü öffnen" aria-expanded={menuOpen} onclick={() => (menuOpen = true)}>
<Menu class="size-7" strokeWidth={2.25} />
</button>
</div>
</header>
<main id="inhalt" class="flex-1 w-full mx-auto max-w-6xl px-4 pt-6 pb-32 lg:pb-20">
{@render children()}
</main>
<footer class="hidden lg:block bg-brand text-on-brand/80 py-10 text-sm">
<div class="mx-auto max-w-6xl px-4 flex flex-wrap items-center gap-x-6 gap-y-2">
<span class="font-bold text-on-brand">© {new Date().getFullYear()} {data.brand.orgName}</span>
<a href="/kontakt" class="hover:text-on-brand">Kontakt</a>
<a href="/impressum" class="hover:text-on-brand">Impressum</a>
<a href="/datenschutz" class="hover:text-on-brand">Datenschutz</a>
<a href="/barrierefreiheit" class="hover:text-on-brand">Barrierefreiheit</a>
<a href="/barrierefreiheit?seite={encodeURIComponent(page.url.pathname)}#message" class="hover:text-on-brand">Barriere melden</a>
<a href="/admin" class="ml-auto hover:text-on-brand">Redaktion</a>
</div>
</footer>
</div>
<!-- Untere Navigationsleiste (Handy) -->
<nav
class="lg:hidden fixed bottom-0 inset-x-0 z-30 safe-bottom bg-surface/95 backdrop-blur-md border-t border-line"
aria-label="Hauptnavigation"
>
<div class="mx-auto max-w-lg grid grid-cols-5 px-1">
{#each nav as item (item.href)}
{@const active = isActive(item.href)}
<a
href={item.href}
class="flex flex-col items-center gap-1 pt-2.5 pb-2.5 text-[0.7rem] font-bold {active ? 'text-brand-ink' : 'text-ink-3'}"
aria-current={active ? 'page' : undefined}
>
<item.icon class="size-6" strokeWidth={active ? 2.4 : 2} />
{item.label}
<span aria-hidden="true" class="size-1.5 rounded-full {active ? 'bg-accent' : 'bg-transparent'}"></span>
</a>
{/each}
<button
class="flex flex-col items-center gap-1 pt-2.5 pb-2.5 text-[0.7rem] font-bold text-ink-3"
onclick={() => (menuOpen = true)}
>
<Menu class="size-6" />
Mehr
<span aria-hidden="true" class="size-1.5"></span>
</button>
</div>
</nav>
<ReadAloudBar />
<MenuSheet bind:open={menuOpen} pages={data.menuPages} website={data.website} />