@@ -248,22 +248,34 @@ class DanmakuItem extends StatelessWidget {
248248
249249 @override
250250 Widget build (BuildContext context) {
251+ final theme = Theme .of (context);
252+ final isDark = theme.brightness == Brightness .dark;
253+
251254 final baseColor = Color .fromARGB (255 , danmaku.color.r, danmaku.color.g, danmaku.color.b);
252255
253- final vibrantColor = baseColor.toARGB32 () == Colors .white.toARGB32 ()
254- ? Colors .black
255- : HSLColor .fromColor (baseColor).withLightness (0.52 ).withSaturation (1 ).toColor ();
256+ final vibrantColor =
257+ baseColor.toARGB32 () == Colors .white.toARGB32 () || baseColor.toARGB32 () == Colors .black.toARGB32 ()
258+ ? (isDark ? Colors .white : Colors .black)
259+ : HSLColor .fromColor (baseColor).withLightness (isDark ? 0.75 : 0.52 ).withSaturation (1 ).toColor ();
260+
261+ final cardBgColor = isDark ? theme.cardColor.withValues (alpha: 0.65 ) : Colors .white.withValues (alpha: 0.72 );
262+
263+ final textColor = isDark ? Colors .white70 : Colors .black87;
256264
257265 return RepaintBoundary (
258266 child: Padding (
259267 padding: const EdgeInsets .symmetric (horizontal: 8 , vertical: 4 ),
260268 child: DecoratedBox (
261269 decoration: BoxDecoration (
262- color: Colors .white. withValues (alpha : 0.72 ),
270+ color: cardBgColor, // 动态背景色
263271 borderRadius: BorderRadius .circular (10 ),
264- border: Border .all (color: vibrantColor.withValues (alpha: 0.01 ), width: 0.5 ),
272+ border: Border .all (color: vibrantColor.withValues (alpha: 0.08 ), width: 0.5 ),
265273 boxShadow: [
266- BoxShadow (color: vibrantColor.withValues (alpha: 0.02 ), blurRadius: 6 , offset: const Offset (0 , 2 )),
274+ BoxShadow (
275+ color: vibrantColor.withValues (alpha: isDark ? 0.05 : 0.02 ),
276+ blurRadius: 6 ,
277+ offset: const Offset (0 , 2 ),
278+ ),
267279 ],
268280 ),
269281 child: Padding (
@@ -279,16 +291,15 @@ class DanmakuItem extends StatelessWidget {
279291 decoration: BoxDecoration (
280292 color: vibrantColor,
281293 shape: BoxShape .circle,
282- boxShadow: [BoxShadow (color: vibrantColor.withValues (alpha: 0.1 ), blurRadius: 6 )],
294+ boxShadow: [BoxShadow (color: vibrantColor.withValues (alpha: 0.2 ), blurRadius: 6 )],
283295 ),
284296 ),
285297
286298 Expanded (
287299 child: GestureDetector (
288- behavior: HitTestBehavior .translucent, // Ensure double-tap is detected anywhere
300+ behavior: HitTestBehavior .translucent,
289301 onDoubleTap: () async {
290302 final String textToCopy = "${danmaku .userName }: ${danmaku .message }" ;
291-
292303 try {
293304 await Clipboard .setData (ClipboardData (text: textToCopy));
294305 ToastUtil .show (i18n ('copied_to_clipboard' ));
@@ -301,16 +312,11 @@ class DanmakuItem extends StatelessWidget {
301312 children: [
302313 TextSpan (
303314 text: "${danmaku .userName }: " ,
304- style: const TextStyle (fontSize: 14 , fontWeight: FontWeight .w700, color: Colors .black87 ),
315+ style: TextStyle (fontSize: 14 , fontWeight: FontWeight .w700, color: textColor ),
305316 ),
306317 TextSpan (
307318 children: parseEmojis (danmaku.message, 14 , vibrantColor),
308- style: const TextStyle (
309- fontSize: 14 ,
310- height: 1.45 ,
311- fontWeight: FontWeight .w500,
312- color: Colors .black87,
313- ),
319+ style: TextStyle (fontSize: 14 , height: 1.45 , fontWeight: FontWeight .w500, color: textColor),
314320 ),
315321 ],
316322 ),
0 commit comments