mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-29 08:00:06 +00:00
feat(mobile): the tour editor as a tab of its own on an iPad and an unfolded foldable
On the wide and split size classes the touch shell no longer sends the tours tab back to the plan. It gets the desktop's tour editor, wired over the shell's own planner (useTripPlannerPageOf): on split the trip's tours and the editor share a pane beside the map, on wide the pane and the map take turns. A phone keeps its tours in the places browser.
This commit is contained in:
@@ -328,9 +328,11 @@ export default function MTripShell({
|
||||
|
||||
const trTab = planner.activeTab
|
||||
|
||||
// The tour editor is a tab on a large screen only; a phone, or a window narrowed
|
||||
// to one, keeps its tours in the places browser.
|
||||
useEffect(() => {
|
||||
if (trTab === 'tour-planner') planner.handleTabChange('plan')
|
||||
}, [trTab, planner.handleTabChange])
|
||||
if (trTab === 'tour-planner' && !wide) planner.handleTabChange('plan')
|
||||
}, [trTab, wide, planner.handleTabChange])
|
||||
|
||||
const setTrTab = (tabId: string) => {
|
||||
planner.handleTabChange(tabId)
|
||||
@@ -862,7 +864,8 @@ export default function MTripShell({
|
||||
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:') && (() => {
|
||||
{/* The tours tab on a large screen reads the same way: its own controls sit in its pane. */}
|
||||
{(trTab.startsWith('plugin:') || trTab === 'tour-planner') && (() => {
|
||||
const tab = planner.TRIP_TABS.find(x => x.id === trTab)
|
||||
if (!tab) return null
|
||||
const Icon = tab.icon
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import type { MTripTabPanelProps } from '../MTripShell'
|
||||
import { lazyWithRetry } from '../../../../utils/lazyWithRetry'
|
||||
import { LazyPanel } from '../../../../pages/tripPlanner/LazyPanel'
|
||||
import { TabScroller } from './tabChrome'
|
||||
import MTransportsTab from './MTransportsTab'
|
||||
import MBookingsTab from './MBookingsTab'
|
||||
@@ -10,6 +12,9 @@ import MRoadtripTab from '../roadtrip/MRoadtripTab'
|
||||
import MJourneyDetail from '../../journey/MJourneyDetail'
|
||||
import PluginFrame from '../../../../components/Plugins/PluginFrame'
|
||||
|
||||
// The desktop's tour editor, map stage included: loaded the first time a large screen opens the tab.
|
||||
const MTourWorkspace = lazyWithRetry(() => import('../tours/MTourWorkspace'))
|
||||
|
||||
/**
|
||||
* Routes the active non-plan trip tab to its panel. `tab` is the legacy id the
|
||||
* desktop planner uses (transports · buchungen · finanzplan · listen · dateien ·
|
||||
@@ -62,6 +67,13 @@ export default function MTripTabPanel({ planner, shell, tab }: MTripTabPanelProp
|
||||
// switch between them must not lose it.
|
||||
case 'roadtrip':
|
||||
return <MRoadtripTab planner={planner} shell={shell} tab={tab} />
|
||||
// Only ever reached on a large screen: the shell sends a phone back to the plan.
|
||||
case 'tour-planner':
|
||||
return (
|
||||
<LazyPanel id="m-tour-workspace">
|
||||
<MTourWorkspace planner={planner} />
|
||||
</LazyPanel>
|
||||
)
|
||||
// The journal the trip links: the Journey addon's own phone screen, moved
|
||||
// below the trip's floating top controls: its bars measure from --m-safe-top.
|
||||
case 'journal':
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
import { List, Map as MapIcon } from 'lucide-react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import TourGpxDropZone from '../../../../components/Tours/TourGpxDropZone';
|
||||
import TourWorkspaceRail from '../../../../components/Tours/TourWorkspaceRail';
|
||||
import { TourPlannerToursRail } from '../../../../components/Tours/planner/TourPlannerPanels';
|
||||
import { useIsSplit } from '../../../../hooks/sizeClass';
|
||||
import { useTouchDragBridge } from '../../../../hooks/useTouchDragBridge';
|
||||
import { LazyPanel } from '../../../../pages/tripPlanner/LazyPanel';
|
||||
import { TourPlannerMapStage } from '../../../../pages/tripPlanner/TourPlannerMapStage';
|
||||
import { useTripPlannerPageOf } from '../../../../pages/tripPlanner/useTripPlannerPage';
|
||||
import MIconBtn from '../../../components/MIconBtn';
|
||||
import MSegmented from '../../../components/MSegmented';
|
||||
import type { MTripTabPanelProps } from '../MTripShell';
|
||||
|
||||
/** The pane's two halves: the trip's tours, or the editor with the tour open in it. */
|
||||
type MTourPane = 'tours' | 'editor';
|
||||
|
||||
/** The editor's title for what is open in it, as the desktop rail heads it. */
|
||||
const EDITOR_TITLE = {
|
||||
neutral: 'tours.planner.title',
|
||||
'new-draft': 'tours.planner.newTitle',
|
||||
'edit-saved': 'tours.planner.editTitle',
|
||||
'view-gpx': 'tours.planner.gpxTitle',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* The tours tab on a large screen (wide and split; a phone has no such tab and
|
||||
* keeps its tours in the places browser). It is the desktop's tour editor, wired
|
||||
* over the shell's own planner through useTripPlannerPageOf, so the two cannot
|
||||
* drift apart: the same rails, the same map stage, the same GPX import.
|
||||
*
|
||||
* Split: the pane beside the map, with the trip's tours and the editor as its two
|
||||
* halves. Wide: one column, the pane or the map, switched at the pane's head and
|
||||
* from the map's corner. Opening a tour (from the list, the map or an import) turns
|
||||
* the pane to the editor, where it is then shown.
|
||||
*
|
||||
* The whole tab sits below the shell's floating top controls rather than under
|
||||
* them: that row spans the window and takes every press in its band, so a map
|
||||
* running beneath it would lose its search field to it.
|
||||
*/
|
||||
export default function MTourWorkspace({ planner }: Pick<MTripTabPanelProps, 'planner'>) {
|
||||
const page = useTripPlannerPageOf(planner);
|
||||
const { tourPlanner, wandererBrowser, tourGpxImport, tourMap, locationSearch, tourDetailActions } = page;
|
||||
const { canPlaceEdit, canDayEdit } = page.permissions;
|
||||
const split = useIsSplit();
|
||||
const [pane, setPane] = useState<MTourPane>('tours');
|
||||
const [mapShown, setMapShown] = useState(false);
|
||||
// The waypoint list and the stage rail reorder by HTML5 drag, which a finger cannot start.
|
||||
useTouchDragBridge(true);
|
||||
|
||||
const mode = tourPlanner.mode.type;
|
||||
const editing = mode !== 'neutral' || wandererBrowser.open;
|
||||
// Something opened in the editor is shown there, on whichever half was up; once
|
||||
// it is closed (discarded, or back to the tours) the list comes back. Only on a
|
||||
// change: a tap on the editor half with nothing open stays where it went.
|
||||
useEffect(() => {
|
||||
setPane(editing ? 'editor' : 'tours');
|
||||
}, [editing, mode]);
|
||||
|
||||
const showPane = split || !mapShown;
|
||||
const showMap = split || mapShown;
|
||||
const { t } = planner;
|
||||
|
||||
return (
|
||||
<TourGpxDropZone gpxImport={tourGpxImport} canEdit={canPlaceEdit} className="absolute inset-0">
|
||||
<div className="absolute inset-x-0 bottom-0 top-[calc(var(--m-safe-top,12px)+50px)] flex">
|
||||
{showPane && (
|
||||
<section
|
||||
aria-label={t('tours.planner.tripTours')}
|
||||
className="flex h-full min-w-0 flex-1 flex-col split:w-[var(--trip-pane-open)] split:flex-none split:border-e split:border-[color:var(--m-rowbr)]"
|
||||
>
|
||||
<div className="flex items-center gap-2 px-4 pb-2 pt-1">
|
||||
<MSegmented<MTourPane>
|
||||
className="min-w-0 flex-1"
|
||||
value={pane}
|
||||
onChange={setPane}
|
||||
options={[
|
||||
{ value: 'tours', label: t('tours.planner.tripTours') },
|
||||
{ value: 'editor', label: t(EDITOR_TITLE[mode]) },
|
||||
]}
|
||||
/>
|
||||
{!split && (
|
||||
<MIconBtn ariaLabel={t('mobileTrip.mapView')} onClick={() => setMapShown(true)} size={36}>
|
||||
<MapIcon size={17} strokeWidth={2} />
|
||||
</MIconBtn>
|
||||
)}
|
||||
</div>
|
||||
<div className="relative min-h-0 flex-1 overflow-hidden pb-[env(safe-area-inset-bottom,0px)]">
|
||||
{pane === 'tours' ? (
|
||||
<LazyPanel id="m-tour-tours">
|
||||
<TourPlannerToursRail
|
||||
planner={tourPlanner}
|
||||
canEdit={canPlaceEdit}
|
||||
canAssign={canDayEdit}
|
||||
tours={planner.tours}
|
||||
days={planner.days}
|
||||
loading={planner.toursLoading}
|
||||
onAssignToDay={planner.handleAssignToDay}
|
||||
onDeleteTour={planner.handleDeleteTour}
|
||||
gpxImport={tourGpxImport}
|
||||
onViewGpxTour={page.viewImportedTour}
|
||||
onTakenOver={tourDetailActions.onTakenOver}
|
||||
/>
|
||||
</LazyPanel>
|
||||
) : (
|
||||
<LazyPanel id="m-tour-editor">
|
||||
<TourWorkspaceRail workspace={page} canEdit={canPlaceEdit} canAssign={canDayEdit} />
|
||||
</LazyPanel>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
{showMap && (
|
||||
<div className="relative h-full min-w-0 flex-1 overflow-hidden">
|
||||
<TourPlannerMapStage
|
||||
tripId={planner.tripId}
|
||||
mapTileUrl={planner.mapTileUrl}
|
||||
leftHidden={false}
|
||||
rightHidden={false}
|
||||
leftPanelPx={0}
|
||||
rightPanelPx={0}
|
||||
t={t}
|
||||
tourPlanner={tourPlanner}
|
||||
tourMap={tourMap}
|
||||
locationSearch={locationSearch}
|
||||
canPlaceEdit={canPlaceEdit}
|
||||
assistantRoutes={planner.assistantMap}
|
||||
onViewportChange={wandererBrowser.onViewportChange}
|
||||
paddleChecklist={page.paddleChecklist}
|
||||
/>
|
||||
{!split && (
|
||||
<div className="absolute start-3 top-3 z-20">
|
||||
<MIconBtn
|
||||
ariaLabel={t('mobileTrip.listView')}
|
||||
onClick={() => setMapShown(false)}
|
||||
className="backdrop-blur-[24px] backdrop-saturate-[1.7]"
|
||||
>
|
||||
<List size={18} strokeWidth={2} />
|
||||
</MIconBtn>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</TourGpxDropZone>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user