Skip to content
TypeScript

refactor(mobile): share pull request actions (#21944)

Julius Marminge2fa1cb43b72a
diff --git a/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx b/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx
index b150e91a049..f699e46d6fb 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx
@@ -1,4 +1,3 @@
-import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
import { PullRequestSectionHeading } from "./PullRequestSectionHeading";
import { AnimatedLegendList } from "@legendapp/list/reanimated";
import Animated from "react-native-reanimated";
@@ -256,19 +255,13 @@ export function usePullRequestFilesContent(props: {
footer: (
<>
{result.nextCursor ? (
- <Pressable
+ <Button
+ label={result.error ? "Retry loading files" : "Load more files"}
+ tone="secondary"
onPress={result.error ? result.refresh : result.loadMore}
- accessibilityRole="button"
- className="min-h-11 items-center justify-center rounded-xl bg-grouped-card px-4 py-3"
- >
- {result.isPending ? (
- <AppActivityIndicator />
- ) : (
- <Text className="text-sm font-t3-medium">
- {result.error ? "Retry loading files" : "Load more files"}
- </Text>
- )}
- </Pressable>
+ loading={result.isPending}
+ fullWidth
+ />
) : null}
{viewed.error ? (
<Text className="py-2 text-xs text-danger-foreground">{viewed.error}</Text>
diff --git a/apps/mobile/src/features/pull-requests/PullRequestMergeControls.tsx b/apps/mobile/src/features/pull-requests/PullRequestMergeControls.tsx
index 97ff786fa86..691f48fcecd 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestMergeControls.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestMergeControls.tsx
@@ -280,13 +280,7 @@ export function PullRequestMergeControls(props: {
</Text>
) : null}
{stack.error && stack.supportsStackActions ? (
- <Pressable
- accessibilityRole="button"
- onPress={stack.refresh}
- className="min-h-11 justify-center px-1"
- >
- <Text className="text-sm text-primary-text">Retry stack lookup</Text>
- </Pressable>
+ <Button label="Retry stack lookup" tone="text" onPress={stack.refresh} />
) : null}
</View>
);
diff --git a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
index 9ff0d0b1868..dcece75411e 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
@@ -1213,13 +1213,9 @@ export function PullRequestFileRouteScreen({
</View>
) : null}
{result.error && result.nextCursor ? (
- <Pressable
- accessibilityRole="button"
- onPress={result.refresh}
- className="min-h-11 items-center justify-center py-2"
- >
- <Text className="text-sm font-t3-medium">Retry loading remaining files</Text>
- </Pressable>
+ <View className="self-center">
+ <Button label="Retry loading remaining files" tone="text" onPress={result.refresh} />
+ </View>
) : null}
{parsed.kind === "files" && parsed.notice ? (
<Text className="px-4 py-2 text-2xs text-foreground-muted">{parsed.notice}</Text>
diff --git a/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx
index 226d13cd40d..7b2e7df98c6 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx
@@ -1,3 +1,4 @@
+import { Button } from "../../components/ui/Button";
import {
applyPullRequestDraftFilterChange,
parsePullRequestQuery,
@@ -10,7 +11,6 @@ import { useAtomValue } from "@effect/atom-react";
import {
Keyboard,
Platform,
- Pressable,
RefreshControl,
ScrollView,
View,
@@ -327,15 +327,14 @@ export function PullRequestsScreen(
/>
</View>
) : result.loadMoreError ? (
- <Pressable
- accessibilityRole="button"
- accessibilityLabel="Retry loading more pull requests"
- onPress={() => void result.loadMore(true)}
- className="items-center gap-2 px-8 py-4"
- >
+ <View className="items-center gap-2 px-8 py-4">
<Text className="text-xs text-foreground-muted">{result.loadMoreError}</Text>
- <Text className="text-sm font-t3-medium text-link">Try again</Text>
- </Pressable>
+ <Button
+ label="Try again"
+ accessibilityLabel="Retry loading more pull requests"
+ onPress={() => void result.loadMore(true)}
+ />
+ </View>
) : undefined
}
ListEmptyComponent={
diff --git a/apps/mobile/src/features/pull-requests/guide/GuideNotice.tsx b/apps/mobile/src/features/pull-requests/guide/GuideNotice.tsx
index 29850c42578..6b4eef34abd 100644
--- a/apps/mobile/src/features/pull-requests/guide/GuideNotice.tsx
+++ b/apps/mobile/src/features/pull-requests/guide/GuideNotice.tsx
@@ -1,4 +1,5 @@
-import { Pressable, View } from "react-native";
+import { Button } from "../../../components/ui/Button";
+import { View } from "react-native";
import Animated, { FadeIn, ReduceMotion } from "react-native-reanimated";
import { AppText as Text } from "../../../components/ui/AppText";
import { SymbolView } from "../../../components/ui/AppSymbol";
@@ -40,28 +41,16 @@ export function GuideNotice({ state }: { readonly state: ReturnType<typeof useRe
</View>
<View className="min-h-12 flex-row items-center justify-between gap-3">
{state.canWrite || busy || notice.kind === "unavailable" ? (
- <Pressable
- accessibilityRole="button"
- accessibilityState={{ disabled: busy, busy }}
- disabled={busy}
- style={{ width: 152 }}
- className={
- compact
- ? "min-h-12 items-center justify-center rounded-full bg-secondary px-4 active:opacity-70"
- : "min-h-12 items-center justify-center rounded-full bg-foreground px-4 active:opacity-70"
- }
- onPress={() => (notice.kind === "unavailable" ? state.refresh() : void state.write())}
- >
- <Text
- className={
- compact
- ? "text-center font-t3-medium text-secondary-foreground"
- : "text-center font-t3-medium text-screen"
- }
- >
- {notice.action}
- </Text>
- </Pressable>
+ <View className="w-40">
+ <Button
+ label={notice.action}
+ tone={compact ? "secondary" : "contrast"}
+ disabled={busy}
+ onPress={() => (notice.kind === "unavailable" ? state.refresh() : void state.write())}
+ fullWidth
+ loading={busy}
+ />
+ </View>
) : (
<Text className="text-xs text-foreground-muted">
{notice.kind === "failed"
diff --git a/apps/mobile/src/features/pull-requests/guide/GuideOutline.tsx b/apps/mobile/src/features/pull-requests/guide/GuideOutline.tsx
index d7acfd5cd9c..1308d4caee7 100644
--- a/apps/mobile/src/features/pull-requests/guide/GuideOutline.tsx
+++ b/apps/mobile/src/features/pull-requests/guide/GuideOutline.tsx
@@ -1,3 +1,4 @@
+import { Button } from "../../../components/ui/Button";
import type { PullRequestReviewGuide } from "@t3tools/contracts";
import { stopFilePaths } from "@t3tools/client-runtime/review-guide-tour";
import { Pressable, View } from "react-native";
@@ -100,14 +101,9 @@ export function GuideOutline({
);
})}
{guide.stops.length ? (
- <Pressable
- accessibilityRole="button"
- onPress={() => onOpen(0)}
- className="min-h-11 flex-row items-center justify-end gap-2 active:opacity-60"
- >
- <Text className="text-sm font-t3-medium">Start tour</Text>
- <SymbolView name="arrow.right" size={17} tintColorClassName="accent-foreground" />
- </Pressable>
+ <View className="self-end">
+ <Button label="Start tour" tone="text" onPress={() => onOpen(0)} icon="arrow.right" />
+ </View>
) : null}
</View>
);