diff --git a/.github/pr-screenshots/2342-android-material/activity-filter-dark.png b/.github/pr-screenshots/2342-android-material/activity-filter-dark.png
new file mode 100644
index 0000000000..871f7e0258
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/activity-filter-dark.png differ
diff --git a/.github/pr-screenshots/2342-android-material/activity-filter-font200-light.png b/.github/pr-screenshots/2342-android-material/activity-filter-font200-light.png
new file mode 100644
index 0000000000..0fd2bf289c
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/activity-filter-font200-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/activity-filter-light.png b/.github/pr-screenshots/2342-android-material/activity-filter-light.png
new file mode 100644
index 0000000000..19a4721883
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/activity-filter-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/activity-unread-off-dark.png b/.github/pr-screenshots/2342-android-material/activity-unread-off-dark.png
new file mode 100644
index 0000000000..1f8774bcf2
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/activity-unread-off-dark.png differ
diff --git a/.github/pr-screenshots/2342-android-material/activity-unread-on-light.png b/.github/pr-screenshots/2342-android-material/activity-unread-on-light.png
new file mode 100644
index 0000000000..2a6069b63f
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/activity-unread-on-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/bg-slider-dragged-dark.png b/.github/pr-screenshots/2342-android-material/bg-slider-dragged-dark.png
new file mode 100644
index 0000000000..04bc6e1776
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/bg-slider-dragged-dark.png differ
diff --git a/.github/pr-screenshots/2342-android-material/bg-slider-dragged-light.png b/.github/pr-screenshots/2342-android-material/bg-slider-dragged-light.png
new file mode 100644
index 0000000000..5b1a843401
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/bg-slider-dragged-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/bg-top-dark.png b/.github/pr-screenshots/2342-android-material/bg-top-dark.png
new file mode 100644
index 0000000000..a6a1aee9ac
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/bg-top-dark.png differ
diff --git a/.github/pr-screenshots/2342-android-material/bg-top-light.png b/.github/pr-screenshots/2342-android-material/bg-top-light.png
new file mode 100644
index 0000000000..1e94a70a5d
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/bg-top-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/look-chips-dark.png b/.github/pr-screenshots/2342-android-material/look-chips-dark.png
new file mode 100644
index 0000000000..ba25412a4b
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/look-chips-dark.png differ
diff --git a/.github/pr-screenshots/2342-android-material/look-chips-light.png b/.github/pr-screenshots/2342-android-material/look-chips-light.png
new file mode 100644
index 0000000000..e25c356513
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/look-chips-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/phone/activity-filter-dark.png b/.github/pr-screenshots/2342-android-material/phone/activity-filter-dark.png
new file mode 100644
index 0000000000..00c1be23a2
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/phone/activity-filter-dark.png differ
diff --git a/.github/pr-screenshots/2342-android-material/phone/activity-filter-font200-light.png b/.github/pr-screenshots/2342-android-material/phone/activity-filter-font200-light.png
new file mode 100644
index 0000000000..c857a31acf
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/phone/activity-filter-font200-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/phone/activity-filter-light.png b/.github/pr-screenshots/2342-android-material/phone/activity-filter-light.png
new file mode 100644
index 0000000000..e6ac8da080
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/phone/activity-filter-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/phone/activity-unread-off-dark.png b/.github/pr-screenshots/2342-android-material/phone/activity-unread-off-dark.png
new file mode 100644
index 0000000000..00c1be23a2
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/phone/activity-unread-off-dark.png differ
diff --git a/.github/pr-screenshots/2342-android-material/phone/activity-unread-on-light.png b/.github/pr-screenshots/2342-android-material/phone/activity-unread-on-light.png
new file mode 100644
index 0000000000..d6e21fd8fa
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/phone/activity-unread-on-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/phone/bg-slider-dragged-dark.png b/.github/pr-screenshots/2342-android-material/phone/bg-slider-dragged-dark.png
new file mode 100644
index 0000000000..89d50ee919
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/phone/bg-slider-dragged-dark.png differ
diff --git a/.github/pr-screenshots/2342-android-material/phone/bg-slider-dragged-light.png b/.github/pr-screenshots/2342-android-material/phone/bg-slider-dragged-light.png
new file mode 100644
index 0000000000..11e72ec9b5
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/phone/bg-slider-dragged-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/phone/bg-top-dark.png b/.github/pr-screenshots/2342-android-material/phone/bg-top-dark.png
new file mode 100644
index 0000000000..47e643af74
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/phone/bg-top-dark.png differ
diff --git a/.github/pr-screenshots/2342-android-material/phone/bg-top-light.png b/.github/pr-screenshots/2342-android-material/phone/bg-top-light.png
new file mode 100644
index 0000000000..b46a288080
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/phone/bg-top-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/phone/look-chips-dark.png b/.github/pr-screenshots/2342-android-material/phone/look-chips-dark.png
new file mode 100644
index 0000000000..dcac2e6771
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/phone/look-chips-dark.png differ
diff --git a/.github/pr-screenshots/2342-android-material/phone/look-chips-light.png b/.github/pr-screenshots/2342-android-material/phone/look-chips-light.png
new file mode 100644
index 0000000000..02b54d0d7b
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/phone/look-chips-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/phone/routine-chips-dark.png b/.github/pr-screenshots/2342-android-material/phone/routine-chips-dark.png
new file mode 100644
index 0000000000..40ddd5bd82
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/phone/routine-chips-dark.png differ
diff --git a/.github/pr-screenshots/2342-android-material/phone/routine-chips-light.png b/.github/pr-screenshots/2342-android-material/phone/routine-chips-light.png
new file mode 100644
index 0000000000..65204d71e5
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/phone/routine-chips-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/phone/usage-dark.png b/.github/pr-screenshots/2342-android-material/phone/usage-dark.png
new file mode 100644
index 0000000000..58009b018f
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/phone/usage-dark.png differ
diff --git a/.github/pr-screenshots/2342-android-material/phone/usage-font200-light.png b/.github/pr-screenshots/2342-android-material/phone/usage-font200-light.png
new file mode 100644
index 0000000000..1eaf4e1ee1
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/phone/usage-font200-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/phone/usage-light.png b/.github/pr-screenshots/2342-android-material/phone/usage-light.png
new file mode 100644
index 0000000000..4f67d4b9df
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/phone/usage-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/routine-chips-dark.png b/.github/pr-screenshots/2342-android-material/routine-chips-dark.png
new file mode 100644
index 0000000000..9186f9b3e5
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/routine-chips-dark.png differ
diff --git a/.github/pr-screenshots/2342-android-material/routine-chips-light.png b/.github/pr-screenshots/2342-android-material/routine-chips-light.png
new file mode 100644
index 0000000000..6a6371c2c4
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/routine-chips-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/usage-dark.png b/.github/pr-screenshots/2342-android-material/usage-dark.png
new file mode 100644
index 0000000000..e2d3cca0cb
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/usage-dark.png differ
diff --git a/.github/pr-screenshots/2342-android-material/usage-font200-light.png b/.github/pr-screenshots/2342-android-material/usage-font200-light.png
new file mode 100644
index 0000000000..ef5a016522
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/usage-font200-light.png differ
diff --git a/.github/pr-screenshots/2342-android-material/usage-light.png b/.github/pr-screenshots/2342-android-material/usage-light.png
new file mode 100644
index 0000000000..118f7f0426
Binary files /dev/null and b/.github/pr-screenshots/2342-android-material/usage-light.png differ
diff --git a/apps/mobile/DESIGN.md b/apps/mobile/DESIGN.md
index d972de6c7f..a2c0d970e4 100644
--- a/apps/mobile/DESIGN.md
+++ b/apps/mobile/DESIGN.md
@@ -44,7 +44,7 @@ Build a ⋯ menu with `ActionMenuButton` (`src/ui/primitives/action-menu-button`
- Activity has two header entries: **Filter and sort** and **Search Activity**. Sorting is part of the same options sheet as category, unread-only, Bot and conversation filters.
- iOS uses native navigation toolbar buttons: the system supplies Liquid Glass on iOS 26 and its supported appearance on earlier versions. Active search replaces the title, Filter and Search buttons with the same header search field as Chats, in the measured header row, so accessibility text can grow without clipping. Android uses opaque Material-style icon actions and its native text input.
-- The iOS options sheet uses system page-sheet presentation with swipe dismissal, inset grouped rows and trailing checkmarks. Android uses the modal bottom-sheet surface, leading radio indicators and system Back dismissal. Unread-only uses a native switch on each platform. Long option lists virtualize and scroll; footer actions remain reachable.
+- The iOS options sheet uses system page-sheet presentation with swipe dismissal, inset grouped rows and trailing checkmarks. Android uses the modal bottom-sheet surface, leading Material 3 radio buttons (Compose `RadioButton` through the `RadioMark` primitive) and system Back dismissal. Unread-only uses the `Toggle` primitive, so each platform gets its native switch. Long option lists virtualize and scroll; footer actions remain reachable.
- Options apply immediately and remain selected after swipe dismissal or Android Back; there are no Cancel/Done actions. Reset all immediately restores default ordering and the Needs you tab, with all Bots/conversations and unread-only off. Search is independent of this reset. The search field keeps the header's outer gutters; iOS search keeps its built-in clear control. Tapping blank list space or ending editing returns the header to its title and buttons and preserves the query for reopening, with the Search button tinted while a query applies, so Filter and sort stay reachable during a search. The close button (iOS) or back arrow and system Back (Android) clears the query. The focused Activity screen owns status-bar contrast for its current appearance.
References: [Apple toolbars](https://developer.apple.com/design/human-interface-guidelines/toolbars), [Apple sheets](https://developer.apple.com/design/human-interface-guidelines/sheets), [Material bottom sheets](https://m3.material.io/components/bottom-sheets/guidelines), [Android radio selection](https://developer.android.com/develop/ui/compose/components/radio-button).
@@ -299,7 +299,7 @@ Each layer has `fill`, `pressed`, `selected` (neutral, such as the current tab),
- A drawer owns one `SheetStack`: its handle stays fixed while secondary pages push/back inside the same native sheet. Global usage, App icon and notifications, profile model/workspace/notifications, routine detail/create/edit, Token detail and memory files share this navigation. Child headers consume no second status-bar inset; headers and bodies use `theme.overlay.fill`, with raised content groups. Editors reuse their existing validation and Host mutation ports.
- Profile token totals retain reported usage when other calls are unknown, using the global Settings count format (`674.7K+`, for example). Completely unreported usage remains unknown; an idle, fully reported window may show zero.
- `src/ui/design/` holds the tokens and theme (ADR-0201).
-- `src/ui/primitives/` holds `Text` (variant `meta` / `body` / `title`, and a tone that is a colour role), `Button`, `Toggle`, `SettingsRow`, `SettingsSection` and `SettingsGroupItem`, `CountBadge`, `Segmented` (the native segmented control: a SwiftUI segmented `Picker` on iOS, a Material 3 `SingleChoiceSegmentedButtonRow` on Android; each label is one short word so no segment wraps), `DayBars` (one bar per day or week, scaled to the busiest, optionally stacked in tones from `design/chart.ts`; an empty day keeps a stub on the layer's `inset`), `DayHeat` (a weeks × weekdays heatmap), and later `Icon`, `IconButton`, `Button`, `Avatar`, `Card`, `SettingsRow` and `EmptyState`.
+- `src/ui/primitives/` holds `Text` (variant `meta` / `body` / `title`, and a tone that is a colour role), `Button`, `Toggle`, `SettingsRow`, `SettingsSection` and `SettingsGroupItem`, `CountBadge`, `Segmented` (the native segmented control: a SwiftUI segmented `Picker` on iOS, a Material 3 `SingleChoiceSegmentedButtonRow` on Android with single-line labels; on Android, when the labels cannot fit on one row at the current system text size it becomes a radio list of the same options, never a wrapped or clipped segment), `PercentageSlider` (a 0–100 slider; Compose `Slider` on Android), `Chip` (a single-choice chip; Compose `FilterChip` on Android), `RadioMark` (a decorative leading radio for a row that owns the radio semantics; Compose `RadioButton` on Android), `DayBars` (one bar per day or week, scaled to the busiest, optionally stacked in tones from `design/chart.ts`; an empty day keeps a stub on the layer's `inset`), `DayHeat` (a weeks × weekdays heatmap), and later `Icon`, `IconButton`, `Button`, `Avatar`, `Card`, `SettingsRow` and `EmptyState`.
- Forms use `TextField` from `primitives/text-field`: the `field` layer, a hairline `field` edge, `radius.md`, a touch-height minimum (two lines when multiline) and the system clear button on single-line fields. Give every field a placeholder or a visible label, and the keyboard and content type its value needs (`url`, `emailAddress`). `SearchField` leads with a magnifying glass and relies on the native iOS clear button; Android, which has none, adds its own.
- Follow the HIG for alerts and action sheets. An action that can't be undone (unpair, remove access, revoke, sign out, reset) asks first through `confirmDestructive`: a title that names the action, Cancel first, then the destructive button. A short list of actions on one item uses `showActionMenu`, which on iOS is an action sheet with the destructive action last and Cancel set apart; never show such a list as a centered alert.
- `src/ui/chat/` will hold the conversation row, bubble, message group, time separator, action cards, composer, working status and scroll-to-bottom.
diff --git a/apps/mobile/src/ui/primitives/chip.android.tsx b/apps/mobile/src/ui/primitives/chip.android.tsx
new file mode 100644
index 0000000000..f3a5234420
--- /dev/null
+++ b/apps/mobile/src/ui/primitives/chip.android.tsx
@@ -0,0 +1,39 @@
+import { FilterChip, Host, Text as ComposeText } from '@expo/ui/jetpack-compose';
+import { View } from 'react-native';
+
+import { useDesignTheme } from '../design/theme';
+
+export function Chip({
+ label,
+ count,
+ selected,
+ onPress,
+}: {
+ label: string;
+ count?: number;
+ selected: boolean;
+ onPress(): void;
+}) {
+ const theme = useDesignTheme();
+ return (
+
+
+
+
+ {count === undefined ? label : `${label} ${count}`}
+
+
+
+
+ );
+}
diff --git a/apps/mobile/src/ui/primitives/percentage-slider.android.tsx b/apps/mobile/src/ui/primitives/percentage-slider.android.tsx
new file mode 100644
index 0000000000..79d62628a7
--- /dev/null
+++ b/apps/mobile/src/ui/primitives/percentage-slider.android.tsx
@@ -0,0 +1,55 @@
+import { Host, Slider } from '@expo/ui/jetpack-compose';
+import { View } from 'react-native';
+
+import { useDesignTheme } from '../design/theme';
+
+export function PercentageSlider({
+ label,
+ value,
+ onChange,
+}: {
+ label: string;
+ value: number;
+ onChange(value: number): void;
+}) {
+ const theme = useDesignTheme();
+ return (
+
+ onChange(
+ Math.max(
+ 0,
+ Math.min(100, value + (event.nativeEvent.actionName === 'increment' ? 5 : -5)),
+ ),
+ )
+ }
+ style={{ minHeight: theme.touch, justifyContent: 'center' }}
+ >
+
+
+ onChange(Math.round(next))}
+ colors={{
+ thumbColor: theme.color.accent,
+ activeTrackColor: theme.color.accent,
+ inactiveTrackColor: theme.layer.raised.inset,
+ }}
+ />
+
+
+
+ );
+}
diff --git a/apps/mobile/src/ui/primitives/radio-mark.android.tsx b/apps/mobile/src/ui/primitives/radio-mark.android.tsx
new file mode 100644
index 0000000000..7ea2b561ba
--- /dev/null
+++ b/apps/mobile/src/ui/primitives/radio-mark.android.tsx
@@ -0,0 +1,18 @@
+import { Host, RadioButton } from '@expo/ui/jetpack-compose';
+import { View } from 'react-native';
+
+import { useDesignTheme } from '../design/theme';
+
+export function RadioMark({ selected }: { selected: boolean }) {
+ const theme = useDesignTheme();
+ return (
+
+
+
+
+
+ );
+}
diff --git a/apps/mobile/src/ui/primitives/radio-mark.tsx b/apps/mobile/src/ui/primitives/radio-mark.tsx
new file mode 100644
index 0000000000..d256e3cd0d
--- /dev/null
+++ b/apps/mobile/src/ui/primitives/radio-mark.tsx
@@ -0,0 +1,32 @@
+import { View } from 'react-native';
+
+import { useDesignTheme } from '../design/theme';
+import { edge, radius, space } from '../design/tokens';
+
+export function RadioMark({ selected }: { selected: boolean }) {
+ const theme = useDesignTheme();
+ return (
+
+ {selected ? (
+
+ ) : null}
+
+ );
+}
diff --git a/apps/mobile/src/ui/primitives/segmented.android.tsx b/apps/mobile/src/ui/primitives/segmented.android.tsx
index 006e51f461..2c302cb349 100644
--- a/apps/mobile/src/ui/primitives/segmented.android.tsx
+++ b/apps/mobile/src/ui/primitives/segmented.android.tsx
@@ -2,30 +2,99 @@ import {
Host,
SegmentedButton,
SingleChoiceSegmentedButtonRow,
- Text,
+ Text as ComposeText,
} from '@expo/ui/jetpack-compose';
import { fillMaxWidth } from '@expo/ui/jetpack-compose/modifiers';
-import { View } from 'react-native';
+import { Pressable, View, useWindowDimensions } from 'react-native';
-import { useDesignTheme } from '../design/theme';
+import { pressTint, useDesignTheme } from '../design/theme';
+import { radius, space } from '../design/tokens';
+import { RadioMark } from './radio-mark';
import type { SegmentedProps } from './segmented';
+import { Text } from './text';
+
+const LABEL_SIZE = 14;
+const SEGMENT_PADDING = 24;
+const CHECK_WIDTH = 26;
+
+function labelWidth(text: string, fontScale: number): number {
+ let ems = 0;
+ for (const char of text) ems += (char.codePointAt(0) ?? 0) >= 0x2e80 ? 1 : 0.5;
+ return ems * LABEL_SIZE * fontScale;
+}
+
+export function segmentsFit(labels: readonly string[], width: number, fontScale: number): boolean {
+ const widest = Math.max(0, ...labels.map((text) => labelWidth(text, fontScale)));
+ return labels.length * (widest + SEGMENT_PADDING) + CHECK_WIDTH <= width - space.x5 * 2;
+}
export function Segmented({
label,
options,
value,
+ on = 'canvas',
onChange,
}: SegmentedProps) {
const theme = useDesignTheme();
+ const layer = theme.layer[on];
+ const { width, fontScale } = useWindowDimensions();
+ if (
+ !segmentsFit(
+ options.map((option) => option.label),
+ width,
+ fontScale,
+ )
+ )
+ return (
+
+ {options.map((option, index) => {
+ const selected = option.value === value;
+ const top = index === 0 ? radius.lg : radius.xs;
+ const bottom = index === options.length - 1 ? radius.lg : radius.xs;
+ return (
+ {
+ if (!selected) onChange(option.value);
+ }}
+ android_ripple={{ color: pressTint(theme.color.fg) }}
+ style={{
+ minHeight: theme.touch,
+ flexDirection: 'row',
+ alignItems: 'center',
+ gap: space.x4,
+ paddingHorizontal: space.x5,
+ paddingVertical: space.x3,
+ overflow: 'hidden',
+ borderTopLeftRadius: top,
+ borderTopRightRadius: top,
+ borderBottomLeftRadius: bottom,
+ borderBottomRightRadius: bottom,
+ backgroundColor: selected ? layer.chosen : layer.fill,
+ }}
+ >
+
+ {option.label}
+
+ );
+ })}
+
+ );
return (
-
+
-
+ option.value).join('\n')}
+ modifiers={[fillMaxWidth()]}
+ >
{options.map((option) => (
({
onClick={() => {
if (option.value !== value) onChange(option.value);
}}
+ colors={{
+ activeContainerColor: layer.chosen,
+ activeContentColor: theme.color.fg,
+ activeBorderColor: theme.color.muted,
+ inactiveContainerColor: 'transparent',
+ inactiveContentColor: theme.color.fg,
+ inactiveBorderColor: theme.color.muted,
+ }}
>
- {option.label}
+
+ {option.label}
+
))}
diff --git a/apps/mobile/src/ui/shell/activity-filters.tsx b/apps/mobile/src/ui/shell/activity-filters.tsx
index 209ff16412..deb19a82d3 100644
--- a/apps/mobile/src/ui/shell/activity-filters.tsx
+++ b/apps/mobile/src/ui/shell/activity-filters.tsx
@@ -1,5 +1,5 @@
import type { ReactNode } from 'react';
-import { FlatList, Modal, Platform, Pressable, Switch, View } from 'react-native';
+import { FlatList, Modal, Platform, Pressable, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { INBOX_SECTIONS, type InboxSection, type InboxSetAside } from '../../host/inbox';
@@ -7,7 +7,9 @@ import { Sheet } from '../chat/sheet';
import { useDesignTheme } from '../design/theme';
import { edge, radius, space } from '../design/tokens';
import { DrawerHeader } from '../primitives/drawer-header';
+import { RadioMark } from '../primitives/radio-mark';
import { Text } from '../primitives/text';
+import { Toggle } from '../primitives/toggle';
import { CheckIcon } from './icons';
import { t } from '../strings';
@@ -71,30 +73,7 @@ function Selection({ selected }: { selected: boolean }) {
const theme = useDesignTheme();
if (Platform.OS === 'ios')
return selected ? : null;
- return (
-
- {selected ? (
-
- ) : null}
-
- );
+ return ;
}
function OptionsEditor({ bots, channels, filter, sort, onFilter, onSort, onClose }: Props) {
@@ -229,11 +208,11 @@ function OptionsEditor({ bots, channels, filter, sort, onFilter, onSort, onClose
}}
>
{t.activityUnreadOnly}
- onFilter({ ...filter, unreadOnly })}
- trackColor={{ true: theme.color.accent }}
+ on="raised"
+ onChange={(unreadOnly) => onFilter({ ...filter, unreadOnly })}
/>
);
diff --git a/apps/mobile/test/material-controls-android.test.tsx b/apps/mobile/test/material-controls-android.test.tsx
new file mode 100644
index 0000000000..ff619a7e66
--- /dev/null
+++ b/apps/mobile/test/material-controls-android.test.tsx
@@ -0,0 +1,195 @@
+// @vitest-environment jsdom
+import { act, createElement, useState, type ReactNode } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, expect, it, vi } from 'vitest';
+
+const screen = vi.hoisted(() => ({ width: 411, height: 914, scale: 3, fontScale: 1 }));
+vi.mock('react-native', async () => ({
+ ...(await import('./react-native-shim')),
+ useWindowDimensions: () => screen,
+ Platform: { OS: 'android' },
+ View: (props: {
+ children?: ReactNode;
+ accessibilityRole?: string;
+ accessibilityLabel?: string;
+ accessibilityValue?: { text?: string };
+ importantForAccessibility?: string;
+ onAccessibilityAction?(event: { nativeEvent: { actionName: string } }): void;
+ }) =>
+ createElement(
+ 'div',
+ {
+ role: props.accessibilityRole,
+ 'aria-label': props.accessibilityLabel,
+ 'aria-valuetext': props.accessibilityValue?.text,
+ 'aria-hidden': props.importantForAccessibility === 'no-hide-descendants',
+ onKeyDown: (event: { key: string }) =>
+ props.onAccessibilityAction?.({
+ nativeEvent: { actionName: event.key === 'ArrowUp' ? 'increment' : 'decrement' },
+ }),
+ },
+ props.children,
+ ),
+}));
+const rows = vi.hoisted(() => new Set());
+vi.mock('@expo/ui/jetpack-compose', async () => {
+ const { useRef } = await import('react');
+ return {
+ Host: ({ children }: { children: ReactNode }) => children,
+ Text: ({ children }: { children: ReactNode }) => createElement('span', {}, children),
+ SingleChoiceSegmentedButtonRow: ({ children }: { children: ReactNode }) => {
+ const row = useRef(Symbol('row'));
+ rows.add(row.current);
+ return createElement('div', { 'data-testid': 'segmented-row' }, children);
+ },
+ SegmentedButton: Object.assign(
+ (props: { selected: boolean; onClick(): void; children: ReactNode }) =>
+ createElement(
+ 'button',
+ { 'data-testid': 'segment', 'aria-pressed': props.selected, onClick: props.onClick },
+ props.children,
+ ),
+ { Label: ({ children }: { children: ReactNode }) => children },
+ ),
+ Slider: (props: { value: number; onValueChange(value: number): void }) =>
+ createElement('input', {
+ 'data-testid': 'native-slider',
+ value: props.value,
+ onChange: (event: { target: { value: string } }) =>
+ props.onValueChange(Number(event.target.value)),
+ }),
+ RadioButton: (props: { selected: boolean }) =>
+ createElement('i', { 'data-testid': 'native-radio', 'data-selected': props.selected }),
+ };
+});
+vi.mock('../src/ui/primitives/radio-mark', () => import('../src/ui/primitives/radio-mark.android'));
+vi.mock('@expo/ui/jetpack-compose/modifiers', () => ({ fillMaxWidth: () => ({}) }));
+
+import { PercentageSlider } from '../src/ui/primitives/percentage-slider.android';
+import { RadioMark } from '../src/ui/primitives/radio-mark.android';
+import { Segmented, segmentsFit } from '../src/ui/primitives/segmented.android';
+
+Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
+let root: Root | undefined;
+let host: HTMLElement | undefined;
+afterEach(() => {
+ act(() => root?.unmount());
+ host?.remove();
+});
+async function mount(node: ReactNode) {
+ host = document.createElement('div');
+ document.body.append(host);
+ root = createRoot(host);
+ await act(async () => root!.render(node));
+ return host;
+}
+
+it('renders Segmented as Material segmented buttons and only reports a new choice', async () => {
+ const changed = vi.fn();
+ function Period() {
+ const [value, setValue] = useState<'day' | 'week'>('day');
+ return (
+ {
+ changed(next);
+ setValue(next);
+ }}
+ />
+ );
+ }
+ const view = await mount();
+ expect(view.querySelector('[role="radiogroup"][aria-label="Period"]')).not.toBeNull();
+ const [today, week] = [...view.querySelectorAll('[data-testid="segment"]')];
+ expect(today!.getAttribute('aria-pressed')).toBe('true');
+ await act(async () => today!.click());
+ expect(changed).not.toHaveBeenCalled();
+ await act(async () => week!.click());
+ expect(changed.mock.calls).toEqual([['week']]);
+ expect(week!.getAttribute('aria-pressed')).toBe('true');
+});
+
+it('drives PercentageSlider from the native slider and from accessibility steps', async () => {
+ const changed = vi.fn();
+ function Dim() {
+ const [value, setValue] = useState(40);
+ return (
+ {
+ changed(next);
+ setValue(next);
+ }}
+ />
+ );
+ }
+ const view = await mount();
+ const control = view.querySelector('[role="adjustable"][aria-label="Dim"]')!;
+ expect(control.getAttribute('aria-valuetext')).toBe('40%');
+ await act(async () =>
+ control.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowUp', bubbles: true })),
+ );
+ expect(control.getAttribute('aria-valuetext')).toBe('45%');
+ expect(
+ view.querySelector('[data-testid="native-slider"]')!.closest('[aria-hidden="true"]'),
+ ).not.toBeNull();
+ expect(changed.mock.calls).toEqual([[45]]);
+});
+
+it('hides the decorative Material radio from accessibility', async () => {
+ const view = await mount();
+ const radio = view.querySelector('[data-testid="native-radio"]')!;
+ expect(radio.getAttribute('data-selected')).toBe('true');
+ expect(radio.closest('[aria-hidden="true"]')).not.toBeNull();
+});
+
+it('rebuilds the native segmented row when the option set changes, so each segment gets its new shape', async () => {
+ const options = (extended: boolean) => [
+ { value: 'today', label: 'Today' },
+ { value: 'week', label: '7 days' },
+ ...(extended ? [{ value: 'month', label: '4 weeks' }] : []),
+ ];
+ const render = (extended: boolean) => (
+ {}} />
+ );
+ const view = await mount(render(false));
+ rows.clear();
+ await act(async () => root!.render(render(false)));
+ const steady = rows.size;
+ await act(async () => root!.render(render(true)));
+ expect(view.querySelectorAll('[data-testid="segment"]')).toHaveLength(3);
+ expect(rows.size).toBe(steady + 1);
+});
+
+it('turns Segmented into a radio list when the labels cannot fit on one line', async () => {
+ const periods = ['Today', '7 days', '4 weeks', '12 weeks'];
+ expect(segmentsFit(periods, 411, 1)).toBe(true);
+ expect(segmentsFit(periods, 411, 2)).toBe(false);
+ screen.fontScale = 2;
+ try {
+ const changed = vi.fn();
+ const view = await mount(
+ ({ value: String(index), label }))}
+ onChange={changed}
+ />,
+ );
+ expect(view.querySelector('[data-testid="segmented-row"]')).toBeNull();
+ expect(view.querySelectorAll('[data-testid="native-radio"]')).toHaveLength(4);
+ const week = [...view.querySelectorAll('button')].find(
+ (button) => button.getAttribute('aria-label') === '12 weeks',
+ );
+ await act(async () => week!.click());
+ expect(changed).toHaveBeenCalledWith('3');
+ } finally {
+ screen.fontScale = 1;
+ }
+});
diff --git a/changes/2342-android-material-controls.md b/changes/2342-android-material-controls.md
new file mode 100644
index 0000000000..ece7ffe321
--- /dev/null
+++ b/changes/2342-android-material-controls.md
@@ -0,0 +1,11 @@
+---
+section: Changed
+---
+
+## en
+
+- On Android, the mobile app's segmented switches, sliders, choice chips, Activity option radios and the Unread only switch now use native Material 3 controls ([#2342](https://github.com/BotHarness/DeepSeekBot/pull/2342)).
+
+## zh
+
+- Android 手机端的分段切换、滑块、选择 Chip、活动筛选的单选项和“只看未读”开关改用原生 Material 3 控件([#2342](https://github.com/BotHarness/DeepSeekBot/pull/2342))。