feat(mobile): settings group their sections by what they reach: your account or this device

A tester could not tell which settings follow the account to every device and which stay on the phone, and looked for offline mode for a while. The section list and dropdown now stand under two headings, "Your account" and "This device". The server the app opens, the app lock and a client certificate move out of Account into a section of their own, "App", shown only in the app, next to Offline; About stands under TREK. Labels in all locales. TestFlight feedback, 5.1.3.
This commit is contained in:
Maurice
2026-11-11 21:31:14 +00:00
parent 948c9ef57b
commit 80c8d9c602
32 changed files with 212 additions and 40 deletions
+50 -9
View File
@@ -6,6 +6,11 @@ export interface MSection {
id: string;
label: string;
icon: LucideIcon;
/**
* The heading the section stands under. Consecutive sections with the same
* group share one heading; a screen whose sections name none shows none.
*/
group?: string;
}
interface MSectionRowProps {
@@ -33,6 +38,50 @@ export function MSectionRow({ section, active, current = false, onPick }: MSecti
);
}
/**
* The sections in order, each run of one group under its heading: the same list
* in the dropdown of a phone and in the list beside the page.
*/
export function MSectionList({
sections,
activeId,
markCurrent = false,
onPick,
}: {
sections: MSection[];
activeId: string;
/** Marks the active row as the page on show (the list beside the page). */
markCurrent?: boolean;
onPick: (id: string) => void;
}) {
return (
<>
{sections.map((section, i) => {
const heading = section.group && section.group !== sections[i - 1]?.group ? section.group : null;
return (
<div key={section.id} role="presentation">
{heading && (
<div
className={`px-[10px] pb-1 font-geist text-[0.625rem] font-bold uppercase tracking-[.09em] text-m-faint ${
i === 0 ? 'pt-1' : 'pt-3'
}`}
>
{heading}
</div>
)}
<MSectionRow
section={section}
active={section.id === activeId}
current={markCurrent && section.id === activeId}
onPick={() => onPick(section.id)}
/>
</div>
);
})}
</>
);
}
/**
* The frame of a settings-like screen (settings, administration), one rule for
* both: the page column on a phone, a centred column on a wide window, and from
@@ -88,15 +137,7 @@ export default function MSectionNav({
<span className="min-w-0 flex-1 truncate text-subtitle font-bold text-m-ink">{title}</span>
</div>
{action && <div className="mb-1 px-[4px]">{action}</div>}
{sections.map((section) => (
<MSectionRow
key={section.id}
section={section}
active={section.id === activeId}
current={section.id === activeId}
onPick={() => onPick(section.id)}
/>
))}
<MSectionList sections={sections} activeId={activeId} markCurrent onPick={onPick} />
</nav>
);
}
@@ -12,6 +12,7 @@ import {
Puzzle,
Settings2,
SlidersHorizontal,
Smartphone,
User,
} from 'lucide-react'
import { useTranslation } from '../../../i18n'
@@ -26,8 +27,11 @@ import MSettingsIntegrations from './MSettingsIntegrations'
import MSettingsAccount from './MSettingsAccount'
import MSettingsAbout from './MSettingsAbout'
import MSettingsServer from './MSettingsServer'
import MAppLockCard from './MAppLockCard'
import MClientCertCard from './MClientCertCard'
import { isNativeApp } from '../../../native/platform'
import { useIsSplit } from '../../../hooks/sizeClass'
import MSectionNav, { MSectionRow, SECTION_SCREEN, type MSection } from '../../components/MSectionNav'
import MSectionNav, { MSectionList, SECTION_SCREEN, type MSection } from '../../components/MSectionNav'
/**
* Mobile settings screen: back + section-switcher pill on top, the section
@@ -44,21 +48,33 @@ export default function MSettings() {
// the page, the way Settings on an iPad does, instead of behind a dropdown.
const split = useIsSplit()
// Two groups, so it is clear what a setting reaches: the account's settings
// follow the user to every device; this device's stay on it (the server the
// app opens, the app lock, a client certificate, the offline copy).
const accountGroup = t('settings.groups.account')
const deviceGroup = t('settings.groups.device')
const app = isNativeApp()
const tabs: MSection[] = [
{ id: 'display', label: t('settings.tabs.display'), icon: SlidersHorizontal },
{ id: 'appearance', label: t('settings.tabs.appearance'), icon: Palette },
{ id: 'map', label: t('settings.tabs.map'), icon: Map },
{ id: 'notifications', label: t('settings.tabs.notifications'), icon: Bell },
...(hasIntegrations ? [{ id: 'integrations', label: t('settings.tabs.integrations'), icon: Plug }] : []),
...(hasPlugins && !managed ? [{ id: 'plugins', label: t('settings.tabs.plugins'), icon: Puzzle }] : []),
{ id: 'offline', label: t('settings.tabs.offline'), icon: CloudOff },
{ id: 'account', label: t('settings.tabs.account'), icon: User },
{ id: 'display', label: t('settings.tabs.display'), icon: SlidersHorizontal, group: accountGroup },
{ id: 'appearance', label: t('settings.tabs.appearance'), icon: Palette, group: accountGroup },
{ id: 'map', label: t('settings.tabs.map'), icon: Map, group: accountGroup },
{ id: 'notifications', label: t('settings.tabs.notifications'), icon: Bell, group: accountGroup },
...(hasIntegrations
? [{ id: 'integrations', label: t('settings.tabs.integrations'), icon: Plug, group: accountGroup }]
: []),
...(hasPlugins && !managed
? [{ id: 'plugins', label: t('settings.tabs.plugins'), icon: Puzzle, group: accountGroup }]
: []),
{ id: 'account', label: t('settings.tabs.account'), icon: User, group: accountGroup },
...(app ? [{ id: 'device', label: t('settings.tabs.device'), icon: Smartphone, group: deviceGroup }] : []),
{ id: 'offline', label: t('settings.tabs.offline'), icon: CloudOff, group: deviceGroup },
// Same call as the desktop page: About is about the project — what TREK is,
// where to file a bug, where to support it — and a customer of a hosted
// instance is the audience for none of it. The version and the source link
// move to the footer below, because AGPL §13 wants those offered wherever
// people reach the software over a network.
...(appVersion && !managed ? [{ id: 'about', label: t('settings.tabs.about'), icon: Info }] : []),
// people reach the software over a network. Under the product's name, not
// under either group.
...(appVersion && !managed ? [{ id: 'about', label: t('settings.tabs.about'), icon: Info, group: 'TREK' }] : []),
]
const active = tabs.find((tab) => tab.id === activeTab) || tabs[0]
@@ -105,17 +121,14 @@ export default function MSettings() {
{/* Section dropdown, in flow (pushes the content down like the demo) */}
{dropOpen && !split && (
<div className="m-pop-in -mt-[6px] mb-3 rounded-2xl border border-[color:var(--m-rowbr)] bg-[color:var(--m-sheetop)] p-[6px] shadow-[0_16px_40px_-20px_rgba(0,0,0,.4)]">
{tabs.map((tab) => (
<MSectionRow
key={tab.id}
section={tab}
active={tab.id === active.id}
onPick={() => {
setActiveTab(tab.id)
setDropOpen(false)
}}
/>
))}
<MSectionList
sections={tabs}
activeId={active.id}
onPick={(id) => {
setActiveTab(id)
setDropOpen(false)
}}
/>
</div>
)}
@@ -126,8 +139,15 @@ export default function MSettings() {
{active.id === 'integrations' && hasIntegrations && <MSettingsIntegrations />}
{/* Per-plugin settings still reuse the existing responsive tab. */}
{active.id === 'plugins' && hasPlugins && !managed && <MSettingsPlugins />}
{/* Each card hides itself where it has nothing to offer; their own margins give way to one gap. */}
{active.id === 'device' && app && (
<div className="flex flex-col gap-3 [&>*]:m-0">
<MSettingsServer />
<MAppLockCard />
<MClientCertCard />
</div>
)}
{active.id === 'offline' && <MSettingsOffline />}
{active.id === 'account' && <MSettingsServer />}
{active.id === 'account' && <MSettingsAccount />}
{active.id === 'about' && appVersion && <MSettingsAbout appVersion={appVersion} />}
@@ -19,8 +19,6 @@ import {
import { useTranslation } from '../../../i18n'
import { MSetCard, MSetEyebrow, MSetInput, MSetButton, MSetHint } from './MSettingsUi'
import MConfirmSheet from './MConfirmSheet'
import MAppLockCard from './MAppLockCard'
import MClientCertCard from './MClientCertCard'
import PasswordChecklist from '../../../components/shared/PasswordChecklist'
import { fmtDate, usePasskeys } from '../../../components/Settings/usePasskeys'
import { stripTrailingSlashes, useAccountSettings } from '../../../components/Settings/useAccountSettings'
@@ -181,11 +179,7 @@ export default function MSettingsAccount() {
)}
{/* ── Two-factor authentication ───────────────────────────── */}
{/* The app lock, inside the app only (Face ID, Touch ID or the passcode). */}
<MAppLockCard />
{/* The client certificate for a server behind mutual TLS, once one is stored. */}
<MClientCertCard />
{/* The app lock and the client certificate belong to this device: MSettings, "This device". */}
<MSetCard title={t('settings.mfa.title')} icon={KeyRound} className="mt-3">
{mfaRequiredByPolicy && (
<div className="mb-3 flex gap-2 rounded-xl border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] p-3">