From a42730fb05a54411dadcbcfc99ed33062836cfc9 Mon Sep 17 00:00:00 2001 From: lxm <1274844347@qq.com> Date: Tue, 25 Nov 2025 17:43:02 +0800 Subject: [PATCH] =?UTF-8?q?refactor(views):=20=E9=87=8D=E6=9E=84=E7=A7=AF?= =?UTF-8?q?=E5=88=86=E6=98=BE=E7=A4=BA=E7=BB=84=E4=BB=B6=E4=B8=BA=E7=8B=AC?= =?UTF-8?q?=E7=AB=8B=E8=A1=8C=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将积分统计卡片重构为独立的行组件,提升代码复用性和可维护性 移除冗余的积分卡片代码,统一积分显示样式 --- .../usage/views/aichat_stats_view.dart | 6 + .../usage/views/meeting_stats_view.dart | 121 ++++++---------- .../usage/views/translation_stats_view.dart | 136 +++++++----------- 3 files changed, 100 insertions(+), 163 deletions(-) diff --git a/lib/modules/usage/views/aichat_stats_view.dart b/lib/modules/usage/views/aichat_stats_view.dart index 7ac2d806b..a04fe6c44 100644 --- a/lib/modules/usage/views/aichat_stats_view.dart +++ b/lib/modules/usage/views/aichat_stats_view.dart @@ -40,6 +40,12 @@ class AiChatStatsView extends GetView { } Widget _buildBody(bool isDarkMode) { + return Column( + children: [_buildIntegralRow(isDarkMode)], + ); + } + + Widget _buildIntegralRow(bool isDarkMode) { return Obx(() { final _ = User.refreshTick.value; final u = User.instance; diff --git a/lib/modules/usage/views/meeting_stats_view.dart b/lib/modules/usage/views/meeting_stats_view.dart index de27ba356..63ea4897a 100644 --- a/lib/modules/usage/views/meeting_stats_view.dart +++ b/lib/modules/usage/views/meeting_stats_view.dart @@ -51,14 +51,13 @@ class MeetingStatsView extends GetView { Widget _buildBody(bool isDarkMode) { return Column( children: [ + _buildIntegralRow(isDarkMode), _buildTimeRangeSelector(isDarkMode), Expanded( child: SingleChildScrollView( padding: EdgeInsets.all(16.w), child: Column( children: [ - _buildIntegralCard(isDarkMode), - SizedBox(height: 16.h), _buildOverviewCard(isDarkMode), ], ), @@ -68,6 +67,51 @@ class MeetingStatsView extends GetView { ); } + Widget _buildIntegralRow(bool isDarkMode) { + return Obx(() { + final _ = User.refreshTick.value; + final u = User.instance; + return Padding( + padding: EdgeInsets.all(16.w), + child: Container( + padding: EdgeInsets.all(16.w), + decoration: BoxDecoration( + color: isDarkMode ? AppColors.cardBackground : Colors.white, + borderRadius: BorderRadius.circular(12.r), + boxShadow: [ + BoxShadow( + color: Colors.black.withValues(alpha: 0.05), + blurRadius: 10, + offset: const Offset(0, 2)), + ], + ), + child: Row( + children: [ + Icon(Icons.people, color: AppColors.primary, size: 20.sp), + SizedBox(width: 8.w), + Expanded( + child: Text( + '会议积分', + style: TextStyle( + fontSize: 16.sp, + fontWeight: FontWeight.w600, + color: isDarkMode ? Colors.white : Colors.black), + ), + ), + Text( + '${u.meetintegral}/${u.meettotalintegral}', + style: TextStyle( + fontSize: 16.sp, + fontWeight: FontWeight.w600, + color: isDarkMode ? Colors.white : Colors.black), + ), + ], + ), + ), + ); + }); + } + Widget _buildTimeRangeSelector(bool isDarkMode) { return Container( margin: EdgeInsets.all(16.w), @@ -212,77 +256,4 @@ class MeetingStatsView extends GetView { ], ); } - - Widget _buildIntegralCard(bool isDarkMode) { - return Container( - padding: EdgeInsets.all(16.w), - decoration: BoxDecoration( - color: isDarkMode ? AppColors.cardBackground : Colors.white, - borderRadius: BorderRadius.circular(12.r), - boxShadow: [ - BoxShadow( - color: Colors.black.withValues(alpha: 0.05), - blurRadius: 10, - offset: const Offset(0, 2), - ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Icon(Icons.stacked_line_chart, - color: AppColors.primary, size: 20.sp), - SizedBox(width: 8.w), - Text( - '积分统计', - style: TextStyle( - fontSize: 16.sp, - fontWeight: FontWeight.w600, - color: isDarkMode ? Colors.white : Colors.black, - ), - ), - ], - ), - SizedBox(height: 16.h), - Obx(() { - final _ = User.refreshTick.value; - final u = User.instance; - return _buildIntegralRow( - '会议', - '${controller.formatNumber(u.meetintegral)}/${controller.formatNumber(u.meettotalintegral)}', - Icons.people, - isDarkMode, - ); - }), - ], - ), - ); - } - - Widget _buildIntegralRow( - String label, String value, IconData icon, bool isDarkMode) { - return Row( - children: [ - Icon(icon, color: AppColors.primary, size: 18.sp), - SizedBox(width: 12.w), - Expanded( - child: Text( - label, - style: TextStyle( - fontSize: 14.sp, - color: isDarkMode ? Colors.white : Colors.black), - ), - ), - Text( - value, - style: TextStyle( - fontSize: 14.sp, - fontWeight: FontWeight.w600, - color: isDarkMode ? Colors.white : Colors.black), - ), - ], - ); - } } diff --git a/lib/modules/usage/views/translation_stats_view.dart b/lib/modules/usage/views/translation_stats_view.dart index 4c98c9493..a966284c4 100644 --- a/lib/modules/usage/views/translation_stats_view.dart +++ b/lib/modules/usage/views/translation_stats_view.dart @@ -89,14 +89,15 @@ class TranslationStatsView extends GetView { Widget _buildBody(bool isDarkMode) { return Column( children: [ + _buildIntegralRow(isDarkMode), _buildTimeRangeSelector(isDarkMode), Expanded( child: SingleChildScrollView( padding: EdgeInsets.all(16.w), child: Column( children: [ - _buildIntegralCard(isDarkMode), - SizedBox(height: 16.h), + // _buildIntegralCard(isDarkMode), + // SizedBox(height: 16.h), if (controller.selectedTabIndex.value == 0) _buildRealtimeStatsCard(isDarkMode), SizedBox(height: 16.h), @@ -115,6 +116,51 @@ class TranslationStatsView extends GetView { ); } + Widget _buildIntegralRow(bool isDarkMode) { + return Obx(() { + final _ = User.refreshTick.value; + final u = User.instance; + return Padding( + padding: EdgeInsets.all(16.w), + child: Container( + padding: EdgeInsets.all(16.w), + decoration: BoxDecoration( + color: isDarkMode ? AppColors.cardBackground : Colors.white, + borderRadius: BorderRadius.circular(12.r), + boxShadow: [ + BoxShadow( + color: Colors.black.withValues(alpha: 0.05), + blurRadius: 10, + offset: const Offset(0, 2)), + ], + ), + child: Row( + children: [ + Icon(Icons.translate, color: AppColors.primary, size: 20.sp), + SizedBox(width: 8.w), + Expanded( + child: Text( + '翻译积分', + style: TextStyle( + fontSize: 16.sp, + fontWeight: FontWeight.w600, + color: isDarkMode ? Colors.white : Colors.black), + ), + ), + Text( + '${u.tradeintegral}/${u.tradetotalintegral}', + style: TextStyle( + fontSize: 16.sp, + fontWeight: FontWeight.w600, + color: isDarkMode ? Colors.white : Colors.black), + ), + ], + ), + ), + ); + }); + } + Widget _buildTimeRangeSelector(bool isDarkMode) { return Container( margin: EdgeInsets.all(16.w), @@ -424,92 +470,6 @@ class TranslationStatsView extends GetView { ); } - Widget _buildIntegralCard(bool isDarkMode) { - return Container( - padding: EdgeInsets.all(16.w), - decoration: BoxDecoration( - color: isDarkMode ? AppColors.cardBackground : Colors.white, - borderRadius: BorderRadius.circular(12.r), - boxShadow: [ - BoxShadow( - color: Colors.black.withValues(alpha: 0.05), - blurRadius: 10, - offset: const Offset(0, 2), - ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Icon( - Icons.stacked_line_chart, - color: AppColors.primary, - size: 20.sp, - ), - SizedBox(width: 8.w), - Text( - '积分统计', - style: TextStyle( - fontSize: 16.sp, - fontWeight: FontWeight.w600, - color: isDarkMode ? Colors.white : Colors.black, - ), - ), - ], - ), - SizedBox(height: 16.h), - Obx(() { - final _ = User.refreshTick.value; - final u = User.instance; - return Column( - children: [ - _buildIntegralRow( - '翻译', - '${controller.formatNumber(u.tradeintegral)}/${controller.formatNumber(u.tradetotalintegral)}', - Icons.translate, - isDarkMode, - ), - ], - ); - }), - ], - ), - ); - } - - Widget _buildIntegralRow( - String label, String value, IconData icon, bool isDarkMode) { - return Row( - children: [ - Icon( - icon, - color: AppColors.primary, - size: 18.sp, - ), - SizedBox(width: 12.w), - Expanded( - child: Text( - label, - style: TextStyle( - fontSize: 14.sp, - color: isDarkMode ? Colors.white : Colors.black, - ), - ), - ), - Text( - value, - style: TextStyle( - fontSize: 14.sp, - fontWeight: FontWeight.w600, - color: isDarkMode ? Colors.white : Colors.black, - ), - ), - ], - ); - } - Widget _buildApiCallRow( String label, int count, IconData icon, bool isDarkMode) { return Row(