From 0e7f0feeb5d6cfdb127f3dd7fba367431a72fa95 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Oct 2026 05:40:21 +0000 Subject: [PATCH 1/2] feat(mobile): customize computers with a preset icon and colour The custom header banner stopped showing once Chats moved to the native header, so Customize computer now picks a native symbol or emoji and one of ten system colours. The icon leads the computer's tab above Chats and its drawer tile; the colour tints the icon and the tab underline. The sheet uses the shared DrawerHeader and raised cards like other sheets. Saved banner colours migrate to the nearest preset; old avatars and pictures are dropped and their files deleted. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_014UiRXqKRSQS39KzeJJnLcA --- apps/mobile/DESIGN.md | 20 +- apps/mobile/app/(tabs)/(home)/index.tsx | 9 +- apps/mobile/app/host-look.tsx | 12 +- .../src/host/conversation-environments.ts | 7 +- apps/mobile/src/host/host-look.ts | 94 ++- apps/mobile/src/host/native-host-look.ts | 53 +- apps/mobile/src/ui/design/host-look.ts | 279 ++++---- .../mobile/src/ui/shell/environment-pager.tsx | 36 +- apps/mobile/src/ui/shell/gradient-fill.tsx | 25 - apps/mobile/src/ui/shell/host-band.tsx | 103 --- apps/mobile/src/ui/shell/host-drawer.tsx | 15 +- apps/mobile/src/ui/shell/host-look-editor.tsx | 602 ++++++++---------- apps/mobile/src/ui/shell/host-tile.tsx | 62 +- apps/mobile/src/ui/strings.ts | 110 +++- apps/mobile/test/home-search.test.tsx | 3 +- apps/mobile/test/host-look.test.tsx | 255 +++----- changes/mobile-computer-icons.md | 11 + 17 files changed, 703 insertions(+), 993 deletions(-) delete mode 100644 apps/mobile/src/ui/shell/gradient-fill.tsx delete mode 100644 apps/mobile/src/ui/shell/host-band.tsx create mode 100644 changes/mobile-computer-icons.md diff --git a/apps/mobile/DESIGN.md b/apps/mobile/DESIGN.md index 56aa8400d9..4d4f37d34f 100644 --- a/apps/mobile/DESIGN.md +++ b/apps/mobile/DESIGN.md @@ -53,11 +53,11 @@ References: [Apple toolbars](https://developer.apple.com/design/human-interface- ## Chats source navigation (#2194) -Chats uses the same canvas and left-aligned title treatment as Activity. The title/chevron opens the workspace drawer; Settings remains on the right. Directly below, a reusable native pager presents a horizontally scrolling **All → Computer → Organization** strip. Selecting a tab or swiping the list changes only the device-local browsing scope. Stable directory order, including empty member Organizations and channel-only guest Organizations, is independent of message arrival. Labels use local Computer names; keys retain full source/account identity. Each tab stays on one line with a bounded width and tail-ellipsized label; the source icon never shrinks. Service URLs do not add a second line. Full source/account identity remains in accessibility labels and the source drawer. +Chats uses the same canvas and left-aligned title treatment as Activity. The title/chevron opens the workspace drawer; Settings remains on the right. Directly below, a reusable native pager presents a horizontally scrolling **All → Computer → Organization** strip. Selecting a tab or swiping the list changes only the device-local browsing scope. Stable directory order, including empty member Organizations and channel-only guest Organizations, is independent of message arrival. Labels use local Computer names; keys retain full source/account identity. Each tab stays on one line with a bounded width and tail-ellipsized label; the source icon leads the label and never shrinks. The Computer tab's icon is that Computer's chosen icon; when the Computer has a chosen colour, the icon (while selected) and the tab underline use it, and other tabs keep the theme accent underline. Service URLs do not add a second line. Full source/account identity remains in accessibility labels and the source drawer. This first slice retains one active Computer plus authorized Organizations. It does not implement simultaneous multiple-Computer connections. Search and creation remain in their existing list-header placement until #2195/#2196. Activity inherits scope and keeps action/replies/unread paging; unsupported Cloud scope has an explicit notice and no borrowed Computer badge. All discloses that Cloud activity is not yet included. Source-owned history, credentials, drafts, permissions and send paths stay unchanged. -The older Host-band description below records prior presentation/customization behavior. The Chats Header and environment selector above supersede that entry layout; saved Computer customization remains available in the drawer. +The older Host-band description below records prior presentation behavior. The Chats Header and environment selector above supersede that entry layout; Computer customization (name, icon, colour) remains available in the drawer. ## Structure @@ -68,17 +68,19 @@ The shell is set by [ADR-0211](../../docs/adr/0211-the-mobile-app-has-two-tabs-w - The app stays connected to every paired Host at once. - The Chats list and every chat show one Host at a time. The Chats header has a Slack-style band in the accent colour (a muted accent in dark mode); the list sits on a panel with rounded top corners below it. - The **Host chip** at the top left shows the Host's initial tile, its name and ▾. Tapping it opens the shared **workspace drawer**. - - **Customize computer** sets how each Host looks, kept on the phone per Host. It is a form sheet with a live preview of the band, opened from that Host's ⋯ menu in the Host drawer (or a long press on its row), so each paired Host is customized where it is listed. - - Name: a local name shown in the Host chip and the drawer instead of the Host's own name; clearing it goes back to the Host's name. - - Avatar: the initial tile (default), one of eight pixel portraits from the PersonaBot avatar generator, or a photo cropped square. - - Banner: the accent band (default), a solid colour (ten swatches or a typed hex), a two-stop gradient (six presets or typed stops), or a picture under a dark scrim. - - A custom colour goes through the accent band's steps, so dark mode mutes it the same way. The ink is white or near-black, whichever reads on every stop; a picture always takes white ink with a soft shadow. + - **Customize computer** sets how each Host looks, kept on the phone per Host. It is a form sheet with the shared `DrawerHeader` (× close, centred title), opened from that Host's ⋯ menu in the Host drawer (or a long press on its row). Changes apply immediately; there is no confirm. + - Preview: the Chats environment strip in miniature (All, then this Computer's tab with its icon, name and underline), so the result is judged where it shows. + - Name: a local name shown in the Chats tab and the drawer instead of the Host's own name; clearing it goes back to the Host's name. + - Icon: a `Segmented` switch between **Symbols** (18 native symbols, SF Symbols on iOS and Material Symbols on Android, the desktop symbol by default) and **Emoji** (18 presets), on a `raised` card of round 44pt targets. There are no photos or free-form avatars: the icon only has to tell Computers apart in the tab strip and the drawer. + - Colour: **Theme colour** (default) or one of ten system colours (blue, indigo, purple, pink, red, orange, yellow, green, teal, graphite) with light and dark values. The colour moves toward `fg` until it reaches 3:1 against `base`, so yellow and graphite stay visible. It tints the icon, the drawer tile (a soft wash of the colour) and the Chats tab underline. The header never takes a custom fill. + - Reset to default is a danger row in its own group and asks first. + - Looks saved before icons existed migrate on first read: a solid banner colour, or a gradient's first stop, becomes the nearest preset colour; avatars and banner pictures are dropped and their files deleted. - **Workspace drawer** switches between paired Computers and Cloud organization workspaces. It slides in from the left, covers about 85% of the width and dims the list behind it. - On iOS 26, unless Reduce Transparency is on, it is a floating Liquid Glass sidebar: inset `sidebar.inset` from the screen's left, top and bottom edges with `sidebar.radius` corners concentric with the display. Its rows are clear; a pressed row and the current Computer or workspace show a `radius.lg` highlight inset from the sidebar's edges, as iOS sidebars do. The pairing card is frosted. A Computer's ⋯ opens a native pull-down menu anchored to it (Customize, Show this computer, Unpair); a long press on the row still opens the action sheet. Older iOS, Reduce Transparency and Android keep the opaque full-height drawer. - Rounded **Computers / Cloud** tabs are the first row above one scrolling list, with no duplicate title or close button. Opening the drawer selects the current route's tab; switching tabs only changes the list, never the active computer or cloud session. Android uses opaque raised chips; iOS uses the existing glass material with Reduce Transparency, older OS and large-text fallbacks. Tabs expose their selected state to accessibility. - One contextual plus action sits directly below the tabs, above the scrolling list: Computers opens **Pair a new computer** directly; Cloud opens **Join by link or QR** directly. There is no mixed action chooser or stacked icon group. Organization creation and service configuration live under **Manage cloud services** on the Cloud tab; Notifications stays at the bottom of a fixed footer on both tabs; Cloud service management sits above it. Only the directory scrolls. - A cloud service is an instance/address; its organization is a cloud workspace; a channel belongs to that organization. An invitation already identifies its service and scope: workspace membership or access to only one channel. The existing preview and acceptance flow keeps this distinction explicit. No separate server-selection step or new authorization store is introduced. - - Each Host row has its Computer avatar tile (the same tile as the Host chip; the current Host's tile has an `fg` ring at radius `lg`, concentric with the tile, as Slack marks the current workspace), its name, an online/offline/checking dot and label, then one **count chip** on the right (see Count chip below). It shows **Needs you** when anything waits for the Human, because that matters most; otherwise it shows **Unread**, the count of unread conversations. A ⋯ button at the end, or a long press on the row, opens the Host's menu: Customize (name, avatar and banner), Show this computer, and Unpair, which asks for confirmation. The ⋯ menu is the system's own anchored menu: a SwiftUI pull-down on iOS and a Material 3 dropdown on Android, with Unpair in the danger colour. + - Each Host row has its Computer icon tile (its chosen icon on a wash of its colour; the current Host's tile has an `fg` ring at radius `lg`, concentric with the tile, as Slack marks the current workspace), its name, an online/offline/checking dot and label, then one **count chip** on the right (see Count chip below). It shows **Needs you** when anything waits for the Human, because that matters most; otherwise it shows **Unread**, the count of unread conversations. A ⋯ button at the end, or a long press on the row, opens the Host's menu: Customize (name, avatar and banner), Show this computer, and Unpair, which asks for confirmation. The ⋯ menu is the system's own anchored menu: a SwiftUI pull-down on iOS and a Material 3 dropdown on Android, with Unpair in the danger colour. - The Host chip opens it, and so does a swipe right from the left edge of a tab's root screen. The edge swipe is never attached inside a pushed chat, where it stays the system Back. - Tapping a Host switches to it and closes the drawer. Tapping the backdrop, swiping left or using the accessibility escape gesture closes it. Opening focuses the selected tab. - It takes screen-reader focus when it opens and returns focus to the Host chip when it closes. With Reduce Motion on it appears without sliding. @@ -134,7 +136,7 @@ The shell is set by [ADR-0211](../../docs/adr/0211-the-mobile-app-has-two-tabs-w - Everything comes from the Host's `overviewUsage` and `overviewMemory`, the same reads as the Web Client's activity view; the card's week total matches its week total. - **Connections**: the current Host and its connection status, Computers (paired Hosts, their status and unpairing, with the same confirmation and error notice as before), Notifications, Storage, and Open full client. - **Storage** pushes a screen that reads the Host's `storageUsage`: the total in `display`, one bar split into media and files, messages, Memory and other (accent at falling opacity, `borderStrong` for other; decorative, the rows below carry the numbers), then one row per part with its size. **Clear chat media** picks an age with checkmark rows (30, 90, 180 days, 1 year, any age), media types and chats with switches (every chat with media starts on), and a danger **Clear…** button. The button asks the Host for `storageCleanupPreview` and shows a destructive confirmation whose message states how many files from how many messages are deleted, the space freed, that text stays, and what is kept and why; nothing that matches gets a dialog with only Done. Confirming calls `storageCleanupConfirm`, shows a success notice and reads the usage again; a `storage-preview-stale` refusal says something changed. **This phone → Clear image cache** empties expo-image's memory and disk caches at once, since it only costs a download. Cleared files show in their message as a dashed `{size} · Cleared` file card. - - **Interface**: App icon (the full DeepSeekBot portrait ships as the default icon; the chibi portrait is the alternate; both have dark and tinted variants on iOS), and Appearance (scheme, accent, chat wallpaper) once it exists. Each Host's name, avatar and banner are customized from its menu in the Host drawer, not here. + - **Interface**: App icon (the full DeepSeekBot portrait ships as the default icon; the chibi portrait is the alternate; both have dark and tinted variants on iOS), and Appearance (scheme, accent, chat wallpaper) once it exists. Each Host's name, icon and colour are customized from its menu in the Host drawer, not here. - **Chats**: Channel sections and Hidden Channels, each pushing its own screen. ## Sheet and drawer surfaces diff --git a/apps/mobile/app/(tabs)/(home)/index.tsx b/apps/mobile/app/(tabs)/(home)/index.tsx index 854e5f4ac4..c0c11706a3 100644 --- a/apps/mobile/app/(tabs)/(home)/index.tsx +++ b/apps/mobile/app/(tabs)/(home)/index.tsx @@ -128,7 +128,14 @@ const HomeContent = memo(function HomeContent({ const filters = useMemo( () => conversationEnvironments( - saved ? { hostId: saved.hostId, name: shownHostName(look, saved.hostName) } : undefined, + saved + ? { + hostId: saved.hostId, + name: shownHostName(look, saved.hostName), + icon: look.icon, + ...(look.color === undefined ? {} : { color: look.color }), + } + : undefined, cloud.rows.filter((r) => r.hasSession).map(cloudViewScope), directory.workspaces, t.allEnvironments, diff --git a/apps/mobile/app/host-look.tsx b/apps/mobile/app/host-look.tsx index 0f9c0853c0..0d9eaa620f 100644 --- a/apps/mobile/app/host-look.tsx +++ b/apps/mobile/app/host-look.tsx @@ -2,7 +2,7 @@ import { useLocalSearchParams, useRouter } from 'expo-router'; import { View } from 'react-native'; import { useHostSession } from '../src/host/host-session'; -import { forgetImage, hostLooks, pickLookImage, useHostLook } from '../src/host/native-host-look'; +import { hostLooks, useHostLook } from '../src/host/native-host-look'; import { useDesignTheme } from '../src/ui/design/theme'; import { space } from '../src/ui/design/tokens'; import { Notice } from '../src/ui/request-parts'; @@ -33,15 +33,7 @@ export default function HostLookScreen() { hostName={host.hostName} look={look} actions={{ - onChange(next) { - const before = hostLooks.look(hostId); - hostLooks.set(hostId, next); - if (before.avatar.kind === 'image' && before.avatar !== next.avatar) - forgetImage(before.avatar.uri); - if (before.banner.kind === 'image' && before.banner !== next.banner) - forgetImage(before.banner.uri); - }, - onPickImage: (slot) => pickLookImage(hostId, slot), + onChange: (next) => hostLooks.set(hostId, next), onClose: () => router.back(), }} /> diff --git a/apps/mobile/src/host/conversation-environments.ts b/apps/mobile/src/host/conversation-environments.ts index a5529bb9e4..d47b58e9a4 100644 --- a/apps/mobile/src/host/conversation-environments.ts +++ b/apps/mobile/src/host/conversation-environments.ts @@ -1,4 +1,5 @@ import type { ConversationWorkspace } from '../cloud/conversations'; +import type { HostColorId, HostIcon } from '../ui/design/host-look'; export type ConversationEnvironment = { key: string; @@ -6,13 +7,15 @@ export type ConversationEnvironment = { detail?: string; accessibilityLabel?: string; kind: 'all' | 'computer' | 'cloud'; + hostIcon?: HostIcon; + hostColor?: HostColorId; }; export const computerEnvironmentKey = (hostId: string) => JSON.stringify(['computer', hostId]); export const cloudEnvironmentKey = (scope: string, organizationId: string) => JSON.stringify([scope, organizationId]); export function conversationEnvironments( - computer: { hostId: string; name: string } | undefined, + computer: { hostId: string; name: string; icon?: HostIcon; color?: HostColorId } | undefined, sourceScopes: readonly string[], workspaces: readonly ConversationWorkspace[], allTitle: string, @@ -23,6 +26,8 @@ export function conversationEnvironments( key: computerEnvironmentKey(computer.hostId), title: computer.name, kind: 'computer', + ...(computer.icon === undefined ? {} : { hostIcon: computer.icon }), + ...(computer.color === undefined ? {} : { hostColor: computer.color }), }); const seen = new Set(); for (const scope of sourceScopes) { diff --git a/apps/mobile/src/host/host-look.ts b/apps/mobile/src/host/host-look.ts index 24bcbbb845..2f8659989c 100644 --- a/apps/mobile/src/host/host-look.ts +++ b/apps/mobile/src/host/host-look.ts @@ -1,16 +1,20 @@ import { - bannerHex, DEFAULT_HOST_LOOK, - HOST_AVATAR_PRESETS, + HOST_COLORS, + HOST_EMOJI, + HOST_SYMBOLS, + hostLook, hostLookName, - type HostAvatar, - type HostBanner, + nearestHostColor, + type HostColorId, + type HostIcon, type HostLook, } from '../ui/design/host-look'; export interface LookStorage { read(): Promise; write(value: Record): void; + forgetLegacyImages?(): void; } export interface HostLooks { @@ -26,69 +30,41 @@ function record(value: unknown): Record { const text = (value: unknown): string | undefined => typeof value === 'string' && value !== '' ? value : undefined; -export function parseHostAvatar(input: unknown): HostAvatar { +export function parseHostIcon(input: unknown): HostIcon { const value = record(input); const id = text(value['id']); - const uri = text(value['uri']); + const emoji = text(value['emoji']); + if (value['kind'] === 'symbol' && id !== undefined && Object.hasOwn(HOST_SYMBOLS, id)) + return { kind: 'symbol', id: id as keyof typeof HOST_SYMBOLS }; if ( - value['kind'] === 'preset' && - id !== undefined && - (HOST_AVATAR_PRESETS as readonly string[]).includes(id) + value['kind'] === 'emoji' && + emoji !== undefined && + (HOST_EMOJI as readonly string[]).includes(emoji) ) - return { kind: 'preset', id }; - if (value['kind'] === 'image' && uri !== undefined) return { kind: 'image', uri }; - return DEFAULT_HOST_LOOK.avatar; + return { kind: 'emoji', emoji }; + return DEFAULT_HOST_LOOK.icon; } -export function parseHostBanner(input: unknown): HostBanner { - const value = record(input); - const hex = (key: string) => { - const raw = text(value[key]); - return raw === undefined ? undefined : bannerHex(raw); - }; - const color = hex('color'); - const from = hex('from'); - const to = hex('to'); - const uri = text(value['uri']); - if (value['kind'] === 'color' && color !== undefined) return { kind: 'color', color }; - if (value['kind'] === 'gradient' && from !== undefined && to !== undefined) - return { kind: 'gradient', from, to }; - if (value['kind'] === 'image' && uri !== undefined) return { kind: 'image', uri }; - return DEFAULT_HOST_LOOK.banner; +export function parseHostColor(input: unknown): HostColorId | undefined { + const id = text(input); + return id !== undefined && Object.hasOwn(HOST_COLORS, id) ? (id as HostColorId) : undefined; } -export function parseHostLook(input: unknown): HostLook { - const value = record(input); - const name = hostLookName(value['name']); - return { - ...(name === undefined ? {} : { name }), - avatar: parseHostAvatar(value['avatar']), - banner: parseHostBanner(value['banner']), - }; +function legacyColor(input: unknown): HostColorId | undefined { + const banner = record(input); + const hex = text(banner['kind'] === 'gradient' ? banner['from'] : banner['color']); + return hex === undefined ? undefined : nearestHostColor(hex.trim().toLowerCase()); } -export const LOOK_IMAGES = 'host-looks'; - -export function rebaseLookImage(uri: string, folderUri: string): string { - const marker = `/${LOOK_IMAGES}/`; - const at = uri.lastIndexOf(marker); - if (at < 0) return uri; - return `${folderUri.replace(/\/?$/u, '/')}${uri.slice(at + marker.length)}`; +export function isLegacyHostLook(input: unknown): boolean { + const value = record(input); + return 'avatar' in value || 'banner' in value; } -export function rebaseLookImages(input: unknown, folderUri: string): unknown { - const looks = record(input); - const slot = (value: unknown) => { - const part = record(value); - const uri = part['uri']; - return typeof uri === 'string' ? { ...part, uri: rebaseLookImage(uri, folderUri) } : value; - }; - return Object.fromEntries( - Object.entries(looks).map(([hostId, look]) => { - const value = record(look); - return [hostId, { ...value, avatar: slot(value['avatar']), banner: slot(value['banner']) }]; - }), - ); +export function parseHostLook(input: unknown): HostLook { + const value = record(input); + const color = 'color' in value ? parseHostColor(value['color']) : legacyColor(value['banner']); + return hostLook(hostLookName(value['name']), parseHostIcon(value['icon']), color); } export function createHostLooks(storage: LookStorage): HostLooks { @@ -101,8 +77,12 @@ export function createHostLooks(storage: LookStorage): HostLooks { void storage.read().then( (value) => { if (touched) return; - for (const [hostId, look] of Object.entries(record(value))) - byHost.set(hostId, parseHostLook(look)); + const stored = Object.entries(record(value)); + for (const [hostId, look] of stored) byHost.set(hostId, parseHostLook(look)); + if (stored.some(([, look]) => isLegacyHostLook(look))) { + storage.write(Object.fromEntries(byHost)); + storage.forgetLegacyImages?.(); + } notify(); }, () => undefined, diff --git a/apps/mobile/src/host/native-host-look.ts b/apps/mobile/src/host/native-host-look.ts index 280611b7c2..f27f4b00ec 100644 --- a/apps/mobile/src/host/native-host-look.ts +++ b/apps/mobile/src/host/native-host-look.ts @@ -1,18 +1,16 @@ import { Directory, File, Paths } from 'expo-file-system'; -import * as ImagePicker from 'expo-image-picker'; import { useCallback, useSyncExternalStore } from 'react'; import type { HostLook } from '../ui/design/host-look'; -import { createHostLooks, LOOK_IMAGES, rebaseLookImages } from './host-look'; +import { createHostLooks } from './host-look'; const file = (): File => new File(Paths.document, 'deepseekbot-host-looks.json'); -const folder = (): Directory => new Directory(Paths.document, LOOK_IMAGES); export const hostLooks = createHostLooks({ async read() { const stored = file(); if (!stored.exists) return undefined; - return rebaseLookImages(JSON.parse(await stored.text()) as unknown, folder().uri); + return JSON.parse(await stored.text()) as unknown; }, write(value) { try { @@ -21,6 +19,12 @@ export const hostLooks = createHostLooks({ stored.writeSync(JSON.stringify(value)); } catch {} }, + forgetLegacyImages() { + try { + const pictures = new Directory(Paths.document, 'host-looks'); + if (pictures.exists) pictures.delete(); + } catch {} + }, }); export function useHostLook(hostId: string | undefined): HostLook { @@ -29,44 +33,3 @@ export function useHostLook(hostId: string | undefined): HostLook { useCallback(() => hostLooks.look(hostId ?? ''), [hostId]), ); } - -let imported = 0; - -async function keep(uri: string, hostId: string, slot: 'avatar' | 'banner'): Promise { - try { - const dir = folder(); - if (!dir.exists) dir.create({ intermediates: true }); - imported += 1; - const extension = /\.(png|jpe?g|heic|webp|gif)$/i.exec(uri)?.[0] ?? '.jpg'; - const safe = hostId.replace(/[^a-z0-9_-]/giu, '_'); - const target = new File(dir, `${safe}-${slot}-${Date.now()}-${imported}${extension}`); - await new File(uri).copy(target); - return target.uri; - } catch { - return uri; - } -} - -export function forgetImage(uri: string | undefined): void { - if (uri === undefined) return; - try { - const dir = folder(); - if (!uri.startsWith(dir.uri)) return; - const stale = new File(uri); - if (stale.exists) stale.delete(); - } catch {} -} - -export async function pickLookImage( - hostId: string, - slot: 'avatar' | 'banner', -): Promise { - const result = await ImagePicker.launchImageLibraryAsync({ - mediaTypes: ['images'], - allowsEditing: slot === 'avatar', - aspect: [1, 1], - quality: 0.9, - }); - const asset = result.canceled ? undefined : result.assets[0]; - return asset === undefined ? undefined : keep(asset.uri, hostId, slot); -} diff --git a/apps/mobile/src/ui/design/host-look.ts b/apps/mobile/src/ui/design/host-look.ts index a8a97a10bd..2cfc55c56a 100644 --- a/apps/mobile/src/ui/design/host-look.ts +++ b/apps/mobile/src/ui/design/host-look.ts @@ -1,189 +1,148 @@ -import { - contrast, - headerBand, - withAccent, - type ColorRole, - type ColorScheme, -} from './resolve-theme'; - -export type HostAvatar = - | { kind: 'initial' } - | { kind: 'preset'; id: string } - | { kind: 'image'; uri: string }; - -export type HostBanner = - | { kind: 'accent' } - | { kind: 'color'; color: string } - | { kind: 'gradient'; from: string; to: string } - | { kind: 'image'; uri: string }; - -export type HostLook = { name?: string; avatar: HostAvatar; banner: HostBanner }; +import { contrast, mix, type ColorRole, type ColorScheme } from './resolve-theme'; + +export const HOST_SYMBOLS = { + desktop: { ios: 'desktopcomputer', android: 'computer' }, + laptop: { ios: 'laptopcomputer', android: 'laptop' }, + display: { ios: 'display', android: 'monitor' }, + server: { ios: 'server.rack', android: 'dns' }, + terminal: { ios: 'terminal', android: 'terminal' }, + cpu: { ios: 'cpu', android: 'memory' }, + home: { ios: 'house', android: 'home' }, + office: { ios: 'building.2', android: 'apartment' }, + work: { ios: 'briefcase', android: 'work' }, + lab: { ios: 'flask', android: 'science' }, + game: { ios: 'gamecontroller', android: 'sports_esports' }, + art: { ios: 'paintbrush', android: 'brush' }, + book: { ios: 'book', android: 'menu_book' }, + globe: { ios: 'globe', android: 'public' }, + bolt: { ios: 'bolt', android: 'bolt' }, + star: { ios: 'star', android: 'star' }, + heart: { ios: 'heart', android: 'favorite' }, + leaf: { ios: 'leaf', android: 'eco' }, +} as const; + +export type HostSymbolId = keyof typeof HOST_SYMBOLS; + +export const HOST_SYMBOL_IDS = Object.keys(HOST_SYMBOLS) as HostSymbolId[]; + +export const HOST_EMOJI = [ + '💻', + '🖥️', + '🏠', + '🏢', + '🧪', + '🎮', + '🎨', + '📚', + '🚀', + '⚡', + '🔥', + '⭐', + '🌙', + '☀️', + '🍀', + '🐱', + '🐶', + '🦊', +] as const; + +export type HostIcon = { kind: 'symbol'; id: HostSymbolId } | { kind: 'emoji'; emoji: string }; + +export const HOST_COLORS = { + blue: { light: '#007aff', dark: '#0a84ff' }, + indigo: { light: '#5856d6', dark: '#5e5ce6' }, + purple: { light: '#af52de', dark: '#bf5af2' }, + pink: { light: '#ff2d55', dark: '#ff375f' }, + red: { light: '#ff3b30', dark: '#ff453a' }, + orange: { light: '#ff9500', dark: '#ff9f0a' }, + yellow: { light: '#ffcc00', dark: '#ffd60a' }, + green: { light: '#34c759', dark: '#30d158' }, + teal: { light: '#30b0c7', dark: '#40c8e0' }, + graphite: { light: '#8e8e93', dark: '#98989d' }, +} as const; + +export type HostColorId = keyof typeof HOST_COLORS; + +export const HOST_COLOR_IDS = Object.keys(HOST_COLORS) as HostColorId[]; + +export type HostLook = { name?: string; icon: HostIcon; color?: HostColorId }; export const HOST_NAME_MAX = 40; +export const DEFAULT_HOST_LOOK: HostLook = { icon: { kind: 'symbol', id: 'desktop' } }; + export function hostLookName(name: unknown): string | undefined { if (typeof name !== 'string') return undefined; const trimmed = name.trim().slice(0, HOST_NAME_MAX); return trimmed === '' ? undefined : trimmed; } -export function withHostName(look: HostLook, text: string): HostLook { - const name = hostLookName(text); - return name === undefined - ? { avatar: look.avatar, banner: look.banner } - : { name, avatar: look.avatar, banner: look.banner }; +export function hostLook( + name: string | undefined, + icon: HostIcon, + color: HostColorId | undefined, +): HostLook { + return { + ...(name === undefined ? {} : { name }), + icon, + ...(color === undefined ? {} : { color }), + }; } -export function shownHostName(look: HostLook, hostName: string): string { - return look.name ?? hostName; +export function withHostName(look: HostLook, text: string): HostLook { + return hostLook(hostLookName(text), look.icon, look.color); } -export const DEFAULT_HOST_LOOK: HostLook = { - avatar: { kind: 'initial' }, - banner: { kind: 'accent' }, -}; - -export const HOST_AVATAR_PRESETS = [ - 'sora', - 'studio', - 'ren', - 'nova', - 'kai2', - 'nova2', - 'ember', - 'sora2', -] as const; - -export const BANNER_COLORS = [ - '#3461c1', - '#2f80ed', - '#0f9d8a', - '#2e9e4f', - '#e8a317', - '#e8613c', - '#d6336c', - '#8e44ec', - '#5b5f97', - '#1f2329', -] as const; - -export const BANNER_GRADIENTS = [ - { from: '#4f7cff', to: '#8e44ec' }, - { from: '#ff7a59', to: '#ff3d77' }, - { from: '#12c2e9', to: '#1e6fd9' }, - { from: '#38d39f', to: '#0f8a7e' }, - { from: '#f7b733', to: '#fc4a1a' }, - { from: '#232526', to: '#5b5f97' }, -] as const; - -export const HEX_PLACEHOLDER = '#3461C1'; - -const HEX = /^#[0-9a-f]{6}$/i; +export function withHostIcon(look: HostLook, icon: HostIcon): HostLook { + return hostLook(look.name, icon, look.color); +} -export function bannerHex(value: string): string | undefined { - const trimmed = value.trim().replace(/^#?/, '#').toLowerCase(); - if (/^#[0-9a-f]{3}$/.test(trimmed)) - return `#${Array.from(trimmed.slice(1)) - .map((digit) => digit + digit) - .join('')}`; - return HEX.test(trimmed) ? trimmed : undefined; +export function withHostColor(look: HostLook, color: HostColorId | undefined): HostLook { + return hostLook(look.name, look.icon, color); } -export type HostBand = { - top: string; - bottom: string; - ink: string; - tileInk: string; - lightInk: boolean; - image?: string; - fill?: BandGradient; - shadow?: string; -}; - -export type BandGradient = { - from: string; - to: string; - fromOpacity: number; - toOpacity: number; - direction: 'diagonal' | 'vertical'; -}; - -const INK_LIGHT = '#ffffff'; -const INK_DARK = '#0f1115'; - -function inkFor(stops: readonly string[]): { ink: string; lightInk: boolean } { - const worst = (ink: string) => Math.min(...stops.map((stop) => contrast(stop, ink))); - return worst(INK_LIGHT) >= worst(INK_DARK) - ? { ink: INK_LIGHT, lightInk: true } - : { ink: INK_DARK, lightInk: false }; +export function shownHostName(look: HostLook, hostName: string): string { + return look.name ?? hostName; } -function band( +const GRAPHIC_CONTRAST = 3; + +export function hostColorInk( scheme: ColorScheme, color: Record, - source: string, -): { top: string; bottom: string } { - const own = headerBand(scheme, withAccent(color, source)); - return { top: own.top, bottom: own.bottom }; + id: HostColorId | undefined, +): string { + if (id === undefined) return color.accent; + const source = HOST_COLORS[id][scheme]; + const steps = Array.from({ length: 41 }, (_, step) => step / 40); + const step = + steps.find( + (amount) => contrast(mix(source, color.fg, amount), color.base) >= GRAPHIC_CONTRAST, + ) ?? 1; + return mix(source, color.fg, step); } -export function hostBand( +export function hostTileFill( scheme: ColorScheme, color: Record, - banner: HostBanner, -): HostBand { - if (banner.kind === 'image') { - const fallback = headerBand(scheme, color); - return { - top: fallback.top, - bottom: fallback.bottom, - ink: INK_LIGHT, - tileInk: INK_DARK, - lightInk: true, - image: banner.uri, - fill: { - from: '#000000', - to: '#000000', - fromOpacity: scheme === 'dark' ? 0.5 : 0.35, - toOpacity: scheme === 'dark' ? 0.65 : 0.5, - direction: 'vertical', - }, - shadow: 'rgba(0, 0, 0, 0.6)', - }; - } - if (banner.kind === 'accent') { - const own = headerBand(scheme, color); - return { - top: own.top, - bottom: own.bottom, - ink: color[own.ink], - tileInk: own.top, - lightInk: own.lightInk, - }; - } - const stops = - banner.kind === 'color' - ? band(scheme, color, banner.color) - : { - top: band(scheme, color, banner.from).top, - bottom: band(scheme, color, banner.to).top, - }; - const { ink, lightInk } = inkFor([stops.top, stops.bottom]); - return { ...stops, ink, tileInk: stops.top, lightInk }; + id: HostColorId | undefined, + behind: string, +): string { + if (id === undefined) return behind; + return mix(HOST_COLORS[id][scheme], behind, scheme === 'dark' ? 0.72 : 0.84); } -export function screenBackground(value: HostBand): string { - return `linear-gradient(180deg, ${value.top} 0%, ${value.bottom} 40%)`; +function rgb(hex: string): [number, number, number] { + const value = Number.parseInt(hex.slice(1), 16); + return [(value >> 16) & 0xff, (value >> 8) & 0xff, value & 0xff]; } -export function headerFill(value: HostBand, banner: HostBanner): BandGradient | undefined { - if (banner.kind === 'gradient') - return { - from: value.top, - to: value.bottom, - fromOpacity: 1, - toOpacity: 1, - direction: 'diagonal', - }; - return value.fill; +export function nearestHostColor(hex: string): HostColorId | undefined { + if (!/^#[0-9a-f]{6}$/i.test(hex)) return undefined; + const [r, g, b] = rgb(hex.toLowerCase()); + const distance = (id: HostColorId) => { + const [pr, pg, pb] = rgb(HOST_COLORS[id].light); + return (r - pr) ** 2 + (g - pg) ** 2 + (b - pb) ** 2; + }; + return HOST_COLOR_IDS.reduce((best, id) => (distance(id) < distance(best) ? id : best)); } diff --git a/apps/mobile/src/ui/shell/environment-pager.tsx b/apps/mobile/src/ui/shell/environment-pager.tsx index 6755dc9a32..0b9906531d 100644 --- a/apps/mobile/src/ui/shell/environment-pager.tsx +++ b/apps/mobile/src/ui/shell/environment-pager.tsx @@ -6,6 +6,8 @@ import type { ConversationEnvironment } from '../../host/conversation-environmen import { useDesignTheme } from '../design/theme'; import { edge, environmentTab, space } from '../design/tokens'; import { Text } from '../primitives/text'; +import { hostColorInk } from '../design/host-look'; +import { HostGlyph } from './host-tile'; import { CloudIcon, ComputerIcon } from './icons'; export function EnvironmentPager({ @@ -35,12 +37,20 @@ export function EnvironmentPager({ { accessibilityLabel: route.accessibilityLabel ?? route.title, label: ({ focused }: { focused: boolean }) => { - const Icon = - route.kind === 'cloud' - ? CloudIcon - : route.kind === 'computer' - ? ComputerIcon - : undefined; + const tint = !focused + ? theme.color.muted + : route.hostColor === undefined + ? theme.color.fg + : hostColorInk(theme.scheme, theme.color, route.hostColor); + const size = theme.type.meta.line; + const leading = + route.hostIcon !== undefined ? ( + + ) : route.kind === 'cloud' ? ( + + ) : route.kind === 'computer' ? ( + + ) : null; return ( + {leading === null ? null : {leading}} {route.title} - {Icon ? ( - - - - ) : null} ); }, @@ -95,7 +101,13 @@ export function EnvironmentPager({ paddingVertical: space.x4, }} style={{ backgroundColor: theme.color.base, elevation: 0, shadowOpacity: 0 }} - indicatorStyle={{ backgroundColor: theme.color.accent, height: edge.focus }} + indicatorStyle={{ + backgroundColor: + routes[index]?.hostColor === undefined + ? theme.color.accent + : hostColorInk(theme.scheme, theme.color, routes[index].hostColor), + height: edge.focus, + }} /> )} renderScene={({ route }) => renderPage(route, route.key === routes[index]?.key)} diff --git a/apps/mobile/src/ui/shell/gradient-fill.tsx b/apps/mobile/src/ui/shell/gradient-fill.tsx deleted file mode 100644 index 06e33669fc..0000000000 --- a/apps/mobile/src/ui/shell/gradient-fill.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { useId } from 'react'; -import Svg, { Defs, LinearGradient, Rect, Stop } from 'react-native-svg'; - -import type { BandGradient } from '../design/host-look'; - -export function GradientFill({ gradient }: { gradient: BandGradient }) { - const id = `band-${useId().replace(/[^a-z0-9]/giu, '')}`; - const diagonal = gradient.direction === 'diagonal'; - return ( - - - - - - - - - - ); -} diff --git a/apps/mobile/src/ui/shell/host-band.tsx b/apps/mobile/src/ui/shell/host-band.tsx deleted file mode 100644 index 62e5f81bb7..0000000000 --- a/apps/mobile/src/ui/shell/host-band.tsx +++ /dev/null @@ -1,103 +0,0 @@ -import { useMemo, type ReactNode } from 'react'; -import { Image, View } from 'react-native'; - -import { - headerFill, - type HostAvatar, - hostBand, - screenBackground, - type HostBand, - type HostBanner, -} from '../design/host-look'; -import { useDesignTheme } from '../design/theme'; -import { radius, space } from '../design/tokens'; -import { Text } from '../primitives/text'; -import { GradientFill } from './gradient-fill'; -import { HostTile } from './host-tile'; -import { ChevronDownIcon } from './icons'; - -export function useHostBand(banner: HostBanner): HostBand { - const theme = useDesignTheme(); - return useMemo(() => hostBand(theme.scheme, theme.color, banner), [theme, banner]); -} - -const FILL = { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 } as const; - -export function HostBandLayer({ - band, - banner, - header, - children, - flex = true, -}: { - band: HostBand; - banner: HostBanner; - header: ReactNode; - children: ReactNode; - flex?: boolean; -}) { - const fill = headerFill(band, banner); - return ( - - - {band.image === undefined && fill === undefined ? null : ( - - {band.image === undefined ? null : ( - - )} - {fill === undefined ? null : } - - )} - {header} - - {children} - - ); -} - -export function HostChipFace({ - hostName, - avatar, - band, - singleLine = false, -}: { - hostName: string; - avatar: HostAvatar; - band: HostBand; - singleLine?: boolean; -}) { - const theme = useDesignTheme(); - return ( - <> - - - {hostName} - - - - ); -} diff --git a/apps/mobile/src/ui/shell/host-drawer.tsx b/apps/mobile/src/ui/shell/host-drawer.tsx index e1aaa6a2ee..8098eac454 100644 --- a/apps/mobile/src/ui/shell/host-drawer.tsx +++ b/apps/mobile/src/ui/shell/host-drawer.tsx @@ -36,7 +36,7 @@ import { createHostGlances, liveGlance, type HostStatus } from '../../host/host- import { hostSession, useHostSession, useHostSnapshot, useInbox } from '../../host/host-session'; import { nativeCarrier } from '../../host/native-carrier'; import { useHostLook } from '../../host/native-host-look'; -import { shownHostName, type HostLook } from '../design/host-look'; +import { hostColorInk, hostTileFill, shownHostName, type HostLook } from '../design/host-look'; import { glassShadow, pressTint, useDesignTheme, type DesignTheme } from '../design/theme'; import { useMounted } from '../mounted'; import { drawerSpring, edge, motion, radius, scrim, sidebar, space } from '../design/tokens'; @@ -236,10 +236,14 @@ function DrawerTile({ look, name, current }: { look: HostLook; name: string; cur > ); @@ -475,10 +479,9 @@ function WorkspaceRow({ > diff --git a/apps/mobile/src/ui/shell/host-look-editor.tsx b/apps/mobile/src/ui/shell/host-look-editor.tsx index 09b112bde0..3cbe868d6e 100644 --- a/apps/mobile/src/ui/shell/host-look-editor.tsx +++ b/apps/mobile/src/ui/shell/host-look-editor.tsx @@ -1,101 +1,106 @@ -import { TextInput } from '../primitives/system-text'; -import { TextField } from '../primitives/text-field'; import { useState, type ReactNode } from 'react'; import { Pressable, View } from 'react-native'; -import { KeyboardFormScroll } from '../primitives/keyboard-form'; -import { SvgXml } from 'react-native-svg'; import { - BANNER_COLORS, - BANNER_GRADIENTS, - bannerHex, DEFAULT_HOST_LOOK, - HEX_PLACEHOLDER, - HOST_AVATAR_PRESETS, + HOST_COLOR_IDS, + HOST_COLORS, + HOST_EMOJI, HOST_NAME_MAX, + HOST_SYMBOL_IDS, + hostColorInk, hostLookName, + hostTileFill, shownHostName, + withHostColor, + withHostIcon, withHostName, - type HostAvatar, - type HostBanner, + type HostColorId, + type HostIcon, type HostLook, } from '../design/host-look'; +import { contrast } from '../design/resolve-theme'; import { useDesignTheme } from '../design/theme'; import { edge, radius, space } from '../design/tokens'; -import { Button } from '../primitives/button'; +import type { LayerName } from '../design/layers'; +import { confirmDestructive } from '../primitives/app-dialog'; +import { DrawerHeader } from '../primitives/drawer-header'; +import { KeyboardFormScroll } from '../primitives/keyboard-form'; +import { Segmented } from '../primitives/segmented'; +import { SettingsHeading, SettingsRow, SettingsSection } from '../primitives/settings-row'; import { Text } from '../primitives/text'; -import { Notice } from '../request-parts'; +import { TextField } from '../primitives/text-field'; import { t } from '../strings'; -import { Chip } from '../primitives/chip'; -import { GradientFill } from './gradient-fill'; -import { HostBandLayer, HostChipFace, useHostBand } from './host-band'; -import { hostInitial, HostTile, presetAvatarSvg } from './host-tile'; -import { confirmDestructive } from '../primitives/app-dialog'; +import { HostGlyph } from './host-tile'; +import { CheckIcon } from './icons'; export interface HostLookActions { onChange(look: HostLook): void; - onPickImage(slot: 'avatar' | 'banner'): Promise; onClose(): void; } -type BannerKind = HostBanner['kind']; - -const KINDS: readonly BannerKind[] = ['accent', 'color', 'gradient', 'image']; +type IconSet = HostIcon['kind']; -const KIND_LABEL: Record = { - accent: t.bannerAccent, - color: t.bannerSolid, - gradient: t.bannerGradient, - image: t.bannerImage, -}; +const SHEET_GROUP: LayerName = 'raised'; function Preview({ hostName, look }: { hostName: string; look: HostLook }) { const theme = useDesignTheme(); - const band = useHostBand(look.banner); - return ( - - - - - } + const ink = hostColorInk(theme.scheme, theme.color, look.color); + const tab = (label: string, selected: boolean, leading?: ReactNode) => ( + + - - + {leading} + + {label} + + + ); -} - -function Section({ title, children }: { title: string; children: ReactNode }) { return ( - - - {title} - - {children} + + {tab(t.allEnvironments, false)} + {tab( + hostName, + true, + , + )} ); } @@ -103,42 +108,46 @@ function Section({ title, children }: { title: string; children: ReactNode }) { function Swatch({ label, selected, - round = false, + ring, + fill, + testID, onPress, children, }: { label: string; selected: boolean; - round?: boolean; + ring: string; + fill: string; + testID?: string; onPress(): void; - children: ReactNode; + children?: ReactNode; }) { const theme = useDesignTheme(); - const size = theme.touch + space.x3; + const size = theme.touch; return ( ({ - width: size + space.x3, - height: size + space.x3, - padding: space.x1, - borderRadius: round ? radius.round : radius.md + space.x2, + width: size + space.x2, + height: size + space.x2, + padding: space.x1 / 2, + borderRadius: radius.round, borderWidth: edge.focus, - borderColor: selected ? theme.color.fg : 'transparent', + borderColor: selected ? ring : 'transparent', opacity: pressed ? 0.7 : 1, })} > {children} @@ -147,79 +156,30 @@ function Swatch({ ); } -function Grid({ children }: { children: ReactNode }) { - return {children}; -} - -function HexField({ - label, - value, - onValid, -}: { - label: string; - value: string; - onValid(hex: string): void; -}) { +function Card({ children }: { children: ReactNode }) { const theme = useDesignTheme(); - const [draft, setDraft] = useState(value); - const [shown, setShown] = useState(value); - if (shown !== value) { - setShown(value); - if (bannerHex(draft) !== bannerHex(value)) setDraft(value); - } - const valid = bannerHex(draft) !== undefined; return ( - - - {label} - - - - { - setDraft(text); - const hex = bannerHex(text); - if (hex !== undefined) onValid(hex); - }} - style={{ - flex: 1, - minHeight: theme.touch, - color: theme.color.fg, - fontSize: theme.type.body.size, - fontFamily: theme.mono, - }} - /> - + + {children} ); } +const sameIcon = (a: HostIcon, b: HostIcon) => + a.kind === 'symbol' + ? b.kind === 'symbol' && a.id === b.id + : b.kind === 'emoji' && a.emoji === b.emoji; + export function HostLookEditor({ hostName, look, @@ -230,224 +190,174 @@ export function HostLookEditor({ actions: HostLookActions; }) { const theme = useDesignTheme(); - const [kind, setKind] = useState(look.banner.kind); - const [pickError, setPickError] = useState(false); + const [set, setSet] = useState(look.icon.kind); const [nameDraft, setNameDraft] = useState(look.name ?? ''); const [stored, setStored] = useState(look); if (stored !== look) { setStored(look); - if (look.banner.kind !== stored.banner.kind) setKind(look.banner.kind); + if (look.icon.kind !== stored.icon.kind) setSet(look.icon.kind); if (look.name !== stored.name && hostLookName(nameDraft) !== look.name) setNameDraft(look.name ?? ''); } const shown = shownHostName(look, hostName); - const setAvatar = (avatar: HostAvatar) => actions.onChange({ ...look, avatar }); - const setBanner = (banner: HostBanner) => actions.onChange({ ...look, banner }); - const banner = look.banner; - const color = banner.kind === 'color' ? banner.color : BANNER_COLORS[0]; - const gradient = - banner.kind === 'gradient' ? { from: banner.from, to: banner.to } : BANNER_GRADIENTS[0]; - - const pick = (slot: 'avatar' | 'banner') => { - setPickError(false); - actions.onPickImage(slot).then( - (uri) => { - if (uri === undefined) return; - if (slot === 'avatar') setAvatar({ kind: 'image', uri }); - else setBanner({ kind: 'image', uri }); - }, - () => setPickError(true), - ); - }; - - const choose = (next: BannerKind) => { - setKind(next); - if (next === 'accent') setBanner({ kind: 'accent' }); - if (next === 'color' && banner.kind !== 'color') setBanner({ kind: 'color', color }); - if (next === 'gradient' && banner.kind !== 'gradient') - setBanner({ kind: 'gradient', ...gradient }); - }; + const ink = hostColorInk(theme.scheme, theme.color, look.color); + const tile = hostTileFill(theme.scheme, theme.color, look.color, theme.layer[SHEET_GROUP].inset); + const glyph = look.color === undefined ? theme.color.fg : ink; + const ring = look.color === undefined ? theme.color.fg : ink; + const setIcon = (icon: HostIcon) => actions.onChange(withHostIcon(look, icon)); + const setColor = (color: HostColorId | undefined) => actions.onChange(withHostColor(look, color)); + const iconSize = theme.type.title.line; return ( - - - - {t.hostLook} - - ({ - minWidth: theme.touch, - minHeight: theme.touch, - paddingHorizontal: space.x3, - alignItems: 'center', - justifyContent: 'center', - opacity: pressed ? 0.7 : 1, - })} - > - - {t.done} - - + + + - + + -
- { - setNameDraft(text); - actions.onChange(withHostName(look, text)); - }} - /> -
+ + {t.hostLookName} + { + setNameDraft(text); + actions.onChange(withHostName(look, text)); + }} + /> + + + + {t.hostIcon} + + label={t.hostIcon} + on={SHEET_GROUP} + value={set} + onChange={setSet} + options={[ + { value: 'symbol', label: t.hostIconSymbols }, + { value: 'emoji', label: t.hostIconEmoji }, + ]} + /> + + {set === 'symbol' + ? HOST_SYMBOL_IDS.map((id) => { + const icon: HostIcon = { kind: 'symbol', id }; + const selected = sameIcon(look.icon, icon); + return ( + setIcon(icon)} + > + + + ); + }) + : HOST_EMOJI.map((emoji) => { + const icon: HostIcon = { kind: 'emoji', emoji }; + const selected = sameIcon(look.icon, icon); + return ( + setIcon(icon)} + > + + + ); + })} + + -
- - setAvatar({ kind: 'initial' })} - > - {hostInitial(shown)} - - {HOST_AVATAR_PRESETS.map((id, index) => ( + + {t.hostAccent} + setAvatar({ kind: 'preset', id })} + testID="host-color-default" + label={t.hostColorDefault} + selected={look.color === undefined} + ring={theme.color.fg} + fill={theme.color.accent} + onPress={() => setColor(undefined)} > - + {look.color === undefined ? ( + + ) : null} - ))} - pick('avatar')} - > - {look.avatar.kind === 'image' ? ( - - ) : ( - - + - - )} - - -
- -
- - {KINDS.map((option) => ( - choose(option)} - /> - ))} - - - {kind === 'color' ? ( - <> - - {BANNER_COLORS.map((hex) => ( - setBanner({ kind: 'color', color: hex })} - > - - - ))} - - setBanner({ kind: 'color', color: hex })} - /> - - ) : null} - - {kind === 'gradient' ? ( - <> - - {BANNER_GRADIENTS.map((stops) => ( + {HOST_COLOR_IDS.map((id) => { + const swatch = HOST_COLORS[id][theme.scheme]; + const selected = look.color === id; + return ( setBanner({ kind: 'gradient', ...stops })} + key={id} + testID={`host-color-${id}`} + label={t.hostColorName[id]} + selected={selected} + ring={hostColorInk(theme.scheme, theme.color, id)} + fill={swatch} + onPress={() => setColor(id)} > - + {selected ? ( + contrast(swatch, theme.color.fg) + ? theme.color.base + : theme.color.fg + } + size={iconSize} + /> + ) : null} - ))} - - - setBanner({ kind: 'gradient', from, to: gradient.to })} - /> - setBanner({ kind: 'gradient', from: gradient.from, to })} - /> - - - ) : null} + ); + })} + + + {t.hostColorHint} + + - {kind === 'image' ? ( -
- - {pickError ? {t.hostLookPickFailed} : null} - -