添加版本更新UI跟接口

This commit is contained in:
魏少阳 2024-03-12 17:14:12 +08:00
parent ce9621d6bd
commit fdc8a93fac
11 changed files with 212 additions and 47 deletions

View File

@ -127,28 +127,6 @@ void openBlueScan() {
}
}
//
void getVersionData() async {
// var entity = await ApiRepository.to.deletOwnerLockData(
// lockId: state.lockSetInfoData.value.lockId.toString(),
// );
// if (entity.errorCode!.codeIsSuccessful) {
// BlueManage().connectDeviceMacAddress = "";
// SchedulerBinding.instance.addPostFrameCallback((_) {
// eventBus.fire(RefreshLockListInfoDataEvent());
// });
// if(state.isOnlyOneData.value == true){
// Future.delayed(const Duration(milliseconds: 200)).then((e) {
// Get.close(1);
// });
// }else{
// Future.delayed(const Duration(milliseconds: 200)).then((e) {
// Get.close(2);
// });
// }
// }
}
///
Future<bool> getMicrophonePermission() async {
// You can request multiple permissions at once.

View File

@ -865,4 +865,5 @@ class LockDetailLogic extends BaseGetXController {
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent!.cancel();
// _scanListDiscoveredDeviceSubscription.cancel();
}
}

View File

@ -59,7 +59,7 @@ class _UploadElectricQuantityPageState extends State<UploadElectricQuantityPage>
)),
],
)),
Obx(() => Row(
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
@ -68,7 +68,7 @@ class _UploadElectricQuantityPageState extends State<UploadElectricQuantityPage>
style: TextStyle(fontSize: 20.sp),
)),
],
)),
),
SizedBox(height: 10.h),
Obx(() => Row(
mainAxisAlignment: MainAxisAlignment.start,

View File

@ -38,11 +38,11 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
final state = Get.find<LockMainLogic>().state;
Future<void> getHttpData() async {
await logic.getStarLockInfo();
setState(() {});
// logic.getStarLockInfo().then((LockListInfoEntity value) {
// setState(() {});
// });
// await logic.getStarLockInfo();
// setState(() {});
logic.getStarLockInfo().then((LockListInfoEntity value) {
setState(() {});
});
}
@override

View File

@ -1544,10 +1544,11 @@ class ApiProvider extends BaseProvider {
}));
//
Future<Response> getVersionData(String messageId) => post(
Future<Response> getVersionData(String brandName, String currentVersion) => post(
getVersionURL.toUrl,
jsonEncode({
'id': messageId,
'brandName': brandName,
'currentVersion': currentVersion,
}));
}

View File

@ -48,6 +48,7 @@ import '../mine/minePersonInfo/minePersonInfoPage/minePersonGetUploadFileInfo_en
import '../mine/mineSet/transferGateway/selectGetewayList_entity.dart';
import '../mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_entity.dart';
import '../mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_entity.dart';
import '../versionUndate/versionUndate_entity.dart';
import 'api_provider.dart';
class ApiRepository {
@ -1556,4 +1557,13 @@ class ApiRepository {
final res = await apiProvider.deletMessageLoadData(messageId);
return MessageListEntity.fromJson(res.body);
}
//
Future<VersionUndateEntity> getVersionData({
required String brandName,
required String currentVersion
}) async {
final res = await apiProvider.getVersionData(brandName, currentVersion);
return VersionUndateEntity.fromJson(res.body);
}
}

View File

@ -1,16 +0,0 @@
import 'package:flutter/material.dart';
class VersionUndateWidget extends StatefulWidget {
const VersionUndateWidget({Key? key}) : super(key: key);
@override
State<VersionUndateWidget> createState() => _VersionUndateWidgetState();
}
class _VersionUndateWidgetState extends State<VersionUndateWidget> {
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}

View File

