GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(mobile): undo toasts keep their action on one row (#23910) · incognitojam/styal@f4ac1e2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/mobile/src/components/ui
    • Toast.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: apps/mobile/src/components/ui/Toast.tsx
+10-6Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { MOBILE_SHAPE } from "../../lib/designTokens";
22
import { useEffect } from "react";
3-
import { AccessibilityInfo, Platform, View } from "react-native";
3+
import { AccessibilityInfo, Platform, View, useWindowDimensions } from "react-native";
44

55
import { AppText } from "./AppText";
66
import { Button } from "./Button";
@@ -20,6 +20,13 @@ export interface ToastProps {
2020

2121
/** The owning screen places and dismisses feedback; actions are never implicit. */
2222
export function Toast(props: ToastProps) {
23+
const { fontScale } = useWindowDimensions();
24+
// A one-line message keeps its action on the same row. Descriptions and
25+
// accessibility text sizes need the full width, so the action moves below.
26+
const inlineAction = !props.description && fontScale < 1.5;
27+
const action = props.action ? (
28+
<Button label={props.action.label} onPress={props.action.onPress} />
29+
) : null;
2330
useEffect(() => {
2431
if (Platform.OS === "ios") AccessibilityInfo.announceForAccessibility(props.message);
2532
}, [props.message]);
@@ -47,15 +54,12 @@ export function Toast(props: ToastProps) {
4754
</AppText>
4855
) : null}
4956
</View>
57+
{inlineAction ? action : null}
5058
{props.onDismiss ? (
5159
<IconButton accessibilityLabel="Dismiss message" icon="xmark" onPress={props.onDismiss} />
5260
) : null}
5361
</View>
54-
{props.action ? (
55-
<View className="mt-2 self-end">
56-
<Button label={props.action.label} onPress={props.action.onPress} />
57-
</View>
58-
) : null}
62+
{action && !inlineAction ? <View className="mt-2 self-end">{action}</View> : null}
5963
</GlassSurface>
6064
);
6165
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.