2024-08-21 14:12:15 +08:00
|
|
|
|
|
2023-07-10 17:50:31 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import '../../../../app_settings/app_colors.dart';
|
|
|
|
|
|
import '../../../../tools/submitBtn.dart';
|
|
|
|
|
|
import '../../../../tools/titleAppBar.dart';
|
2023-09-07 18:36:16 +08:00
|
|
|
|
import 'lockEscalation_logic.dart';
|
2023-07-10 17:50:31 +08:00
|
|
|
|
|
|
|
|
|
|
class LockEscalationPage extends StatefulWidget {
|
2023-07-15 15:11:28 +08:00
|
|
|
|
const LockEscalationPage({Key? key}) : super(key: key);
|
2023-07-10 17:50:31 +08:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
State<LockEscalationPage> createState() => _LockEscalationPageState();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _LockEscalationPageState extends State<LockEscalationPage> {
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
2024-04-24 16:04:07 +08:00
|
|
|
|
return GetBuilder<LockEscalationLogic>(
|
|
|
|
|
|
init: LockEscalationLogic(),
|
|
|
|
|
|
builder: (LockEscalationLogic logic) {
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
|
appBar: TitleAppBar(
|
2024-07-31 17:24:30 +08:00
|
|
|
|
barTitle: '锁升级'.tr,
|
2024-04-24 16:04:07 +08:00
|
|
|
|
haveBack: true,
|
|
|
|
|
|
backgroundColor: AppColors.mainColor,
|
|
|
|
|
|
backAction: logic.getBack,
|
2023-07-10 17:50:31 +08:00
|
|
|
|
),
|
2024-04-24 16:04:07 +08:00
|
|
|
|
body: Container(
|
|
|
|
|
|
padding: EdgeInsets.all(30.w),
|
2024-05-13 14:08:21 +08:00
|
|
|
|
child: Obx(() {
|
|
|
|
|
|
return updateView(logic);
|
|
|
|
|
|
}),
|
2024-04-24 16:04:07 +08:00
|
|
|
|
));
|
|
|
|
|
|
});
|
2023-07-10 17:50:31 +08:00
|
|
|
|
}
|
2024-05-13 14:08:21 +08:00
|
|
|
|
|
|
|
|
|
|
Widget updateView(LockEscalationLogic logic) {
|
2024-06-12 18:13:13 +08:00
|
|
|
|
if (logic.state.loading.value) {
|
|
|
|
|
|
return Padding(
|
|
|
|
|
|
padding: EdgeInsets.only(top: 60.h),
|
|
|
|
|
|
child: Align(
|
|
|
|
|
|
alignment: Alignment.topCenter,
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'加载数据中'.tr,
|
|
|
|
|
|
style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 40.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
CircularProgressIndicator(
|
|
|
|
|
|
color: AppColors.mainColor,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2024-05-13 14:08:21 +08:00
|
|
|
|
if (logic.state.otaUpdateIng.value) {
|
|
|
|
|
|
return otaUpdate(logic);
|
|
|
|
|
|
}
|
2024-06-12 18:13:13 +08:00
|
|
|
|
if (logic.model == '') {
|
|
|
|
|
|
return Padding(
|
|
|
|
|
|
padding: EdgeInsets.only(top: 60.h),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'加载数据失败'.tr,
|
|
|
|
|
|
style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 40.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
SubmitBtn(
|
|
|
|
|
|
btnName: '重试'.tr,
|
|
|
|
|
|
onClick: () {
|
|
|
|
|
|
logic.getStarLockStatus();
|
|
|
|
|
|
}),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2024-05-13 14:08:21 +08:00
|
|
|
|
return defaultUpdate(logic);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//升级
|
|
|
|
|
|
Widget defaultUpdate(LockEscalationLogic logic) {
|
|
|
|
|
|
return Column(
|
2024-06-12 18:13:13 +08:00
|
|
|
|
children: <Widget>[
|
2024-05-13 14:08:21 +08:00
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 60.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
2024-06-12 18:13:13 +08:00
|
|
|
|
children: <Widget>[
|
2024-05-13 14:08:21 +08:00
|
|
|
|
Image.asset(
|
|
|
|
|
|
'images/main/icon_main_lockSet_lockEscalation.png',
|
|
|
|
|
|
width: 36.w,
|
|
|
|
|
|
height: 36.w,
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
width: 10.w,
|
|
|
|
|
|
),
|
2024-05-31 14:28:52 +08:00
|
|
|
|
Obx(() {
|
|
|
|
|
|
if (logic.state.isShowUpDataBtn.value) {
|
|
|
|
|
|
return Text(
|
2024-07-31 17:24:30 +08:00
|
|
|
|
'有新版本'.tr +
|
2024-06-12 18:13:13 +08:00
|
|
|
|
logic.state.showNewVersion.value,
|
2024-05-31 14:28:52 +08:00
|
|
|
|
style:
|
|
|
|
|
|
TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600),
|
|
|
|
|
|
);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return Text(
|
|
|
|
|
|
'已是最新版本'.tr,
|
|
|
|
|
|
style:
|
|
|
|
|
|
TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2024-05-13 14:08:21 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 30.h,
|
|
|
|
|
|
),
|
2024-05-31 14:28:52 +08:00
|
|
|
|
Obx(() {
|
|
|
|
|
|
return Text(
|
2024-07-31 17:24:30 +08:00
|
|
|
|
'${'当前版本'.tr}:${logic.state.showVersion.value}',
|
2024-05-31 14:28:52 +08:00
|
|
|
|
style:
|
|
|
|
|
|
TextStyle(fontSize: 18.sp, color: AppColors.darkGrayTextColor),
|
|
|
|
|
|
);
|
|
|
|
|
|
}),
|
2024-05-13 14:08:21 +08:00
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 40.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
Obx(() {
|
2024-05-31 14:28:52 +08:00
|
|
|
|
final bool show = !logic.state.otaUpdateIng.value &&
|
|
|
|
|
|
logic.state.isShowUpDataBtn.value;
|
|
|
|
|
|
return show
|
2024-05-13 14:08:21 +08:00
|
|
|
|
? SubmitBtn(
|
2024-07-31 17:24:30 +08:00
|
|
|
|
btnName: '升级'.tr,
|
2024-05-31 14:28:52 +08:00
|
|
|
|
onClick: () {
|
|
|
|
|
|
logic.downloadTheFile();
|
|
|
|
|
|
})
|
|
|
|
|
|
: const SizedBox();
|
2024-05-13 14:08:21 +08:00
|
|
|
|
}),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 10.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
Align(
|
|
|
|
|
|
alignment: Alignment.topRight,
|
|
|
|
|
|
child: GestureDetector(
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
logic.otaUpdate();
|
|
|
|
|
|
},
|
|
|
|
|
|
child: Padding(
|
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
'手动升级'.tr,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: AppColors.mainColor,
|
|
|
|
|
|
fontSize: 18.sp,
|
|
|
|
|
|
fontWeight: FontWeight.w400),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//ota升级
|
|
|
|
|
|
Widget otaUpdate(LockEscalationLogic logic) {
|
|
|
|
|
|
return Column(
|
2024-06-12 18:13:13 +08:00
|
|
|
|
children: <Widget>[
|
2024-05-13 14:08:21 +08:00
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 20.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
Text(
|
2024-07-08 18:25:06 +08:00
|
|
|
|
'${'机型'.tr}:${logic.headJson?['platform']}',
|
2024-05-13 14:08:21 +08:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: AppColors.blackColor,
|
|
|
|
|
|
fontSize: 22.sp,
|
|
|
|
|
|
fontWeight: FontWeight.w600),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 10.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'${'固件版本'.tr}:${logic.headJson?['fwVersion']}',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: AppColors.blackColor,
|
|
|
|
|
|
fontSize: 22.sp,
|
|
|
|
|
|
fontWeight: FontWeight.w600),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 20.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'传输期间请勿离开当前页面'.tr,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: AppColors.blackColor,
|
|
|
|
|
|
fontSize: 20.sp,
|
|
|
|
|
|
fontWeight: FontWeight.w400),
|
|
|
|
|
|
),
|
|
|
|
|
|
Padding(
|
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 50.w, vertical: 15.h),
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
2024-06-12 18:13:13 +08:00
|
|
|
|
children: <Widget>[
|
2024-05-13 14:08:21 +08:00
|
|
|
|
Text(
|
2024-08-21 14:12:15 +08:00
|
|
|
|
'固件传输中'.tr,
|
2024-05-13 14:08:21 +08:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: AppColors.mainColor,
|
|
|
|
|
|
fontSize: 18.sp,
|
|
|
|
|
|
fontWeight: FontWeight.w400),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
width: 10.w,
|
|
|
|
|
|
),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: ClipRRect(
|
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10.r)),
|
|
|
|
|
|
child: LinearProgressIndicator(
|
|
|
|
|
|
value: logic.state.otaProgress.value, // 50% 进度
|
|
|
|
|
|
backgroundColor: Colors.grey[200],
|
|
|
|
|
|
valueColor:
|
|
|
|
|
|
AlwaysStoppedAnimation<Color>(AppColors.mainColor),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
|
}
|