Skip to content

Commit fa9bdfa

Browse files
shivamhwpclaude
andcommitted
fix(mobile): shorten the iOS undo toast and balance its insets
The iOS toast with an action button was about 63pt tall because the action used the full 48pt button inside 12pt padding, and its icon sat closer to the edge than the action label did. Add a compact Button size, use it in iOS toasts with 8pt padding, and give the leading icon the same inset as the action label. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent 8648aea commit fa9bdfa

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

‎apps/mobile/src/components/ui/Button.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface ButtonProps {
1414
readonly loading?: boolean;
1515
readonly tone?: "primary" | "secondary" | "danger" | "text" | "contrast";
1616
readonly fullWidth?: boolean;
17+
readonly size?: "default" | "compact";
1718
}
1819

1920
const TONE_CLASS_NAMES = {
@@ -36,7 +37,8 @@ export function Button(props: ButtonProps) {
3637
disabled={disabled}
3738
onPress={props.onPress}
3839
className={cn(
39-
"min-h-12 flex-row items-center justify-center gap-2 rounded-full px-6 active:opacity-70",
40+
"flex-row items-center justify-center gap-2 rounded-full active:opacity-70",
41+
props.size === "compact" ? "min-h-10 px-5" : "min-h-12 px-6",
4042
props.fullWidth ? "w-full" : "self-start",
4143
disabled ? "bg-subtle-strong" : containerClassName,
4244
)}

‎apps/mobile/src/components/ui/Toast.tsx‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { cn } from "../../lib/cn";
12
import { MOBILE_MOTION, MOBILE_SHAPE } from "../../lib/designTokens";
23
import { useCallback, useEffect, useLayoutEffect, useState } from "react";
34
import { AccessibilityInfo, Platform, StyleSheet, View, useWindowDimensions } from "react-native";
@@ -45,15 +46,19 @@ export function Toast(props: ToastProps) {
4546
function ToastContent(props: ToastProps & { readonly glassReady?: boolean }) {
4647
const { fontScale } = useWindowDimensions();
4748
const { colorScheme } = useControlTheme();
48-
const borderRadius = Platform.OS === "ios" ? 31 : MOBILE_SHAPE.toast;
49+
const borderRadius = Platform.OS === "ios" ? 28 : MOBILE_SHAPE.toast;
4950
// Explicit single-line notices reserve the action's width and truncate the text.
5051
const inlineAction = props.singleLine || (!props.description && fontScale < 1.5);
5152
const message =
5253
props.singleLine && props.description
5354
? `${props.message}: ${props.description}`
5455
: props.message;
5556
const action = props.action ? (
56-
<Button label={props.action.label} onPress={props.action.onPress} />
57+
<Button
58+
label={props.action.label}
59+
onPress={props.action.onPress}
60+
size={Platform.OS === "ios" ? "compact" : "default"}
61+
/>
5762
) : null;
5863
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- announces the toast message to VoiceOver through AccessibilityInfo
5964
useEffect(() => {
@@ -64,10 +69,16 @@ function ToastContent(props: ToastProps & { readonly glassReady?: boolean }) {
6469
key={props.glassReady === false ? "entering" : "settled"}
6570
chrome={Platform.OS === "ios" && colorScheme === "dark" ? "none" : undefined}
6671
tintColor={Platform.OS === "ios" ? null : undefined}
67-
className={Platform.OS === "ios" ? "bg-transparent p-3" : "p-3"}
72+
className={Platform.OS === "ios" ? "bg-transparent p-2" : "p-3"}
6873
style={{ borderRadius }}
6974
>
70-
<View className="flex-row items-center gap-3">
75+
<View
76+
className={cn(
77+
"flex-row items-center gap-3",
78+
// Match the leading inset to the action label's, which sits inside the button's padding.
79+
Platform.OS === "ios" && inlineAction && action && "pl-5",
80+
)}
81+
>
7182
{props.busy ? (
7283
<AppActivityIndicator />
7384
) : (

0 commit comments

Comments
 (0)