Skip to content

Commit b4c0be1

Browse files
refactor(mobile): use shared buttons for preview actions
1 parent 817ba55 commit b4c0be1

9 files changed

Lines changed: 112 additions & 163 deletions

File tree

‎apps/mobile/src/components/ComposerContextAttachment.tsx‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Button } from "./ui/Button";
12
import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
23
import { AsyncResult } from "effect/reactivity";
34
import * as Dialog from "./ui/Dialog";
@@ -118,16 +119,14 @@ export function ComposerContextAttachment(props: {
118119
</Text>
119120
) : null}
120121
<PresentationSource identifier={shareSourceIdentifier}>
121-
<Pressable
122-
accessibilityRole="button"
122+
<Button
123+
label={sharing ? "Opening attachment…" : "Open or share attachment"}
124+
tone="secondary"
123125
disabled={sharing}
124126
onPress={() => void share()}
125-
className="rounded-xl bg-subtle p-4"
126-
>
127-
<Text className="text-foreground">
128-
{sharing ? "Opening attachment…" : "Open or share attachment"}
129-
</Text>
130-
</Pressable>
127+
fullWidth
128+
loading={sharing}
129+
/>
131130
</PresentationSource>
132131
{previewOpen && record.kind === "image" && uri ? (
133132
<FilePreviewModal

‎apps/mobile/src/components/ComposerContextSheet.tsx‎

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Button } from "./ui/Button";
12
import * as Dialog from "./ui/Dialog";
23
import { useOpenPullRequest } from "../native/useOpenPullRequest";
34
import { SourceFileSurface } from "../features/files/SourceFileSurface";
@@ -299,18 +300,17 @@ export function ComposerContextSheet(props: {
299300
<View className="gap-3">
300301
<ContextField label="Thread" value={record.title} />
301302
{props.onOpenThread ? (
302-
<Pressable
303-
accessibilityRole="button"
303+
<Button
304+
label="Open thread"
305+
tone="secondary"
304306
onPress={() =>
305307
props.onOpenThread?.({
306308
environmentId: record.environmentId,
307309
threadId: record.threadId,
308310
})
309311
}
310-
className="rounded-xl bg-subtle p-4"
311-
>
312-
<Text className="text-foreground">Open thread</Text>
313-
</Pressable>
312+
fullWidth
313+
/>
314314
) : null}
315315
</View>
316316
) : null}
@@ -322,13 +322,12 @@ export function ComposerContextSheet(props: {
322322
value={props.skillDescription ?? "No description is available for this skill."}
323323
/>
324324
{props.onOpenSkill ? (
325-
<Pressable
326-
accessibilityRole="button"
325+
<Button
326+
label="View instructions"
327+
tone="secondary"
327328
onPress={props.onOpenSkill}
328-
className="rounded-xl bg-subtle p-4"
329-
>
330-
<Text className="text-foreground">View instructions</Text>
331-
</Pressable>
329+
fullWidth
330+
/>
332331
) : null}
333332
</View>
334333
) : null}
@@ -364,31 +363,23 @@ export function ComposerContextSheet(props: {
364363
</Pressable>
365364
) : null}
366365
{props.onOpenAttachment ? (
367-
<Pressable
368-
accessibilityRole="button"
366+
<Button
367+
label="Open attachment"
368+
tone="secondary"
369369
onPress={props.onOpenAttachment}
370-
className="rounded-xl bg-subtle p-4"
371-
>
372-
<Text className="text-foreground">Open attachment</Text>
373-
</Pressable>
370+
fullWidth
371+
/>
374372
) : null}
375373
{props.onOpenPullRequest && !pullRequestUrl ? (
376-
<Pressable
377-
accessibilityRole="button"
374+
<Button
375+
label="Open pull request"
376+
tone="secondary"
378377
onPress={props.onOpenPullRequest}
379-
className="rounded-xl bg-subtle p-4"
380-
>
381-
<Text className="text-foreground">Open pull request</Text>
382-
</Pressable>
378+
fullWidth
379+
/>
383380
) : null}
384381
{props.onRemove ? (
385-
<Pressable
386-
accessibilityRole="button"
387-
onPress={props.onRemove}
388-
className="rounded-xl bg-subtle p-4"
389-
>
390-
<Text className="text-foreground">Remove from draft</Text>
391-
</Pressable>
382+
<Button label="Remove from draft" tone="secondary" onPress={props.onRemove} fullWidth />
392383
) : null}
393384
</ScrollView>
394385
</Sheet>

‎apps/mobile/src/components/FilePreview.tsx‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { Button } from "./ui/Button";
12
import * as Dialog from "./ui/Dialog";
23
import { useEffect, useEffectEvent } from "react";
3-
import { Modal, Pressable, View } from "react-native";
4+
import { Modal, View } from "react-native";
45
import ImageViewing from "react-native-image-viewing";
56
import { useSafeAreaInsets } from "react-native-safe-area-context";
67

@@ -84,13 +85,9 @@ function DocumentPreview(props: {
8485
<Text className="text-foreground-muted" numberOfLines={2}>
8586
{name ?? "Document"}
8687
</Text>
87-
<Pressable
88-
accessibilityRole="button"
89-
onPress={props.onRequestClose}
90-
className="self-end p-3"
91-
>
92-
<Text className="text-foreground">Cancel</Text>
93-
</Pressable>
88+
<View className="items-end">
89+
<Button label="Cancel" tone="text" onPress={props.onRequestClose} />
90+
</View>
9491
</View>
9592
</View>
9693
</Modal>

‎apps/mobile/src/features/browser/PreviewStreamWebView.tsx‎

Lines changed: 28 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Button } from "../../components/ui/Button";
12
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
23
import * as Dialog from "../../components/ui/Dialog";
34
import previewStreamScript from "@t3tools/mobile-preview-stream";
@@ -142,13 +143,9 @@ export function PreviewStreamWebView(
142143
{error || "Connecting to browser..."}
143144
</AppText>
144145
{error && (
145-
<Pressable
146-
accessibilityRole="button"
147-
className="rounded-full border border-secondary-border bg-secondary px-6 py-3"
148-
onPress={refresh}
149-
>
150-
<AppText className="text-secondary-foreground">Retry</AppText>
151-
</Pressable>
146+
<View className="items-center">
147+
<Button label="Retry" tone="secondary" onPress={refresh} />
148+
</View>
152149
)}
153150
</>
154151
)}
@@ -335,19 +332,14 @@ function PreviewStreamDocumentView({
335332
{previewStreamControlLabel(control)}
336333
</AppText>
337334
{control?.canOperate ? (
338-
<Pressable
339-
accessibilityRole="button"
335+
<Button
336+
label={control.controller === "you" ? "Release control" : "Take control"}
337+
tone="secondary"
340338
disabled={control.controller === "another-viewer"}
341-
accessibilityState={{ disabled: control.controller === "another-viewer" }}
342-
className="rounded-full border border-secondary-border bg-secondary px-3 py-2"
343339
onPress={() =>
344340
command({ type: control.controller === "you" ? "releaseControl" : "takeControl" })
345341
}
346-
>
347-
<AppText className="text-xs text-secondary-foreground">
348-
{control.controller === "you" ? "Release control" : "Take control"}
349-
</AppText>
350-
</Pressable>
342+
/>
351343
) : null}
352344
</View>
353345
) : null}
@@ -445,22 +437,12 @@ function PreviewStreamDocumentView({
445437
The page asks for {fileChooser.multiple ? "files" : "a file"}.
446438
</AppText>
447439
<View className="flex-row justify-end gap-3">
448-
<Pressable
449-
accessibilityRole="button"
450-
className="px-3 py-2"
451-
onPress={() => answerFileChooser(false)}
452-
>
453-
<AppText className="text-secondary-foreground">Cancel</AppText>
454-
</Pressable>
455-
<Pressable
456-
accessibilityRole="button"
457-
className="px-3 py-2"
440+
<Button label="Cancel" tone="text" onPress={() => answerFileChooser(false)} />
441+
<Button
442+
label={`Choose ${fileChooser.multiple ? "files" : "file"}`}
443+
tone="secondary"
458444
onPress={() => answerFileChooser(true)}
459-
>
460-
<AppText className="text-secondary-foreground">
461-
Choose {fileChooser.multiple ? "files" : "file"}
462-
</AppText>
463-
</Pressable>
445+
/>
464446
</View>
465447
</View>
466448
) : null}
@@ -480,26 +462,22 @@ function PreviewStreamDocumentView({
480462
/>
481463
) : null}
482464
<View className="flex-row justify-end gap-3">
483-
<Pressable
484-
accessibilityRole="button"
485-
className="px-3 py-2"
465+
<Button
466+
label="Dismiss"
467+
tone="text"
486468
onPress={() => command({ type: "dialog", accept: false })}
487-
>
488-
<AppText className="text-secondary-foreground">Dismiss</AppText>
489-
</Pressable>
490-
<Pressable
491-
accessibilityRole="button"
492-
className="px-3 py-2"
469+
/>
470+
<Button
471+
label="Accept"
472+
tone="secondary"
493473
onPress={() =>
494474
command({
495475
type: "dialog",
496476
accept: true,
497477
...(control.dialog?.type === "prompt" ? { promptText } : {}),
498478
})
499479
}
500-
>
501-
<AppText className="text-secondary-foreground">Accept</AppText>
502-
</Pressable>
480+
/>
503481
</View>
504482
</>
505483
) : (
@@ -537,15 +515,13 @@ function PreviewStreamDocumentView({
537515
</Pressable>
538516
) : null}
539517
{status === "error" && !gone && !compact ? (
540-
<Pressable
541-
accessibilityRole="button"
542-
className="rounded-full border border-secondary-border bg-secondary px-6 py-3"
543-
onPress={onRetry}
544-
>
545-
<AppText className="text-secondary-foreground">
546-
{hostSetup ? "Try again" : "Reconnect"}
547-
</AppText>
548-
</Pressable>
518+
<View className="items-center">
519+
<Button
520+
label={hostSetup ? "Try again" : "Reconnect"}
521+
tone="secondary"
522+
onPress={onRetry}
523+
/>
524+
</View>
549525
) : null}
550526
</View>
551527
) : null}

