fix(mobile): share settings control row layout (#12356)
This commit is contained in:
1 parent
05a8c6016a
commit
a1390ac655
3 files changed
+61
-49
No files matched your search
@@ -22,6 +22,7 @@ import {
|
||||
SettingsEnvironmentFilterHeader,
|
||||
} from "./components/SettingsEnvironmentFilterHeader";
|
||||
import { SettingsSection } from "./components/SettingsSection";
|
||||
import { SettingsControlRow } from "./components/SettingsControlRow";
|
||||
import { SettingsSwitchRow } from "./components/SettingsSwitchRow";
|
||||
import { SettingsProjectOverridesSection } from "./components/SettingsProjectOverridesSection";
|
||||
import { useSettingsEnvironmentFilter } from "./settings-environment-filter";
|
||||
@@ -454,21 +455,21 @@ function FanoutSwitchRow(props: {
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="flex-row items-center gap-4 p-4">
|
||||
<SymbolView name={props.icon} size={22} tintColorClassName="accent-icon" />
|
||||
<View className="min-w-0 flex-1 gap-1">
|
||||
<Text className="text-lg text-foreground">{props.label}</Text>
|
||||
<Text className="text-sm text-foreground-muted">{props.subtitle}</Text>
|
||||
</View>
|
||||
<SettingsControlRow
|
||||
disabled={props.disabled}
|
||||
icon={props.icon}
|
||||
label={props.label}
|
||||
subtitle={props.subtitle}
|
||||
>
|
||||
<Pressable
|
||||
accessibilityLabel={`Set ${props.label} on for selected environments`}
|
||||
accessibilityRole="button"
|
||||
disabled={props.disabled}
|
||||
className="rounded-full bg-subtle px-3 py-2 active:opacity-70 disabled:opacity-40"
|
||||
className="rounded-full bg-subtle px-3 py-2 active:opacity-70"
|
||||
onPress={() => props.onValueChange(true)}
|
||||
>
|
||||
<Text className="text-sm font-t3-medium text-foreground">Mixed · Set on</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
</SettingsControlRow>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
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<typeof SymbolView>["name"];
|
||||
readonly label: string;
|
||||
readonly subtitle?: string;
|
||||
readonly children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<View
|
||||
className={cn(
|
||||
"flex-row items-center gap-4 p-4 android:min-h-14 android:py-3",
|
||||
props.subtitle && "android:min-h-18",
|
||||
props.disabled && "opacity-[0.45]",
|
||||
)}
|
||||
>
|
||||
<SymbolView
|
||||
name={props.icon}
|
||||
size={Platform.OS === "android" ? 24 : 22}
|
||||
tintColorClassName="accent-icon"
|
||||
type="monochrome"
|
||||
weight="regular"
|
||||
/>
|
||||
<View className="min-w-0 flex-1 android:gap-1">
|
||||
<Text className="text-lg text-foreground android:text-base">{props.label}</Text>
|
||||
{props.subtitle ? (
|
||||
<Text className="text-sm text-foreground-muted">{props.subtitle}</Text>
|
||||
) : null}
|
||||
</View>
|
||||
{props.children}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,55 +1,27 @@
|
||||
import { cn } from "../../../lib/cn";
|
||||
import type { ComponentProps } from "react";
|
||||
import { Platform, View } from "react-native";
|
||||
|
||||
import { SymbolView } from "../../../components/AppSymbol";
|
||||
import { AppText as Text } from "../../../components/AppText";
|
||||
import { ThemedSwitch } from "../../../components/ThemedSwitch";
|
||||
import { SettingsControlRow } from "./SettingsControlRow";
|
||||
|
||||
type SymbolName = ComponentProps<typeof SymbolView>["name"];
|
||||
|
||||
export function SettingsSwitchRow(props: {
|
||||
readonly disabled?: boolean;
|
||||
readonly icon: SymbolName;
|
||||
readonly label: string;
|
||||
readonly subtitle?: string;
|
||||
readonly value: boolean;
|
||||
readonly onValueChange: (value: boolean) => void;
|
||||
}) {
|
||||
export function SettingsSwitchRow(
|
||||
props: Omit<ComponentProps<typeof SettingsControlRow>, "children"> & {
|
||||
readonly value: boolean;
|
||||
readonly onValueChange: (value: boolean) => void;
|
||||
},
|
||||
) {
|
||||
return (
|
||||
<View
|
||||
className={cn(
|
||||
"flex-row items-center gap-4",
|
||||
Platform.OS === "android" ? "min-h-14 px-4 py-3" : "p-4",
|
||||
Platform.OS === "android" && props.subtitle && "min-h-18",
|
||||
props.disabled && "opacity-[0.45]",
|
||||
)}
|
||||
<SettingsControlRow
|
||||
disabled={props.disabled}
|
||||
icon={props.icon}
|
||||
label={props.label}
|
||||
subtitle={props.subtitle}
|
||||
>
|
||||
<SymbolView
|
||||
name={props.icon}
|
||||
size={Platform.OS === "android" ? 24 : 22}
|
||||
tintColorClassName="accent-icon"
|
||||
type="monochrome"
|
||||
weight="regular"
|
||||
/>
|
||||
<View className={cn("min-w-0 flex-1", Platform.OS === "android" && "gap-1")}>
|
||||
<Text
|
||||
className={
|
||||
Platform.OS === "android" ? "text-base text-foreground" : "text-lg text-foreground"
|
||||
}
|
||||
>
|
||||
{props.label}
|
||||
</Text>
|
||||
{props.subtitle ? (
|
||||
<Text className="text-sm text-foreground-muted">{props.subtitle}</Text>
|
||||
) : null}
|
||||
</View>
|
||||
<ThemedSwitch
|
||||
accessibilityLabel={props.label}
|
||||
disabled={props.disabled}
|
||||
onValueChange={props.onValueChange}
|
||||
value={props.value}
|
||||
/>
|
||||
</View>
|
||||
</SettingsControlRow>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user