From 9a2b9a2d4040c7e78c03a95d59b76b92e6bf2957 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sun, 11 Oct 2026 22:31:14 -0700 Subject: [PATCH] refactor(mobile): share themed toggle rows in settings (#18511) --- apps/mobile/src/components/ListToggleRow.tsx | 45 ++++++++++++++++++ .../components/SettingsControlRow.tsx | 39 ---------------- .../settings/components/SettingsSwitchRow.tsx | 46 ++++--------------- 3 files changed, 53 insertions(+), 77 deletions(-) create mode 100644 apps/mobile/src/components/ListToggleRow.tsx delete mode 100644 apps/mobile/src/features/settings/components/SettingsControlRow.tsx diff --git a/apps/mobile/src/components/ListToggleRow.tsx b/apps/mobile/src/components/ListToggleRow.tsx new file mode 100644 index 0000000000000000000000000000000000000000..41d433b9c022a437fa0b4622bcebf4bbcb66cf77 --- /dev/null +++ b/apps/mobile/src/components/ListToggleRow.tsx @@ -0,0 +1,45 @@ +import { Pressable } from "react-native"; + +import { AppText } from "./AppText"; +import { ListRowLayout, type ListRowContentProps } from "./ListRowLayout"; +import { ThemedSwitch } from "./ThemedSwitch"; + +/** A null value means the selected environments disagree; activation sets them all on. */ +export function ListToggleRow( + props: Omit & { + readonly value: boolean | null; + readonly onValueChange: (value: boolean) => void; + }, +) { + return ( + props.onValueChange(true)} + > + Mixed · Set on + + ) : ( + + ) + } + /> + ); +} diff --git a/apps/mobile/src/features/settings/components/SettingsControlRow.tsx b/apps/mobile/src/features/settings/components/SettingsControlRow.tsx deleted file mode 100644 index 6f442af1b2fcd148bf496588a694bb997c762e94..0000000000000000000000000000000000000000 --- a/apps/mobile/src/features/settings/components/SettingsControlRow.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import type { ComponentProps, ReactNode } from "react"; -import { Platform, View } from "react-native"; - -import { SymbolView } from "../../../components/AppSymbol"; -import { AppText as Text } from "../../../components/AppText"; -import { cn } from "../../../lib/cn"; - -export function SettingsControlRow(props: { - readonly disabled?: boolean; - readonly icon: ComponentProps["name"]; - readonly label: string; - readonly subtitle?: string; - readonly children: ReactNode; -}) { - return ( - - - - {props.label} - {props.subtitle ? ( - {props.subtitle} - ) : null} - - {props.children} - - ); -} diff --git a/apps/mobile/src/features/settings/components/SettingsSwitchRow.tsx b/apps/mobile/src/features/settings/components/SettingsSwitchRow.tsx index 3fb95f5699a959c73f48476720505bc77cd9b9d9..156e5e7db3895df439ee3182636e0811c0ec58fb 100644 --- a/apps/mobile/src/features/settings/components/SettingsSwitchRow.tsx +++ b/apps/mobile/src/features/settings/components/SettingsSwitchRow.tsx @@ -1,42 +1,12 @@ import type { ComponentProps } from "react"; -import { Pressable } from "react-native"; -import { AppText as Text } from "../../../components/AppText"; -import { ThemedSwitch } from "../../../components/ThemedSwitch"; -import { SettingsControlRow } from "./SettingsControlRow"; +import { ListToggleRow } from "../../../components/ListToggleRow"; -export function SettingsSwitchRow( - props: Omit, "children"> & { - readonly value: boolean | null; - readonly onValueChange: (value: boolean) => void; - }, -) { - return ( - - {props.value === null ? ( - props.onValueChange(true)} - > - Mixed · Set on - - ) : ( - - )} - - ); +export function SettingsSwitchRow({ + subtitle, + ...props +}: Omit, "description"> & { + readonly subtitle?: string; +}) { + return ; } -- 2.54.0