@@ -50,6 +50,32 @@ function WindowRow(props: {
5050 const timeLeft = elapsed === null ? null : Math . round ( ( 1 - elapsed ) * 100 ) ;
5151 const pace = paceOf ( window , now ) ;
5252 const resetsIn = formatResetsIn ( window , now ) ;
53+ const [ barWidth , setBarWidth ] = useState ( 0 ) ;
54+ const tickX =
55+ timeLeft === null || barWidth < 6
56+ ? null
57+ : Math . min ( Math . max ( ( barWidth * timeLeft ) / 100 , 3 ) , barWidth - 3 ) ;
58+ const bar = (
59+ < View
60+ className = "h-1.5 flex-row overflow-hidden rounded-full bg-subtle"
61+ style = { barWidth > 0 ? { width : barWidth } : undefined }
62+ >
63+ < View
64+ className = {
65+ remaining <= 10
66+ ? "h-full rounded-full bg-red-500"
67+ : remaining <= 30
68+ ? "h-full rounded-full bg-amber-500"
69+ : "h-full rounded-full bg-foreground"
70+ }
71+ style = { [
72+ { flex : remaining } ,
73+ remaining > 30 && props . color ? { backgroundColor : props . color } : null ,
74+ ] }
75+ />
76+ < View style = { { flex : 100 - remaining } } />
77+ </ View >
78+ ) ;
5379 return (
5480 < View className = "gap-1" >
5581 < View className = "flex-row items-baseline justify-between gap-3" >
@@ -58,27 +84,35 @@ function WindowRow(props: {
5884 { remaining } % left
5985 </ Text >
6086 </ View >
61- < View className = "h-3 justify-center" >
62- < View className = "h-1.5 flex-row overflow-hidden rounded-full bg-subtle" >
63- < View
64- className = {
65- remaining <= 10
66- ? "h-full rounded-full bg-red-500"
67- : remaining <= 30
68- ? "h-full rounded-full bg-amber-500"
69- : "h-full rounded-full bg-foreground"
70- }
71- style = { [
72- { flex : remaining } ,
73- remaining > 30 && props . color ? { backgroundColor : props . color } : null ,
74- ] }
75- />
76- < View style = { { flex : 100 - remaining } } />
77- </ View >
78- { timeLeft !== null ? (
87+ < View
88+ className = "h-3 justify-center"
89+ onLayout = { ( event ) => setBarWidth ( event . nativeEvent . layout . width ) }
90+ >
91+ { tickX === null ? (
92+ bar
93+ ) : (
94+ < View className = "h-1.5" >
95+ { /* Clip the same full-width bar so neither fill proportions nor corner radii change. */ }
96+ { (
97+ [
98+ [ 0 , tickX - 3 ] ,
99+ [ tickX + 3 , barWidth ] ,
100+ ] as const
101+ ) . map ( ( [ start , end ] ) => (
102+ < View
103+ key = { start }
104+ className = "absolute top-0 bottom-0 overflow-hidden"
105+ style = { { left : start , width : end - start } }
106+ >
107+ < View style = { { marginLeft : - start } } > { bar } </ View >
108+ </ View >
109+ ) ) }
110+ </ View >
111+ ) }
112+ { tickX !== null ? (
79113 < View
80- className = "absolute top-0 bottom-0 w-px bg-foreground"
81- style = { { left : ` ${ timeLeft } %` , opacity : 0.6 } }
114+ className = "absolute top-px bottom-px w-0.5 rounded-full bg-foreground"
115+ style = { { left : tickX - 1 } }
82116 />
83117 ) : null }
84118 </ View >
0 commit comments