Skip to content
TypeScript

refactor(mobile): remaining className platform ternaries become class variants (#13188)

Julius Marmingedb898a30629a
diff --git a/apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx b/apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx
index 5c58dfc1eaf..bfcaf4013ab 100644
--- a/apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx
+++ b/apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx
@@ -264,7 +264,7 @@ export function ConnectionsNewRouteScreen({
{pairingConnectionError ? <ErrorBanner message={pairingConnectionError} /> : null}
- <View className={Platform.OS === "android" ? "flex-row justify-end" : undefined}>
+ <View className="android:flex-row android:justify-end">
<ConnectionSheetButton
icon="plus"
label={isSubmitting ? "Pairing..." : "Add environment"}
diff --git a/apps/mobile/src/features/files/thread-file-navigator-pane.tsx b/apps/mobile/src/features/files/thread-file-navigator-pane.tsx
index c3c906e3d51..dfe0c05743c 100644
--- a/apps/mobile/src/features/files/thread-file-navigator-pane.tsx
+++ b/apps/mobile/src/features/files/thread-file-navigator-pane.tsx
@@ -147,7 +147,7 @@ export function ThreadFileNavigatorPane(props: {
}
>
<View
- className={Platform.OS === "android" ? "bg-header" : "border-b border-border"}
+ className="ios:border-b ios:border-border android:bg-header"
style={{ paddingTop: Platform.OS === "android" ? 0 : props.headerInset }}
>
{Platform.OS === "android" ? (
diff --git a/apps/mobile/src/features/home/HomeScreen.tsx b/apps/mobile/src/features/home/HomeScreen.tsx
index a01f5fbe606..946672ca711 100644
--- a/apps/mobile/src/features/home/HomeScreen.tsx
+++ b/apps/mobile/src/features/home/HomeScreen.tsx
@@ -1106,7 +1106,7 @@ export function HomeScreen(props: HomeScreenProps) {
if (!hasAnyThreads) {
return (
- <View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
+ <View className="flex-1 bg-screen android:bg-header">
<View
className={cn(
"flex-1 items-center justify-center bg-screen px-8",
@@ -1217,7 +1217,7 @@ export function HomeScreen(props: HomeScreenProps) {
if (threadListV2Enabled) {
return (
- <View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
+ <View className="flex-1 bg-screen android:bg-header">
<View
className={
Platform.OS === "android"
@@ -1263,7 +1263,7 @@ export function HomeScreen(props: HomeScreenProps) {
}
return (
- <View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
+ <View className="flex-1 bg-screen android:bg-header">
<View
className={
Platform.OS === "android"
diff --git a/apps/mobile/src/features/review/ReviewSheet.tsx b/apps/mobile/src/features/review/ReviewSheet.tsx
index 2fac5376e5b..08888dd469d 100644
--- a/apps/mobile/src/features/review/ReviewSheet.tsx
+++ b/apps/mobile/src/features/review/ReviewSheet.tsx
@@ -735,7 +735,7 @@ export function ReviewSheet(props: ReviewSheetProps) {
/>
<MaterialScreenContent>
- <View className={Platform.OS === "android" ? "flex-1 bg-sheet-solid" : "flex-1 bg-sheet"}>
+ <View className="flex-1 bg-sheet android:bg-sheet-solid">
{showConnectionNotice ? (
<View className="flex-1" style={{ paddingTop: topContentInset }}>
<EnvironmentConnectionNotice
diff --git a/apps/mobile/src/features/settings/SettingsThreadsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsThreadsRouteScreen.tsx
index bd8ec325215..9a98481d5be 100644
--- a/apps/mobile/src/features/settings/SettingsThreadsRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsThreadsRouteScreen.tsx
@@ -3,13 +3,12 @@ import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollVie
import { useAtomSet, useAtomValue } from "@effect/atom-react";
import { AsyncResult } from "effect/unstable/reactivity";
import { useRef, useState } from "react";
-import { Platform, Pressable, View } from "react-native";
+import { Pressable, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { DEFAULT_SERVER_SETTINGS } from "@t3tools/contracts";
import { supportsSharedSettingsSync } from "@t3tools/client-runtime/state/shared-settings";
import { AppText as Text } from "../../components/AppText";
-import { cn } from "../../lib/cn";
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
import { serverEnvironment } from "../../state/server";
import { useAtomCommand } from "../../state/use-atom-command";
@@ -182,21 +181,9 @@ function AutoSettleSettingsRows() {
}
/>
{afterDays !== null ? (
- <View
- className={cn(
- "flex-row items-center gap-4 px-4",
- Platform.OS === "android" ? "min-h-14 py-3" : "py-4",
- )}
- >
- <View style={{ width: Platform.OS === "android" ? 24 : 22 }} />
- <Text
- className={cn(
- "flex-1 text-foreground",
- Platform.OS === "android" ? "text-base" : "text-lg",
- )}
- >
- Inactive days
- </Text>
+ <View className="flex-row items-center gap-4 px-4 py-4 android:min-h-14 android:py-3">
+ <View className="w-[22px] android:w-6" />
+ <Text className="flex-1 text-foreground text-lg android:text-base">Inactive days</Text>
<AutoSettleDaysField
value={afterDays}
disabled={disabled}
diff --git a/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx b/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx
index 7edb07f4e3d..b30175b5b0d 100644
--- a/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx
+++ b/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx
@@ -402,7 +402,7 @@ export function NewTaskBranchPickerRouteScreen() {
const branchContent =
flow.filteredBranches.length === 0 ? (
<ScrollView
- className={Platform.OS === "android" ? "flex-1 bg-sheet-solid" : "flex-1 bg-sheet"}
+ className="flex-1 bg-sheet android:bg-sheet-solid"
contentInsetAdjustmentBehavior="automatic"
contentContainerStyle={{ flexGrow: 1, paddingHorizontal: 16, paddingTop: 16 }}
scrollEnabled={false}
@@ -443,7 +443,7 @@ export function NewTaskBranchPickerRouteScreen() {
alwaysBounceVertical={false}
automaticallyAdjustsScrollIndicatorInsets
automaticallyAdjustKeyboardInsets={Platform.OS === "ios"}
- className={Platform.OS === "android" ? "flex-1 bg-sheet-solid" : "flex-1 bg-sheet"}
+ className="flex-1 bg-sheet android:bg-sheet-solid"
contentInsetAdjustmentBehavior="automatic"
contentContainerStyle={branchListContentStyle}
data={flow.filteredBranches}
diff --git a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx
index e5bfc1590cf..3cc9852ea8a 100644
--- a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx
+++ b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx
@@ -947,18 +947,7 @@ function ThreadRouteContent(
<>
<GitActionProgressOverlay progress={gitActionProgress} onDismiss={dismissGitActionResult} />
- <View
- className={Platform.OS === "android" ? "flex-1 bg-thread-canvas" : "flex-1 bg-screen"}
- style={
- Platform.OS === "android"
- ? {
- borderTopLeftRadius: 28,
- borderTopRightRadius: 28,
- overflow: "hidden",
- }
- : undefined
- }
- >
+ <View className="flex-1 bg-screen android:overflow-hidden android:rounded-t-[28px] android:bg-thread-canvas">
<ThreadDetailScreen
selectedThread={selectedThreadWithDraftSettings ?? selectedThread}
contentPresentation={contentPresentation}
diff --git a/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx b/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
index dc989a4de2d..97282f6948c 100644
--- a/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
+++ b/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
@@ -158,9 +158,8 @@ function ProviderHeader(props: {
accessibilityLabel={`${props.label}, ${props.modelCount} models`}
accessibilityRole="button"
accessibilityState={{ expanded: !props.collapsed }}
- className="mx-4 mt-1 min-h-11 flex-row items-center gap-2 rounded-xl px-1 pt-2 active:opacity-60"
+ className="mx-4 mt-1 min-h-11 flex-row items-center gap-2 rounded-xl px-1 pt-2 active:opacity-60 android:min-h-12"
onPress={props.onToggle}
- style={Platform.OS === "android" ? { minHeight: 48 } : undefined}
>
{content}
</Pressable>
@@ -185,9 +184,8 @@ function DisclosureRow(props: {
<Pressable
accessibilityRole="button"
onPress={props.onPress}
- style={Platform.OS === "android" ? { minHeight: 56 } : undefined}
className={cn(
- "min-h-11 flex-row items-center gap-2 bg-card px-4 py-2 active:bg-subtle",
+ "min-h-11 flex-row items-center gap-2 bg-card px-4 py-2 active:bg-subtle android:min-h-14",
!props.isLast && "border-b border-border-subtle",
)}
>
diff --git a/apps/mobile/src/features/usage/UsageRouteScreen.tsx b/apps/mobile/src/features/usage/UsageRouteScreen.tsx
index d1bec8cbc14..7494ac9b34b 100644
--- a/apps/mobile/src/features/usage/UsageRouteScreen.tsx
+++ b/apps/mobile/src/features/usage/UsageRouteScreen.tsx
@@ -267,20 +267,20 @@ export function UsageRouteScreen() {
<>
{/* Period and metric together: neither applies to Limits, and
both change every number below, so they share one bar. */}
- <View className={cn("gap-3", Platform.OS !== "android" && "flex-row items-center")}>
+ <View className="gap-3 ios:flex-row ios:items-center">
<SegmentedControl
options={WINDOW_OPTIONS}
selected={windowDays}
onSelect={selectWindow}
size="compact"
- className={Platform.OS === "android" ? "w-full" : "flex-1"}
+ className="w-full ios:flex-1"
/>
<SegmentedControl
options={METRIC_OPTIONS}
selected={metric}
onSelect={setMetric}
size="compact"
- className={Platform.OS === "android" ? "w-full" : "w-36"}
+ className="w-full ios:w-36"
/>
</View>
{merged.duplicateSources.length > 0 ? (