Skip to content
TypeScript

refactor(mobile): adopt shared controls and add component catalog (#18541)

Julius Marmingee64cee0a92ea
diff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsx
index 4dfa3f3a985..8a16c17bc2b 100644
--- a/apps/mobile/src/Stack.tsx
+++ b/apps/mobile/src/Stack.tsx
@@ -1,3 +1,4 @@
+import { ComponentCatalogScreen } from "./features/development/ComponentCatalogScreen";
import { PullRequestGuideStopScreen } from "./features/pull-requests/guide/PullRequestGuideScreen";
import { PullRequestInlineCommentScreen } from "./features/pull-requests/PullRequestInlineCommentScreen";
import { PullRequestDiscussionScreen } from "./features/pull-requests/PullRequestDiscussionScreen";
@@ -716,6 +717,15 @@ const RootStackConfig = createWorkspaceStackNavigator({
headerShown: false,
},
screens: {
+ ...(__DEV__
+ ? {
+ ComponentCatalog: createNativeStackScreen({
+ screen: ComponentCatalogScreen,
+ linking: "dev/components",
+ options: { title: "UI components" },
+ }),
+ }
+ : {}),
Home: createNativeStackScreen({
screen: WorkspaceRootScreen,
linking: "",
diff --git a/apps/mobile/src/components/Button.android.tsx b/apps/mobile/src/components/Button.android.tsx
index 1d891903421..7c0fcf45bcb 100644
--- a/apps/mobile/src/components/Button.android.tsx
+++ b/apps/mobile/src/components/Button.android.tsx
@@ -13,13 +13,13 @@ import {
import { defaultMinSize, fillMaxWidth, size } from "@expo/ui/jetpack-compose/modifiers";
import { View } from "react-native";
-import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
+import { useControlTheme } from "./useControlTheme";
import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
import type { ButtonProps } from "./Button";
import { useAndroidControlSizing } from "./useAndroidControlSizing";
export function Button(props: ButtonProps) {
- const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
+ const { colorScheme, colors } = useControlTheme();
const typography = useScaledTextRole("footnote");
const { scale, mediumIconSize } = useAndroidControlSizing();
const tone = props.tone ?? "secondary";
@@ -64,7 +64,7 @@ export function Button(props: ButtonProps) {
<View importantForAccessibility="no-hide-descendants">
<Host
matchContents={props.fullWidth ? { vertical: true } : true}
- colorScheme={themeAppearance}
+ colorScheme={colorScheme}
ignoreSafeAreaKeyboardInsets
style={props.fullWidth ? { width: "100%" } : { alignSelf: "flex-start" }}
>
diff --git a/apps/mobile/src/components/Chip.tsx b/apps/mobile/src/components/Chip.tsx
new file mode 100644
index 00000000000..9f46e7ffd3b
--- /dev/null
+++ b/apps/mobile/src/components/Chip.tsx
@@ -0,0 +1,90 @@
+import { GlassView } from "expo-glass-effect";
+import { Pressable, View } from "react-native";
+import { withUniwind } from "uniwind";
+
+import { cn } from "../lib/cn";
+import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../native/native-glass";
+import { AppText } from "./AppText";
+import { SymbolView, type AppSymbolName } from "./AppSymbol";
+
+const ChipGlass = withUniwind(GlassView, {
+ style: { fromClassName: "className" },
+ tintColor: { fromClassName: "tintColorClassName", styleProperty: "accentColor" },
+});
+
+/** Compact labels and filter triggers. Menu owners can wrap the non-pressable form. */
+export function Chip(props: {
+ readonly label: string;
+ readonly selected?: boolean;
+ readonly icon?: AppSymbolName;
+ readonly trailingIcon?: AppSymbolName;
+ readonly size?: "small" | "default";
+ readonly glass?: boolean;
+ readonly colorScheme?: "light" | "dark";
+ readonly onPress?: () => void;
+ readonly accessibilityLabel?: string;
+ readonly disabled?: boolean;
+}) {
+ const small = props.size === "small";
+ const layout = cn(
+ "flex-row items-center gap-1.5 rounded-2xl px-3",
+ small ? "py-1" : "min-h-8 py-1.5",
+ );
+ const iconColor = props.selected ? "accent-primary-foreground" : "accent-icon-muted";
+ const content = (
+ <>
+ {props.icon ? (
+ <SymbolView name={props.icon} size={15} tintColorClassName={iconColor} />
+ ) : null}
+ <AppText
+ numberOfLines={small ? undefined : 1}
+ className={cn(
+ "shrink",
+ !small && "max-w-[180px]",
+ small ? "text-2xs" : "text-sm font-t3-medium",
+ props.selected ? "text-primary-foreground" : "text-foreground-muted",
+ )}
+ >
+ {props.label}
+ </AppText>
+ {props.trailingIcon ? (
+ <SymbolView name={props.trailingIcon} size={11} tintColorClassName={iconColor} />
+ ) : null}
+ </>
+ );
+ const body =
+ props.glass && NATIVE_LIQUID_GLASS_SUPPORTED ? (
+ <ChipGlass
+ isInteractive
+ colorScheme={props.colorScheme}
+ tintColorClassName={props.selected ? "accent-primary" : undefined}
+ className={layout}
+ >
+ {content}
+ </ChipGlass>
+ ) : (
+ <View
+ className={cn(
+ layout,
+ props.selected ? "bg-primary" : small ? "bg-grouped-card" : "bg-subtle",
+ )}
+ >
+ {content}
+ </View>
+ );
+ return props.onPress ? (
+ <Pressable
+ accessibilityRole="button"
+ accessibilityLabel={props.accessibilityLabel ?? props.label}
+ accessibilityState={{ selected: props.selected, disabled: Boolean(props.disabled) }}
+ disabled={props.disabled}
+ onPress={props.onPress}
+ hitSlop={6}
+ className={props.disabled ? "opacity-45" : "active:opacity-70"}
+ >
+ {body}
+ </Pressable>
+ ) : (
+ body
+ );
+}
diff --git a/apps/mobile/src/components/ErrorBanner.tsx b/apps/mobile/src/components/ErrorBanner.tsx
index 38f85de195b..c049fccc421 100644
--- a/apps/mobile/src/components/ErrorBanner.tsx
+++ b/apps/mobile/src/components/ErrorBanner.tsx
@@ -1,10 +1,5 @@
-import { View } from "react-native";
+import { Notice } from "./Notice";
-import { AppText as Text } from "./AppText";
export function ErrorBanner(props: { readonly message: string }) {
- return (
- <View className="rounded-2xl border border-danger-border bg-danger px-3.5 py-3">
- <Text className="font-t3-medium text-sm text-danger-foreground">{props.message}</Text>
- </View>
- );
+ return <Notice tone="danger" message={props.message} />;
}
diff --git a/apps/mobile/src/components/MaterialIconButton.android.tsx b/apps/mobile/src/components/MaterialIconButton.android.tsx
index 64387e3a4f4..0c7e6daa5e8 100644
--- a/apps/mobile/src/components/MaterialIconButton.android.tsx
+++ b/apps/mobile/src/components/MaterialIconButton.android.tsx
@@ -7,7 +7,7 @@ import {
import { size } from "@expo/ui/jetpack-compose/modifiers";
import { View } from "react-native";
-import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
+import { useControlTheme } from "./useControlTheme";
import { useAndroidControlSizing } from "./useAndroidControlSizing";
import { SymbolView, type AppSymbolName } from "./AppSymbol";
@@ -20,7 +20,7 @@ export function MaterialIconButton(props: {
readonly variant?: "standard" | "primary" | "tonal" | "danger";
readonly tintColorClassName?: string;
}) {
- const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
+ const { colorScheme, colors } = useControlTheme();
const { iconSize, buttonSize } = useAndroidControlSizing();
const variant = props.variant ?? "standard";
const Component =
@@ -58,7 +58,7 @@ export function MaterialIconButton(props: {
>
<View importantForAccessibility="no-hide-descendants">
<Host
- colorScheme={themeAppearance}
+ colorScheme={colorScheme}
ignoreSafeAreaKeyboardInsets
style={{ width: buttonSize, height: buttonSize }}
>
diff --git a/apps/mobile/src/components/MaterialSearchField.tsx b/apps/mobile/src/components/MaterialSearchField.tsx
index 639249313bf..f32ac5e86d5 100644
--- a/apps/mobile/src/components/MaterialSearchField.tsx
+++ b/apps/mobile/src/components/MaterialSearchField.tsx
@@ -6,12 +6,14 @@ import { useAndroidControlSizing } from "./useAndroidControlSizing";
export function MaterialSearchField({
inputRef,
+ autoFocus = true,
accessibilityLabel,
clearAccessibilityLabel,
placeholder,
value,
onChangeText,
}: {
+ readonly autoFocus?: boolean;
readonly inputRef: RefObject<TextInputInstance | null>;
readonly accessibilityLabel: string;
readonly clearAccessibilityLabel: string;
@@ -37,7 +39,7 @@ export function MaterialSearchField({
<TextInput
ref={inputRef}
accessibilityLabel={accessibilityLabel}
- autoFocus
+ autoFocus={autoFocus}
autoCapitalize="none"
autoCorrect={false}
returnKeyType="search"
diff --git a/apps/mobile/src/components/MaterialSwitch.android.tsx b/apps/mobile/src/components/MaterialSwitch.android.tsx
index f08fa78690f..1c1478f0b50 100644
--- a/apps/mobile/src/components/MaterialSwitch.android.tsx
+++ b/apps/mobile/src/components/MaterialSwitch.android.tsx
@@ -2,11 +2,11 @@ import { Host, Switch as ComposeSwitch } from "@expo/ui/jetpack-compose";
import { View } from "react-native";
import type { ThemedSwitchProps } from "./MaterialSwitch.types";
-import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
+import { useControlTheme } from "./useControlTheme";
/** Material's native switch, with the same palette and accessibility contract as our RN controls. */
export function MaterialSwitch(props: ThemedSwitchProps) {
- const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
+ const { colorScheme, colors } = useControlTheme();
const toggle = () => {
if (!props.disabled) props.onValueChange?.(!props.value);
};
@@ -25,7 +25,7 @@ export function MaterialSwitch(props: ThemedSwitchProps) {
>
<View importantForAccessibility="no-hide-descendants">
<Host
- colorScheme={themeAppearance}
+ colorScheme={colorScheme}
ignoreSafeAreaKeyboardInsets
style={{ width: 52, height: 48 }}
>
diff --git a/apps/mobile/src/components/Notice.tsx b/apps/mobile/src/components/Notice.tsx
new file mode 100644
index 00000000000..d6cf26d40c3
--- /dev/null
+++ b/apps/mobile/src/components/Notice.tsx
@@ -0,0 +1,85 @@
+import { useEffect } from "react";
+import { AccessibilityInfo, Platform, Pressable, View } from "react-native";
+
+import { cn } from "../lib/cn";
+import { AppText } from "./AppText";
+import { SymbolView, type AppSymbolName } from "./AppSymbol";
+import { GlassSurface } from "./GlassSurface";
+
+/** Inline feedback or a dismissible notice positioned by its owning screen. */
+export function Notice(props: {
+ readonly message: string;
+ readonly tone?: "default" | "danger";
+ readonly icon?: AppSymbolName;
+ readonly iconTone?: "default" | "danger";
+ readonly floating?: boolean;
+ readonly onDismiss?: () => void;
+ readonly dismissLabel?: string;
+}) {
+ const danger = props.tone === "danger";
+ useEffect(() => {
+ // Live regions reach TalkBack; VoiceOver needs an explicit announcement.
+ if (Platform.OS === "ios") AccessibilityInfo.announceForAccessibility(props.message);
+ }, [props.message]);
+
+ const content = (
+ <View className="flex-row items-start gap-3">
+ {props.icon ? (
+ <View className="pt-0.5">
+ <SymbolView
+ name={props.icon}
+ size={16}
+ tintColorClassName={
+ danger || props.iconTone === "danger"
+ ? "accent-danger-foreground"
+ : "accent-icon-muted"
+ }
+ />
+ </View>
+ ) : null}
+ <AppText
+ selectable
+ accessibilityLiveRegion="polite"
+ className={cn(
+ "min-w-0 flex-1 text-sm",
+ danger ? "text-danger-foreground" : "text-foreground",
+ !props.floating && "font-t3-medium",
+ )}
+ >
+ {props.message}
+ </AppText>
+ {props.onDismiss ? (
+ <Pressable
+ accessibilityRole="button"
+ accessibilityLabel={props.dismissLabel ?? "Dismiss message"}
+ onPress={props.onDismiss}
+ hitSlop={10}
+ className="min-h-6 min-w-6 items-center justify-center active:opacity-60"
+ >
+ <SymbolView
+ name="xmark"
+ size={14}
+ tintColorClassName={danger ? "accent-danger-foreground" : "accent-icon-muted"}
+ />
+ </Pressable>
+ ) : null}
+ </View>
+ );
+ if (props.floating && Platform.OS === "ios")
+ return (
+ <GlassSurface className="p-4" style={{ borderRadius: 20 }}>
+ {content}
+ </GlassSurface>
+ );
+ return (
+ <View
+ className={cn(
+ "rounded-2xl border px-3.5 py-3",
+ danger ? "border-danger-border bg-danger" : "border-border bg-card",
+ props.floating && "p-4",
+ )}
+ >
+ {content}
+ </View>
+ );
+}
diff --git a/apps/mobile/src/components/NumberField.android.tsx b/apps/mobile/src/components/NumberField.android.tsx
new file mode 100644
index 00000000000..23095ee862f
--- /dev/null
+++ b/apps/mobile/src/components/NumberField.android.tsx
@@ -0,0 +1,44 @@
+import { View } from "react-native";
+
+import { AppText } from "./AppText";
+import { MaterialIconButton } from "./MaterialIconButton";
+import type { NumberFieldProps } from "./NumberField";
+
+export function NumberField(props: NumberFieldProps) {
+ const adjust = (amount: number) => {
+ if (props.disabled) return;
+ const next = Math.max(props.min, Math.min(props.max, props.value + amount));
+ if (next !== props.value) props.onValueChange(next);
+ };
+
+ return (
+ <View className="shrink-0 flex-row items-center">
+ {/* Match the 32dp switch track while retaining 48dp button touch targets. */}
+ <View
+ pointerEvents="none"
+ className="absolute inset-x-0 rounded-full bg-subtle"
+ style={{ height: 32 }}
+ />
+ <MaterialIconButton
+ icon="minus"
+ accessibilityLabel={`Decrease ${props.label}`}
+ disabled={props.disabled || props.value <= props.min}
+ onPress={() => adjust(-1)}
+ />
+ <AppText
+ className="min-w-8 text-center text-base"
+ style={{ fontVariant: ["tabular-nums"] }}
+ accessibilityLabel={`${props.label}: ${props.formatValue?.(props.value) ?? props.value}`}
+ accessibilityLiveRegion="polite"
+ >
+ {props.value}
+ </AppText>
+ <MaterialIconButton
+ icon="plus"
+ accessibilityLabel={`Increase ${props.label}`}
+ disabled={props.disabled || props.value >= props.max}
+ onPress={() => adjust(1)}
+ />
+ </View>
+ );
+}
diff --git a/apps/mobile/src/features/settings/components/AutoSettleDaysField.ios.tsx b/apps/mobile/src/components/NumberField.ios.tsx
similarity index 70%
rename from apps/mobile/src/features/settings/components/AutoSettleDaysField.ios.tsx
rename to apps/mobile/src/components/NumberField.ios.tsx
index d7734f5a923..958698b65a9 100644
--- a/apps/mobile/src/features/settings/components/AutoSettleDaysField.ios.tsx
+++ b/apps/mobile/src/components/NumberField.ios.tsx
@@ -11,26 +11,18 @@ import {
presentationBackground,
tag,
} from "@expo/ui/swift-ui/modifiers";
-import {
- MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
- MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
-} from "@t3tools/contracts";
import { useState } from "react";
-import { useAppearancePreferences } from "../appearance/AppearancePreferencesProvider";
-import type { AutoSettleDaysFieldProps } from "./AutoSettleDaysField";
-
-const days = Array.from(
- { length: MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS - MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS + 1 },
- (_, index) => MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS + index,
-);
+import { useControlTheme } from "./useControlTheme";
+import type { NumberFieldProps } from "./NumberField";
-export function AutoSettleDaysField(props: AutoSettleDaysFieldProps) {
- const { themeAppearance, themeVariables: colors, appearance } = useAppearancePreferences();
+export function NumberField(props: NumberFieldProps) {
+ const { colorScheme, colors, fontSize } = useControlTheme();
+ const values = Array.from({ length: props.max - props.min + 1 }, (_, index) => props.min + index);
const [open, setOpen] = useState(false);
const [draft, setDraft] = useState(props.value);
return (
- <Host matchContents colorScheme={themeAppearance} seedColor={colors["--color-primary"]}>
+ <Host matchContents colorScheme={colorScheme} seedColor={colors["--color-primary"]}>
<Popover isPresented={open} onIsPresentedChange={setOpen}>
<Popover.Trigger>
<Button
@@ -42,10 +34,12 @@ export function AutoSettleDaysField(props: AutoSettleDaysFieldProps) {
modifiers={[
buttonStyle("bordered"),
disabled(props.disabled),
- accessibilityLabel(`Days before auto-settle: ${props.value}`),
+ accessibilityLabel(
+ `${props.label}: ${props.formatValue?.(props.value) ?? props.value}`,
+ ),
frame({ minWidth: 64, minHeight: 44 }),
foregroundStyle(colors["--color-primary-text"]),
- font({ size: appearance.baseFontSize }),
+ font({ size: fontSize }),
]}
>
<Text>{String(props.value)}</Text>
@@ -60,17 +54,17 @@ export function AutoSettleDaysField(props: AutoSettleDaysFieldProps) {
]}
>
<Picker
- label="Days before auto-settle"
+ label={props.label}
selection={draft}
onSelectionChange={setDraft}
modifiers={[pickerStyle("wheel"), frame({ height: 180 })]}
>
- {days.map((value) => (
+ {values.map((value) => (
<Text
key={value}
modifiers={[tag(value), foregroundStyle(colors["--color-foreground"])]}
>
- {`${value} ${value === 1 ? "day" : "days"}`}
+ {props.formatValue?.(value) ?? String(value)}
</Text>
))}
</Picker>
diff --git a/apps/mobile/src/components/NumberField.tsx b/apps/mobile/src/components/NumberField.tsx
new file mode 100644
index 00000000000..cbffd8ba1eb
--- /dev/null
+++ b/apps/mobile/src/components/NumberField.tsx
@@ -0,0 +1,47 @@
+import { useState } from "react";
+import { AppTextInput } from "./AppText";
+
+export interface NumberFieldProps {
+ readonly label: string;
+ readonly min: number;
+ readonly max: number;
+ readonly formatValue?: (value: number) => string;
+ readonly value: number;
+ readonly onValueChange: (value: number) => void;
+ readonly disabled?: boolean;
+}
+
+export function NumberField(props: NumberFieldProps) {
+ const [draft, setDraft] = useState<string | null>(null);
+ const commit = () => {
+ if (props.disabled) {
+ setDraft(null);
+ return;
+ }
+ const text = (draft ?? "").trim();
+ setDraft(null);
+ // Validate the whole input; decimals and trailing text must not become whole days.
+ const parsed = /^\d+$/.test(text) ? Number(text) : Number.NaN;
+ if (
+ Number.isInteger(parsed) &&
+ parsed >= props.min &&
+ parsed <= props.max &&
+ parsed !== props.value
+ ) {
+ props.onValueChange(parsed);
+ }
+ };
+ return (
+ <AppTextInput
+ className="min-h-10 w-20 rounded-xl px-3 py-2 text-center text-base"
+ keyboardType="number-pad"
+ returnKeyType="done"
+ value={draft ?? String(props.value)}
+ onChangeText={setDraft}
+ onBlur={commit}
+ onSubmitEditing={commit}
+ accessibilityLabel={props.label}
+ editable={!props.disabled}
+ />
+ );
+}
diff --git a/apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.android.tsx b/apps/mobile/src/components/SliderRow.android.tsx
similarity index 82%
rename from apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.android.tsx
rename to apps/mobile/src/components/SliderRow.android.tsx
index 6588895f73a..5ca89ae94a4 100644
--- a/apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.android.tsx
+++ b/apps/mobile/src/components/SliderRow.android.tsx
@@ -4,17 +4,13 @@ import * as Haptics from "expo-haptics";
import { useRef, type ComponentProps } from "react";
import { View } from "react-native";
-import { AppText as Text } from "../../../../components/AppText";
-import { SymbolView } from "../../../../components/AppSymbol";
-import { useAppearancePreferences } from "../AppearancePreferencesProvider";
-import type { FontSizeSliderRow as SharedFontSizeSliderRow } from "./FontSizeSliderRow.shared";
+import { AppText as Text } from "./AppText";
+import { SymbolView } from "./AppSymbol";
+import { useControlTheme } from "./useControlTheme";
+import type { SliderRow as SharedSliderRow } from "./SliderRow";
-export function FontSizeSliderRow(props: ComponentProps<typeof SharedFontSizeSliderRow>) {
- const {
- themeAppearance,
- systemColorsActive,
- themeVariables: colors,
- } = useAppearancePreferences();
+export function SliderRow(props: ComponentProps<typeof SharedSliderRow>) {
+ const { colorScheme, systemColorsActive, colors } = useControlTheme();
const draft = useRef(props.value);
const commit = (value: number) => {
if (props.disabled) return;
@@ -52,7 +48,7 @@ export function FontSizeSliderRow(props: ComponentProps<typeof SharedFontSizeSli
>
<View importantForAccessibility="no-hide-descendants">
<Host
- colorScheme={themeAppearance}
+ colorScheme={colorScheme}
seedColor={systemColorsActive ? undefined : colors["--color-primary"]}
style={{ height: 48, width: "100%" }}
>
diff --git a/apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.shared.tsx b/apps/mobile/src/components/SliderRow.tsx
similarity index 89%
rename from apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.shared.tsx
rename to apps/mobile/src/components/SliderRow.tsx
index 98a17388485..789eefdd270 100644
--- a/apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.shared.tsx
+++ b/apps/mobile/src/components/SliderRow.tsx
@@ -1,5 +1,5 @@
import * as Haptics from "expo-haptics";
-import { SymbolView } from "../../../../components/AppSymbol";
+import { SymbolView } from "./AppSymbol";
import { useCallback, useEffect, useMemo, useRef } from "react";
import { View, type AccessibilityActionEvent } from "react-native";
import { Gesture, GestureDetector } from "react-native-gesture-handler";
@@ -11,7 +11,7 @@ import Animated, {
} from "react-native-reanimated";
import type { ComponentProps } from "react";
-import { AppText as Text } from "../../../../components/AppText";
+import { AppText as Text } from "./AppText";
type SymbolName = ComponentProps<typeof SymbolView>["name"];
@@ -24,9 +24,11 @@ function clampFraction(value: number): number {
return Math.min(1, Math.max(0, value));
}
-export function FontSizeSliderRow(props: {
+export function SliderRow(props: {
readonly disabled?: boolean;
readonly icon: SymbolName;
+ readonly minimumIcon?: SymbolName;
+ readonly maximumIcon?: SymbolName;
readonly label: string;
readonly valueLabel: string;
readonly min: number;
@@ -146,13 +148,15 @@ export function FontSizeSliderRow(props: {
<Text className="text-base font-t3-medium text-foreground-muted">{props.valueLabel}</Text>
</View>
<View className="flex-row items-center gap-3">
- <SymbolView
- name="textformat.size.smaller"
- size={15}
- tintColorClassName={"accent-icon-muted"}
- type="monochrome"
- weight="regular"
- />
+ {props.minimumIcon ? (
+ <SymbolView
+ name={props.minimumIcon}
+ size={15}
+ tintColorClassName={"accent-icon-muted"}
+ type="monochrome"
+ weight="regular"
+ />
+ ) : null}
<GestureDetector gesture={gesture}>
<View
accessible
@@ -180,7 +184,7 @@ export function FontSizeSliderRow(props: {
/>
</View>
<Animated.View
- className="absolute left-0 rounded-full border-border bg-primary-foreground"
+ className="absolute left-0 rounded-full border-border bg-primary"
style={[
{
borderWidth: 1,
@@ -198,13 +202,15 @@ export function FontSizeSliderRow(props: {
/>
</View>
</GestureDetector>
- <SymbolView
- name="textformat.size.larger"
- size={22}
- tintColorClassName={"accent-icon-muted"}
- type="monochrome"
- weight="regular"
- />
+ {props.maximumIcon ? (
+ <SymbolView
+ name={props.maximumIcon}
+ size={22}
+ tintColorClassName={"accent-icon-muted"}
+ type="monochrome"
+ weight="regular"
+ />
+ ) : null}
</View>
</View>
);
diff --git a/apps/mobile/src/components/useControlTheme.ts b/apps/mobile/src/components/useControlTheme.ts
new file mode 100644
index 00000000000..de686e62f9e
--- /dev/null
+++ b/apps/mobile/src/components/useControlTheme.ts
@@ -0,0 +1,13 @@
+import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
+
+/** Palette and type size for native controls hosted outside the RN style tree. */
+export function useControlTheme() {
+ const { themeAppearance, themeVariables, systemColorsActive, appearance } =
+ useAppearancePreferences();
+ return {
+ colorScheme: themeAppearance,
+ colors: themeVariables,
+ systemColorsActive,
+ fontSize: appearance.baseFontSize,
+ };
+}
diff --git a/apps/mobile/src/dependency-graph.test.ts b/apps/mobile/src/dependency-graph.test.ts
index 7f2b0abdfc5..5b148384f7b 100644
--- a/apps/mobile/src/dependency-graph.test.ts
+++ b/apps/mobile/src/dependency-graph.test.ts
@@ -269,7 +269,7 @@ describe("mobile dependency graph", () => {
["lib", "features", 7, "lib must not add imports from features"],
// components -> features: mostly the appearance preferences provider
// and the layout toolbar bridges.
- ["components", "features", 33, "components must not add imports from features"],
+ ["components", "features", 31, "components must not add imports from features"],
// native -> features: native glue reading appearance/keyboard/review features.
["native", "features", 8, "native must not add imports from features"],
// lib -> state: attachment/session plumbing that predates the cycle
diff --git a/apps/mobile/src/features/development/ComponentCatalogScreen.tsx b/apps/mobile/src/features/development/ComponentCatalogScreen.tsx
new file mode 100644
index 00000000000..8069ffe7068
--- /dev/null
+++ b/apps/mobile/src/features/development/ComponentCatalogScreen.tsx
@@ -0,0 +1,272 @@
+import { useNavigation } from "@react-navigation/native";
+import { useRef, useState } from "react";
+import { Alert, Platform, View, type TextInputInstance } from "react-native";
+
+import { AppText, AppTextInput } from "../../components/AppText";
+import { AppSheet } from "../../components/AppSheet";
+import { Chip } from "../../components/Chip";
+import { ControlPillMenu } from "../../components/ControlPillMenu";
+import { ListActionRow } from "../../components/ListActionRow";
+import { ListChoiceRow } from "../../components/ListChoiceRow";
+import { ListRow } from "../../components/ListRow";
+import { ListSection } from "../../components/ListSection";
+import { ListToggleRow } from "../../components/ListToggleRow";
+import { Button } from "../../components/Button";
+import { MaterialIconButton } from "../../components/MaterialIconButton";
+import { MaterialFloatingActionButton } from "../../components/MaterialFloatingActionButton";
+import { MaterialSearchField } from "../../components/MaterialSearchField";
+import { LoadingStrip } from "../../components/LoadingStrip";
+import { Notice } from "../../components/Notice";
+import { NumberField } from "../../components/NumberField";
+import { ScreenHeader } from "../../components/ScreenHeader";
+import { ScreenScrollView } from "../../components/ScreenScrollView";
+import { SegmentedControl } from "../../components/SegmentedControl";
+import { SliderRow } from "../../components/SliderRow";
+import { showConfirmDialog } from "../../components/ConfirmDialogHost";
+import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
+import { MOBILE_THEME_IDS } from "../../lib/mobileTheme";
+
+const CHOICES = [
+ { value: "overview", label: "Overview" },
+ { value: "activity", label: "Activity" },
+];
+
+/** Development-only, real controls with local state and no environment commands. */
+export function ComponentCatalogScreen() {
+ const navigation = useNavigation();
+ const appearance = useAppearancePreferences();
+ const [page, setPage] = useState("controls");
+ const [tab, setTab] = useState("overview");
+ const [enabled, setEnabled] = useState(true);
+ const [value, setValue] = useState(3);
+ const [text, setText] = useState("");
+ const [search, setSearch] = useState("");
+ const [sheet, setSheet] = useState(false);
+ const [notice, setNotice] = useState(true);
+ const searchRef = useRef<TextInputInstance>(null);
+ const announceAction = () => setNotice(true);
+ const confirm = () => {
+ if (Platform.OS === "ios")
+ Alert.alert("Discard changes?", "This example only changes local catalog state.", [
+ { text: "Cancel", style: "cancel" },
+ { text: "Discard", style: "destructive", onPress: () => setText("") },
+ ]);
+ else
+ showConfirmDialog({
+ title: "Discard changes?",
+ message: "This example only changes local catalog state.",
+ confirmText: "Discard",
+ destructive: true,
+ onConfirm: () => setText(""),
+ });
+ };
+ return (
+ <View className="flex-1 bg-screen">
+ <ScreenHeader title="UI components" onBack={() => navigation.goBack()} sidebar={false} />
+ <ScreenScrollView
+ contentInsetAdjustmentBehavior="automatic"
+ contentContainerStyle={{ padding: 16, gap: 20, paddingBottom: 40 }}
+ keyboardShouldPersistTaps="handled"
+ >
+ <View className="gap-3">
+ <AppText className="text-sm text-foreground-muted">Theme preview</AppText>
+ <View className="flex-row flex-wrap gap-2">
+ {MOBILE_THEME_IDS.filter(
+ (id) => id !== "material-you" || appearance.systemColorsAvailable,
+ ).map((id) => (
+ <Chip
+ key={id}
+ label={id}
+ selected={appearance.themeId === id}
+ onPress={() => appearance.setThemeIdForBothAppearances(id)}
+ />
+ ))}
+ </View>
+ <SegmentedControl
+ options={[
+ { value: "light", label: "Light" },
+ { value: "dark", label: "Dark" },
+ ]}
+ selected={appearance.themeAppearance}
+ onSelect={appearance.setThemeMode}
+ size="compact"
+ />
+ </View>
+ <SegmentedControl
+ options={[
+ { value: "controls", label: "Controls" },
+ { value: "forms", label: "Forms" },
+ { value: "feedback", label: "Feedback" },
+ ]}
+ selected={page}
+ onSelect={setPage}
+ size="compact"
+ />
+ {page === "controls" ? (
+ <>
+ <View className="gap-3">
+ <AppText className="text-lg font-t3-semibold">Lists and selection</AppText>
+ <ListSection>
+ <ListRow icon="folder" label="Projects" detail="4" onPress={() => setSheet(true)} />
+ <ListToggleRow
+ icon="bell.badge"
+ label="Notifications"
+ description="Updates from your active threads"
+ value={enabled}
+ onValueChange={setEnabled}
+ />
+ <ListChoiceRow label="Selected option" selected onPress={announceAction} />
+ <ListActionRow
+ icon="trash"
+ label="Discard changes"
+ tone="danger"
+ onPress={confirm}
+ />
+ </ListSection>
+ <SegmentedControl
+ options={CHOICES}
+ selected={tab}
+ onSelect={setTab}
+ size="compact"
+ role="tab"
+ />
+ <View className="flex-row flex-wrap gap-2">
+ <Chip
+ label="Selected filter"
+ selected={enabled}
+ onPress={() => setEnabled(!enabled)}
+ />
+ <Chip label="Label" size="small" />
+ <Chip label="Disabled" disabled onPress={announceAction} />
+ </View>
+ </View>
+ <View className="gap-3">
+ <AppText className="text-lg font-t3-semibold">Buttons</AppText>
+ <View className="flex-row flex-wrap gap-2">
+ <Button label="Primary" tone="primary" onPress={announceAction} />
+ <Button label="Secondary" onPress={announceAction} />
+ <Button label="Contrast" tone="contrast" onPress={announceAction} />
+ </View>
+ <View className="flex-row flex-wrap gap-2">
+ <Button label="Disabled" disabled onPress={announceAction} />
+ <Button label="Loading" loading onPress={announceAction} />
+ <MaterialIconButton
+ accessibilityLabel="Open example sheet"
+ icon="plus"
+ variant="tonal"
+ onPress={() => setSheet(true)}
+ />
+ </View>
+ </View>
+ </>
+ ) : null}
+ {page === "forms" ? (
+ <View className="gap-3">
+ <AppText className="text-lg font-t3-semibold">Forms</AppText>
+ <AppTextInput
+ accessibilityLabel="Example name"
+ placeholder="Name"
+ value={text}
+ onChangeText={setText}
+ />
+ <View className="flex-row">
+ <MaterialSearchField
+ inputRef={searchRef}
+ accessibilityLabel="Search examples"
+ clearAccessibilityLabel="Clear examples search"
+ placeholder="Search examples"
+ value={search}
+ onChangeText={setSearch}
+ autoFocus={false}
+ />
+ </View>
+ <View className="flex-row items-center justify-between">
+ <AppText>Count</AppText>
+ <NumberField
+ label="Example count"
+ min={1}
+ max={10}
+ value={value}
+ onValueChange={setValue}
+ />
+ </View>
+ <ListSection>
+ <SliderRow
+ icon="textformat.size"
+ label="Example slider"
+ valueLabel={String(value)}
+ min={1}
+ max={10}
+ step={1}
+ value={value}
+ onChange={setValue}
+ />
+ </ListSection>
+ </View>
+ ) : null}
+ {page === "feedback" ? (
+ <View className="gap-3">
+ <AppText className="text-lg font-t3-semibold">Feedback and presentation</AppText>
+ <Notice message="This action could not finish. Try again." tone="danger" />
+ {notice ? (
+ <Notice
+ message="Changes are ready to review."
+ icon="checkmark.circle"
+ floating
+ onDismiss={() => setNotice(false)}
+ />
+ ) : (
+ <Button label="Show notice" onPress={announceAction} />
+ )}
+ <View className="flex-row flex-wrap gap-2">
+ <Button label="Sheet" onPress={() => setSheet(true)} />
+ <Button label="Dialog" onPress={confirm} />
+ <ControlPillMenu
+ title="Example menu"
+ actions={[
+ { id: "copy", title: "Copy", image: "doc.on.doc" },
+ { id: "discard", title: "Discard", attributes: { destructive: true } },
+ ]}
+ onPressAction={({ nativeEvent }) =>
+ nativeEvent.event === "discard" ? confirm() : announceAction()
+ }
+ >
+ <Chip label="Menu" trailingIcon="chevron.down" />
+ </ControlPillMenu>
+ </View>
+ <View className="relative h-3 overflow-hidden rounded-full bg-subtle">
+ <LoadingStrip progress={0.6} />
+ </View>
+ <View className="items-start">
+ <MaterialFloatingActionButton
+ label="New thread"
+ icon="plus"
+ variant="extended"
+ tone="primary"
+ onPress={() => setSheet(true)}
+ />
+ </View>
+ </View>
+ ) : null}
+ </ScreenScrollView>
+ {sheet ? (
+ <AppSheet title="Example sheet" onClose={() => setSheet(false)}>
+ <View className="p-4">
+ <ListSection>
+ <ListChoiceRow
+ label="Overview"
+ selected={tab === "overview"}
+ onPress={() => setTab("overview")}
+ />
+ <ListChoiceRow
+ label="Activity"
+ selected={tab === "activity"}
+ onPress={() => setTab("activity")}
+ />
+ </ListSection>
+ </View>
+ </AppSheet>
+ ) : null}
+ </View>
+ );
+}
diff --git a/apps/mobile/src/features/pull-requests/PullRequestOverviewLoading.tsx b/apps/mobile/src/features/pull-requests/PullRequestOverviewLoading.tsx
index 7e6e4f490ae..7bb8631e1b9 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestOverviewLoading.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestOverviewLoading.tsx
@@ -1,7 +1,7 @@
+import { Chip } from "../../components/Chip";
import { PullRequestSectionHeading } from "./PullRequestSectionHeading";
import type { PullRequestListEntry } from "@t3tools/contracts";
import { View } from "react-native";
-import { AppText as Text } from "../../components/AppText";
import { PullRequestCardGroup, PullRequestCardRow } from "./PullRequestControls";
import { PullRequestStackCard } from "./PullRequestStackCard";
import type { PullRequestParams } from "./usePullRequestDiff";
@@ -91,9 +91,7 @@ export function PullRequestOverviewLoading({
{summary.labels.length ? (
<View className="flex-row flex-wrap gap-2">
{summary.labels.map((label) => (
- <View key={label.name} className="rounded-full bg-grouped-card px-3 py-1">
- <Text className="text-2xs text-foreground-muted">{label.name}</Text>
- </View>
+ <Chip key={label.name} label={label.name} size="small" />
))}
</View>
) : null}
diff --git a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
index 5afd705aae8..5459cb77c61 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
@@ -1,3 +1,4 @@
+import { Chip } from "../../components/Chip";
import { pullRequestTabOffset } from "./pullRequestTabScroll";
import { guideFocusedRows, type GuideDiffFocus } from "./guide/guideDiffFocus";
import { PullRequestGuideContent } from "./guide/PullRequestGuideScreen";
@@ -259,9 +260,7 @@ function PullRequestOverview(props: {
{pr.labels.length ? (
<Animated.View layout={PR_ROW_LAYOUT} className="flex-row flex-wrap gap-2">
{pr.labels.map((label) => (
- <View key={label.name} className="rounded-full bg-grouped-card px-3 py-1">
- <Text className="text-2xs text-foreground-muted">{label.name}</Text>
- </View>
+ <Chip key={label.name} label={label.name} size="small" />
))}
</Animated.View>
) : null}
diff --git a/apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.tsx b/apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.tsx
index 76f18645c0b..dbde61fae84 100644
--- a/apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.tsx
+++ b/apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.tsx
@@ -1 +1,14 @@
-export { FontSizeSliderRow } from "./FontSizeSliderRow.shared";
+import type { ComponentProps } from "react";
+import { SliderRow } from "../../../../components/SliderRow";
+
+export function FontSizeSliderRow(
+ props: Omit<ComponentProps<typeof SliderRow>, "minimumIcon" | "maximumIcon">,
+) {
+ return (
+ <SliderRow
+ {...props}
+ minimumIcon="textformat.size.smaller"
+ maximumIcon="textformat.size.larger"
+ />
+ );
+}
diff --git a/apps/mobile/src/features/settings/components/AutoSettleDaysField.android.tsx b/apps/mobile/src/features/settings/components/AutoSettleDaysField.android.tsx
deleted file mode 100644
index 572812880ad..00000000000
--- a/apps/mobile/src/features/settings/components/AutoSettleDaysField.android.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import {
- MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
- MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
-} from "@t3tools/contracts";
-import { View } from "react-native";
-
-import { AppText } from "../../../components/AppText";
-import { MaterialIconButton } from "../../../components/MaterialIconButton";
-import type { AutoSettleDaysFieldProps } from "./AutoSettleDaysField";
-
-export function AutoSettleDaysField(props: AutoSettleDaysFieldProps) {
- const adjust = (amount: number) => {
- if (props.disabled) return;
- const next = Math.max(
- MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
- Math.min(MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS, props.value + amount),
- );
- if (next !== props.value) props.onValueChange(next);
- };
-
- return (
- <View className="shrink-0 flex-row items-center">
- {/* Match the 32dp switch track while retaining 48dp button touch targets. */}
- <View
- pointerEvents="none"
- className="absolute inset-x-0 rounded-full bg-subtle"
- style={{ height: 32 }}
- />
- <MaterialIconButton
- icon="minus"
- accessibilityLabel="Decrease days before auto-settle"
- disabled={props.disabled || props.value <= MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS}
- onPress={() => adjust(-1)}
- />
- <AppText
- className="min-w-8 text-center text-base"
- style={{ fontVariant: ["tabular-nums"] }}
- accessibilityLabel={`${props.value} ${props.value === 1 ? "day" : "days"} before auto-settle`}
- accessibilityLiveRegion="polite"
- >
- {props.value}
- </AppText>
- <MaterialIconButton
- icon="plus"
- accessibilityLabel="Increase days before auto-settle"
- disabled={props.disabled || props.value >= MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS}
- onPress={() => adjust(1)}
- />
- </View>
- );
-}
diff --git a/apps/mobile/src/features/settings/components/AutoSettleDaysField.tsx b/apps/mobile/src/features/settings/components/AutoSettleDaysField.tsx
index ddbca55b643..20603c7f91f 100644
--- a/apps/mobile/src/features/settings/components/AutoSettleDaysField.tsx
+++ b/apps/mobile/src/features/settings/components/AutoSettleDaysField.tsx
@@ -1,48 +1,23 @@
-import { useState } from "react";
import {
MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
} from "@t3tools/contracts";
+import type { ComponentProps } from "react";
+import { NumberField } from "../../../components/NumberField";
-import { AppTextInput } from "../../../components/AppText";
-
-export interface AutoSettleDaysFieldProps {
- readonly value: number;
- readonly onValueChange: (value: number) => void;
- readonly disabled?: boolean;
-}
+export type AutoSettleDaysFieldProps = Pick<
+ ComponentProps<typeof NumberField>,
+ "value" | "onValueChange" | "disabled"
+>;
export function AutoSettleDaysField(props: AutoSettleDaysFieldProps) {
- const [draft, setDraft] = useState<string | null>(null);
- const commit = () => {
- if (props.disabled) {
- setDraft(null);
- return;
- }
- const text = (draft ?? "").trim();
- setDraft(null);
- // Validate the whole input; decimals and trailing text must not become whole days.
- const parsed = /^\d+$/.test(text) ? Number(text) : Number.NaN;
- if (
- Number.isInteger(parsed) &&
- parsed >= MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS &&
- parsed <= MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS &&
- parsed !== props.value
- ) {
- props.onValueChange(parsed);
- }
- };
return (
- <AppTextInput
- className="min-h-10 w-20 rounded-xl px-3 py-2 text-center text-base"
- keyboardType="number-pad"
- returnKeyType="done"
- value={draft ?? String(props.value)}
- onChangeText={setDraft}
- onBlur={commit}
- onSubmitEditing={commit}
- accessibilityLabel="Days before auto-settle"
- editable={!props.disabled}
+ <NumberField
+ {...props}
+ min={MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS}
+ max={MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS}
+ label="Days before auto-settle"
+ formatValue={(value) => `${value} ${value === 1 ? "day" : "days"}`}
/>
);
}
diff --git a/apps/mobile/src/features/threads/ComposerErrorNotice.tsx b/apps/mobile/src/features/threads/ComposerErrorNotice.tsx
index 37ea6078f2a..020b23ffca5 100644
--- a/apps/mobile/src/features/threads/ComposerErrorNotice.tsx
+++ b/apps/mobile/src/features/threads/ComposerErrorNotice.tsx
@@ -1,55 +1,21 @@
-import { useEffect } from "react";
-import { AccessibilityInfo, Platform, Pressable, View } from "react-native";
-
-import { AppText as Text } from "../../components/AppText";
-import { SymbolView } from "../../components/AppSymbol";
+import { View } from "react-native";
+import { Notice } from "../../components/Notice";
/** Why the thread's last message did not send, above the composer until dismissed. */
-export function ComposerErrorNotice({
- message,
- onDismiss,
-}: {
+export function ComposerErrorNotice(props: {
readonly message: string;
readonly onDismiss: () => void;
}) {
- // accessibilityLiveRegion below only reaches TalkBack; VoiceOver needs an
- // explicit announcement.
- useEffect(() => {
- if (Platform.OS === "ios") {
- AccessibilityInfo.announceForAccessibility(message);
- }
- }, [message]);
return (
<View className="px-4 pb-3">
- <View className="flex-row items-start gap-3 rounded-[20px] border-continuous bg-card p-4">
- <SymbolView
- name="exclamationmark.circle"
- size={16}
- tintColorClassName="accent-danger-foreground"
- type="monochrome"
- />
- <Text
- selectable
- accessibilityLiveRegion="polite"
- className="min-w-0 flex-1 text-sm text-foreground"
- >
- {message}
- </Text>
- <Pressable
- accessibilityLabel="Dismiss error"
- accessibilityRole="button"
- hitSlop={12}
- onPress={onDismiss}
- className="p-1 active:opacity-60"
- >
- <SymbolView
- name="xmark"
- size={14}
- tintColorClassName="accent-icon-muted"
- type="monochrome"
- />
- </Pressable>
- </View>
+ <Notice
+ message={props.message}
+ icon="exclamationmark.circle"
+ iconTone="danger"
+ floating
+ onDismiss={props.onDismiss}
+ dismissLabel="Dismiss error"
+ />
</View>
);
}
diff --git a/apps/mobile/src/features/workspace/ListFilterMenu.tsx b/apps/mobile/src/features/workspace/ListFilterMenu.tsx
index b645722f53d..ad08ee45a76 100644
--- a/apps/mobile/src/features/workspace/ListFilterMenu.tsx
+++ b/apps/mobile/src/features/workspace/ListFilterMenu.tsx
@@ -1,21 +1,9 @@
-import { GlassView } from "expo-glass-effect";
-import { Pressable, View } from "react-native";
-import { withUniwind } from "uniwind";
-import { AppText as Text } from "../../components/AppText";
-import { SymbolView } from "../../components/AppSymbol";
+import { Pressable } from "react-native";
+import { Chip } from "../../components/Chip";
import { ControlPillMenu } from "../../components/ControlPillMenu";
import type { ControlPillMenuProps } from "../../components/ControlPillMenu.types";
-import { cn } from "../../lib/cn";
-import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
-const FilterGlass = withUniwind(GlassView, {
- style: { fromClassName: "className" },
- tintColor: { fromClassName: "tintColorClassName", styleProperty: "accentColor" },
-});
-
-const PILL = "h-8 flex-row items-center gap-1.5 rounded-full px-3";
-
/** A visible filter with a native menu containing only that filter's choices. */
export function ListFilterMenu(props: {
readonly label: string;
@@ -26,33 +14,6 @@ export function ListFilterMenu(props: {
readonly onSelect: (id: string) => void;
}) {
const { themeAppearance } = useAppearancePreferences();
- const content = (
- <>
- {props.icon ? (
- <SymbolView
- name="line.3.horizontal.decrease"
- size={15}
- tintColorClassName={props.active ? "accent-primary-foreground" : "accent-icon-muted"}
- />
- ) : null}
- <Text
- numberOfLines={1}
- className={cn(
- "max-w-[180px] text-sm font-t3-medium",
- props.active ? "text-primary-foreground" : "text-foreground-muted",
- )}
- >
- {props.label}
- </Text>
- {!props.icon ? (
- <SymbolView
- name="chevron.down"
- size={11}
- tintColorClassName={props.active ? "accent-primary-foreground" : "accent-icon-muted"}
- />
- ) : null}
- </>
- );
return (
<ControlPillMenu
title={props.accessibilityLabel}
@@ -62,20 +23,17 @@ export function ListFilterMenu(props: {
<Pressable
accessibilityRole="button"
accessibilityLabel={props.accessibilityLabel}
+ accessibilityState={{ selected: Boolean(props.active) }}
hitSlop={6}
>
- {NATIVE_LIQUID_GLASS_SUPPORTED ? (
- <FilterGlass
- isInteractive
- colorScheme={themeAppearance}
- tintColorClassName={props.active ? "accent-primary" : undefined}
- className={PILL}
- >
- {content}
- </FilterGlass>
- ) : (
- <View className={cn(PILL, props.active ? "bg-primary" : "bg-subtle")}>{content}</View>
- )}
+ <Chip
+ label={props.label}
+ selected={props.active}
+ icon={props.icon ? "line.3.horizontal.decrease" : undefined}
+ trailingIcon={props.icon ? undefined : "chevron.down"}
+ glass
+ colorScheme={themeAppearance}
+ />
</Pressable>
</ControlPillMenu>
);