Browse Source

- 在TranslationView中调整语言选择对话框的对齐方式和宽度

- 修改SnackBar的显示时长
- 在HomeView中添加设备管理按钮并优化电池显示
newdev_shunjiawei
lxm 1 year ago
parent
commit
fc25d4c31e
  1. 103
      lib/modules/home/views/home_view.dart
  2. 2
      lib/modules/settings/controllers/settings_controller.dart
  3. 22
      lib/modules/translation/views/translation_view.dart
  4. 3
      local_plugins/agent_service/lib/agent_service.dart

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

@ -271,7 +271,7 @@ class HomeView extends GetView<HomeController> {
), ),
], ],
), ),
padding: EdgeInsets.all(16.w), padding: EdgeInsets.fromLTRB(16.w, 16.h, 16.w, 16.h),
child: Column( child: Column(
children: [ children: [
// 状态标题行 // 状态标题行
@ -294,7 +294,7 @@ class HomeView extends GetView<HomeController> {
if (!controller.isFullyConnectedRx.value) { if (!controller.isFullyConnectedRx.value) {
return _buildConnectButton(); return _buildConnectButton();
} else { } else {
return const SizedBox(); return _buildDeviceButton(isDarkMode);
} }
}), }),
], ],
@ -417,12 +417,42 @@ class HomeView extends GetView<HomeController> {
), ),
SizedBox(height: 12.h), SizedBox(height: 12.h),
_buildBatteryInfoGrid(isDarkMode), _buildBatteryInfoGrid(isDarkMode),
// SizedBox(height: 16.h),
// _buildDeviceDetailsCard(isDarkMode),
], ],
); );
} }
// 设备管理按钮
Widget _buildDeviceButton(bool isDarkMode) {
return ElevatedButton(
onPressed: () {
Get.toNamed(Routes.devices); // 跳转到设备管理页面
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
minimumSize: Size(double.infinity, 44.h),
elevation: 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.r),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.device_hub, size: 16.sp), // 设备图标
SizedBox(width: 8.w),
Text(
'deviceManagement'.tr,
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.w500,
),
),
],
),
);
}
// 电池信息网格布局 // 电池信息网格布局
Widget _buildBatteryInfoGrid(bool isDarkMode) { Widget _buildBatteryInfoGrid(bool isDarkMode) {
return Obx(() { return Obx(() {
@ -522,6 +552,8 @@ class HomeView extends GetView<HomeController> {
batteryColor = Colors.red[600]!; batteryColor = Colors.red[600]!;
} }
bool isBatteryZero = batteryLevel == 0;
return Expanded( return Expanded(
child: Padding( child: Padding(
padding: EdgeInsets.symmetric(vertical: 6.h), padding: EdgeInsets.symmetric(vertical: 6.h),
@ -540,32 +572,45 @@ class HomeView extends GetView<HomeController> {
), ),
SizedBox(height: 4.h), SizedBox(height: 4.h),
// 电池指示器 // 电池指示器 - 当电量为0时,显示横线
Row( isBatteryZero
mainAxisAlignment: MainAxisAlignment.center, ? Container(
children: [ width: 20.w, // 横线宽度
Icon( height: 12.sp, // 设置与图标相同的高度,确保对齐
batteryIcon, alignment: Alignment.center, // 居中对齐
size: 12.sp, child: Container(
color: batteryColor, width: 10.w,
), height: 1.5.h, // 实际横线高度
SizedBox(width: 2.w), color: isDarkMode
Text( ? Colors.grey[600]
'$batteryLevel%', : Colors.grey[400], // 横线颜色
style: TextStyle( ),
fontSize: 11.sp, )
fontWeight: FontWeight.w500, : Row(
color: batteryColor, mainAxisAlignment: MainAxisAlignment.center,
), children: [
), Icon(
if (isCharging) batteryIcon,
Icon( size: 12.sp,
Icons.bolt, color: batteryColor,
size: 10.sp, ),
color: Colors.green[600], SizedBox(width: 2.w),
Text(
'$batteryLevel%',
style: TextStyle(
fontSize: 11.sp,
fontWeight: FontWeight.w500,
color: batteryColor,
),
),
if (isCharging)
Icon(
Icons.bolt,
size: 10.sp,
color: Colors.green[600],
),
],
), ),
],
),
], ],
), ),
), ),

2
lib/modules/settings/controllers/settings_controller.dart

@ -247,11 +247,9 @@ class SettingsController extends GetxController {
final PackageInfo packageInfo = await PackageInfo.fromPlatform(); final PackageInfo packageInfo = await PackageInfo.fromPlatform();
appVersion.value = packageInfo.version; appVersion.value = packageInfo.version;
buildNumber.value = packageInfo.buildNumber; buildNumber.value = packageInfo.buildNumber;
print('版本信息: ${packageInfo.version}+${packageInfo.buildNumber}');
} catch (e) { } catch (e) {
appVersion.value = '未知'; appVersion.value = '未知';
buildNumber.value = '0'; buildNumber.value = '0';
print('获取版本信息失败: $e');
} }
} }

