11import { Platform , Text as NativeText , View } from "react-native" ;
22
3+ import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider" ;
4+ import type { DiffColorScheme } from "@t3tools/contracts/settings" ;
35import { cn } from "../../lib/cn" ;
46import { MOBILE_CODE_SURFACE } from "../../lib/typography" ;
57
@@ -19,36 +21,48 @@ export function renderVisibleWhitespace(value: string): string {
1921 return expandedTabs . replace ( / ^ ( + ) / , ( leading ) => leading . replaceAll ( " " , "\u00A0" ) ) ;
2022}
2123
22- export function changeTone ( change : ReviewRenderableLineRow [ "change" ] ) : string {
23- if ( change === "add" ) return "bg-emerald-500/10" ;
24- if ( change === "delete" ) return "bg-rose-500/10" ;
24+ export function changeTone (
25+ change : ReviewRenderableLineRow [ "change" ] ,
26+ scheme : DiffColorScheme = "red-green" ,
27+ ) : string {
28+ if ( change === "add" ) return scheme === "blue-orange" ? "bg-blue-500/10" : "bg-emerald-500/10" ;
29+ if ( change === "delete" ) return scheme === "blue-orange" ? "bg-orange-500/10" : "bg-rose-500/10" ;
2530 return "bg-card" ;
2631}
2732
28- export function changeBarTone ( change : ReviewRenderableLineRow [ "change" ] ) : string {
29- if ( change === "add" ) return "bg-emerald-400" ;
30- if ( change === "delete" ) return "bg-rose-400" ;
33+ export function changeBarTone (
34+ change : ReviewRenderableLineRow [ "change" ] ,
35+ scheme : DiffColorScheme = "red-green" ,
36+ ) : string {
37+ if ( change === "add" ) return scheme === "blue-orange" ? "bg-blue-400" : "bg-emerald-400" ;
38+ if ( change === "delete" ) return scheme === "blue-orange" ? "bg-orange-400" : "bg-rose-400" ;
3139 return "bg-border/50" ;
3240}
3341
34- function diffHighlightColor ( change : ReviewRenderableLineRow [ "change" ] ) : string | undefined {
35- if ( change === "add" ) return "rgba(16, 185, 129, 0.24)" ;
36- if ( change === "delete" ) return "rgba(244, 63, 94, 0.24)" ;
42+ function diffHighlightColor (
43+ change : ReviewRenderableLineRow [ "change" ] ,
44+ scheme : DiffColorScheme ,
45+ ) : string | undefined {
46+ if ( change === "add" )
47+ return scheme === "blue-orange" ? "rgba(59, 130, 246, 0.24)" : "rgba(16, 185, 129, 0.24)" ;
48+ if ( change === "delete" )
49+ return scheme === "blue-orange" ? "rgba(249, 115, 22, 0.24)" : "rgba(244, 63, 94, 0.24)" ;
3750 return undefined ;
3851}
3952
4053export function ReviewChangeBar ( props : {
4154 readonly change : ReviewRenderableLineRow [ "change" ] ;
4255 readonly height ?: number ;
4356} ) {
57+ const { diffColorScheme } = useAppearancePreferences ( ) ;
4458 const height = props . height ?? REVIEW_DIFF_LINE_HEIGHT ;
4559 if ( props . change === "delete" ) {
4660 return (
4761 < View className = "w-[5px] overflow-hidden" style = { { height } } >
4862 < View >
4963 { Array . from ( { length : Math . ceil ( height / 2 ) } , ( _ , index ) => (
5064 < View key = { index } >
51- < View className = "h-px w-[5px] bg-rose-400" />
65+ < View className = { cn ( "h-px w-[5px]" , changeBarTone ( "delete" , diffColorScheme ) ) } />
5266 < View className = "h-px" />
5367 </ View >
5468 ) ) }
@@ -59,7 +73,7 @@ export function ReviewChangeBar(props: {
5973
6074 return (
6175 < View className = "w-[5px] overflow-hidden" style = { { height } } >
62- < View className = { cn ( "h-full w-[5px] flex-1" , changeBarTone ( props . change ) ) } />
76+ < View className = { cn ( "h-full w-[5px] flex-1" , changeBarTone ( props . change , diffColorScheme ) ) } />
6377 </ View >
6478 ) ;
6579}
@@ -72,6 +86,7 @@ export function DiffTokenText(props: {
7286 readonly fontSize ?: number ;
7387 readonly lineHeight ?: number ;
7488} ) {
89+ const { diffColorScheme } = useAppearancePreferences ( ) ;
7590 const fontSize = props . fontSize ?? MOBILE_CODE_SURFACE . fontSize ;
7691 const lineHeight = props . lineHeight ?? MOBILE_CODE_SURFACE . rowHeight ;
7792 if ( ! props . tokens || props . tokens . length === 0 ) {
@@ -129,7 +144,7 @@ export function DiffTokenText(props: {
129144 fontStyle,
130145 backgroundColor :
131146 token . diffHighlight && props . change
132- ? diffHighlightColor ( props . change )
147+ ? diffHighlightColor ( props . change , diffColorScheme )
133148 : undefined ,
134149 borderRadius : token . diffHighlight ? 4 : undefined ,
135150 } }
0 commit comments