TypeScript
fix(mobile): shorten the iOS undo toast and balance its insets (#29775)
shivamf6503f0e717f
diff --git a/apps/mobile/src/components/ui/Button.tsx b/apps/mobile/src/components/ui/Button.tsxindex 05c6e008524..bb187f66713 100644--- a/apps/mobile/src/components/ui/Button.tsx+++ b/apps/mobile/src/components/ui/Button.tsx@@ -14,6 +14,7 @@ export interface ButtonProps {readonly loading?: boolean;readonly tone?: "primary" | "secondary" | "danger" | "text" | "contrast";readonly fullWidth?: boolean;+ readonly size?: "default" | "compact";}const TONE_CLASS_NAMES = {@@ -36,7 +37,8 @@ export function Button(props: ButtonProps) {disabled={disabled}onPress={props.onPress}className={cn(- "min-h-12 flex-row items-center justify-center gap-2 rounded-full px-6 active:opacity-70",+ "flex-row items-center justify-center gap-2 rounded-full active:opacity-70",+ props.size === "compact" ? "min-h-10 px-5" : "min-h-12 px-6",props.fullWidth ? "w-full" : "self-start",disabled ? "bg-subtle-strong" : containerClassName,)}diff --git a/apps/mobile/src/components/ui/Toast.tsx b/apps/mobile/src/components/ui/Toast.tsxindex 2483ac9fa12..49efbdf5203 100644--- a/apps/mobile/src/components/ui/Toast.tsx+++ b/apps/mobile/src/components/ui/Toast.tsx@@ -1,3 +1,4 @@+import { cn } from "../../lib/cn";import { MOBILE_MOTION, MOBILE_SHAPE } from "../../lib/designTokens";import { useCallback, useEffect, useLayoutEffect, useState } from "react";import { AccessibilityInfo, Platform, StyleSheet, View, useWindowDimensions } from "react-native";@@ -45,7 +46,7 @@ export function Toast(props: ToastProps) {function ToastContent(props: ToastProps & { readonly glassReady?: boolean }) {const { fontScale } = useWindowDimensions();const { colorScheme } = useControlTheme();- const borderRadius = Platform.OS === "ios" ? 31 : MOBILE_SHAPE.toast;+ const borderRadius = Platform.OS === "ios" ? 28 : MOBILE_SHAPE.toast;// Explicit single-line notices reserve the action's width and truncate the text.const inlineAction = props.singleLine || (!props.description && fontScale < 1.5);const message =@@ -53,7 +54,11 @@ function ToastContent(props: ToastProps & { readonly glassReady?: boolean }) {? `${props.message}: ${props.description}`: props.message;const action = props.action ? (- <Button label={props.action.label} onPress={props.action.onPress} />+ <Button+ label={props.action.label}+ onPress={props.action.onPress}+ size={Platform.OS === "ios" ? "compact" : "default"}+ />) : null;// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- announces the toast message to VoiceOver through AccessibilityInfouseEffect(() => {@@ -64,10 +69,16 @@ function ToastContent(props: ToastProps & { readonly glassReady?: boolean }) {key={props.glassReady === false ? "entering" : "settled"}chrome={Platform.OS === "ios" && colorScheme === "dark" ? "none" : undefined}tintColor={Platform.OS === "ios" ? null : undefined}- className={Platform.OS === "ios" ? "bg-transparent p-3" : "p-3"}+ className={Platform.OS === "ios" ? "bg-transparent p-2" : "p-3"}style={{ borderRadius }}>- <View className="flex-row items-center gap-3">+ <View+ className={cn(+ "flex-row items-center gap-3",+ // Match the leading inset to the action label's, which sits inside the button's padding.+ Platform.OS === "ios" && inlineAction && action && "pl-5",+ )}+ >{props.busy ? (<AppActivityIndicator />) : (