|
|
@ -10,70 +10,125 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> { |
|
|
Widget build(BuildContext context) { |
|
|
Widget build(BuildContext context) { |
|
|
final isDarkMode = Theme.of(context).brightness == Brightness.dark; |
|
|
final isDarkMode = Theme.of(context).brightness == Brightness.dark; |
|
|
|
|
|
|
|
|
return Scaffold( |
|
|
return WillPopScope( |
|
|
backgroundColor: isDarkMode ? Colors.black : Colors.grey[100], |
|
|
onWillPop: () async { |
|
|
appBar: AppBar( |
|
|
if (controller.isUpgrade.value) { |
|
|
automaticallyImplyLeading: false, |
|
|
// 显示确认弹窗 |
|
|
centerTitle: true, |
|
|
await Get.dialog( |
|
|
elevation: 0, |
|
|
AlertDialog( |
|
|
backgroundColor: isDarkMode ? Colors.black : Colors.white, |
|
|
title: Text('提示'), |
|
|
leading: IconButton( |
|
|
content: Text('当前正在升级,退出将中断升级进程,确定要退出吗?'), |
|
|
icon: Icon( |
|
|
actions: [ |
|
|
Icons.arrow_back_ios, |
|
|
TextButton( |
|
|
size: 20.sp, |
|
|
onPressed: () => Get.back(), // 关闭弹窗 |
|
|
color: isDarkMode ? Colors.white : Colors.black, |
|
|
child: Text('取消'), |
|
|
|
|
|
), |
|
|
|
|
|
TextButton( |
|
|
|
|
|
onPressed: () { |
|
|
|
|
|
controller.stopUpgrading(); |
|
|
|
|
|
Get.back(); // 关闭弹窗 |
|
|
|
|
|
Get.back(); // 返回上一页 |
|
|
|
|
|
}, |
|
|
|
|
|
child: Text('确定'), |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
); |
|
|
|
|
|
return false; // 阻止默认返回 |
|
|
|
|
|
} |
|
|
|
|
|
return true; // 允许返回 |
|
|
|
|
|
}, |
|
|
|
|
|
child: Scaffold( |
|
|
|
|
|
backgroundColor: isDarkMode ? Colors.black : Colors.grey[100], |
|
|
|
|
|
appBar: AppBar( |
|
|
|
|
|
automaticallyImplyLeading: false, |
|
|
|
|
|
centerTitle: true, |
|
|
|
|
|
elevation: 0, |
|
|
|
|
|
backgroundColor: isDarkMode ? Colors.black : Colors.white, |
|
|
|
|
|
leading: IconButton( |
|
|
|
|
|
icon: Icon( |
|
|
|
|
|
Icons.arrow_back_ios, |
|
|
|
|
|
size: 20.sp, |
|
|
|
|
|
color: isDarkMode ? Colors.white : Colors.black, |
|
|
|
|
|
), |
|
|
|
|
|
onPressed: () { |
|
|
|
|
|
if (controller.isUpgrade.value) { |
|
|
|
|
|
// 显示确认弹窗 |
|
|
|
|
|
Get.dialog( |
|
|
|
|
|
AlertDialog( |
|
|
|
|
|
title: Text('提示'), |
|
|
|
|
|
content: Text('当前正在升级,退出将中断升级进程,确定要退出吗?'), |
|
|
|
|
|
actions: [ |
|
|
|
|
|
TextButton( |
|
|
|
|
|
onPressed: () => Get.back(), // 关闭弹窗 |
|
|
|
|
|
child: Text('取消'), |
|
|
|
|
|
), |
|
|
|
|
|
TextButton( |
|
|
|
|
|
onPressed: () { |
|
|
|
|
|
controller.stopUpgrading(); |
|
|
|
|
|
Get.back(); // 关闭弹窗 |
|
|
|
|
|
Get.back(); // 返回上一页 |
|
|
|
|
|
}, |
|
|
|
|
|
child: Text('确定'), |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
); |
|
|
|
|
|
} else { |
|
|
|
|
|
Get.back(); // 正常返回 |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
), |
|
|
), |
|
|
onPressed: () => Get.back(), |
|
|
title: Text( |
|
|
), |
|
|
'固件升级'.tr, |
|
|
title: Text( |
|
|
style: TextStyle( |
|
|
'固件升级'.tr, |
|
|
fontSize: 20.sp, |
|
|
style: TextStyle( |
|
|
color: isDarkMode ? Colors.white : Colors.black, |
|
|
fontSize: 20.sp, |
|
|
), |
|
|
color: isDarkMode ? Colors.white : Colors.black, |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
body: SingleChildScrollView( |
|
|
body: SingleChildScrollView( |
|
|
child: Padding( |
|
|
child: Padding( |
|
|
padding: EdgeInsets.all(20), |
|
|
padding: EdgeInsets.all(20), |
|
|
child: Column( |
|
|
child: Column( |
|
|
mainAxisSize: MainAxisSize.min, |
|
|
mainAxisSize: MainAxisSize.min, |
|
|
children: [ |
|
|
children: [ |
|
|
// 设备信息卡片 |
|
|
// 设备信息卡片 |
|
|
Card( |
|
|
Card( |
|
|
elevation: 2, |
|
|
elevation: 2, |
|
|
shape: RoundedRectangleBorder( |
|
|
shape: RoundedRectangleBorder( |
|
|
borderRadius: BorderRadius.circular(16), |
|
|
borderRadius: BorderRadius.circular(16), |
|
|
), |
|
|
), |
|
|
color: isDarkMode ? Colors.grey[900] : Colors.white, |
|
|
color: isDarkMode ? Colors.grey[900] : Colors.white, |
|
|
child: Padding( |
|
|
child: Padding( |
|
|
padding: EdgeInsets.all(20), |
|
|
padding: EdgeInsets.all(20), |
|
|
child: Column( |
|
|
child: Column( |
|
|
children: [ |
|
|
children: [ |
|
|
_buildDeviceIcon(isDarkMode), |
|
|
_buildDeviceIcon(isDarkMode), |
|
|
SizedBox(height: 20), |
|
|
SizedBox(height: 20), |
|
|
_buildVersionInfo(isDarkMode), |
|
|
_buildVersionInfo(isDarkMode), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
SizedBox(height: 20), |
|
|
SizedBox(height: 20), |
|
|
|
|
|
|
|
|
|
|
|
// 更新说明 |
|
|
// 更新说明 |
|
|
_buildUpdateNotes(isDarkMode), |
|
|
_buildUpdateNotes(isDarkMode), |
|
|
SizedBox(height: 20), |
|
|
SizedBox(height: 20), |
|
|
|
|
|
|
|
|
// 状态显示区域 |
|
|
// 状态显示区域 |
|
|
Obx(() { |
|
|
Obx(() { |
|
|
if (controller.isFetchingDeviceInfo.value) { |
|
|
if (controller.isFetchingDeviceInfo.value) { |
|
|
return _buildLoadingIndicator(isDarkMode); |
|
|
return _buildLoadingIndicator(isDarkMode); |
|
|
} |
|
|
} |
|
|
if (controller.errorMessage.value.isNotEmpty) { |
|
|
if (controller.errorMessage.value.isNotEmpty) { |
|
|
return _buildErrorInfo(isDarkMode); |
|
|
return _buildErrorInfo(isDarkMode); |
|
|
} |
|
|
} |
|
|
return _buildUpdateButton(isDarkMode); |
|
|
return _buildUpdateButton(isDarkMode); |
|
|
}), |
|
|
}), |
|
|
], |
|
|
], |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
@ -227,7 +282,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> { |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
Widget _buildUpdateButton(bool isDarkMode) { |
|
|
Widget _buildUpdateButton(bool isDarkMode) { |
|
|
return controller.jlota.isUpgrade.value |
|
|
return controller.isUpgrade.value |
|
|
? _buildProgressIndicator(isDarkMode) |
|
|
? _buildProgressIndicator(isDarkMode) |
|
|
: Container( |
|
|
: Container( |
|
|
width: double.infinity, |
|
|
width: double.infinity, |
|
|
@ -276,8 +331,8 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> { |
|
|
|
|
|
|
|
|
Widget _buildProgressIndicator(bool isDarkMode) { |
|
|
Widget _buildProgressIndicator(bool isDarkMode) { |
|
|
return Obx(() { |
|
|
return Obx(() { |
|
|
final progress = controller.jlota.progress.value; |
|
|
final progress = controller.progress.value; |
|
|
final type = controller.jlota.type.value; |
|
|
final type = controller.type.value; |
|
|
|
|
|
|
|
|
// // 处理升级失败状态:弹出 snackbar 并显示错误提示 |
|
|
// // 处理升级失败状态:弹出 snackbar 并显示错误提示 |
|
|
// if (type == OtaUpgradeController.UPGRADE_FAILED || |
|
|
// if (type == OtaUpgradeController.UPGRADE_FAILED || |
|
|
|