243 lines
6.8 KiB
Dart
Raw Normal View History

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) {
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,
haveBack: true,
backgroundColor: AppColors.mainColor,
backAction: logic.getBack,
2023-07-10 17:50:31 +08:00
),
body: Container(
padding: EdgeInsets.all(30.w),
child: Obx(() {
return updateView(logic);
}),
));
});
2023-07-10 17:50:31 +08:00
}
Widget updateView(LockEscalationLogic logic) {
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,
),
],
),
),
);
}
if (logic.state.otaUpdateIng.value) {
return otaUpdate(logic);
}
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();
}),
],
),
);
}
return defaultUpdate(logic);
}
//升级
Widget defaultUpdate(LockEscalationLogic logic) {
return Column(
children: <Widget>[
SizedBox(
height: 60.h,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
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 +
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),
);
}
})
],
),
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),
);
}),
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
? SubmitBtn(
2024-07-31 17:24:30 +08:00
btnName: '升级'.tr,
2024-05-31 14:28:52 +08:00
onClick: () {
logic.downloadTheFile();
})
: const SizedBox();
}),
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(
children: <Widget>[
SizedBox(
height: 20.h,
),
Text(
'${'机型'.tr}${logic.headJson?['platform']}',
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,
children: <Widget>[
Text(
'固件传输中'.tr,
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
}