22
lib/modules/translation/views/translation_view.dart

@ -662,13 +662,15 @@ class TranslationView extends GetView<TranslationController> {
// 显示语言选择对话框 // 显示语言选择对话框
void _showLanguageSelectionDialog(bool isSource, bool isDarkMode) { void _showLanguageSelectionDialog(bool isSource, bool isDarkMode) {
Get.dialog( Get.dialog(Dialog(
Dialog( backgroundColor: isDarkMode ? Colors.grey[900] : Colors.white,
backgroundColor: isDarkMode ? Colors.grey[900] : Colors.white, shape: RoundedRectangleBorder(
shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16.r), // 统一圆角尺寸为16
borderRadius: BorderRadius.circular(16.r), // 统一圆角尺寸为16 ),
), alignment: isSource ? Alignment.centerLeft : Alignment.centerRight,
insetPadding: EdgeInsets.symmetric(horizontal: 20.w), insetPadding: EdgeInsets.symmetric(horizontal: 10.w),
child: SizedBox(
width: 0.4.sw,
child: Padding( child: Padding(
// 使用Padding替代Container的padding // 使用Padding替代Container的padding
padding: EdgeInsets.all(12.w), // 统一内边距 padding: EdgeInsets.all(12.w), // 统一内边距
@ -807,7 +809,7 @@ class TranslationView extends GetView<TranslationController> {
), ),
), ),
), ),
); ));
} }
// 构建加载更多指示器 // 构建加载更多指示器
@ -1035,7 +1037,7 @@ class TranslationView extends GetView<TranslationController> {
snackPosition: SnackPosition.BOTTOM, snackPosition: SnackPosition.BOTTOM,
backgroundColor: Get.isDarkMode ? Colors.grey[800] : Colors.grey[200], backgroundColor: Get.isDarkMode ? Colors.grey[800] : Colors.grey[200],
colorText: Get.isDarkMode ? Colors.white : Colors.black, colorText: Get.isDarkMode ? Colors.white : Colors.black,
duration: const Duration(seconds: 2), duration: const Duration(milliseconds: 800),
); );
} catch (e) { } catch (e) {
// 显示删除失败提示 // 显示删除失败提示
@ -1045,7 +1047,7 @@ class TranslationView extends GetView<TranslationController> {
snackPosition: SnackPosition.BOTTOM, snackPosition: SnackPosition.BOTTOM,
backgroundColor: Colors.red[400], backgroundColor: Colors.red[400],
colorText: Colors.white, colorText: Colors.white,
duration: const Duration(seconds: 3), duration: const Duration(milliseconds: 1500),
); );
} }
} }

3
local_plugins/agent_service/lib/agent_service.dart

@ -332,8 +332,6 @@ class AgentService {
} }
} }
/// 停止语音合成 /// 停止语音合成
static Future<bool> stopAiSteam() async { static Future<bool> stopAiSteam() async {
try { try {
@ -385,6 +383,7 @@ class AgentService {
/// ///
/// [imagePath] 图片文件路径 /// [imagePath] 图片文件路径
/// [text] 可选的文本描述或问题 /// [text] 可选的文本描述或问题
/// [imageUrl] 图片url
/// [speakResponse] 是否朗读响应 /// [speakResponse] 是否朗读响应
/// 返回是否成功处理图片 /// 返回是否成功处理图片
static Future<bool> processImageInput(String imagePath, String imageUrl, static Future<bool> processImageInput(String imagePath, String imageUrl,

Loading…
Cancel
Save