Skip to content

Commit 83bea0a

Browse files
committed
修复主题和弹幕
1 parent df8f216 commit 83bea0a

2 files changed

Lines changed: 35 additions & 43 deletions

File tree

lib/modules/live_play/widgets/danmaku_list_view.dart

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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
),

lib/modules/settings/settings_page.dart

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -248,36 +248,22 @@ class SettingsPage extends GetView<SettingsService> {
248248
return SimpleDialog(
249249
title: Text(i18n('change_theme_mode')),
250250
children: [
251-
RadioGroup<String>(
252-
groupValue: controller.themeModeName.value,
253-
onChanged: (String? value) {
254-
controller.changeThemeMode(value!);
255-
Navigator.of(context).pop();
256-
},
257-
child: Padding(
258-
padding: const EdgeInsets.only(top: 0, bottom: 10, left: 16, right: 16),
251+
Obx(
252+
() => RadioGroup<String>(
253+
groupValue: controller.themeModeName.value,
254+
onChanged: (String? value) {
255+
if (value != null) {
256+
controller.changeThemeMode(value);
257+
Navigator.of(context).pop();
258+
}
259+
},
259260
child: Column(
260261
mainAxisSize: MainAxisSize.min,
261-
crossAxisAlignment: CrossAxisAlignment.start,
262262
children: AppConsts.themeModes.keys.map<Widget>((name) {
263-
return Row(
264-
mainAxisSize: MainAxisSize.min,
265-
children: [
266-
Radio(
267-
value: i18n(AppConsts.themeModeI18n[name]!),
268-
activeColor: Theme.of(Get.context!).colorScheme.primary,
269-
),
270-
GestureDetector(
271-
onTap: () {
272-
controller.changeThemeMode(name);
273-
Navigator.of(context).pop();
274-
},
275-
child: Text(
276-
i18n(AppConsts.themeModeI18n[name]!),
277-
style: Theme.of(context).textTheme.bodyLarge,
278-
),
279-
),
280-
],
263+
return RadioListTile<String>(
264+
title: Text(i18n(AppConsts.themeModeI18n[name]!)),
265+
value: name,
266+
activeColor: Theme.of(context).colorScheme.primary,
281267
);
282268
}).toList(),
283269
),

0 commit comments

Comments
 (0)