‎apps/mobile/src/features/devices/DevicePreviewRouteScreen.tsx‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Button } from "../../components/ui/Button";
12
import * as Dialog from "../../components/ui/Dialog";
23
import {
34
deviceToolVersionLabels,
@@ -270,13 +271,9 @@ function DevicePreviewScreen({
270271
<AppText selectable className="text-center text-sm text-foreground-muted">
271272
{state.error}
272273
</AppText>
273-
<Pressable
274-
accessibilityRole="button"
275-
className="rounded-full border border-secondary-border bg-secondary px-6 py-3"
276-
onPress={state.refresh}
277-
>
278-
<AppText className="text-secondary-foreground">Retry</AppText>
279-
</Pressable>
274+
<View className="items-center">
275+
<Button label="Retry" tone="secondary" onPress={state.refresh} />
276+
</View>
280277
</>
281278
) : focused && foreground ? (
282279
<AppActivityIndicator color={themeVariables["--color-icon"]} />
@@ -399,13 +396,9 @@ function OpenDevicePreview({
399396
<AppText selectable className="text-center text-sm text-foreground-muted">
400397
{error}
401398
</AppText>
402-
<Pressable
403-
accessibilityRole="button"
404-
className="rounded-full border border-secondary-border bg-secondary px-6 py-3"
405-
onPress={refresh}
406-
>
407-
<AppText className="text-secondary-foreground">Retry</AppText>
408-
</Pressable>
399+
<View className="items-center">
400+
<Button label="Retry" tone="secondary" onPress={refresh} />
401+
</View>
409402
</>
410403
) : (
411404
<>

‎apps/mobile/src/features/devices/DeviceStreamWebView.tsx‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Button } from "../../components/ui/Button";
12
import deviceStreamScript from "@t3tools/mobile-device-stream";
23
import {
34
useEffect,
@@ -8,7 +9,7 @@ import {
89
useState,
910
type Ref,
1011
} from "react";
11-
import { Platform, Pressable, View } from "react-native";
12+
import { Platform, View } from "react-native";
1213
import { WebView } from "react-native-webview";
1314
import type { DeviceStreamStatus } from "@t3tools/client-runtime/device/stream";
1415

@@ -194,13 +195,9 @@ function DeviceStreamDocumentView({
194195
{status === "error" ? error : "Connecting to device..."}
195196
</AppText>
196197
{status === "error" ? (
197-
<Pressable
198-
accessibilityRole="button"
199-
className="rounded-full border border-secondary-border bg-secondary px-6 py-3"
200-
onPress={onRetry}
201-
>
202-
<AppText className="text-secondary-foreground">Reconnect</AppText>
203-
</Pressable>
198+
<View className="items-center">
199+
<Button label="Reconnect" tone="secondary" onPress={onRetry} />
200+
</View>
204201
) : null}
205202
</View>
206203
) : null}

0 commit comments

Comments
 (0)