TypeScript
refactor(mobile): git sheets use uniwind platform variants instead of className ternaries (#13161)
Julius Marmingeec28eefa0d01
diff --git a/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx b/apps/mobile/src/features/threads/git/GitBranchesSheet.tsxindex 7ca5085965f..d16b72d13d8 100644--- a/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx+++ b/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx@@ -63,7 +63,7 @@ export function GitBranchesSheet(_props: GitBranchesSheetProps) {return (<Viewcollapsable={false}- className={Platform.OS === "android" ? "bg-sheet" : "flex-1 bg-sheet"}+ className="bg-sheet ios:flex-1"style={Platform.OS === "android" ? { maxHeight: windowHeight * 0.92 } : undefined}>{Platform.OS === "android" ? (@@ -83,31 +83,19 @@ export function GitBranchesSheet(_props: GitBranchesSheetProps) {) : null}<MaterialScreenContent fitToContents><ScrollView- className={Platform.OS === "android" ? "shrink grow-0" : "flex-1"}+ className="android:shrink android:grow-0 ios:flex-1"keyboardShouldPersistTaps="handled"showsVerticalScrollIndicator={false}contentInset={{ bottom: Math.max(insets.bottom, 18) + 18 }}- contentContainerClassName={Platform.OS === "android" ? "gap-2 p-2" : "gap-4 px-5 pt-2"}+ contentContainerClassName="android:gap-2 android:p-2 ios:gap-4 ios:px-5 ios:pt-2"contentContainerStyle={Platform.OS === "android"? { paddingBottom: Math.max(insets.bottom, 18) + 18 }: undefined}>- <View- className={- Platform.OS === "android"- ? "gap-3 rounded-[20px] bg-card p-4"- : "gap-2 rounded-[18px] border border-border bg-card px-4 py-4"- }- >- <Text- className={- Platform.OS === "android"- ? "text-foreground text-base font-t3-medium"- : "text-foreground-secondary text-2xs font-t3-bold tracking-[1px] uppercase"- }- >+ <View className="bg-card android:gap-3 android:rounded-[20px] android:p-4 ios:gap-2 ios:rounded-[18px] ios:border ios:border-border ios:px-4 ios:py-4">+ <Text className="android:text-foreground android:text-base android:font-t3-medium ios:text-foreground-secondary ios:text-2xs ios:font-t3-bold ios:tracking-[1px] ios:uppercase">New branch</Text><TextInput@@ -115,7 +103,7 @@ export function GitBranchesSheet(_props: GitBranchesSheetProps) {onChangeText={setNewBranchName}placeholder="feature/mobile-polish"accessibilityLabel="New branch name"- className={Platform.OS === "android" ? "rounded-xl bg-sheet-solid" : "rounded-[18px]"}+ className="android:rounded-xl android:bg-sheet-solid ios:rounded-[18px]"/><SheetActionButtonicon="plus"@@ -133,20 +121,8 @@ export function GitBranchesSheet(_props: GitBranchesSheetProps) {/></View>- <View- className={- Platform.OS === "android"- ? "gap-3 rounded-[20px] bg-card p-4"- : "gap-2 rounded-[18px] border border-border bg-card px-4 py-4"- }- >- <Text- className={- Platform.OS === "android"- ? "text-foreground text-base font-t3-medium"- : "text-foreground-secondary text-2xs font-t3-bold tracking-[1px] uppercase"- }- >+ <View className="bg-card android:gap-3 android:rounded-[20px] android:p-4 ios:gap-2 ios:rounded-[18px] ios:border ios:border-border ios:px-4 ios:py-4">+ <Text className="android:text-foreground android:text-base android:font-t3-medium ios:text-foreground-secondary ios:text-2xs ios:font-t3-bold ios:tracking-[1px] ios:uppercase">New worktree</Text>{Platform.OS === "android" ? (@@ -157,7 +133,7 @@ export function GitBranchesSheet(_props: GitBranchesSheetProps) {onChangeText={setWorktreeBaseBranch}placeholder="main"accessibilityLabel="Worktree base branch"- className={Platform.OS === "android" ? "rounded-xl bg-sheet-solid" : "rounded-[18px]"}+ className="android:rounded-xl android:bg-sheet-solid ios:rounded-[18px]"/>{Platform.OS === "android" ? (<Text className="text-foreground-secondary text-sm">New branch</Text>@@ -167,7 +143,7 @@ export function GitBranchesSheet(_props: GitBranchesSheetProps) {onChangeText={setWorktreeBranchName}placeholder="feature/mobile-thread"accessibilityLabel="Worktree branch name"- className={Platform.OS === "android" ? "rounded-xl bg-sheet-solid" : "rounded-[18px]"}+ className="android:rounded-xl android:bg-sheet-solid ios:rounded-[18px]"/><SheetActionButtonicon="square.split.2x1"@@ -193,32 +169,16 @@ export function GitBranchesSheet(_props: GitBranchesSheetProps) {</View><View className="gap-2">- <Text- className={- Platform.OS === "android"- ? "px-4 pb-1 pt-3 text-foreground-secondary text-sm font-t3-medium"- : "text-foreground-secondary text-2xs font-t3-bold tracking-[1px] uppercase"- }- >+ <Text className="text-foreground-secondary android:px-4 android:pb-1 android:pt-3 android:text-sm android:font-t3-medium ios:text-2xs ios:font-t3-bold ios:tracking-[1px] ios:uppercase">Existing branches</Text>{branchesLoading ? (- <Text- className={cn(- "text-foreground-secondary text-sm font-medium",- Platform.OS === "android" && "px-4",- )}- >+ <Text className="text-foreground-secondary text-sm font-medium android:px-4">Loading branches...</Text>) : null}{!branchesLoading && availableBranches.length === 0 ? (- <Text- className={cn(- "text-foreground-secondary text-sm font-medium",- Platform.OS === "android" && "px-4",- )}- >+ <Text className="text-foreground-secondary text-sm font-medium android:px-4">No local branches found.</Text>) : null}@@ -236,16 +196,10 @@ export function GitBranchesSheet(_props: GitBranchesSheetProps) {<Pressablekey={branch.name}className={cn(- "gap-1 px-4 py-3 disabled:opacity-[0.45]",- Platform.OS === "android"- ? cn(- "rounded-[20px] active:bg-subtle",- branch.current ? "bg-secondary" : "bg-card",- )- : cn(- "rounded-[18px] border",- branch.current ? "border-subtle-strong" : "border-border",- ),+ "gap-1 px-4 py-3 disabled:opacity-[0.45] android:rounded-[20px] android:active:bg-subtle ios:rounded-[18px] ios:border",+ branch.current+ ? "android:bg-secondary ios:border-subtle-strong"+ : "android:bg-card ios:border-border",)}accessibilityRole="button"accessibilityState={{ selected: branch.current, disabled: busy || disabled }}@@ -259,12 +213,7 @@ export function GitBranchesSheet(_props: GitBranchesSheetProps) {{Platform.OS !== "android" ? (<View className="absolute inset-0 rounded-[18px] bg-card" />) : null}- <Text- className={cn(- "text-foreground text-base",- Platform.OS === "android" ? "font-t3-medium" : "font-t3-bold",- )}- >+ <Text className="text-foreground text-base android:font-t3-medium ios:font-t3-bold">{branch.name}</Text><Text className="text-foreground-secondary text-xs font-medium">{subtitle}</Text>diff --git a/apps/mobile/src/features/threads/git/GitCommitSheet.tsx b/apps/mobile/src/features/threads/git/GitCommitSheet.tsxindex 7f70a39d937..19d77a327de 100644--- a/apps/mobile/src/features/threads/git/GitCommitSheet.tsx+++ b/apps/mobile/src/features/threads/git/GitCommitSheet.tsx@@ -72,7 +72,7 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {return (<Viewcollapsable={false}- className={Platform.OS === "android" ? "bg-sheet" : "flex-1 bg-sheet"}+ className="bg-sheet ios:flex-1"style={Platform.OS === "android" ? { maxHeight: windowHeight * 0.92 } : undefined}>{Platform.OS === "android" ? (@@ -92,35 +92,21 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {) : null}<MaterialScreenContent fitToContents><ScrollView- className={Platform.OS === "android" ? "shrink grow-0" : "flex-1"}+ className="android:shrink android:grow-0 ios:flex-1"keyboardShouldPersistTaps="handled"showsVerticalScrollIndicator={false}contentInset={{ bottom: Math.max(insets.bottom, 18) + 18 }}- contentContainerClassName={Platform.OS === "android" ? "gap-2 p-2" : "gap-4 px-5 pt-2"}+ contentContainerClassName="android:gap-2 android:p-2 ios:gap-4 ios:px-5 ios:pt-2"contentContainerStyle={Platform.OS === "android"? { paddingBottom: Math.max(insets.bottom, 18) + 18 }: undefined}>- <View- className={cn(- "gap-3 bg-card p-4",- Platform.OS === "android" ? "rounded-[20px]" : "rounded-[22px] border border-border",- )}- >- <View- className={- Platform.OS === "android" ? "gap-1" : "flex-row items-center justify-between gap-3"- }- >+ <View className="gap-3 bg-card p-4 android:rounded-[20px] ios:rounded-[22px] ios:border ios:border-border">+ <View className="android:gap-1 ios:flex-row ios:items-center ios:justify-between ios:gap-3"><Text className="text-foreground-muted text-sm font-medium">Branch</Text>- <Text- className={cn(- "text-foreground text-base",- Platform.OS === "android" ? "font-t3-medium" : "font-t3-bold",- )}- >+ <Text className="text-foreground text-base android:font-t3-medium ios:font-t3-bold">{gitStatus.data?.refName ?? "(detached HEAD)"}</Text></View>@@ -131,20 +117,10 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {) : null}</View>- <View- className={cn(- "gap-3 bg-card p-4",- Platform.OS === "android" ? "rounded-[20px]" : "rounded-[22px] border border-border",- )}- >+ <View className="gap-3 bg-card p-4 android:rounded-[20px] ios:rounded-[22px] ios:border ios:border-border"><View className="flex-row items-center justify-between gap-3"><View className="gap-1">- <Text- className={cn(- "text-foreground text-base",- Platform.OS === "android" ? "font-t3-medium" : "font-t3-bold",- )}- >+ <Text className="text-foreground text-base android:font-t3-medium ios:font-t3-bold">Files</Text><Text className="text-foreground-muted text-xs leading-normal">@@ -154,39 +130,19 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {<View className="flex-row items-center gap-2">{!allSelected && isEditingFiles ? (<Pressable- className={- Platform.OS === "android"- ? "min-h-12 justify-center rounded-full px-3 active:bg-subtle"- : "bg-subtle rounded-full px-3 py-2"- }+ className="rounded-full px-3 android:min-h-12 android:justify-center android:active:bg-subtle ios:bg-subtle ios:py-2"onPress={() => setExcludedFiles(new Set())}>- <Text- className={- Platform.OS === "android"- ? "text-primary-text text-sm font-t3-medium"- : "text-foreground text-2xs font-t3-bold uppercase"- }- >+ <Text className="android:text-primary-text android:text-sm android:font-t3-medium ios:text-foreground ios:text-2xs ios:font-t3-bold ios:uppercase">Reset</Text></Pressable>) : null}<Pressable- className={- Platform.OS === "android"- ? "min-h-12 justify-center rounded-full px-3 active:bg-subtle"- : "bg-subtle rounded-full px-3 py-2"- }+ className="rounded-full px-3 android:min-h-12 android:justify-center android:active:bg-subtle ios:bg-subtle ios:py-2"onPress={() => setIsEditingFiles((current) => !current)}>- <Text- className={- Platform.OS === "android"- ? "text-primary-text text-sm font-t3-medium"- : "text-foreground text-2xs font-t3-bold uppercase"- }- >+ <Text className="android:text-primary-text android:text-sm android:font-t3-medium ios:text-foreground ios:text-2xs ios:font-t3-bold ios:uppercase">{isEditingFiles ? "Done" : "Edit"}</Text></Pressable>@@ -226,15 +182,10 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {<Pressablekey={file.path}className={cn(- "px-4 py-3",- Platform.OS === "android"- ? included- ? "rounded-xl bg-subtle"- : "rounded-xl"- : cn(- "rounded-[18px] border",- included ? "border-border" : "border-border-subtle",- ),+ "px-4 py-3 android:rounded-xl ios:rounded-[18px] ios:border",+ included+ ? "android:bg-subtle ios:border-border"+ : "ios:border-border-subtle",)}accessibilityRole="checkbox"accessibilityLabel={file.path}@@ -303,16 +254,8 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {)}</View>- <View- className={Platform.OS === "android" ? "gap-3 rounded-[20px] bg-card p-4" : "gap-2"}- >- <Text- className={- Platform.OS === "android"- ? "text-foreground text-base font-t3-medium"- : "text-foreground text-sm font-t3-bold"- }- >+ <View className="android:gap-3 android:rounded-[20px] android:bg-card android:p-4 ios:gap-2">+ <Text className="text-foreground android:text-base android:font-t3-medium ios:text-sm ios:font-t3-bold">Commit message</Text><TextInput@@ -322,15 +265,12 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {onChangeText={setDialogCommitMessage}placeholder="Leave empty to auto-generate"textAlignVertical="top"- className={cn(- "min-h-[128px] px-4 py-3.5",- Platform.OS === "android" ? "rounded-xl bg-sheet-solid" : "rounded-[20px]",- )}+ className="min-h-[128px] px-4 py-3.5 android:rounded-xl android:bg-sheet-solid ios:rounded-[20px]"/></View>- <View className={Platform.OS === "android" ? "gap-2" : "flex-row gap-3"}>- <View className={Platform.OS === "android" ? undefined : "flex-1"}>+ <View className="android:gap-2 ios:flex-row ios:gap-3">+ <View className="ios:flex-1"><SheetActionButtonicon="arrow.branch"label="Commit on new branch"@@ -338,7 +278,7 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {onPress={() => void runCommitAction(true)}/></View>- <View className={Platform.OS === "android" ? undefined : "flex-1"}>+ <View className="ios:flex-1"><SheetActionButtonicon="checkmark.circle"label="Commit"diff --git a/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx b/apps/mobile/src/features/threads/git/GitConfirmSheet.tsxindex bc5e88f3fd6..06cce85791f 100644--- a/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx+++ b/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx@@ -107,7 +107,7 @@ export function GitConfirmSheet(props: GitConfirmSheetProps) {return (<Viewcollapsable={false}- className={Platform.OS === "android" ? "bg-sheet" : "flex-1 bg-sheet"}+ className="bg-sheet ios:flex-1"style={Platform.OS === "android" ? { maxHeight: windowHeight * 0.92 } : undefined}>{Platform.OS === "android" ? (@@ -130,49 +130,31 @@ export function GitConfirmSheet(props: GitConfirmSheetProps) {<MaterialScreenContent fitToContents><ScrollView- className={Platform.OS === "android" ? "shrink grow-0" : "flex-1"}+ className="android:shrink android:grow-0 ios:flex-1"showsVerticalScrollIndicator={false}- contentContainerClassName={Platform.OS === "android" ? "gap-2 p-2" : undefined}+ contentContainerClassName="android:gap-2 android:p-2"contentContainerStyle={Platform.OS === "android"? { paddingBottom: Math.max(insets.bottom, 18) + 8 }: undefined}>- <View- className={- Platform.OS === "android"- ? "gap-2 rounded-[20px] bg-card p-3"- : "items-center gap-1 px-5 pb-3 pt-4"- }- >+ <View className="android:gap-2 android:rounded-[20px] android:bg-card android:p-3 ios:items-center ios:gap-1 ios:px-5 ios:pb-3 ios:pt-4">{Platform.OS !== "android" ? (<Text className="text-xs font-t3-bold tracking-[1px] uppercase text-foreground-muted">Confirm</Text>) : null}- <Text- className={- Platform.OS === "android"- ? "text-xl font-t3-medium"- : "text-center text-3xl font-t3-bold"- }- >+ <Text className="android:text-xl android:font-t3-medium ios:text-center ios:text-3xl ios:font-t3-bold">{copy?.title ?? "Run action on default branch?"}</Text>- <Text- className={- Platform.OS === "android"- ? "text-foreground-secondary text-base leading-normal"- : "text-center text-foreground-secondary text-sm font-medium leading-normal"- }- >+ <Text className="text-foreground-secondary leading-normal android:text-base ios:text-center ios:text-sm ios:font-medium">{copy?.description ?? "Choose how to continue."}</Text></View><View- className={Platform.OS === "android" ? "gap-2" : "gap-3 px-5 pt-2"}+ className="android:gap-2 ios:gap-3 ios:px-5 ios:pt-2"style={Platform.OS === "android"? undefineddiff --git a/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx b/apps/mobile/src/features/threads/git/GitOverviewSheet.tsxindex 7293173ecee..831ef1145ce 100644--- a/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx+++ b/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx@@ -234,7 +234,7 @@ export function GitOverviewSheet(props: GitOverviewSheetProps) {const content = (<ScrollViewalwaysBounceVertical- className={Platform.OS === "android" ? "flex-1 bg-sheet-solid" : "flex-1 bg-screen"}+ className="flex-1 android:bg-sheet-solid ios:bg-screen"contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}showsVerticalScrollIndicator={false}contentInset={{ bottom: Math.max(insets.bottom, 18) + 18 }}@@ -248,13 +248,9 @@ export function GitOverviewSheet(props: GitOverviewSheetProps) {}><View- className={- Platform.OS === "android"- ? "overflow-hidden rounded-[20px] bg-card"- : isInspector- ? "overflow-hidden rounded-2xl border border-border bg-card px-3 py-1"- : "overflow-hidden rounded-[22px] border border-border bg-card px-4 py-1"- }+ className={`overflow-hidden bg-card android:rounded-[20px] ios:border ios:border-border ${+ isInspector ? "ios:rounded-2xl ios:px-3 ios:py-1" : "ios:rounded-[22px] ios:px-4 ios:py-1"+ }`}>{sheetMenuItems.map(({ item, disabledReason }, index) => (<View key={`${item.id}-${item.label}`}>@@ -320,11 +316,7 @@ export function GitOverviewSheet(props: GitOverviewSheetProps) {{linkedPrChains.map((chain) => (<Viewkey={threadPullRequestKeyOf(chain.layers[0]!)}- className={- Platform.OS === "android"- ? "overflow-hidden rounded-[20px] bg-card"- : "overflow-hidden rounded-2xl border border-border bg-card px-3 py-1"- }+ className="overflow-hidden bg-card android:rounded-[20px] ios:rounded-2xl ios:border ios:border-border ios:px-3 ios:py-1">{chain.layers.length > 1 ? (<View className="flex-row items-center gap-2 px-1 pt-2 pb-1">@@ -483,13 +475,7 @@ export function GitOverviewSheet(props: GitOverviewSheetProps) {) : null}{isInspector ? (- <View- className={- Platform.OS === "android"- ? "gap-1 bg-header px-4 pb-4 pt-3"- : "gap-1 border-b border-border px-4 pb-4 pt-3"- }- >+ <View className="gap-1 px-4 pb-4 pt-3 android:bg-header ios:border-b ios:border-border">{Platform.OS === "android" ? (<View className="absolute right-3 top-4 z-[1]">{refreshMenu}</View>) : (diff --git a/apps/mobile/src/features/threads/git/gitSheetComponents.tsx b/apps/mobile/src/features/threads/git/gitSheetComponents.tsxindex daf494cb79c..c358466e22d 100644--- a/apps/mobile/src/features/threads/git/gitSheetComponents.tsx+++ b/apps/mobile/src/features/threads/git/gitSheetComponents.tsx@@ -71,13 +71,7 @@ export function SheetActionButton(props: {export function MetaCard(props: { readonly label: string; readonly value: string }) {return (- <View- className={- Platform.OS === "android"- ? "rounded-[20px] bg-card px-4 py-3"- : "rounded-[18px] border border-border bg-card px-4 py-3"- }- >+ <View className="bg-card px-4 py-3 android:rounded-[20px] ios:rounded-[18px] ios:border ios:border-border"><Text className="text-foreground-muted text-2xs font-t3-bold tracking-[0.9px] uppercase">{props.label}</Text>@@ -97,21 +91,11 @@ export function SheetListRow(props: {}) {return (<Pressable- className={- Platform.OS === "android"- ? "min-h-16 flex-row items-center gap-4 px-4 py-3 active:bg-subtle disabled:opacity-[0.45]"- : "flex-row items-center gap-3 px-1 py-3 disabled:opacity-[0.45]"- }+ className="flex-row items-center py-3 disabled:opacity-[0.45] android:min-h-16 android:gap-4 android:px-4 android:active:bg-subtle ios:gap-3 ios:px-1"disabled={props.disabled}onPress={props.onPress}>- <View- className={- Platform.OS === "android"- ? "size-6 items-center justify-center"- : "bg-subtle h-9 w-9 items-center justify-center rounded-full"- }- >+ <View className="items-center justify-center android:size-6 ios:bg-subtle ios:h-9 ios:w-9 ios:rounded-full"><SymbolViewname={props.icon}size={Platform.OS === "android" ? 24 : 16}@@ -120,13 +104,7 @@ export function SheetListRow(props: {/></View><View className="flex-1 gap-0.5">- <Text- className={- Platform.OS === "android"- ? "text-foreground text-base font-t3-medium"- : "text-foreground text-base font-t3-bold"- }- >+ <Text className="text-foreground text-base android:font-t3-medium ios:font-t3-bold">{props.title}</Text>{props.subtitle ? (