Browse Source

fix(主题): 修复主题颜色不一致问题并优化主页布局

- 将主页视图中的开关和图标颜色从动态主题色改为固定蓝色,确保视觉一致性
- 修复电池电量检测逻辑,增加对0%电量的判断
- 优化主页语音打断开关的布局,保持紧凑排列
newdev_shunjiawei
lxm 12 months ago
parent
commit
f43934c167
  1. 7
      lib/core/themes/app_theme.dart
  2. 9
      lib/modules/home/views/home_view.dart

7
lib/core/themes/app_theme.dart

@ -5,6 +5,13 @@ class AppTheme {
brightness: Brightness.light,
primaryColor: Colors.blue,
scaffoldBackgroundColor: Colors.white,
// colorScheme: const ColorScheme.light(
// primary: Colors.blue, // 主色:蓝色(修复:确保 colorScheme.primary 为蓝色)
// secondary: Color(0xFF5E5CE6), // 次色:紫色,与暗色主题保持一致
// surface: Colors.white,
// background: Colors.white,
// error: Colors.redAccent,
// ),
appBarTheme: const AppBarTheme(
backgroundColor: Colors.blue,
foregroundColor: Colors.white,

9
lib/modules/home/views/home_view.dart

@ -167,15 +167,14 @@ class HomeView extends GetView<HomeController> {
// 中文注释:去除菜单模式,直接在同一行展示“语音打断”与开关
Obx(() => Row(
mainAxisSize: MainAxisSize.min, // 中文注释:按需占宽,避免占满右侧
mainAxisAlignment:
MainAxisAlignment.end, // 中文注释:靠右紧凑排布
mainAxisAlignment: MainAxisAlignment.end, // 中文注释:靠右紧凑排布
children: [
Icon(
controller.isTtsInterruptEnabled.value
? Icons.voice_over_off
: Icons.voice_over_off_outlined,
color: controller.isTtsInterruptEnabled.value
? Theme.of(Get.context!).colorScheme.primary
? Colors.blue
: (isDarkMode ? Colors.grey[600] : Colors.grey[600]),
size: 14.sp, // 中文注释:图标保持较小尺寸,减少占位
),
@ -194,7 +193,7 @@ class HomeView extends GetView<HomeController> {
child: Switch(
value: controller.isTtsInterruptEnabled.value,
onChanged: (value) => controller.toggleTtsInterrupt(),
activeColor: Theme.of(Get.context!).colorScheme.primary,
activeColor: Colors.blue,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
),
@ -631,7 +630,7 @@ class HomeView extends GetView<HomeController> {
batteryColor = Colors.red[600]!;
}
bool isBatteryZero = batteryLevel == -1;
bool isBatteryZero = batteryLevel == -1 || batteryLevel == 0;
return Expanded(
child: Padding(

Loading…
Cancel
Save