@ -0,0 +1,56 @@
class VersionUndateEntity {
int? errorCode;
String? description;
String? errorMsg;
Data? data;
VersionUndateEntity(
{this.errorCode, this.description, this.errorMsg, this.data});
VersionUndateEntity.fromJson(Map<String, dynamic> json) {
errorCode = json['errorCode'];
description = json['description'];
errorMsg = json['errorMsg'];
data = json['data'] != null ? Data.fromJson(json['data']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['errorCode'] = errorCode;
data['description'] = description;
data['errorMsg'] = errorMsg;
if (this.data != null) {
data['data'] = this.data!.toJson();
}
return data;
}
}
class Data {
int? isUpdate;
String? appDownloadUrl;
String? description;
int? isForceUpdate;
Data(
{this.isUpdate,
this.appDownloadUrl,
this.description,
this.isForceUpdate});
Data.fromJson(Map<String, dynamic> json) {
isUpdate = json['isUpdate'];
appDownloadUrl = json['appDownloadUrl'];
description = json['description'];
isForceUpdate = json['isForceUpdate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['isUpdate'] = isUpdate;
data['appDownloadUrl'] = appDownloadUrl;
data['description'] = description;
data['isForceUpdate'] = isForceUpdate;
return data;
}
}

View File

@ -0,0 +1,88 @@
import 'package:device_info_plus/device_info_plus.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import '../network/api_repository.dart';
import 'versionUndate_state.dart';
class VersionUndateLogic extends BaseGetXController{
VersionUndateState state = VersionUndateState();
//
void getVersionData() async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
// print('androidInfo.manufacturer:${androidInfo.manufacturer}'
// 'androidInfo.device:${androidInfo.device}'
// 'androidInfo.model:${androidInfo.model}'
// 'androidInfo.product:${androidInfo.product}'
// 'androidInfo.version.release:${androidInfo.version.release}'
// 'androidInfo.version.sdkInt:${androidInfo.version.sdkInt}'
// 'androidInfo.version.securityPatch:${androidInfo.version.securityPatch}'
// 'androidInfo.version.incremental:${androidInfo.version.incremental}'
// 'androidInfo.version.codename:${androidInfo.version.codename}'
// 'androidInfo.version.baseOS:${androidInfo.version.baseOS}'
// 'androidInfo.board:${androidInfo.board}'
// 'androidInfo.bootloader:${androidInfo.bootloader}');
PackageInfo packageInfo = await PackageInfo.fromPlatform();
var version = packageInfo.version;
var entity = await ApiRepository.to.getVersionData(
brandName: androidInfo.manufacturer,
currentVersion: version,
);
if (entity.errorCode!.codeIsSuccessful) {
state.versionUndateEntity.value = entity;
}
}
void showUpdateAlertDialog() {
// showCupertinoDialog(
// context: Get.context!,
// builder: (context) {
// return CupertinoAlertDialog(
// content: const Text('重置后,该锁的指纹都将被删除哦,确认要重置吗?'),
// actions: [
// CupertinoDialogAction(
// child: Text(TranslationLoader.lanKeys!.cancel!.tr),
// onPressed: () {
// Navigator.pop(context);
// },
// ),
// CupertinoDialogAction(
// child: Text(TranslationLoader.lanKeys!.sure!.tr),
// onPressed: () {
//
// },
// ),
// ],
// );
// },
// );
}
@override
void onReady() {
// TODO: implement onReady
super.onReady();
getVersionData();
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
@override
void onClose() {
// TODO: implement onClose
}
}

View File

@ -0,0 +1,38 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/versionUndate/versionUndate_logic.dart';
class VersionUndatePage extends StatefulWidget {
const VersionUndatePage({Key? key}) : super(key: key);
@override
State<VersionUndatePage> createState() => _VersionUndatePageState();
}
class _VersionUndatePageState extends State<VersionUndatePage> {
final logic = Get.put(VersionUndateLogic());
final state = Get.find<VersionUndateLogic>().state;
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: [
Container(
// color: AppColors.mainColor,
alignment: Alignment.topCenter,
height: 50.h,
child: Text('版本更新', style: TextStyle(fontSize: 28.sp, color: Colors.blue),)
),
Container(
padding: EdgeInsets.only(left:20.w, right: 20.w, top: 10.h),
alignment: Alignment.centerLeft,
child: Text('1、修复了一些bug \n2、优化了部分问题 \n3、修补了设置模块bug \n4、优化了部分问题 \n5、修补了设置模块bug', textAlign:TextAlign.start, style: TextStyle(fontSize: 20.sp))
),
],
),
);
}
}

View File

@ -0,0 +1,9 @@
import 'package:get/get.dart';
import 'versionUndate_entity.dart';
class VersionUndateState{
final versionUndateEntity = VersionUndateEntity().obs;
}