Skip to content
TypeScript

refactor(mobile): share settings and connection actions (#21941)

Julius Marminge5a5fd540dfde
diff --git a/apps/mobile/src/features/cloud/ConnectOnboardingRouteScreen.tsx b/apps/mobile/src/features/cloud/ConnectOnboardingRouteScreen.tsx
index 5e3eac56da6..e11933e271b 100644
--- a/apps/mobile/src/features/cloud/ConnectOnboardingRouteScreen.tsx
+++ b/apps/mobile/src/features/cloud/ConnectOnboardingRouteScreen.tsx
@@ -1,10 +1,11 @@
+import { Button } from "../../components/ui/Button";
import { Toolbar } from "../../components/ui/Toolbar";
import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
import { useAuth } from "@clerk/expo";
import { StackActions, useNavigation } from "@react-navigation/native";
import { useEffect, useState } from "react";
-import { Platform, Pressable, RefreshControl, View } from "react-native";
+import { Platform, RefreshControl, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { reportAtomCommandResult, settlePromise } from "@t3tools/client-runtime/state/runtime";
@@ -125,14 +126,7 @@ function ConfiguredConnectOnboardingRouteScreen() {
)}
{userId ? (
- <Pressable
- accessibilityRole="button"
- hitSlop={8}
- onPress={handleDontShowAgain}
- className="items-center py-1 active:opacity-70"
- >
- <Text className="text-xs text-foreground-muted">{"Don't show this again"}</Text>
- </Pressable>
+ <Button label={"Don't show this again"} tone="text" onPress={handleDontShowAgain} />
) : null}
</ScrollView>
</View>
diff --git a/apps/mobile/src/features/connection/CloudEnvironmentRows.tsx b/apps/mobile/src/features/connection/CloudEnvironmentRows.tsx
index dc498a873cc..a3ab8a682eb 100644
--- a/apps/mobile/src/features/connection/CloudEnvironmentRows.tsx
+++ b/apps/mobile/src/features/connection/CloudEnvironmentRows.tsx
@@ -1,3 +1,4 @@
+import { Button } from "../../components/ui/Button";
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
import { ConnectionTraceId } from "./ConnectionTraceId";
import { useAuth } from "@clerk/expo";
@@ -161,15 +162,13 @@ function CloudEnvironmentRowsContent(
{controller.relayDiscovery.errorTraceId ? (
<CopyTraceIdButton traceId={controller.relayDiscovery.errorTraceId} />
) : null}
- <Pressable
- accessibilityRole="button"
+ <Button
+ label="Try again"
+ tone="secondary"
onPress={() => {
void controller.refreshRelayEnvironments();
}}
- className="self-start rounded-full bg-subtle px-3.5 py-2 active:opacity-70"
- >
- <Text className="text-xs font-t3-bold text-foreground">Try again</Text>
- </Pressable>
+ />
</View>
) : null}
</View>
@@ -432,20 +431,13 @@ function CloudEnvironmentRowShell(props: {
function CopyTraceIdButton(props: { readonly traceId: string }) {
return (
- <Pressable
- accessibilityRole="button"
+ <Button
+ label="Copy trace ID"
+ tone="secondary"
onPress={() => {
copyTextWithHaptic(props.traceId, { target: "connection-trace-id" });
}}
- className="self-start flex-row items-center gap-1.5 rounded-full bg-subtle px-3 py-2 active:opacity-70"
- >
- <SymbolView
- name="doc.on.doc"
- size={12}
- tintColorClassName={"accent-icon"}
- type="monochrome"
- />
- <Text className="text-xs font-t3-bold text-foreground">Copy trace ID</Text>
- </Pressable>
+ icon="doc.on.doc"
+ />
);
}
diff --git a/apps/mobile/src/features/connection/EnvironmentConnectionNotice.tsx b/apps/mobile/src/features/connection/EnvironmentConnectionNotice.tsx
index 27db2c88f20..a3e9f38d30a 100644
--- a/apps/mobile/src/features/connection/EnvironmentConnectionNotice.tsx
+++ b/apps/mobile/src/features/connection/EnvironmentConnectionNotice.tsx
@@ -1,3 +1,4 @@
+import { Button } from "../../components/ui/Button";
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
import { ConnectionTraceId } from "./ConnectionTraceId";
import {
@@ -5,7 +6,7 @@ import {
type EnvironmentConnectionPresentation,
} from "@t3tools/client-runtime/connection";
import { SymbolView } from "../../components/ui/AppSymbol";
-import { Pressable, View } from "react-native";
+import { View } from "react-native";
import { AppText as Text } from "../../components/ui/AppText";
@@ -87,13 +88,9 @@ export function EnvironmentConnectionNotice(props: {
</Text>
{props.connection.phase !== "offline" && props.connection.phase !== "unsupported" ? (
- <Pressable
- accessibilityRole="button"
- className="mt-1 rounded-full bg-subtle px-4 py-2.5 active:opacity-70"
- onPress={props.onRetry}
- >
- <Text className="text-sm font-t3-bold text-foreground">Retry now</Text>
- </Pressable>
+ <View className="mt-1">
+ <Button label="Retry now" tone="secondary" onPress={props.onRetry} />
+ </View>
) : null}
</View>
</View>
diff --git a/apps/mobile/src/features/projects/AddProjectScreen.tsx b/apps/mobile/src/features/projects/AddProjectScreen.tsx
index 6aef5430654..8dc8750ab0c 100644
--- a/apps/mobile/src/features/projects/AddProjectScreen.tsx
+++ b/apps/mobile/src/features/projects/AddProjectScreen.tsx
@@ -433,12 +433,13 @@ function EmptyEnvironmentState() {
<Text className="text-center text-sm leading-normal text-foreground-muted">
Start or reconnect an environment before adding a project.
</Text>
- <Pressable
- onPress={() => navigation.dispatch(StackActions.replace("ConnectionsNew"))}
- className="mt-1 rounded-full bg-primary px-4 py-2.5 active:opacity-70"
- >
- <Text className="text-sm font-t3-bold text-primary-foreground">Add environment</Text>
- </Pressable>
+ <View className="mt-1">
+ <Button
+ label="Add environment"
+ tone="primary"
+ onPress={() => navigation.dispatch(StackActions.replace("ConnectionsNew"))}
+ />
+ </View>
</View>
);
}
diff --git a/apps/mobile/src/features/settings/EnvironmentRoutesSection.tsx b/apps/mobile/src/features/settings/EnvironmentRoutesSection.tsx
index b34ce987fa2..42bc0e28bd3 100644
--- a/apps/mobile/src/features/settings/EnvironmentRoutesSection.tsx
+++ b/apps/mobile/src/features/settings/EnvironmentRoutesSection.tsx
@@ -1,3 +1,4 @@
+import { Button } from "../../components/ui/Button";
import * as Dialog from "../../components/ui/Dialog";
import { useAtomValue } from "@effect/atom-react";
import {
@@ -132,15 +133,11 @@ export function EnvironmentRoutesSection({
title="Routes"
trailing={
routes.length > 1 ? (
- <Pressable
- accessibilityRole="button"
+ <Button
+ label={editing ? "Done" : "Edit"}
+ tone="text"
onPress={() => setEditing((value) => !value)}
- className="px-2 py-1 active:opacity-70"
- >
- <Text className="text-sm font-t3-medium text-foreground android:text-primary-text">
- {editing ? "Done" : "Edit"}
- </Text>
- </Pressable>
+ />
) : undefined
}
>
diff --git a/apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx
index 495ac0031fc..77154bb071d 100644
--- a/apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx
@@ -1,3 +1,4 @@
+import { Button } from "../../components/ui/Button";
import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
import { useAtomSet, useAtomValue } from "@effect/atom-react";
import { AsyncResult } from "effect/reactivity";
@@ -166,15 +167,11 @@ export function SettingsMicrophoneRouteScreen() {
title="Preferred order"
trailing={
hasDevices ? (
- <Pressable
- accessibilityRole="button"
+ <Button
+ label={editing ? "Done" : "Edit"}
+ tone="text"
onPress={() => setEditing((value) => !value)}
- className="px-2 py-1 active:opacity-70"
- >
- <Text className="text-sm font-t3-medium text-foreground">
- {editing ? "Done" : "Edit"}
- </Text>
- </Pressable>
+ />
) : undefined
}
>
diff --git a/apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx
index f79b26e86bf..8913502da91 100644
--- a/apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx
@@ -1067,9 +1067,9 @@ function WebhookScheduleDetails({
{resolved.note !== null ? (
<Text className="text-sm text-foreground-muted">{resolved.note}</Text>
) : null}
- <Pressable
- accessibilityRole="button"
- accessibilityState={{ disabled: disabled || rotating }}
+ <Button
+ label={rotating ? "Rotating…" : "Rotate URL"}
+ tone="danger"
disabled={disabled || rotating}
onPress={() =>
Dialog.alert("Rotate URL?", "The current URL stops working immediately.", [
@@ -1092,12 +1092,8 @@ function WebhookScheduleDetails({
},
])
}
- className="min-h-11 justify-center active:opacity-70 disabled:opacity-50"
- >
- <Text className="text-base text-danger-foreground">
- {rotating ? "Rotating…" : "Rotate URL"}
- </Text>
- </Pressable>
+ loading={rotating}
+ />
</>
)}
{signatureConfigured ? (
diff --git a/apps/mobile/src/features/settings/SettingsThreadsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsThreadsRouteScreen.tsx
index d023e5c57e3..c7883989ddb 100644
--- a/apps/mobile/src/features/settings/SettingsThreadsRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsThreadsRouteScreen.tsx
@@ -1,3 +1,4 @@
+import { Button } from "../../components/ui/Button";
import { AuthSettingsWriteScope } from "@t3tools/contracts";
import { readEnvironmentScope, useEnvironmentsWithScope } from "../../state/session";
import { AutoSettleDaysField } from "./components/AutoSettleDaysField";
@@ -5,7 +6,7 @@ import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScroll
import { useAtomSet, useAtomValue } from "@effect/atom-react";
import { AsyncResult } from "effect/reactivity";
import { useRef, useState } from "react";
-import { Pressable, View } from "react-native";
+import { View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { DEFAULT_SERVER_SETTINGS } from "@t3tools/contracts";
@@ -228,16 +229,12 @@ function AutoSettleSettingsRows() {
<Text className="text-sm text-foreground-muted">
{mismatches.map((mismatch) => mismatch.label).join(", ")}
</Text>
- <Pressable
- accessibilityRole="button"
+ <Button
+ label="Apply auto-settle defaults"
+ tone="secondary"
disabled={disabled}
onPress={() => writeToAll(autoSettlePatch)}
- className="self-start rounded-full bg-subtle px-4 py-2 active:opacity-70"
- >
- <Text className="text-sm font-t3-medium text-foreground">
- Apply auto-settle defaults
- </Text>
- </Pressable>
+ />
</View>
</SettingsSection>
) : null}
diff --git a/apps/mobile/src/features/threads/NewTaskRouteScreen.tsx b/apps/mobile/src/features/threads/NewTaskRouteScreen.tsx
index ff539280c11..acbb805c5be 100644
--- a/apps/mobile/src/features/threads/NewTaskRouteScreen.tsx
+++ b/apps/mobile/src/features/threads/NewTaskRouteScreen.tsx
@@ -400,33 +400,28 @@ export function NewTaskRouteScreen({ route }: StaticScreenProps<NewTaskRoutePara
) : null}
</>
) : !catalogState.hasReadyEnvironment ? (
- <Pressable
- className="mt-1 rounded-full bg-primary px-4 py-2.5 active:opacity-70"
- onPress={() => navigation.navigate("ConnectionsNew")}
- >
- <Text className="text-sm font-t3-bold text-primary-foreground">
- Add environment
- </Text>
- </Pressable>
+ <View className="mt-1">
+ <Button
+ label="Add environment"
+ tone="primary"
+ onPress={() => navigation.navigate("ConnectionsNew")}
+ />
+ </View>
) : (
<>
- <Pressable
- className="mt-1 rounded-full bg-primary px-4 py-2.5 active:opacity-70"
- onPress={() => navigation.dispatch(StackActions.push("AddProject"))}
- >
- <Text className="text-sm font-t3-bold text-primary-foreground">
- Add new project
- </Text>
- </Pressable>
+ <View className="mt-1">
+ <Button
+ label="Add new project"
+ tone="primary"
+ onPress={() => navigation.dispatch(StackActions.push("AddProject"))}
+ />
+ </View>
{canStartScratch ? (
- <Pressable
- className="rounded-full bg-subtle px-4 py-2.5 active:opacity-70"
+ <Button
+ label="Start without a project"
+ tone="secondary"
onPress={() => void startScratch()}
- >
- <Text className="text-sm font-t3-bold text-foreground">
- Start without a project
- </Text>
- </Pressable>
+ />
) : null}
</>
)}