Browse Source

feat: 调整字体大小并优化设备信息刷新逻辑

- 修改设置和探索页面的标题字体大小
- 在设备连接时主动刷新设备信息
- 为路由添加页面切换动画
- 清理调试日志和注释代码
- 为翻译统计页面添加返回按钮
weicu
lxm 1 year ago
parent
commit
57fc7f1018
  1. 9
      lib/data/services/ble_manager.dart
  2. 12
      lib/data/services/version_update_service.dart
  3. 2
      lib/modules/explore/views/explore_view.dart
  4. 11
      lib/modules/home/controllers/home_controller.dart
  5. 2
      lib/modules/settings/views/settings_view.dart
  6. 68
      lib/modules/translation/views/translation_stats_view.dart
  7. 4
      lib/routes/app_pages.dart

9
lib/data/services/ble_manager.dart

@ -156,7 +156,7 @@ class BleManager extends GetxService {
/// 设置BLE事件监听 /// 设置BLE事件监听
void _setupBleListener() { void _setupBleListener() {
Logger.info('lxm--_setupBleListener被调用,开始设置BLE事件监听'); //Logger.info('lxm--_setupBleListener被调用,开始设置BLE事件监听');
_statusSubscription?.cancel(); _statusSubscription?.cancel();
_dataSubscription?.cancel(); _dataSubscription?.cancel();
@ -394,6 +394,7 @@ class BleManager extends GetxService {
Logger.info('lxm-- overallBattery: $overallBattery'); Logger.info('lxm-- overallBattery: $overallBattery');
Logger.info('lxm--准备调用_updateDeviceInfoIfNeeded'); Logger.info('lxm--准备调用_updateDeviceInfoIfNeeded');
// 更新设备信息 // 更新设备信息
_updateDeviceInfoIfNeeded( _updateDeviceInfoIfNeeded(
batteryLevel: overallBattery, batteryLevel: overallBattery,
@ -796,12 +797,12 @@ class BleManager extends GetxService {
/// 主动获取电池信息 /// 主动获取电池信息
Future<bool> fetchBatteryInfo() async { Future<bool> fetchBatteryInfo() async {
try { try {
Logger.info('lxm--fetchBatteryInfo被调用,准备向设备发送获取电池信息指令'); //Logger.info('lxm--fetchBatteryInfo被调用,准备向设备发送获取电池信息指令');
final result = await _bleService.getBatteryInfo(); final result = await _bleService.getBatteryInfo();
Logger.info('lxm--getBatteryInfo指令发送结果: $result'); //Logger.info('lxm--getBatteryInfo指令发送结果: $result');
return result; return result;
} catch (e) { } catch (e) {
Logger.error('lxm--获取电池信息失败: ${e.toString()}'); //Logger.error('lxm--获取电池信息失败: ${e.toString()}');
return false; return false;
} }
} }

12
lib/data/services/version_update_service.dart

@ -353,12 +353,12 @@ class VersionUpdateService extends GetxService {
/// 执行更新操作 /// 执行更新操作
Future<bool> performUpdate(VersionUpdateInfo updateInfo) async { Future<bool> performUpdate(VersionUpdateInfo updateInfo) async {
print('lxm---updateInfo详情:'); //print('lxm---updateInfo详情:');
print('lxm---hasUpdate: ${updateInfo.hasUpdate}'); //print('lxm---hasUpdate: ${updateInfo.hasUpdate}');
print('lxm---currentVersion: ${updateInfo.currentVersion}'); //print('lxm---currentVersion: ${updateInfo.currentVersion}');
print('lxm---latestVersion: ${updateInfo.latestVersion}'); //print('lxm---latestVersion: ${updateInfo.latestVersion}');
print('lxm---updateType: ${updateInfo.updateType}'); //print('lxm---updateType: ${updateInfo.updateType}');
print('lxm---appInfo: ${updateInfo.appInfo?.toJson()}'); //print('lxm---appInfo: ${updateInfo.appInfo?.toJson()}');
if (!updateInfo.hasUpdate || updateInfo.appInfo == null) { if (!updateInfo.hasUpdate || updateInfo.appInfo == null) {
return false; return false;
} }

2
lib/modules/explore/views/explore_view.dart

@ -99,7 +99,7 @@ class ExploreView extends GetView<ExploreController> {
Text( Text(
'explore'.tr, // 发现 'explore'.tr, // 发现
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 20.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: isDarkMode ? Colors.white : Colors.grey[800], color: isDarkMode ? Colors.white : Colors.grey[800],
), ),

11
lib/modules/home/controllers/home_controller.dart

@ -140,7 +140,16 @@ class HomeController extends GetxController {
Future<void> refreshDeviceConnection() async { Future<void> refreshDeviceConnection() async {
await _checkConnectionStatus(); await _checkConnectionStatus();
// 移除了立即刷新电池信息的逻辑
// 如果设备已连接,主动刷新设备信息
if (_isFullyConnected.value) {
try {
Logger.d(_tag, '刷新设备信息');
await _bleManager.fetchDeviceInfo();
} catch (e) {
Logger.e(_tag, '刷新设备信息失败: $e');
}
}
} }
void rescanDevices() { void rescanDevices() {

2
lib/modules/settings/views/settings_view.dart

@ -29,7 +29,7 @@ class SettingsView extends GetView<SettingsController> {
title: Text( title: Text(
'settings'.tr, // 设置 'settings'.tr, // 设置
style: TextStyle( style: TextStyle(
fontSize: 17.sp, fontSize: 18.sp,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: isDarkMode ? Colors.white : Colors.black, color: isDarkMode ? Colors.white : Colors.black,
), ),

68
lib/modules/translation/views/translation_stats_view.dart

@ -24,6 +24,14 @@ class TranslationStatsView extends GetView<TranslationStatsController> {
/// 构建应用栏 /// 构建应用栏
PreferredSizeWidget _buildAppBar(bool isDarkMode) { PreferredSizeWidget _buildAppBar(bool isDarkMode) {
return AppBar( return AppBar(
leading: IconButton(
icon: Icon(
Icons.arrow_back_ios,
color: isDarkMode ? Colors.white : Colors.black,
size: 20.sp,
),
onPressed: () => Get.back(),
),
backgroundColor: isDarkMode ? AppColors.darkBackground : Colors.white, backgroundColor: isDarkMode ? AppColors.darkBackground : Colors.white,
elevation: 0.5, elevation: 0.5,
title: Text( title: Text(
@ -251,7 +259,8 @@ class TranslationStatsView extends GetView<TranslationStatsController> {
Expanded( Expanded(
child: _buildStatItem( child: _buildStatItem(
'录音时长', '录音时长',
controller.formatDuration(controller.realtimeStats.recordingDuration), controller.formatDuration(
controller.realtimeStats.recordingDuration),
Icons.mic, Icons.mic,
isDarkMode, isDarkMode,
), ),
@ -305,7 +314,8 @@ class TranslationStatsView extends GetView<TranslationStatsController> {
Expanded( Expanded(
child: _buildStatItem( child: _buildStatItem(
'总调用次数', '总调用次数',
controller.formatNumber(controller.currentStats.totalApiCalls), controller
.formatNumber(controller.currentStats.totalApiCalls),
Icons.api, Icons.api,
isDarkMode, isDarkMode,
), ),
@ -313,7 +323,8 @@ class TranslationStatsView extends GetView<TranslationStatsController> {
Expanded( Expanded(
child: _buildStatItem( child: _buildStatItem(
'预估成本', '预估成本',
controller.formatCost(controller.currentStats.estimatedCost), controller
.formatCost(controller.currentStats.estimatedCost),
Icons.attach_money, Icons.attach_money,
isDarkMode, isDarkMode,
), ),
@ -334,7 +345,8 @@ class TranslationStatsView extends GetView<TranslationStatsController> {
Expanded( Expanded(
child: _buildStatItem( child: _buildStatItem(
'总字符数', '总字符数',
controller.formatNumber(controller.currentStats.totalCharacterCount), controller.formatNumber(
controller.currentStats.totalCharacterCount),
Icons.text_snippet, Icons.text_snippet,
isDarkMode, isDarkMode,
), ),
@ -347,7 +359,8 @@ class TranslationStatsView extends GetView<TranslationStatsController> {
} }
/// 构建统计项 /// 构建统计项
Widget _buildStatItem(String label, String value, IconData icon, bool isDarkMode) { Widget _buildStatItem(
String label, String value, IconData icon, bool isDarkMode) {
return Column( return Column(
children: [ children: [
Icon( Icon(
@ -415,13 +428,23 @@ class TranslationStatsView extends GetView<TranslationStatsController> {
SizedBox(height: 16.h), SizedBox(height: 16.h),
Obx(() => Column( Obx(() => Column(
children: [ children: [
_buildApiCallRow('翻译API', controller.currentStats.translationApiCalls, Icons.translate, isDarkMode), _buildApiCallRow(
'翻译API',
controller.currentStats.translationApiCalls,
Icons.translate,
isDarkMode),
SizedBox(height: 12.h), SizedBox(height: 12.h),
_buildApiCallRow('语音识别', controller.currentStats.asrApiCalls, Icons.mic, isDarkMode), _buildApiCallRow('语音识别', controller.currentStats.asrApiCalls,
Icons.mic, isDarkMode),
SizedBox(height: 12.h), SizedBox(height: 12.h),
_buildApiCallRow('语音合成', controller.currentStats.ttsApiCalls, Icons.volume_up, isDarkMode), _buildApiCallRow('语音合成', controller.currentStats.ttsApiCalls,
Icons.volume_up, isDarkMode),
SizedBox(height: 12.h), SizedBox(height: 12.h),
_buildApiCallRow('AI摘要', controller.currentStats.aiSummaryApiCalls, Icons.summarize, isDarkMode), _buildApiCallRow(
'AI摘要',
controller.currentStats.aiSummaryApiCalls,
Icons.summarize,
isDarkMode),
], ],
)), )),
], ],
@ -430,7 +453,8 @@ class TranslationStatsView extends GetView<TranslationStatsController> {
} }
/// 构建API调用行 /// 构建API调用行
Widget _buildApiCallRow(String label, int count, IconData icon, bool isDarkMode) { Widget _buildApiCallRow(
String label, int count, IconData icon, bool isDarkMode) {
return Row( return Row(
children: [ children: [
Icon( Icon(
@ -504,7 +528,8 @@ class TranslationStatsView extends GetView<TranslationStatsController> {
Expanded( Expanded(
child: _buildStatItem( child: _buildStatItem(
'源文本字符', '源文本字符',
controller.formatNumber(controller.currentStats.sourceTextCharacters), controller.formatNumber(
controller.currentStats.sourceTextCharacters),
Icons.text_fields, Icons.text_fields,
isDarkMode, isDarkMode,
), ),
@ -512,7 +537,8 @@ class TranslationStatsView extends GetView<TranslationStatsController> {
Expanded( Expanded(
child: _buildStatItem( child: _buildStatItem(
'TTS文本字符', 'TTS文本字符',
controller.formatNumber(controller.currentStats.ttsTextCharacters), controller.formatNumber(
controller.currentStats.ttsTextCharacters),
Icons.translate, Icons.translate,
isDarkMode, isDarkMode,
), ),
@ -525,7 +551,8 @@ class TranslationStatsView extends GetView<TranslationStatsController> {
Expanded( Expanded(
child: _buildStatItem( child: _buildStatItem(
'有效音频时长', '有效音频时长',
controller.formatDuration(controller.currentStats.effectiveAudioDuration), controller.formatDuration(
controller.currentStats.effectiveAudioDuration),
Icons.mic, Icons.mic,
isDarkMode, isDarkMode,
), ),
@ -533,7 +560,8 @@ class TranslationStatsView extends GetView<TranslationStatsController> {
Expanded( Expanded(
child: _buildStatItem( child: _buildStatItem(
'总会话时长', '总会话时长',
controller.formatDuration(controller.currentStats.totalSessionDuration), controller.formatDuration(
controller.currentStats.totalSessionDuration),
Icons.volume_up, Icons.volume_up,
isDarkMode, isDarkMode,
), ),
@ -605,7 +633,8 @@ class TranslationStatsView extends GetView<TranslationStatsController> {
), ),
), ),
Text( Text(
controller.formatCost(controller.currentStats.estimatedCost), controller.formatCost(
controller.currentStats.estimatedCost),
style: TextStyle( style: TextStyle(
fontSize: 18.sp, fontSize: 18.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -628,7 +657,8 @@ class TranslationStatsView extends GetView<TranslationStatsController> {
), ),
), ),
Text( Text(
controller.formatCost(controller.dailyCostThreshold.value), controller
.formatCost(controller.dailyCostThreshold.value),
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
color: isDarkMode ? Colors.white70 : Colors.black54, color: isDarkMode ? Colors.white70 : Colors.black54,
@ -648,7 +678,8 @@ class TranslationStatsView extends GetView<TranslationStatsController> {
), ),
), ),
Text( Text(
controller.formatCost(controller.monthlyCostThreshold.value), controller
.formatCost(controller.monthlyCostThreshold.value),
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
color: isDarkMode ? Colors.white70 : Colors.black54, color: isDarkMode ? Colors.white70 : Colors.black54,
@ -725,7 +756,8 @@ class TranslationStatsView extends GetView<TranslationStatsController> {
} }
/// 构建使用行为行 /// 构建使用行为行
Widget _buildUsageBehaviorRow(String label, String value, IconData icon, bool isDarkMode) { Widget _buildUsageBehaviorRow(
String label, String value, IconData icon, bool isDarkMode) {
return Row( return Row(
children: [ children: [
Icon( Icon(

4
lib/routes/app_pages.dart

@ -122,6 +122,8 @@ abstract class AppPages {
name: Routes.OTA_UPGRADE, name: Routes.OTA_UPGRADE,
page: () => const OtaUpgradeView(), page: () => const OtaUpgradeView(),
binding: OtaUpgradeBinding(), binding: OtaUpgradeBinding(),
transition: Transition.rightToLeft,
transitionDuration: Duration(milliseconds: 250),
), ),
// GetPage( // GetPage(
// name: Routes.profile, // name: Routes.profile,
@ -273,6 +275,8 @@ abstract class AppPages {
name: Routes.devices, name: Routes.devices,
page: () => const DevicesView(), page: () => const DevicesView(),
binding: DevicesBinding(), binding: DevicesBinding(),
transition: Transition.rightToLeft,
transitionDuration: Duration(milliseconds: 250),
), ),
GetPage( GetPage(
name: Routes.ble, name: Routes.ble,

Loading…
Cancel
Save