mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 07:30:04 +00:00
62bc7ff8fd
* Open a running trip on today Asked for in discussion #1567: during a trip, opening the planner starts at day 1 and you scroll to find out what is planned for today. The mobile shell has done this since the plan tab was built - it seeds the active day with today when the trip is running. The desktop day plan never did, so the same trip behaved differently depending on the screen you opened it on. It now selects today's day, expands it and scrolls it into view, once per mount and only while nothing is selected yet, so a deep link or a day picked before switching tabs still wins. The date comparison moved into one helper both sides use. It is deliberately local rather than toISOString(): 08:00 in Tokyo is still yesterday in UTC, and a trip day is a calendar day where the traveller is standing. Also fixes a note losing its colour when dragged to another day. A move is a delete plus a create, and the create was still sending the three fields notes had before colours existed. * Open a collection place in a map app Asked for in discussion #1455: a saved place is somewhere you intend to go, but the only way to get directions to one was to add it to a trip first, where the button has been for a while. The collection detail gets the same picker off the same helper: Google Maps, Waze, Apple Maps and OpenStreetMap, filtered by what the place can actually be located with. A place with coordinates offers all of them; a place typed in by hand with just a name and an address still offers the two that take a search string, and a place with neither shows no button at all. It sits on the meta line beside the address, quieter than the link chips below it, because it is an action on the place rather than a piece of it. * Drag a place off the map onto a day Asked for in discussion #891: assigning a place means finding it again in the sidebar, even though it is right there under the cursor on the map. The drop half already existed and did not need touching. Every day, every row and every gap between rows in the day plan reads a placeId and calls onAssignToDay with the position it was dropped at, complete with the toast and the undo entry. What was missing was a second place to pick a place UP from - the only one was the row in the places sidebar. Markers become that second source. Both renderers build their markers as real DOM nodes, so one helper covers Leaflet and the GL variants alike, and it sets the same two channels the sidebar row does: dataTransfer for the drop, and window.__dragData because browsers hide dataTransfer while the pointer is merely hovering. The day plan cannot tell the two apart. Not offered on touch: HTML5 drag is a pointer feature, and on a phone the day plan is not on screen next to the map anyway. * Show the landing time in the PDF Asked for in discussion #1310: the export prints a flight's departure and nothing else, so a reader cannot tell how much of the day is left for anything after it. The day plan has drawn both times as "14:30 - 16:45" for a while; the export never got the rule. Now it does, for any transport that begins and ends on the same day - a train and a ferry read the same way a flight does. Across a span it stays as it was: the arrival belongs to the arrival day, which already prints it as its own time, and repeating it on the departure day would put tomorrow's clock next to today's departure.
567 lines
25 KiB
TypeScript
567 lines
25 KiB
TypeScript
import { useEffect, useRef, useState, type ComponentType, type ReactNode } from 'react'
|
|
import { findTodayDayId } from '../../../components/Planner/today'
|
|
import {
|
|
ChevronLeft, FileDown, List, Map as MapIcon, MoreHorizontal, PackageCheck,
|
|
Plane, Plus, Rows3, Ticket, TrainFront, Trash2, Upload, Wallet,
|
|
} from 'lucide-react'
|
|
import type { LucideIcon } from 'lucide-react'
|
|
import { useTripPlanner } from '../../../pages/tripPlanner/useTripPlanner'
|
|
import MIconBtn from '../../components/MIconBtn'
|
|
import MPlanTimeline from './plan/MPlanTimeline'
|
|
import MMapArea from './map/MMapArea'
|
|
import MPlacesBrowser from './places/MPlacesBrowser'
|
|
import MTripTabPanel from './tabs/MTripTabPanel'
|
|
import MTripSheets from './sheets/MTripSheets'
|
|
import MTripLoadingSplash from './MTripLoadingSplash'
|
|
import { usePluginDayTints, dayTintBackground } from '../../../components/Plugins/PluginDaySchedule'
|
|
import type { Day } from '../../../types'
|
|
|
|
/**
|
|
* Mobile trip screen frame. Owns the chrome the design shares across every
|
|
* trip view — glass top controls (per-tab centre variants), the day-chip rail,
|
|
* the bottom dock — plus the view/mode machine on top of the planner state.
|
|
* All data and mutations come from useTripPlanner() (same hook the desktop
|
|
* page wires), so WebSocket sync, offline persistence, undo and the
|
|
* ?create=/sessionStorage contracts are inherited unchanged.
|
|
*
|
|
* The actual content areas (plan timeline, map, places browser, tab panels,
|
|
* sheets) are slots: typed component props whose defaults are the real screens
|
|
* under screens/trip/ (the non-plan tab panels route through tabs/MTripTabPanel).
|
|
*/
|
|
|
|
/** Everything useTripPlanner() returns — data, permissions, CRUD, modal state. */
|
|
export type TripPlanner = ReturnType<typeof useTripPlanner>
|
|
|
|
export type MTripView = 'plan' | 'map'
|
|
export type MTripMode = 'go' | 'edit' | 'browse'
|
|
export type MTripListsTab = 'packing' | 'todo'
|
|
export type MTripCollabTab = 'chat' | 'notes' | 'polls'
|
|
|
|
/**
|
|
* Currently open bottom/floating sheet. Well-known ids (owned by the sheets
|
|
* screen): 'day' (payload { dayId }), 'days', 'mehr', 'note' (payload
|
|
* { dayId, note? }), 'transport' (payload { reservationId }), 'bract'
|
|
* (payload { placeId, dayPicker? }), 'import', 'export', 'members',
|
|
* 'tripedit', 'bags', 'task'. The place inspector keys off the planner's
|
|
* place selection instead of a sheet id, and planner-backed editors (place
|
|
* form, transport, booking, expense) keep using the planner's own modal flags.
|
|
*/
|
|
export interface MTripSheetState {
|
|
id: string
|
|
payload?: unknown
|
|
}
|
|
|
|
/**
|
|
* Shell-owned UI state handed to every slot. Ownership split: the planner
|
|
* hook owns trip data + CRUD + editor-modal flags; the shell owns chrome
|
|
* state (view/mode machine, active tab, sheet routing, header sub-states).
|
|
*/
|
|
export interface MTripShellApi {
|
|
/** 'plan' = list chrome, 'map' = fullscreen map. Plan tab only. */
|
|
view: MTripView
|
|
/** Travel/Plan/Places segment: go | edit | browse. */
|
|
mode: MTripMode
|
|
/** Legacy tab ids: plan · transports · buchungen · listen · finanzplan · dateien · collab · plugin:* */
|
|
trTab: string
|
|
/** Switch trip tab (persists to sessionStorage['trip-tab-{id}'], resets browse → go). */
|
|
setTrTab: (tabId: string) => void
|
|
/** Set go/edit/browse — forces the plan tab and the plan view. */
|
|
setTravelMode: (mode: MTripMode) => void
|
|
/** Plan ⇄ map. Leaving to the map resets browse → go. */
|
|
toggleView: () => void
|
|
/** True while browse was entered from edit — the places browser seeds its 'unplanned' filter. */
|
|
browseFromEdit: boolean
|
|
sheet: MTripSheetState | null
|
|
openSheet: (id: string, payload?: unknown) => void
|
|
closeSheet: () => void
|
|
/** Lists header segment; persisted per trip like the desktop sub-tab. */
|
|
listsTab: MTripListsTab
|
|
setListsTab: (tab: MTripListsTab) => void
|
|
collabTab: MTripCollabTab
|
|
setCollabTab: (tab: MTripCollabTab) => void
|
|
/** Header compact toggles for the transports / bookings lists. */
|
|
transportsCompact: boolean
|
|
bookingsCompact: boolean
|
|
/** Header intent signals — increment-only counters, consumed by the tab panels. */
|
|
addExpenseSignal: number
|
|
exportCostsCsvSignal: number
|
|
uploadFilesSignal: number
|
|
openFilesTrashSignal: number
|
|
}
|
|
|
|
/**
|
|
* Day timeline for go/edit mode (plan tab, plan view). Renders the scrollable
|
|
* day content below the top controls + day chips and above the dock
|
|
* (clearance: top ~158px incl. safe-area, bottom var(--bottom-nav-h)).
|
|
* Reads the active day from planner.selectedDayId.
|
|
*/
|
|
export interface MPlanTimelineProps {
|
|
planner: TripPlanner
|
|
shell: MTripShellApi
|
|
}
|
|
|
|
/**
|
|
* Fullscreen map area (plan tab). Mounted for the whole plan-tab lifetime so
|
|
* the map stays warm under the timeline; visible when shell.view === 'map'.
|
|
* Marker/route data comes from planner (mapPlaces, dayPlaces, route, …).
|
|
*/
|
|
export interface MMapAreaProps {
|
|
planner: TripPlanner
|
|
shell: MTripShellApi
|
|
}
|
|
|
|
/**
|
|
* Places browser overlay (mode === 'browse'). Owns its own filter/search/
|
|
* selection state; seeds the 'unplanned' filter when shell.browseFromEdit.
|
|
*/
|
|
export interface MPlacesBrowserProps {
|
|
planner: TripPlanner
|
|
shell: MTripShellApi
|
|
}
|
|
|
|
/**
|
|
* Non-plan tab panel, rendered as a full overlay above map/chips. `tab` is the
|
|
* active legacy id (transports, buchungen, listen, finanzplan, dateien,
|
|
* collab, plugin:*). Consumes the shell header state for its tab (compact
|
|
* toggles, listsTab/collabTab, intent signals).
|
|
*/
|
|
export interface MTripTabPanelProps {
|
|
planner: TripPlanner
|
|
shell: MTripShellApi
|
|
tab: string
|
|
}
|
|
|
|
/**
|
|
* Sheet host — always mounted, renders whatever shell.sheet points at plus the
|
|
* planner-flag editors (place form, transport/booking/expense, imports,
|
|
* members, trip edit) as MSheet instances portaled to #m-sheet-root.
|
|
*/
|
|
export interface MTripSheetsProps {
|
|
planner: TripPlanner
|
|
shell: MTripShellApi
|
|
}
|
|
|
|
interface MTripShellProps {
|
|
PlanTimeline?: ComponentType<MPlanTimelineProps>
|
|
MapArea?: ComponentType<MMapAreaProps>
|
|
PlacesBrowser?: ComponentType<MPlacesBrowserProps>
|
|
TabPanel?: ComponentType<MTripTabPanelProps>
|
|
Sheets?: ComponentType<MTripSheetsProps>
|
|
}
|
|
|
|
/** The 5 dock tabs in demo order; files/collab/plugins live in the Mehr sheet. */
|
|
const DOCK_TABS: { id: string; icon: LucideIcon }[] = [
|
|
{ id: 'plan', icon: MapIcon },
|
|
{ id: 'transports', icon: TrainFront },
|
|
{ id: 'buchungen', icon: Ticket },
|
|
{ id: 'finanzplan', icon: Wallet },
|
|
{ id: 'listen', icon: PackageCheck },
|
|
]
|
|
|
|
function dayChipLabel(day: Day, language: string, fallback: string): string {
|
|
if (day.date) {
|
|
const date = new Date(`${day.date.slice(0, 10)}T00:00:00`)
|
|
if (!Number.isNaN(date.getTime())) {
|
|
return `${new Intl.DateTimeFormat(language, { weekday: 'short' }).format(date)} ${date.getDate()}`
|
|
}
|
|
}
|
|
return fallback
|
|
}
|
|
|
|
export default function MTripShell({
|
|
PlanTimeline = MPlanTimeline,
|
|
MapArea = MMapArea,
|
|
PlacesBrowser = MPlacesBrowser,
|
|
TabPanel = MTripTabPanel,
|
|
Sheets = MTripSheets,
|
|
}: MTripShellProps) {
|
|
const planner = useTripPlanner()
|
|
const { t, language, tripId, days, trip, navigate, packingItems, todoItems } = planner
|
|
|
|
// Per-day colours from the dayTintProvider plugin hook — the mobile counterpart
|
|
// of the desktop day-card wash, carried on the day chips. Empty without a plugin.
|
|
const dayTints = usePluginDayTints(tripId)
|
|
|
|
const [view, setView] = useState<MTripView>('plan')
|
|
const [mode, setMode] = useState<MTripMode>('go')
|
|
const [browseFromEdit, setBrowseFromEdit] = useState(false)
|
|
const [sheet, setSheet] = useState<MTripSheetState | null>(null)
|
|
const [listsTab, setListsTabState] = useState<MTripListsTab>(() => {
|
|
const saved = sessionStorage.getItem(`trip-lists-subtab-${tripId}`)
|
|
return saved === 'todo' ? 'todo' : 'packing'
|
|
})
|
|
const [collabTab, setCollabTab] = useState<MTripCollabTab>('chat')
|
|
const [transportsCompact, setTransportsCompact] = useState(false)
|
|
const [bookingsCompact, setBookingsCompact] = useState(false)
|
|
const [addExpenseSignal, setAddExpenseSignal] = useState(0)
|
|
const [exportCostsCsvSignal, setExportCostsCsvSignal] = useState(0)
|
|
const [uploadFilesSignal, setUploadFilesSignal] = useState(0)
|
|
const [openFilesTrashSignal, setOpenFilesTrashSignal] = useState(0)
|
|
|
|
// The mobile plan is single-day: make sure a day is active once days arrive.
|
|
// Only seed once so an intentional deselect elsewhere is not fought. When the
|
|
// trip is currently running, open on today's day instead of day 1 so you don't
|
|
// have to tap the current day every time; otherwise fall back to the first day.
|
|
const seededDayRef = useRef(false)
|
|
useEffect(() => {
|
|
if (seededDayRef.current || planner.selectedDayId != null || days.length === 0) return
|
|
seededDayRef.current = true
|
|
// Same rule as the desktop day plan (#1567), off the same helper so the two
|
|
// cannot drift on what "today" means.
|
|
planner.tripActions.setSelectedDay(findTodayDayId(days) ?? days[0].id)
|
|
}, [planner.selectedDayId, days, planner.tripActions])
|
|
|
|
const trTab = planner.activeTab
|
|
|
|
const setTrTab = (tabId: string) => {
|
|
planner.handleTabChange(tabId)
|
|
if (mode === 'browse') setMode('go')
|
|
}
|
|
|
|
const setTravelMode = (next: MTripMode) => {
|
|
setBrowseFromEdit(next === 'browse' && mode === 'edit')
|
|
setMode(next)
|
|
setView('plan')
|
|
if (trTab !== 'plan') planner.handleTabChange('plan')
|
|
}
|
|
|
|
const toggleView = () => {
|
|
const next = view === 'plan' ? 'map' : 'plan'
|
|
setView(next)
|
|
if (mode === 'browse') setMode('go')
|
|
// Entering the map: draw the current day's route and frame it — the
|
|
// BoundsController re-fits to include the polyline once OSRM resolves.
|
|
if (next === 'map') {
|
|
planner.setRouteShown(true)
|
|
if (planner.selectedDayId != null) planner.handleSelectDay(planner.selectedDayId, false)
|
|
}
|
|
}
|
|
|
|
const setListsTab = (tab: MTripListsTab) => {
|
|
setListsTabState(tab)
|
|
sessionStorage.setItem(`trip-lists-subtab-${tripId}`, tab)
|
|
}
|
|
|
|
const openSheet = (id: string, payload?: unknown) => setSheet({ id, payload })
|
|
const closeSheet = () => setSheet(null)
|
|
|
|
const shell: MTripShellApi = {
|
|
view, mode, trTab, setTrTab, setTravelMode, toggleView, browseFromEdit,
|
|
sheet, openSheet, closeSheet,
|
|
listsTab, setListsTab, collabTab, setCollabTab,
|
|
transportsCompact, bookingsCompact,
|
|
addExpenseSignal, exportCostsCsvSignal, uploadFilesSignal, openFilesTrashSignal,
|
|
}
|
|
|
|
// Splash — same gate as the desktop page, in the mobile design language.
|
|
if (planner.isLoading || !planner.splashDone) {
|
|
return <MTripLoadingSplash title={trip?.title || ''} />
|
|
}
|
|
if (!trip) return null
|
|
|
|
const enabledTabIds = new Set(planner.TRIP_TABS.map(tab => tab.id))
|
|
const dockTabs = DOCK_TABS.filter(d => enabledTabIds.has(d.id))
|
|
const tabLabel = (id: string) => planner.TRIP_TABS.find(tab => tab.id === id)?.label ?? id
|
|
|
|
const onDayChipTap = (dayId: number) => {
|
|
if (dayId === planner.selectedDayId) openSheet('day', { dayId })
|
|
else {
|
|
planner.handleSelectDay(dayId, view !== 'map')
|
|
// In map mode a day tap fits to that day's places AND draws its route.
|
|
if (view === 'map') planner.setRouteShown(true)
|
|
}
|
|
}
|
|
|
|
const packedCount = packingItems.filter(i => i.checked).length
|
|
const todoOpenCount = todoItems.filter(i => !i.checked).length
|
|
|
|
return (
|
|
<div className="fixed inset-0 z-50 overflow-hidden bg-[color:var(--m-bg)] bg-[image:var(--m-scr)] text-m-ink">
|
|
{/* ── Content layers ─────────────────────────────────────────────── */}
|
|
{trTab === 'plan' && (
|
|
<div className="absolute inset-0">
|
|
<MapArea planner={planner} shell={shell} />
|
|
{view === 'plan' && mode !== 'browse' && (
|
|
<div className="absolute inset-0 z-10 bg-[color:var(--m-bg)] bg-[image:var(--m-scr)]">
|
|
<PlanTimeline planner={planner} shell={shell} />
|
|
</div>
|
|
)}
|
|
{mode === 'browse' && (
|
|
<div className="absolute inset-0 z-30 bg-[color:var(--m-bg)] bg-[image:var(--m-scr)]">
|
|
<PlacesBrowser planner={planner} shell={shell} />
|
|
</div>
|
|
)}
|
|
</div>
|
|
)}
|
|
{trTab !== 'plan' && (
|
|
<div className="absolute inset-0 z-30 bg-[color:var(--m-bg)] bg-[image:var(--m-scr)]">
|
|
<TabPanel planner={planner} shell={shell} tab={trTab} />
|
|
</div>
|
|
)}
|
|
|
|
{/* ── Day chips (z-25 — covered by non-plan tab overlays, stays mounted) ── */}
|
|
{days.length > 0 && (
|
|
<div className="absolute left-4 right-4 z-[25] flex top-[calc(var(--m-safe-top,12px)+50px)]">
|
|
<div className="flex flex-1 items-center gap-[2px] overflow-x-auto rounded-full border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)] p-[3px] backdrop-blur-[24px] backdrop-saturate-[1.7]">
|
|
{days.map((day, idx) => {
|
|
const active = day.id === planner.selectedDayId
|
|
const tint = dayTints[day.id]
|
|
return (
|
|
<button
|
|
key={day.id}
|
|
type="button"
|
|
onClick={() => onDayChipTap(day.id)}
|
|
aria-current={active ? 'true' : undefined}
|
|
title={tint?.label || undefined}
|
|
// The chip is mobile's day-number badge, so it follows badgeTone.
|
|
// Inactive chips only — an inline background would otherwise beat
|
|
// the active chip's bg-m-act class.
|
|
style={active ? undefined : { background: dayTintBackground(tint, 'badge', '--day-tint-chip') }}
|
|
className={`flex-1 whitespace-nowrap rounded-full px-3 py-[5px] text-center text-[0.75rem] font-semibold ${
|
|
active ? 'bg-m-act text-m-actfg shadow-[0_6px_16px_-6px_rgba(0,0,0,.4)]' : 'text-m-ink'
|
|
}`}
|
|
>
|
|
{dayChipLabel(day, language, t('planner.dayN', { n: day.day_number ?? idx + 1 }))}
|
|
</button>
|
|
)
|
|
})}
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{/* ── Top controls (z-42 — above every layer incl. tab overlays) ── */}
|
|
<div className="absolute left-4 right-4 z-[42] flex h-10 items-center justify-between top-[var(--m-safe-top,12px)]">
|
|
<MIconBtn ariaLabel={t('common.back')} onClick={() => navigate('/dashboard')} className="backdrop-blur-[24px] backdrop-saturate-[1.7]">
|
|
<ChevronLeft size={19} strokeWidth={2.2} />
|
|
</MIconBtn>
|
|
|
|
{trTab === 'plan' && (
|
|
<GlassSegment>
|
|
{([
|
|
{ value: 'go' as const, label: t('mobileTrip.travel') },
|
|
{ value: 'edit' as const, label: t('trip.mobilePlan') },
|
|
{ value: 'browse' as const, label: t('trip.mobilePlaces') },
|
|
]).map(seg => (
|
|
<button
|
|
key={seg.value}
|
|
type="button"
|
|
onClick={() => setTravelMode(seg.value)}
|
|
className={`whitespace-nowrap rounded-full px-4 py-2 text-[0.8125rem] ${
|
|
mode === seg.value && view !== 'map' ? 'bg-m-act font-semibold text-m-actfg' : 'font-medium text-m-ink'
|
|
}`}
|
|
>
|
|
{seg.label}
|
|
</button>
|
|
))}
|
|
</GlassSegment>
|
|
)}
|
|
|
|
{trTab === 'transports' && (
|
|
<div className="absolute left-[52px] right-2 top-1/2 flex -translate-y-1/2 items-center justify-center gap-[7px]">
|
|
<PrimaryPill
|
|
label={t('transport.addTransport')}
|
|
onClick={() => {
|
|
planner.setEditingTransport(null)
|
|
planner.setTransitPrefill(null)
|
|
planner.setTransportModalAutomated(false)
|
|
planner.setShowTransportModal(true)
|
|
}}
|
|
/>
|
|
{planner.bookingImportAvailable && (
|
|
<MIconBtn ariaLabel={t('reservations.import.title')} onClick={() => planner.setShowBookingImport(true)} size={40} className="text-m-muted backdrop-blur-[24px] backdrop-saturate-[1.7]">
|
|
<Upload size={15} strokeWidth={2} />
|
|
</MIconBtn>
|
|
)}
|
|
{planner.airTrailAvailable && (
|
|
<MIconBtn ariaLabel={t('reservations.airtrail.title')} onClick={() => planner.setShowAirTrailImport(true)} size={40} className="text-m-muted backdrop-blur-[24px] backdrop-saturate-[1.7]">
|
|
<Plane size={15} strokeWidth={2} />
|
|
</MIconBtn>
|
|
)}
|
|
<CompactToggle active={transportsCompact} onToggle={() => setTransportsCompact(v => !v)} label={t('mobileTrip.compactView')} />
|
|
</div>
|
|
)}
|
|
|
|
{trTab === 'buchungen' && (
|
|
<div className="absolute left-[52px] right-2 top-1/2 flex -translate-y-1/2 items-center justify-center gap-[7px]">
|
|
<PrimaryPill
|
|
label={t('mobileTrip.newReservation')}
|
|
onClick={() => { planner.setEditingReservation(null); planner.setShowReservationModal(true) }}
|
|
/>
|
|
{planner.bookingImportAvailable && (
|
|
<MIconBtn ariaLabel={t('reservations.import.title')} onClick={() => planner.setShowBookingImport(true)} size={40} className="text-m-muted backdrop-blur-[24px] backdrop-saturate-[1.7]">
|
|
<Upload size={15} strokeWidth={2} />
|
|
</MIconBtn>
|
|
)}
|
|
<CompactToggle active={bookingsCompact} onToggle={() => setBookingsCompact(v => !v)} label={t('mobileTrip.compactView')} />
|
|
</div>
|
|
)}
|
|
|
|
{trTab === 'finanzplan' && (
|
|
<div className="absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 items-center gap-[7px]">
|
|
<PrimaryPill label={t('costs.addExpense')} onClick={() => setAddExpenseSignal(s => s + 1)} />
|
|
<MIconBtn ariaLabel={t('budget.exportCsv')} onClick={() => setExportCostsCsvSignal(s => s + 1)} size={40} className="text-m-muted backdrop-blur-[24px] backdrop-saturate-[1.7]">
|
|
<FileDown size={15} strokeWidth={2} />
|
|
</MIconBtn>
|
|
</div>
|
|
)}
|
|
|
|
{trTab === 'listen' && (
|
|
<GlassSegment>
|
|
{([
|
|
{ value: 'packing' as const, label: t('todo.subtab.packing'), count: `${packedCount}/${packingItems.length}` },
|
|
{ value: 'todo' as const, label: t('todo.subtab.todo'), count: t('mobileTrip.todoOpenCount', { count: todoOpenCount }) },
|
|
]).map(seg => (
|
|
<button
|
|
key={seg.value}
|
|
type="button"
|
|
onClick={() => setListsTab(seg.value)}
|
|
className={`flex items-center gap-[5px] whitespace-nowrap rounded-full px-4 py-2 text-[0.8125rem] ${
|
|
listsTab === seg.value ? 'bg-m-act font-semibold text-m-actfg' : 'font-medium text-m-ink'
|
|
}`}
|
|
>
|
|
{seg.label}
|
|
<span className="inline-flex rounded-full bg-[rgba(127,127,130,.22)] px-[7px] py-px font-geist text-[0.5625rem] font-bold leading-[1.6]">
|
|
{seg.count}
|
|
</span>
|
|
</button>
|
|
))}
|
|
</GlassSegment>
|
|
)}
|
|
|
|
{trTab === 'collab' && (
|
|
<GlassSegment>
|
|
{([
|
|
{ value: 'chat' as const, label: t('collab.tabs.chat') },
|
|
{ value: 'notes' as const, label: t('collab.tabs.notes') },
|
|
{ value: 'polls' as const, label: t('collab.tabs.polls') },
|
|
]).map(seg => (
|
|
<button
|
|
key={seg.value}
|
|
type="button"
|
|
onClick={() => setCollabTab(seg.value)}
|
|
className={`whitespace-nowrap rounded-full px-4 py-2 text-[0.8125rem] ${
|
|
collabTab === seg.value ? 'bg-m-act font-semibold text-m-actfg' : 'font-medium text-m-ink'
|
|
}`}
|
|
>
|
|
{seg.label}
|
|
</button>
|
|
))}
|
|
</GlassSegment>
|
|
)}
|
|
|
|
{trTab === 'dateien' && (
|
|
<div className="absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 items-center gap-[7px]">
|
|
<PrimaryPill icon={<Upload size={13} strokeWidth={2.2} />} label={t('common.upload')} onClick={() => setUploadFilesSignal(s => s + 1)} />
|
|
<MIconBtn ariaLabel={t('files.trash')} onClick={() => setOpenFilesTrashSignal(s => s + 1)} size={40} className="text-m-muted backdrop-blur-[24px] backdrop-saturate-[1.7]">
|
|
<Trash2 size={15} strokeWidth={2} />
|
|
</MIconBtn>
|
|
</div>
|
|
)}
|
|
|
|
{/* A plugin tab is the only one that used to arrive without a name: it is
|
|
not in the dock, so nothing was lit up there either, and the screen
|
|
gave no clue which plugin was open. Same treatment as the others, from
|
|
the tab entry the planner already builds (id, label, icon). */}
|
|
{trTab.startsWith('plugin:') && (() => {
|
|
const tab = planner.TRIP_TABS.find(x => x.id === trTab)
|
|
if (!tab) return null
|
|
const Icon = tab.icon
|
|
return (
|
|
<div className="pointer-events-none absolute left-[52px] right-[52px] top-1/2 flex -translate-y-1/2 items-center justify-center gap-[7px]">
|
|
<div className="flex min-w-0 items-center gap-[7px] rounded-full border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)] px-[13px] py-[7px] backdrop-blur-[24px] backdrop-saturate-[1.7]">
|
|
{Icon && <Icon size={14} strokeWidth={2} className="flex-none text-m-muted" />}
|
|
<span className="truncate text-[0.8125rem] font-semibold text-m-ink">{tab.label}</span>
|
|
</div>
|
|
</div>
|
|
)
|
|
})()}
|
|
|
|
{trTab === 'plan' ? (
|
|
<MIconBtn
|
|
ariaLabel={view === 'plan' ? t('mobileTrip.mapView') : t('mobileTrip.listView')}
|
|
onClick={toggleView}
|
|
className="backdrop-blur-[24px] backdrop-saturate-[1.7]"
|
|
>
|
|
{view === 'plan' ? <MapIcon size={18} strokeWidth={2} /> : <List size={18} strokeWidth={2} />}
|
|
</MIconBtn>
|
|
) : (
|
|
<span className="w-[38px] flex-none" />
|
|
)}
|
|
</div>
|
|
|
|
{/* ── Bottom dock (replaces the global bottom nav on this screen) ── */}
|
|
<nav className="absolute left-4 right-4 z-40 flex h-[62px] items-center justify-around rounded-[31px] border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)] px-[14px] shadow-[0_16px_44px_-14px_rgba(0,0,0,.35)] backdrop-blur-[30px] backdrop-saturate-[1.8] bottom-[calc(env(safe-area-inset-bottom,0px)+12px)]">
|
|
{dockTabs.map(({ id, icon: Icon }) => {
|
|
const active = trTab === id
|
|
return (
|
|
<button
|
|
key={id}
|
|
type="button"
|
|
onClick={() => setTrTab(id)}
|
|
aria-label={tabLabel(id)}
|
|
aria-current={active ? 'page' : undefined}
|
|
className={`flex h-[42px] w-[42px] flex-none items-center justify-center rounded-full ${
|
|
active ? 'bg-m-act text-m-actfg' : 'text-m-muted'
|
|
}`}
|
|
>
|
|
<Icon size={19} strokeWidth={2} />
|
|
</button>
|
|
)
|
|
})}
|
|
<button
|
|
type="button"
|
|
onClick={() => openSheet('mehr')}
|
|
aria-label={t('mobileTrip.more')}
|
|
className="flex h-[42px] w-[42px] flex-none items-center justify-center rounded-full text-m-muted"
|
|
>
|
|
<MoreHorizontal size={19} strokeWidth={2.2} />
|
|
</button>
|
|
</nav>
|
|
|
|
<Sheets planner={planner} shell={shell} />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
/** Centre glass pill of the top controls (segments for plan/lists/collab). */
|
|
function GlassSegment({ children }: { children: ReactNode }) {
|
|
return (
|
|
<div className="absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 rounded-full border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)] p-[3px] backdrop-blur-[24px] backdrop-saturate-[1.7]">
|
|
{children}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
/** Primary header action (Add transport / New reservation / Add expense / Upload). */
|
|
function PrimaryPill({ label, onClick, icon }: { label: string; onClick: () => void; icon?: ReactNode }) {
|
|
return (
|
|
<button
|
|
type="button"
|
|
onClick={onClick}
|
|
className="flex h-10 items-center gap-1.5 whitespace-nowrap rounded-full bg-m-act px-[18px] text-[0.8125rem] font-semibold text-m-actfg shadow-[0_10px_24px_-10px_rgba(0,0,0,.45)]"
|
|
>
|
|
{icon ?? <Plus size={14} strokeWidth={2.2} />}
|
|
{label}
|
|
</button>
|
|
)
|
|
}
|
|
|
|
/** 40px list-density toggle on the transports/bookings headers. */
|
|
function CompactToggle({ active, onToggle, label }: { active: boolean; onToggle: () => void; label: string }) {
|
|
return (
|
|
<button
|
|
type="button"
|
|
onClick={onToggle}
|
|
aria-label={label}
|
|
aria-pressed={active}
|
|
className={`flex h-10 w-10 flex-none items-center justify-center rounded-full border ${
|
|
active
|
|
? 'border-[color:var(--m-act)] bg-m-act text-m-actfg'
|
|
: 'border-[color:var(--m-gbr)] bg-[color:var(--m-glass)] text-m-muted backdrop-blur-[24px] backdrop-saturate-[1.7]'
|
|
}`}
|
|
>
|
|
{active ? <Rows3 size={15} strokeWidth={2} /> : <List size={15} strokeWidth={2} />}
|
|
</button>
|
|
)
|
|
}
|