mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-26 02:05:31 +00:00
fix(app): share the settings row label line between row kinds
After the rebase, rows that lead somewhere drew their own label line with no room for an accessory. On Devices, the "Recommended" badge made the Relay row 2 px taller than the Tailscale row and moved its hint down 1 px. SettingsRowTitle now draws the label and accessory for inline-control rows and for rows that lead somewhere. The accessory overlaps the row's padding, so a row with a badge or info tip has the same label and hint positions as a row without one. Give the Tailscale on/off journey a 120 s budget. Its loading checks open Devices and the setup four more times, and the journey took 52 to 58 s against the default 60 s.
This commit is contained in:
@@ -76,6 +76,8 @@ test("turns Tailscale on and off from Devices, asking first over Tailscale", asy
|
||||
baseURL,
|
||||
}, testInfo) => {
|
||||
test.skip(process.platform !== "linux", "Uses a second IPv4 loopback address");
|
||||
// The journey opens Devices or the setup six times, two of them over a slowed connection.
|
||||
test.setTimeout(120_000);
|
||||
if (!baseURL) throw new Error("Expected the app base URL");
|
||||
const daemon = await startTailscaleTestDaemon(baseURL);
|
||||
try {
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
useRef,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
import { View } from "react-native";
|
||||
import { Text, View } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import type {
|
||||
SettingsRowProps,
|
||||
@@ -25,8 +25,9 @@ import { DropdownTrigger } from "@/components/ui/dropdown-trigger";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { settingsStyles } from "@/styles/settings";
|
||||
import { ControlSizeProvider } from "@/components/ui/control-size";
|
||||
import { ExternalLink, type ExternalLinkProps } from "@/components/ui/external-link";
|
||||
import { useSettingsRowLayout } from "./row-density";
|
||||
import { SettingsRowLabel, type SettingsRowLink } from "./row-label";
|
||||
import { SettingsRowTitle } from "./row-label";
|
||||
export { SettingsRowChildren } from "./row-children";
|
||||
export { SettingsGroup } from "./headings/settings-group";
|
||||
export { SettingsSection } from "./headings/settings-section";
|
||||
@@ -46,7 +47,8 @@ interface AppRowExtras {
|
||||
labelAccessory?: ReactNode;
|
||||
/** An icon before the label, such as the thing the row is about. */
|
||||
leading?: ReactNode;
|
||||
link?: SettingsRowLink;
|
||||
/** A page outside the app that helps with this row, drawn under the hint as "Label ↗". */
|
||||
link?: Pick<ExternalLinkProps, "href" | "label" | "accessibilityLabel">;
|
||||
}
|
||||
|
||||
interface AppSettingsRowProps extends Omit<SettingsRowProps, "hint">, AppRowExtras {
|
||||
@@ -68,7 +70,16 @@ export function SettingsCard({ children, testID }: { children: ReactNode; testID
|
||||
);
|
||||
}
|
||||
|
||||
export function SettingsRow({ leading, children, testID, ...text }: AppSettingsRowProps) {
|
||||
export function SettingsRow({
|
||||
label,
|
||||
leading,
|
||||
labelAccessory,
|
||||
hint,
|
||||
link,
|
||||
error,
|
||||
children,
|
||||
testID,
|
||||
}: AppSettingsRowProps) {
|
||||
const compact = useIsCompactFormFactor();
|
||||
const layout = useSettingsRowLayout();
|
||||
const rowStyle = useMemo(() => [layout.row, compact && styles.compactRow], [compact, layout]);
|
||||
@@ -76,7 +87,18 @@ export function SettingsRow({ leading, children, testID, ...text }: AppSettingsR
|
||||
<View style={rowStyle} testID={testID}>
|
||||
{leading ? <View style={styles.leading}>{leading}</View> : null}
|
||||
<View style={styles.label}>
|
||||
<SettingsRowLabel {...text} />
|
||||
<SettingsRowTitle label={label} accessory={labelAccessory} />
|
||||
{typeof hint === "string" ? <Text style={layout.hint}>{hint}</Text> : hint}
|
||||
{link ? (
|
||||
<View style={styles.link}>
|
||||
<ExternalLink {...link} />
|
||||
</View>
|
||||
) : null}
|
||||
{error ? (
|
||||
<Text accessibilityRole="alert" style={settingsStyles.rowError}>
|
||||
{error}
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
{children ? (
|
||||
<View style={styles.control}>
|
||||
@@ -218,6 +240,7 @@ const styles = StyleSheet.create((theme) => ({
|
||||
// The same leading slot as `SettingsRowHeader`, so icons and labels share rails across row kinds.
|
||||
leading: { marginRight: theme.spacing[3], alignItems: "center", justifyContent: "center" },
|
||||
label: { flexGrow: 1, flexShrink: 1, flexBasis: 160, marginRight: theme.spacing[3] },
|
||||
link: { alignItems: "flex-start", marginTop: theme.spacing[1] },
|
||||
control: { flexShrink: 1, maxWidth: "100%" },
|
||||
input: { minWidth: 180 },
|
||||
}));
|
||||
|
||||
@@ -11,6 +11,7 @@ import { SkeletonPulse, useSkeletonPulse } from "@/components/ui/skeleton";
|
||||
import { settingsStyles } from "@/styles/settings";
|
||||
import { ICON_SIZE, type Theme } from "@/styles/theme";
|
||||
import { useSettingsRowLayout, type SettingsRowLayout } from "./row-density";
|
||||
import { SettingsRowTitle } from "./row-label";
|
||||
|
||||
const ThemedChevron = withUnistyles(ChevronRight);
|
||||
const ThemedLoadingSpinner = withUnistyles(LoadingSpinner);
|
||||
@@ -114,9 +115,8 @@ export function SettingsRowHeader({
|
||||
</View>
|
||||
) : null}
|
||||
<View style={[settingsStyles.rowContent, styles.passThrough]}>
|
||||
<View style={labelAccessory ? styles.labelRow : undefined} {...HIDDEN_FROM_ASSISTIVE_TECH}>
|
||||
<Text style={layout.title}>{label}</Text>
|
||||
{labelAccessory}
|
||||
<View {...HIDDEN_FROM_ASSISTIVE_TECH}>
|
||||
<SettingsRowTitle label={label} accessory={labelAccessory} />
|
||||
</View>
|
||||
{hintStatus ? (
|
||||
<RowHintLine hint={hint} status={hintStatus} hintStyle={layout.hint} />
|
||||
@@ -256,7 +256,6 @@ const styles = StyleSheet.create((theme) => ({
|
||||
borderRadius: theme.borderRadius.sm,
|
||||
backgroundColor: theme.colors.surface2,
|
||||
},
|
||||
labelRow: { flexDirection: "row", alignItems: "center", gap: theme.spacing[2] },
|
||||
summary: {
|
||||
flexShrink: 1,
|
||||
color: theme.colors.foregroundMuted,
|
||||
|
||||
@@ -1,70 +1,34 @@
|
||||
import { useMemo, type ReactNode } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { ExternalLink, type ExternalLinkProps } from "@/components/ui/external-link";
|
||||
import { settingsStyles } from "@/styles/settings";
|
||||
import { useSettingsRowLayout } from "./row-density";
|
||||
|
||||
export type SettingsRowLink = Pick<ExternalLinkProps, "href" | "label" | "accessibilityLabel">;
|
||||
|
||||
export interface SettingsRowLabelProps {
|
||||
label: string;
|
||||
/** Shown beside the label, such as a badge. */
|
||||
labelAccessory?: ReactNode;
|
||||
/** A string is drawn as the hint line; any other node is drawn as given. */
|
||||
hint?: ReactNode;
|
||||
/** A page outside the app that helps with this row, drawn under the hint as "Label ↗". */
|
||||
link?: SettingsRowLink;
|
||||
error?: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The text column shared by settings rows with inline controls and collapsible content.
|
||||
* A row's label line: the label, and beside it an accessory such as a badge or an info tip. Rows
|
||||
* with inline controls and rows that lead somewhere both draw it, so their labels and hints keep
|
||||
* the same distances whether or not a row carries an accessory.
|
||||
*/
|
||||
export function SettingsRowLabel({
|
||||
label,
|
||||
labelAccessory,
|
||||
hint,
|
||||
link,
|
||||
error,
|
||||
}: SettingsRowLabelProps) {
|
||||
export function SettingsRowTitle({ label, accessory }: { label: string; accessory?: ReactNode }) {
|
||||
const layout = useSettingsRowLayout();
|
||||
const accessoryTitleStyle = useMemo(() => [layout.title, styles.accessoryLabel], [layout]);
|
||||
const titleStyle = useMemo(() => [layout.title, styles.title], [layout]);
|
||||
if (!accessory) return <Text style={layout.title}>{label}</Text>;
|
||||
return (
|
||||
<>
|
||||
{labelAccessory ? (
|
||||
<View style={styles.labelRow}>
|
||||
<Text style={accessoryTitleStyle}>{label}</Text>
|
||||
<View style={styles.accessory}>{labelAccessory}</View>
|
||||
</View>
|
||||
) : (
|
||||
<Text style={layout.title}>{label}</Text>
|
||||
)}
|
||||
{typeof hint === "string" ? <Text style={layout.hint}>{hint}</Text> : hint}
|
||||
{link ? (
|
||||
<View style={styles.link}>
|
||||
<ExternalLink {...link} />
|
||||
</View>
|
||||
) : null}
|
||||
{error ? (
|
||||
<Text accessibilityRole="alert" style={settingsStyles.rowError}>
|
||||
{error}
|
||||
</Text>
|
||||
) : null}
|
||||
</>
|
||||
<View style={styles.line}>
|
||||
<Text style={titleStyle}>{label}</Text>
|
||||
<View style={styles.accessory}>{accessory}</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
labelRow: {
|
||||
line: {
|
||||
flexDirection: "row",
|
||||
flexWrap: "wrap",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[2],
|
||||
},
|
||||
accessoryLabel: { flexShrink: 1, minWidth: 0 },
|
||||
// A badge is taller than the label's line. It hangs into the row's padding instead, so the label
|
||||
// and hint keep the distances of a row without one.
|
||||
title: { flexShrink: 1, minWidth: 0 },
|
||||
// An accessory is taller than the label's line. It hangs into the row's padding instead, so the
|
||||
// label and hint keep the distances of a row without one.
|
||||
accessory: { marginVertical: -theme.spacing[1] },
|
||||
link: { alignItems: "flex-start", marginTop: theme.spacing[1] },
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user