mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 13:10:29 +00:00
fix(mobile): collections start their first list from the dock, settings sheets aligned
Collections: the empty screen's own New list button is gone; the dock's + starts the first list while there is none and adds places once there is one. Trip settings: counts sit in a badge next to the section title instead of reading as part of it (ACCESS 1), and every round button of the sheet, invite and add guest as well as the member and guest actions, is one 42 px circle; the icon-only buttons were wider than tall. Journey settings: the public link is the same field as the trip's share and invite links, through one shared MLinkField; the shared map's extras hang under the map row with a guide line and smaller labels; removing the link is a full-size button.
This commit is contained in:
@@ -190,7 +190,7 @@
|
||||
"mobile/screens/journey/MJourneyCreateSheet.tsx": 10,
|
||||
"mobile/screens/journey/MJourneyDetail.tsx": 6,
|
||||
"mobile/screens/journey/MJourneyEntrySheet.tsx": 52,
|
||||
"mobile/screens/journey/MJourneySettingsSheet.tsx": 31,
|
||||
"mobile/screens/journey/MJourneySettingsSheet.tsx": 29,
|
||||
"mobile/screens/journey/mobileJourneyMeta.ts": 4,
|
||||
"mobile/screens/notifications/MNotificationRow.tsx": 4,
|
||||
"mobile/screens/notifications/MNotifications.tsx": 3,
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { Check, Copy, Share as ShareIcon } from 'lucide-react';
|
||||
import { canShareLink, shareLink } from '../../native/shareLink';
|
||||
|
||||
/** The round icon buttons next to the link: copy and share, the same size. */
|
||||
const ACTION = 'flex h-[34px] w-[34px] flex-none items-center justify-center rounded-full bg-m-act text-m-actfg';
|
||||
|
||||
/**
|
||||
* A link to hand on, read-only, with copy and (where the system has a share
|
||||
* sheet) share next to it: the trip's share and invite links and a journey's
|
||||
* public link all look the same.
|
||||
*/
|
||||
export default function MLinkField({
|
||||
url,
|
||||
copied,
|
||||
onCopy,
|
||||
copyLabel,
|
||||
copiedLabel,
|
||||
shareLabel,
|
||||
}: {
|
||||
url: string;
|
||||
copied: boolean;
|
||||
onCopy: () => void;
|
||||
copyLabel: string;
|
||||
copiedLabel: string;
|
||||
shareLabel: string;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex items-center gap-2 rounded-full border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] py-1 pe-1 ps-[14px]">
|
||||
<input
|
||||
readOnly
|
||||
value={url}
|
||||
aria-label={url}
|
||||
className="min-w-0 flex-1 border-none bg-transparent font-geist text-[length:calc(11px*var(--fs-scale-caption,1))] text-m-muted outline-none"
|
||||
/>
|
||||
<button type="button" aria-label={copied ? copiedLabel : copyLabel} onClick={onCopy} className={ACTION}>
|
||||
{copied ? <Check size={15} strokeWidth={2.4} /> : <Copy size={15} strokeWidth={2.2} />}
|
||||
</button>
|
||||
{canShareLink() && (
|
||||
<button type="button" aria-label={shareLabel} onClick={() => void shareLink(url)} className={ACTION}>
|
||||
<ShareIcon size={15} strokeWidth={2.2} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -73,16 +73,25 @@ export default function MCollections() {
|
||||
// The bottom-nav "+" hands off via the ?create= contract.
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
const createParam = searchParams.get('create')
|
||||
const { activeId, canEdit, setShowAddPlace, ownedLists } = c
|
||||
const { activeId, canEdit, setShowAddPlace, ownedLists, setEditorTarget } = c
|
||||
const listCount = c.collections.length
|
||||
const listsLoading = c.loading
|
||||
useEffect(() => {
|
||||
if (createParam !== 'place' && createParam !== '1') return
|
||||
// Wait for the lists: whether there is one decides what "+" means.
|
||||
if (listsLoading) return
|
||||
const next = new URLSearchParams(searchParams)
|
||||
next.delete('create')
|
||||
setSearchParams(next, { replace: true })
|
||||
// Without a list yet, "+" starts the first one; places come after.
|
||||
if (listCount === 0) {
|
||||
setEditorTarget('new')
|
||||
return
|
||||
}
|
||||
// Open whenever the user can add somewhere: an editable active list, or at
|
||||
// least one owned list to pick as the target in the sheet.
|
||||
if ((typeof activeId === 'number' && canEdit) || ownedLists.length > 0) setShowAddPlace(true)
|
||||
}, [createParam, searchParams, setSearchParams, activeId, canEdit, ownedLists.length, setShowAddPlace])
|
||||
}, [createParam, searchParams, setSearchParams, activeId, canEdit, ownedLists.length, setShowAddPlace, listsLoading, listCount, setEditorTarget])
|
||||
|
||||
// Close transient popovers when the active list changes under them.
|
||||
useEffect(() => {
|
||||
@@ -219,12 +228,8 @@ export default function MCollections() {
|
||||
</div>
|
||||
) : noLists ? (
|
||||
<div className="mt-6">
|
||||
{/* The dock's "+" starts the first list (see the ?create= handoff above). */}
|
||||
<EmptyNote scene="collections" title={t('collections.empty.firstTitle')} />
|
||||
<div className="mt-4 flex justify-center">
|
||||
<PrimaryPill onClick={openNewList}>
|
||||
<Bookmark size={14} strokeWidth={2.2} /> {t('collections.newList')}
|
||||
</PrimaryPill>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useRef, useState } from 'react'
|
||||
import { X, Image, Plus, Trash2, UserPlus, Link as LinkIcon, List, Grid3x3, MapPin, Route, Archive, ArchiveRestore, Undo2, Link2, ListChecks, RefreshCw, Share as ShareIcon, Copy, Check } from 'lucide-react'
|
||||
import { canShareLink, shareLink } from '../../../native/shareLink'
|
||||
import { X, Image, Plus, Trash2, UserPlus, Link as LinkIcon, List, Grid3x3, MapPin, Route, Archive, ArchiveRestore, Undo2, Link2, ListChecks, RefreshCw } from 'lucide-react'
|
||||
import MLinkField from '../../components/MLinkField'
|
||||
import MSheet from '../../components/MSheet'
|
||||
import MIconBtn from '../../components/MIconBtn'
|
||||
import MToggle from '../../components/MToggle'
|
||||
@@ -257,28 +257,16 @@ export default function MJourneySettingsSheet({
|
||||
</button>
|
||||
) : (
|
||||
<>
|
||||
<div className="flex items-center gap-2 rounded-[14px] bg-[color:var(--m-ic)] px-3 py-[10px]">
|
||||
<LinkIcon size={13} className="flex-none text-m-faint" />
|
||||
<span className="min-w-0 flex-1 truncate font-geist text-[0.6875rem] text-m-muted">{shareUrl}</span>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={copied ? t('journey.share.copied') : t('journey.share.copy')}
|
||||
onClick={copyShareUrl}
|
||||
className="flex h-7 w-7 flex-none items-center justify-center rounded-full bg-m-act text-m-actfg"
|
||||
>
|
||||
{copied ? <Check size={13} strokeWidth={2.4} /> : <Copy size={13} strokeWidth={2.2} />}
|
||||
</button>
|
||||
{canShareLink() && shareUrl && (
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t('common.share')}
|
||||
onClick={() => void shareLink(shareUrl)}
|
||||
className="flex h-7 w-7 flex-none items-center justify-center rounded-full bg-m-act text-m-actfg"
|
||||
>
|
||||
<ShareIcon size={13} strokeWidth={2.2} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{shareUrl && (
|
||||
<MLinkField
|
||||
url={shareUrl}
|
||||
copied={copied}
|
||||
onCopy={copyShareUrl}
|
||||
copyLabel={t('journey.share.copy')}
|
||||
copiedLabel={t('journey.share.copied')}
|
||||
shareLabel={t('common.share')}
|
||||
/>
|
||||
)}
|
||||
{([
|
||||
{ key: 'share_timeline' as const, label: t('journey.share.timeline'), icon: List },
|
||||
{ key: 'share_gallery' as const, label: t('journey.share.gallery'), icon: Grid3x3 },
|
||||
@@ -294,9 +282,9 @@ export default function MJourneySettingsSheet({
|
||||
<button
|
||||
type="button"
|
||||
onClick={deleteShareLink}
|
||||
className="mt-1 font-geist text-[0.6875rem] font-semibold text-[color:var(--m-st-danger)]"
|
||||
className="flex h-[38px] w-full items-center justify-center gap-1.5 rounded-full text-[length:calc(12px*var(--fs-scale-body,1))] font-semibold text-[color:var(--m-st-danger)]"
|
||||
>
|
||||
{t('journey.share.removeLink')}
|
||||
<Trash2 size={13} strokeWidth={2.2} /> {t('journey.share.removeLink')}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
@@ -425,11 +413,12 @@ function MRecordingPrepRow({ prep, enabled }: { prep: JourneyRecordingPrepState;
|
||||
function MShareMapExtras({ link, onToggle }: { link: JourneyShareLink; onToggle: (key: JourneyShareMapExtra) => unknown }) {
|
||||
const { t } = useTranslation()
|
||||
return (
|
||||
<>
|
||||
// Hangs under the map row: a line from below its pin, smaller labels.
|
||||
<div className="mb-1 ms-[9px] border-s-2 border-[color:var(--m-rowbr)] ps-[16px]">
|
||||
{SHARE_MAP_EXTRAS.map(({ key, labelKey, hintKey }) => (
|
||||
<div key={key} className={`flex items-center gap-[11px] py-[8px] ps-[29px] pe-[2px] ${link.share_map ? '' : 'opacity-50'}`}>
|
||||
<div key={key} className={`flex items-center gap-[11px] py-[7px] pe-[2px] ${link.share_map ? '' : 'opacity-50'}`}>
|
||||
<span className="flex min-w-0 flex-1 flex-col">
|
||||
<span className="text-body font-bold">{t(labelKey)}</span>
|
||||
<span className="text-[length:calc(13px*var(--fs-scale-body,1))] font-semibold">{t(labelKey)}</span>
|
||||
<span className="font-geist text-caption text-m-muted">
|
||||
{link.share_map ? t(hintKey) : t('journey.share.needsMap')}
|
||||
</span>
|
||||
@@ -442,6 +431,6 @@ function MShareMapExtras({ link, onToggle }: { link: JourneyShareLink; onToggle:
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
Check,
|
||||
Copy,
|
||||
Crown,
|
||||
Link2,
|
||||
LogOut,
|
||||
@@ -8,7 +7,6 @@ import {
|
||||
Plus,
|
||||
RefreshCw,
|
||||
Settings2,
|
||||
Share as ShareIcon,
|
||||
Trash2,
|
||||
UserMinus,
|
||||
UserPlus,
|
||||
@@ -27,8 +25,8 @@ import {
|
||||
type ListedMember,
|
||||
} from '../../../../components/Trips/useTripShare';
|
||||
import { useTranslation } from '../../../../i18n';
|
||||
import { canShareLink, shareLink } from '../../../../native/shareLink';
|
||||
import MChip from '../../../components/MChip';
|
||||
import MLinkField from '../../../components/MLinkField';
|
||||
import MSheet from '../../../components/MSheet';
|
||||
import MConfirmSheet from '../../settings/MConfirmSheet';
|
||||
import { Eyebrow, INNER_CLS, TileHeader } from './MTripSheetUi';
|
||||
@@ -51,17 +49,37 @@ const FIELD =
|
||||
const PRIMARY =
|
||||
'flex h-[42px] flex-none items-center gap-1.5 rounded-full bg-m-act px-4 text-[length:calc(13px*var(--fs-scale-body,1))] font-semibold text-m-actfg disabled:opacity-40';
|
||||
/** The round icon buttons next to a link: copy, share. */
|
||||
const LINK_ACTION = 'flex h-[34px] w-[34px] flex-none items-center justify-center rounded-full bg-m-act text-m-actfg';
|
||||
/** The round, filled icon button next to a picker or field: invite, add. */
|
||||
const ROUND_PRIMARY =
|
||||
'flex h-[42px] w-[42px] flex-none items-center justify-center rounded-full bg-m-act text-m-actfg disabled:opacity-40';
|
||||
const ROUND =
|
||||
'flex h-[34px] w-[34px] flex-none items-center justify-center rounded-full bg-[color:var(--m-ic)] text-m-muted disabled:opacity-40';
|
||||
'flex h-[42px] w-[42px] flex-none items-center justify-center rounded-full bg-[color:var(--m-ic)] text-m-muted disabled:opacity-40';
|
||||
const PILL =
|
||||
'flex h-[22px] flex-none items-center gap-[3px] rounded-full px-[8px] font-geist text-[length:calc(9.5px*var(--fs-scale-caption,1))] font-bold uppercase tracking-[.06em]';
|
||||
|
||||
/** A titled block of the sheet: the eyebrow, an optional line under it and the content on the inner surface. */
|
||||
function Section({ title, hint, children }: { title: string; hint?: string; children: ReactNode }) {
|
||||
function Section({
|
||||
title,
|
||||
count,
|
||||
hint,
|
||||
children,
|
||||
}: {
|
||||
title: string;
|
||||
/** How many there are, as a small badge next to the title rather than glued onto it. */
|
||||
count?: number;
|
||||
hint?: string;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<section className={`rounded-[18px] p-3 ${INNER_CLS}`}>
|
||||
<Eyebrow className="uppercase">{title}</Eyebrow>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<Eyebrow className="uppercase">{title}</Eyebrow>
|
||||
{count != null && (
|
||||
<span className="flex h-[16px] min-w-[16px] items-center justify-center rounded-full bg-[color:var(--m-ic)] px-[5px] font-geist text-[length:calc(9.5px*var(--fs-scale-caption,1))] font-bold text-m-muted">
|
||||
{count}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{hint && (
|
||||
<p className="mt-1 font-geist text-[length:calc(11px*var(--fs-scale-caption,1))] leading-snug text-m-muted">
|
||||
{hint}
|
||||
@@ -98,48 +116,6 @@ function PersonRow({
|
||||
);
|
||||
}
|
||||
|
||||
/** A link with its copy button, read-only, the way the phone shows one to hand on. */
|
||||
function LinkField({
|
||||
url,
|
||||
copied,
|
||||
onCopy,
|
||||
t,
|
||||
}: {
|
||||
url: string;
|
||||
copied: boolean;
|
||||
onCopy: () => void;
|
||||
t: (key: string) => string;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex items-center gap-2 rounded-full border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] py-1 pe-1 ps-[14px]">
|
||||
<input
|
||||
readOnly
|
||||
value={url}
|
||||
aria-label={url}
|
||||
className="min-w-0 flex-1 border-none bg-transparent font-geist text-[length:calc(11px*var(--fs-scale-caption,1))] text-m-muted outline-none"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={copied ? t('common.copied') : t('common.copy')}
|
||||
onClick={onCopy}
|
||||
className={LINK_ACTION}
|
||||
>
|
||||
{copied ? <Check size={15} strokeWidth={2.4} /> : <Copy size={15} strokeWidth={2.2} />}
|
||||
</button>
|
||||
{canShareLink() && (
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t('common.share')}
|
||||
onClick={() => void shareLink(url)}
|
||||
className={LINK_ACTION}
|
||||
>
|
||||
<ShareIcon size={15} strokeWidth={2.2} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ShareLinkSection({ tripId }: { tripId: number }) {
|
||||
const { t } = useTranslation();
|
||||
const link = useShareLink(tripId);
|
||||
@@ -168,7 +144,14 @@ function ShareLinkSection({ tripId }: { tripId: number }) {
|
||||
</div>
|
||||
{link.url ? (
|
||||
<>
|
||||
<LinkField url={link.url} copied={link.copied} onCopy={() => void link.copy()} t={t} />
|
||||
<MLinkField
|
||||
url={link.url}
|
||||
copied={link.copied}
|
||||
onCopy={() => void link.copy()}
|
||||
copyLabel={t('common.copy')}
|
||||
copiedLabel={t('common.copied')}
|
||||
shareLabel={t('common.share')}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void link.remove()}
|
||||
@@ -194,7 +177,14 @@ function InviteLinkSection({ tripId }: { tripId: number }) {
|
||||
<Section title={t('trip.invite.linkTitle')} hint={t('trip.invite.linkHint')}>
|
||||
{invite.url ? (
|
||||
<>
|
||||
<LinkField url={invite.url} copied={invite.copied} onCopy={() => void invite.copy()} t={t} />
|
||||
<MLinkField
|
||||
url={invite.url}
|
||||
copied={invite.copied}
|
||||
onCopy={() => void invite.copy()}
|
||||
copyLabel={t('common.copy')}
|
||||
copiedLabel={t('common.copied')}
|
||||
shareLabel={t('common.share')}
|
||||
/>
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
type="button"
|
||||
@@ -298,7 +288,7 @@ function MemberBadges({ member, m }: { member: ListedMember; m: Members }) {
|
||||
function AccessSection({ m, ask }: { m: Members; ask: Ask }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Section title={`${t('members.access')} ${m.realMembers.length}`}>
|
||||
<Section title={t('members.access')} count={m.realMembers.length}>
|
||||
{m.canManageMembers && (
|
||||
<div className="flex gap-2">
|
||||
<CustomSelect
|
||||
@@ -318,7 +308,7 @@ function AccessSection({ m, ask }: { m: Members; ask: Ask }) {
|
||||
onClick={() => void m.add()}
|
||||
disabled={m.adding || !m.selectedUserId}
|
||||
aria-label={t('members.invite')}
|
||||
className={PRIMARY}
|
||||
className={ROUND_PRIMARY}
|
||||
>
|
||||
<UserPlus size={14} strokeWidth={2.2} />
|
||||
</button>
|
||||
@@ -404,7 +394,8 @@ function GuestsSection({ m, ask }: { m: Members; ask: Ask }) {
|
||||
if (!m.isCurrentOwner && m.guests.length === 0) return null;
|
||||
return (
|
||||
<Section
|
||||
title={m.guests.length > 0 ? `${t('members.guests')} ${m.guests.length}` : t('members.guests')}
|
||||
title={t('members.guests')}
|
||||
count={m.guests.length > 0 ? m.guests.length : undefined}
|
||||
hint={t('members.guestsHint')}
|
||||
>
|
||||
{m.guests.map((guest) => (
|
||||
@@ -427,7 +418,7 @@ function GuestsSection({ m, ask }: { m: Members; ask: Ask }) {
|
||||
onClick={() => void m.addGuest()}
|
||||
disabled={m.addingGuest || !m.newGuestName.trim()}
|
||||
aria-label={t('members.addGuest')}
|
||||
className={PRIMARY}
|
||||
className={ROUND_PRIMARY}
|
||||
>
|
||||
<Plus size={15} strokeWidth={2.2} />
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user