2024-05-31 14:28:52 +08:00

210 lines
6.1 KiB
Dart
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/tools/commonDataManage.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/submitBtn.dart';
import '../../../../tools/titleAppBar.dart';
import '../../../../translations/trans_lib.dart';
import 'lockEscalation_logic.dart';
class LockEscalationPage extends StatefulWidget {
const LockEscalationPage({Key? key}) : super(key: key);
@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(
barTitle: TranslationLoader.lanKeys!.lockEscalation!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor,
backAction: logic.getBack,
),
body: Container(
padding: EdgeInsets.all(30.w),
child: Obx(() {
return updateView(logic);
}),
));
});
}
Widget updateView(LockEscalationLogic logic) {
if (logic.state.otaUpdateIng.value) {
return otaUpdate(logic);
}
return defaultUpdate(logic);
}
//升级
Widget defaultUpdate(LockEscalationLogic logic) {
return Column(
children: [
SizedBox(
height: 60.h,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'images/main/icon_main_lockSet_lockEscalation.png',
width: 36.w,
height: 36.w,
),
SizedBox(
width: 10.w,
),
Obx(() {
if (logic.state.isShowUpDataBtn.value) {
return Text(
TranslationLoader.lanKeys!.haveNewVersion!.tr + logic.state.showNewVersion.value,
style:
TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600),
);
} else {
return Text(
'已是最新版本'.tr,
style:
TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600),
);
}
})
],
),
SizedBox(
height: 30.h,
),
Obx(() {
return Text(
'${TranslationLoader.lanKeys!.currentVersion!.tr}${logic.state.showVersion.value}',
style:
TextStyle(fontSize: 18.sp, color: AppColors.darkGrayTextColor),
);
}),
SizedBox(
height: 40.h,
),
Obx(() {
final bool show = !logic.state.otaUpdateIng.value &&
logic.state.isShowUpDataBtn.value;
return show
? SubmitBtn(
btnName: TranslationLoader.lanKeys!.upgrade!.tr,
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: [
SizedBox(
height: 20.h,
),
Text(
'${'机型'.tr}${logic.headJson?['platform']}-${logic.headJson?['product']}',
style: TextStyle(
color: AppColors.blackColor,
fontSize: 22.sp,
fontWeight: FontWeight.w600),
),
SizedBox(
height: 10.h,
),
Text(
'${'硬件版本'.tr}${logic.headJson?['hwVersion']}',
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: [
Text(
'固件传输中',
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),
),
),
),
],
),
),
],
);
}
}