Browse Source

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

- 将主页视图中的开关和图标颜色从动态主题色改为固定蓝色,确保视觉一致性
- 修复电池电量检测逻辑,增加对0%电量的判断
- 优化主页语音打断开关的布局,保持紧凑排列
weicu
lxm 12 months ago
parent
commit
cdd704d6fa
  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, brightness: Brightness.light,
primaryColor: Colors.blue, primaryColor: Colors.blue,
scaffoldBackgroundColor: Colors.white, 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( appBarTheme: const AppBarTheme(
backgroundColor: Colors.blue, backgroundColor: Colors.blue,
foregroundColor: Colors.white, foregroundColor: Colors.white,

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

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

Loading…
Cancel
Save