Skip to content
TypeScript

refactor(mobile): share preview actions (#21942)

Julius Marminge6e37f7116c70
diff --git a/apps/mobile/src/components/ComposerContextAttachment.tsx b/apps/mobile/src/components/ComposerContextAttachment.tsx
index e766a35177e..b198c5add65 100644
--- a/apps/mobile/src/components/ComposerContextAttachment.tsx
+++ b/apps/mobile/src/components/ComposerContextAttachment.tsx
@@ -1,3 +1,4 @@
+import { Button } from "./ui/Button";
import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
import { AsyncResult } from "effect/reactivity";
import * as Dialog from "./ui/Dialog";
@@ -118,16 +119,14 @@ export function ComposerContextAttachment(props: {
</Text>
) : null}
<PresentationSource identifier={shareSourceIdentifier}>
- <Pressable
- accessibilityRole="button"
+ <Button
+ label={sharing ? "Opening attachment…" : "Open or share attachment"}
+ tone="secondary"
disabled={sharing}
onPress={() => void share()}
- className="rounded-xl bg-subtle p-4"
- >
- <Text className="text-foreground">
- {sharing ? "Opening attachment…" : "Open or share attachment"}
- </Text>
- </Pressable>
+ fullWidth
+ loading={sharing}
+ />
</PresentationSource>
{previewOpen && record.kind === "image" && uri ? (
<FilePreviewModal
diff --git a/apps/mobile/src/components/ComposerContextSheet.tsx b/apps/mobile/src/components/ComposerContextSheet.tsx
index 3f941d65aec..1cafc5814c5 100644
--- a/apps/mobile/src/components/ComposerContextSheet.tsx
+++ b/apps/mobile/src/components/ComposerContextSheet.tsx
@@ -1,3 +1,4 @@
+import { Button } from "./ui/Button";
import * as Dialog from "./ui/Dialog";
import { useOpenPullRequest } from "../native/useOpenPullRequest";
import { SourceFileSurface } from "../features/files/SourceFileSurface";
@@ -299,18 +300,17 @@ export function ComposerContextSheet(props: {
<View className="gap-3">
<ContextField label="Thread" value={record.title} />
{props.onOpenThread ? (
- <Pressable
- accessibilityRole="button"
+ <Button
+ label="Open thread"
+ tone="secondary"
onPress={() =>
props.onOpenThread?.({
environmentId: record.environmentId,
threadId: record.threadId,
})
}
- className="rounded-xl bg-subtle p-4"
- >
- <Text className="text-foreground">Open thread</Text>
- </Pressable>
+ fullWidth
+ />
) : null}
</View>
) : null}
@@ -322,13 +322,12 @@ export function ComposerContextSheet(props: {
value={props.skillDescription ?? "No description is available for this skill."}
/>
{props.onOpenSkill ? (
- <Pressable
- accessibilityRole="button"
+ <Button
+ label="View instructions"
+ tone="secondary"
onPress={props.onOpenSkill}
- className="rounded-xl bg-subtle p-4"
- >
- <Text className="text-foreground">View instructions</Text>
- </Pressable>
+ fullWidth
+ />
) : null}
</View>
) : null}
@@ -364,31 +363,23 @@ export function ComposerContextSheet(props: {
</Pressable>
) : null}
{props.onOpenAttachment ? (
- <Pressable
- accessibilityRole="button"
+ <Button
+ label="Open attachment"
+ tone="secondary"
onPress={props.onOpenAttachment}
- className="rounded-xl bg-subtle p-4"
- >
- <Text className="text-foreground">Open attachment</Text>
- </Pressable>
+ fullWidth
+ />
) : null}
{props.onOpenPullRequest && !pullRequestUrl ? (
- <Pressable
- accessibilityRole="button"
+ <Button
+ label="Open pull request"
+ tone="secondary"
onPress={props.onOpenPullRequest}
- className="rounded-xl bg-subtle p-4"
- >
- <Text className="text-foreground">Open pull request</Text>
- </Pressable>
+ fullWidth
+ />
) : null}
{props.onRemove ? (
- <Pressable
- accessibilityRole="button"
- onPress={props.onRemove}
- className="rounded-xl bg-subtle p-4"
- >
- <Text className="text-foreground">Remove from draft</Text>
- </Pressable>
+ <Button label="Remove from draft" tone="secondary" onPress={props.onRemove} fullWidth />
) : null}
</ScrollView>
</Sheet>
diff --git a/apps/mobile/src/components/FilePreview.tsx b/apps/mobile/src/components/FilePreview.tsx
index 179b48d1610..b0cf1fc5c3a 100644
--- a/apps/mobile/src/components/FilePreview.tsx
+++ b/apps/mobile/src/components/FilePreview.tsx
@@ -1,6 +1,7 @@
+import { Button } from "./ui/Button";
import * as Dialog from "./ui/Dialog";
import { useEffect, useEffectEvent } from "react";
-import { Modal, Pressable, View } from "react-native";
+import { Modal, View } from "react-native";
import ImageViewing from "react-native-image-viewing";
import { useSafeAreaInsets } from "react-native-safe-area-context";
@@ -84,13 +85,9 @@ function DocumentPreview(props: {
<Text className="text-foreground-muted" numberOfLines={2}>
{name ?? "Document"}
</Text>
- <Pressable
- accessibilityRole="button"
- onPress={props.onRequestClose}
- className="self-end p-3"
- >
- <Text className="text-foreground">Cancel</Text>
- </Pressable>
+ <View className="items-end">
+ <Button label="Cancel" tone="text" onPress={props.onRequestClose} />
+ </View>
</View>
</View>
</Modal>
diff --git a/apps/mobile/src/features/browser/PreviewStreamWebView.tsx b/apps/mobile/src/features/browser/PreviewStreamWebView.tsx
index 1f436162594..c13383e98b6 100644
--- a/apps/mobile/src/features/browser/PreviewStreamWebView.tsx
+++ b/apps/mobile/src/features/browser/PreviewStreamWebView.tsx
@@ -1,3 +1,4 @@
+import { Button } from "../../components/ui/Button";
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
import * as Dialog from "../../components/ui/Dialog";
import previewStreamScript from "@t3tools/mobile-preview-stream";
@@ -142,13 +143,9 @@ export function PreviewStreamWebView(
{error || "Connecting to browser..."}
</AppText>
{error && (
- <Pressable
- accessibilityRole="button"
- className="rounded-full border border-secondary-border bg-secondary px-6 py-3"
- onPress={refresh}
- >
- <AppText className="text-secondary-foreground">Retry</AppText>
- </Pressable>
+ <View className="items-center">
+ <Button label="Retry" tone="secondary" onPress={refresh} />
+ </View>
)}
</>
)}
@@ -335,19 +332,14 @@ function PreviewStreamDocumentView({
{previewStreamControlLabel(control)}
</AppText>
{control?.canOperate ? (
- <Pressable
- accessibilityRole="button"
+ <Button
+ label={control.controller === "you" ? "Release control" : "Take control"}
+ tone="secondary"
disabled={control.controller === "another-viewer"}
- accessibilityState={{ disabled: control.controller === "another-viewer" }}
- className="rounded-full border border-secondary-border bg-secondary px-3 py-2"
onPress={() =>
command({ type: control.controller === "you" ? "releaseControl" : "takeControl" })
}
- >
- <AppText className="text-xs text-secondary-foreground">
- {control.controller === "you" ? "Release control" : "Take control"}
- </AppText>
- </Pressable>
+ />
) : null}
</View>
) : null}
@@ -445,22 +437,12 @@ function PreviewStreamDocumentView({
The page asks for {fileChooser.multiple ? "files" : "a file"}.
</AppText>
<View className="flex-row justify-end gap-3">
- <Pressable
- accessibilityRole="button"
- className="px-3 py-2"
- onPress={() => answerFileChooser(false)}
- >
- <AppText className="text-secondary-foreground">Cancel</AppText>
- </Pressable>
- <Pressable
- accessibilityRole="button"
- className="px-3 py-2"
+ <Button label="Cancel" tone="text" onPress={() => answerFileChooser(false)} />
+ <Button
+ label={`Choose ${fileChooser.multiple ? "files" : "file"}`}
+ tone="secondary"
onPress={() => answerFileChooser(true)}
- >
- <AppText className="text-secondary-foreground">
- Choose {fileChooser.multiple ? "files" : "file"}
- </AppText>
- </Pressable>
+ />
</View>
</View>
) : null}
@@ -480,16 +462,14 @@ function PreviewStreamDocumentView({
/>
) : null}
<View className="flex-row justify-end gap-3">
- <Pressable
- accessibilityRole="button"
- className="px-3 py-2"
+ <Button
+ label="Dismiss"
+ tone="text"
onPress={() => command({ type: "dialog", accept: false })}
- >
- <AppText className="text-secondary-foreground">Dismiss</AppText>
- </Pressable>
- <Pressable
- accessibilityRole="button"
- className="px-3 py-2"
+ />
+ <Button
+ label="Accept"
+ tone="secondary"
onPress={() =>
command({
type: "dialog",
@@ -497,9 +477,7 @@ function PreviewStreamDocumentView({
...(control.dialog?.type === "prompt" ? { promptText } : {}),
})
}
- >
- <AppText className="text-secondary-foreground">Accept</AppText>
- </Pressable>
+ />
</View>
</>
) : (
@@ -537,15 +515,13 @@ function PreviewStreamDocumentView({
</Pressable>
) : null}
{status === "error" && !gone && !compact ? (
- <Pressable
- accessibilityRole="button"
- className="rounded-full border border-secondary-border bg-secondary px-6 py-3"
- onPress={onRetry}
- >
- <AppText className="text-secondary-foreground">
- {hostSetup ? "Try again" : "Reconnect"}
- </AppText>
- </Pressable>
+ <View className="items-center">
+ <Button
+ label={hostSetup ? "Try again" : "Reconnect"}
+ tone="secondary"
+ onPress={onRetry}
+ />
+ </View>
) : null}
</View>
) : null}
diff --git a/apps/mobile/src/features/devices/DevicePreviewRouteScreen.tsx b/apps/mobile/src/features/devices/DevicePreviewRouteScreen.tsx
index b09152e9f90..58a9e134d5f 100644
--- a/apps/mobile/src/features/devices/DevicePreviewRouteScreen.tsx
+++ b/apps/mobile/src/features/devices/DevicePreviewRouteScreen.tsx
@@ -1,3 +1,4 @@
+import { Button } from "../../components/ui/Button";
import * as Dialog from "../../components/ui/Dialog";
import {
deviceToolVersionLabels,
@@ -270,13 +271,9 @@ function DevicePreviewScreen({
<AppText selectable className="text-center text-sm text-foreground-muted">
{state.error}
</AppText>
- <Pressable
- accessibilityRole="button"
- className="rounded-full border border-secondary-border bg-secondary px-6 py-3"
- onPress={state.refresh}
- >
- <AppText className="text-secondary-foreground">Retry</AppText>
- </Pressable>
+ <View className="items-center">
+ <Button label="Retry" tone="secondary" onPress={state.refresh} />
+ </View>
</>
) : focused && foreground ? (
<AppActivityIndicator color={themeVariables["--color-icon"]} />
@@ -399,13 +396,9 @@ function OpenDevicePreview({
<AppText selectable className="text-center text-sm text-foreground-muted">
{error}
</AppText>
- <Pressable
- accessibilityRole="button"
- className="rounded-full border border-secondary-border bg-secondary px-6 py-3"
- onPress={refresh}
- >
- <AppText className="text-secondary-foreground">Retry</AppText>
- </Pressable>
+ <View className="items-center">
+ <Button label="Retry" tone="secondary" onPress={refresh} />
+ </View>
</>
) : (
<>
diff --git a/apps/mobile/src/features/devices/DeviceStreamWebView.tsx b/apps/mobile/src/features/devices/DeviceStreamWebView.tsx
index 76fc8333791..4614bbd10b8 100644
--- a/apps/mobile/src/features/devices/DeviceStreamWebView.tsx
+++ b/apps/mobile/src/features/devices/DeviceStreamWebView.tsx
@@ -1,3 +1,4 @@
+import { Button } from "../../components/ui/Button";
import deviceStreamScript from "@t3tools/mobile-device-stream";
import {
useEffect,
@@ -8,7 +9,7 @@ import {
useState,
type Ref,
} from "react";
-import { Platform, Pressable, View } from "react-native";
+import { Platform, View } from "react-native";
import { WebView } from "react-native-webview";
import type { DeviceStreamStatus } from "@t3tools/client-runtime/device/stream";
@@ -194,13 +195,9 @@ function DeviceStreamDocumentView({
{status === "error" ? error : "Connecting to device..."}
</AppText>
{status === "error" ? (
- <Pressable
- accessibilityRole="button"
- className="rounded-full border border-secondary-border bg-secondary px-6 py-3"
- onPress={onRetry}
- >
- <AppText className="text-secondary-foreground">Reconnect</AppText>
- </Pressable>
+ <View className="items-center">
+ <Button label="Reconnect" tone="secondary" onPress={onRetry} />
+ </View>
) : null}
</View>
) : null}
diff --git a/apps/mobile/src/features/files/AudioFilePreview.tsx b/apps/mobile/src/features/files/AudioFilePreview.tsx
index 6da6524ade6..02358055e2a 100644
--- a/apps/mobile/src/features/files/AudioFilePreview.tsx
+++ b/apps/mobile/src/features/files/AudioFilePreview.tsx
@@ -1,6 +1,7 @@
+import { Button } from "../../components/ui/Button";
import { useAudioPlayer, useAudioPlayerStatus } from "expo-audio";
import { useEffect, useState } from "react";
-import { Pressable, View } from "react-native";
+import { View } from "react-native";
import { AppText as Text } from "../../components/ui/AppText";
import { useFullscreenVideoOpen, useMediaAudioSessionHold } from "../../lib/videoAudioSession";
@@ -34,47 +35,39 @@ export function AudioFilePreview(props: { uri: string; onRetry: () => void }) {
{timestamp(status.currentTime)} / {timestamp(status.duration)}
</Text>
<View className="flex-row items-center gap-4">
- <Pressable
- accessibilityRole="button"
+ <Button
+ label="−15s"
+ tone="text"
accessibilityLabel="Back 15 seconds"
disabled={!status.isLoaded}
onPress={() => seek(Math.max(0, status.currentTime - 15))}
- className="p-4"
- >
- <Text className="text-foreground">−15s</Text>
- </Pressable>
- <Pressable
- accessibilityRole="button"
+ />
+ <Button
+ label={!status.isLoaded ? "Loading…" : status.playing ? "Pause" : "Play"}
+ tone="secondary"
disabled={!status.isLoaded}
onPress={() => {
if (status.playing) player.pause();
else if (status.didJustFinish || status.currentTime >= status.duration) seek(0, true);
else player.play();
}}
- className="rounded-xl bg-subtle px-6 py-4"
- >
- <Text className="text-foreground">
- {!status.isLoaded ? "Loading…" : status.playing ? "Pause" : "Play"}
- </Text>
- </Pressable>
- <Pressable
- accessibilityRole="button"
+ />
+ <Button
+ label="+15s"
+ tone="text"
accessibilityLabel="Forward 15 seconds"
disabled={!status.isLoaded}
onPress={() => seek(Math.min(status.duration, status.currentTime + 15))}
- className="p-4"
- >
- <Text className="text-foreground">+15s</Text>
- </Pressable>
+ />
</View>
{status.error || seekError ? (
<View className="items-center gap-3">
<Text className="text-center text-foreground">
This audio could not be played. Try again or save it to open in another app.
</Text>
- <Pressable accessibilityRole="button" onPress={props.onRetry} className="p-3">
- <Text className="text-foreground">Try again</Text>
- </Pressable>
+ <View className="items-center">
+ <Button label="Try again" tone="secondary" onPress={props.onRetry} />
+ </View>
</View>
) : null}
</View>
diff --git a/apps/mobile/src/features/files/FileTreeBrowser.tsx b/apps/mobile/src/features/files/FileTreeBrowser.tsx
index dd3fd1a574c..b1f7e7658da 100644
--- a/apps/mobile/src/features/files/FileTreeBrowser.tsx
+++ b/apps/mobile/src/features/files/FileTreeBrowser.tsx
@@ -1,3 +1,4 @@
+import { Button } from "../../components/ui/Button";
import { LegendList } from "@legendapp/list/react-native";
import type { ProjectEntry } from "@t3tools/contracts";
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
@@ -264,14 +265,14 @@ export function FileTreeBrowser(props: {
>
{props.error}
</Text>
- <Pressable
- accessibilityRole="button"
- onPress={props.onRefresh}
- disabled={props.isPending}
- className="mt-3 min-h-11 self-start justify-center rounded-full bg-subtle px-4 active:opacity-70 disabled:opacity-50"
- >
- <Text className="text-sm font-t3-medium text-foreground">Try again</Text>
- </Pressable>
+ <View className="mt-3">
+ <Button
+ label="Try again"
+ tone="secondary"
+ onPress={props.onRefresh}
+ disabled={props.isPending}
+ />
+ </View>
</>
) : props.isPending ? (
<AppActivityIndicator size="small" />
diff --git a/apps/mobile/src/features/threads/McpAppWebView.tsx b/apps/mobile/src/features/threads/McpAppWebView.tsx
index 9e99f29864c..601ee7fc8a4 100644
--- a/apps/mobile/src/features/threads/McpAppWebView.tsx
+++ b/apps/mobile/src/features/threads/McpAppWebView.tsx
@@ -1,3 +1,4 @@
+import { Button } from "../../components/ui/Button";
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
import * as Dialog from "../../components/ui/Dialog";
import type { EnvironmentId, ThreadId, TurnItemId } from "@t3tools/contracts";
@@ -23,7 +24,7 @@ import * as Predicate from "effect/Predicate";
import Constants from "expo-constants";
import { useNavigation } from "@react-navigation/native";
import { useEffect, useMemo, useRef, useState } from "react";
-import { Platform, Pressable, View } from "react-native";
+import { Platform, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { WebView, type WebViewMessageEvent } from "react-native-webview";
@@ -490,15 +491,16 @@ export function ThreadMcpApp(props: {
className="items-center justify-center gap-2 rounded-lg border border-border"
>
<Text className="text-sm text-foreground-muted">The {app.server} app was closed</Text>
- <Pressable
- accessibilityRole="button"
- onPress={() => {
- setDocumentKey((value) => value + 1);
- setClosed(false);
- }}
- >
- <Text className="text-sm text-foreground">Show app</Text>
- </Pressable>
+ <View className="items-center">
+ <Button
+ label="Show app"
+ tone="secondary"
+ onPress={() => {
+ setDocumentKey((value) => value + 1);
+ setClosed(false);
+ }}
+ />
+ </View>
</View>
);
}