Skip to content

Commit db898a3

Browse files
juliusmarmingejulusy
andauthored
refactor(mobile): remaining className platform ternaries become class variants (#13188)
Co-authored-by: julusy <[email protected]>
1 parent 21be723 commit db898a3

9 files changed

Lines changed: 18 additions & 44 deletions

File tree

‎apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export function ConnectionsNewRouteScreen({
264264

265265
{pairingConnectionError ? <ErrorBanner message={pairingConnectionError} /> : null}
266266

267-
<View className={Platform.OS === "android" ? "flex-row justify-end" : undefined}>
267+
<View className="android:flex-row android:justify-end">
268268
<ConnectionSheetButton
269269
icon="plus"
270270
label={isSubmitting ? "Pairing..." : "Add environment"}

‎apps/mobile/src/features/files/thread-file-navigator-pane.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export function ThreadFileNavigatorPane(props: {
147147
}
148148
>
149149
<View
150-
className={Platform.OS === "android" ? "bg-header" : "border-b border-border"}
150+
className="ios:border-b ios:border-border android:bg-header"
151151
style={{ paddingTop: Platform.OS === "android" ? 0 : props.headerInset }}
152152
>
153153
{Platform.OS === "android" ? (

‎apps/mobile/src/features/home/HomeScreen.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ export function HomeScreen(props: HomeScreenProps) {
11061106

11071107
if (!hasAnyThreads) {
11081108
return (
1109-
<View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
1109+
<View className="flex-1 bg-screen android:bg-header">
11101110
<View
11111111
className={cn(
11121112
"flex-1 items-center justify-center bg-screen px-8",
@@ -1217,7 +1217,7 @@ export function HomeScreen(props: HomeScreenProps) {
12171217

12181218
if (threadListV2Enabled) {
12191219
return (
1220-
<View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
1220+
<View className="flex-1 bg-screen android:bg-header">
12211221
<View
12221222
className={
12231223
Platform.OS === "android"
@@ -1263,7 +1263,7 @@ export function HomeScreen(props: HomeScreenProps) {
12631263
}
12641264

12651265
return (
1266-
<View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
1266+
<View className="flex-1 bg-screen android:bg-header">
12671267
<View
12681268
className={
12691269
Platform.OS === "android"

‎apps/mobile/src/features/review/ReviewSheet.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ export function ReviewSheet(props: ReviewSheetProps) {
735735
/>
736736

737737
<MaterialScreenContent>
738-
<View className={Platform.OS === "android" ? "flex-1 bg-sheet-solid" : "flex-1 bg-sheet"}>
738+
<View className="flex-1 bg-sheet android:bg-sheet-solid">
739739
{showConnectionNotice ? (
740740
<View className="flex-1" style={{ paddingTop: topContentInset }}>
741741
<EnvironmentConnectionNotice

‎apps/mobile/src/features/settings/SettingsThreadsRouteScreen.tsx‎

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollVie
33
import { useAtomSet, useAtomValue } from "@effect/atom-react";
44
import { AsyncResult } from "effect/unstable/reactivity";
55
import { useRef, useState } from "react";
6-
import { Platform, Pressable, View } from "react-native";
6+
import { Pressable, View } from "react-native";
77
import { useSafeAreaInsets } from "react-native-safe-area-context";
88

99
import { DEFAULT_SERVER_SETTINGS } from "@t3tools/contracts";
1010
import { supportsSharedSettingsSync } from "@t3tools/client-runtime/state/shared-settings";
1111
import { AppText as Text } from "../../components/AppText";
12-
import { cn } from "../../lib/cn";
1312
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
1413
import { serverEnvironment } from "../../state/server";
1514
import { useAtomCommand } from "../../state/use-atom-command";
@@ -182,21 +181,9 @@ function AutoSettleSettingsRows() {
182181
}
183182
/>
184183
{afterDays !== null ? (
185-
<View
186-
className={cn(
187-
"flex-row items-center gap-4 px-4",
188-
Platform.OS === "android" ? "min-h-14 py-3" : "py-4",
189-
)}
190-
>
191-
<View style={{ width: Platform.OS === "android" ? 24 : 22 }} />
192-
<Text
193-
className={cn(
194-
"flex-1 text-foreground",
195-
Platform.OS === "android" ? "text-base" : "text-lg",
196-
)}
197-
>
198-
Inactive days
199-
</Text>
184+
<View className="flex-row items-center gap-4 px-4 py-4 android:min-h-14 android:py-3">
185+
<View className="w-[22px] android:w-6" />
186+
<Text className="flex-1 text-foreground text-lg android:text-base">Inactive days</Text>
200187
<AutoSettleDaysField
201188
value={afterDays}
202189
disabled={disabled}

‎apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ export function NewTaskBranchPickerRouteScreen() {
402402
const branchContent =
403403
flow.filteredBranches.length === 0 ? (
404404
<ScrollView
405-
className={Platform.OS === "android" ? "flex-1 bg-sheet-solid" : "flex-1 bg-sheet"}
405+
className="flex-1 bg-sheet android:bg-sheet-solid"
406406
contentInsetAdjustmentBehavior="automatic"
407407
contentContainerStyle={{ flexGrow: 1, paddingHorizontal: 16, paddingTop: 16 }}
408408
scrollEnabled={false}
@@ -443,7 +443,7 @@ export function NewTaskBranchPickerRouteScreen() {
443443
alwaysBounceVertical={false}
444444
automaticallyAdjustsScrollIndicatorInsets
445445
automaticallyAdjustKeyboardInsets={Platform.OS === "ios"}
446-
className={Platform.OS === "android" ? "flex-1 bg-sheet-solid" : "flex-1 bg-sheet"}
446+
className="flex-1 bg-sheet android:bg-sheet-solid"
447447
contentInsetAdjustmentBehavior="automatic"
448448
contentContainerStyle={branchListContentStyle}
449449
data={flow.filteredBranches}

‎apps/mobile/src/features/threads/ThreadRouteScreen.tsx‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -947,18 +947,7 @@ function ThreadRouteContent(
947947
<>
948948
<GitActionProgressOverlay progress={gitActionProgress} onDismiss={dismissGitActionResult} />
949949

950-
<View
951-
className={Platform.OS === "android" ? "flex-1 bg-thread-canvas" : "flex-1 bg-screen"}
952-
style={
953-
Platform.OS === "android"
954-
? {
955-
borderTopLeftRadius: 28,
956-
borderTopRightRadius: 28,
957-
overflow: "hidden",
958-
}
959-
: undefined
960-
}
961-
>
950+
<View className="flex-1 bg-screen android:overflow-hidden android:rounded-t-[28px] android:bg-thread-canvas">
962951
<ThreadDetailScreen
963952
selectedThread={selectedThreadWithDraftSettings ?? selectedThread}
964953
contentPresentation={contentPresentation}

‎apps/mobile/src/features/threads/ThreadSettingsSheet.tsx‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,8 @@ function ProviderHeader(props: {
158158
accessibilityLabel={`${props.label}, ${props.modelCount} models`}
159159
accessibilityRole="button"
160160
accessibilityState={{ expanded: !props.collapsed }}
161-
className="mx-4 mt-1 min-h-11 flex-row items-center gap-2 rounded-xl px-1 pt-2 active:opacity-60"
161+
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"
162162
onPress={props.onToggle}
163-
style={Platform.OS === "android" ? { minHeight: 48 } : undefined}
164163
>
165164
{content}
166165
</Pressable>
@@ -185,9 +184,8 @@ function DisclosureRow(props: {
185184
<Pressable
186185
accessibilityRole="button"
187186
onPress={props.onPress}
188-
style={Platform.OS === "android" ? { minHeight: 56 } : undefined}
189187
className={cn(
190-
"min-h-11 flex-row items-center gap-2 bg-card px-4 py-2 active:bg-subtle",
188+
"min-h-11 flex-row items-center gap-2 bg-card px-4 py-2 active:bg-subtle android:min-h-14",
191189
!props.isLast && "border-b border-border-subtle",
192190
)}
193191
>

‎apps/mobile/src/features/usage/UsageRouteScreen.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,20 +267,20 @@ export function UsageRouteScreen() {
267267
<>
268268
{/* Period and metric together: neither applies to Limits, and
269269
both change every number below, so they share one bar. */}
270-
<View className={cn("gap-3", Platform.OS !== "android" && "flex-row items-center")}>
270+
<View className="gap-3 ios:flex-row ios:items-center">
271271
<SegmentedControl
272272
options={WINDOW_OPTIONS}
273273
selected={windowDays}
274274
onSelect={selectWindow}
275275
size="compact"
276-
className={Platform.OS === "android" ? "w-full" : "flex-1"}
276+
className="w-full ios:flex-1"
277277
/>
278278
<SegmentedControl
279279
options={METRIC_OPTIONS}
280280
selected={metric}
281281
onSelect={setMetric}
282282
size="compact"
283-
className={Platform.OS === "android" ? "w-full" : "w-36"}
283+
className="w-full ios:w-36"
284284
/>
285285
</View>
286286
{merged.duplicateSources.length > 0 ? (

0 commit comments

Comments
 (0)