From d884436dcf1096ea4ff359f40040efb0b9a89fef Mon Sep 17 00:00:00 2001 From: 18631081161 <2088094923@qq.com> Date: Thu, 25 Sep 2025 22:29:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/images/ic_update.png | Bin 0 -> 8048 bytes lib/bean/update_bean.dart | 18 +++ lib/bean/update_bean.g.dart | 24 +++ lib/dialog/add_note_dialog.dart | 4 +- lib/dialog/modify_info_dialog.dart | 226 ++++++++++++----------------- lib/dialog/update_dialog.dart | 81 +++++++++++ lib/network/NetworkConfig.dart | 2 + lib/tools/home/home_model.dart | 19 ++- lib/tools/home/home_page.dart | 44 +++++- pubspec.yaml | 2 + 10 files changed, 279 insertions(+), 141 deletions(-) create mode 100644 assets/images/ic_update.png create mode 100644 lib/bean/update_bean.dart create mode 100644 lib/bean/update_bean.g.dart create mode 100644 lib/dialog/update_dialog.dart diff --git a/assets/images/ic_update.png b/assets/images/ic_update.png new file mode 100644 index 0000000000000000000000000000000000000000..f6479fc20e5512ec7be7354f91d319547179427c GIT binary patch literal 8048 zcmY*ec_38Z`@S)w0LyPWf$_nvd!=ZQ2j&|;$Jp$7nfNk^M-0{|e@R|o*3qdx9< z7TE&;0?;8`HTH$9T3UKe%c5M3di`EqA;-OaWjxO&nuXiT&r&y6X`hVuF~Bae6-V8e z|3>p{a=$9F;|z1b!Oy+~LI@bia_)h>c5d*=;Bg+rT|QJ23Be|aL2)GK`s^rH2oeR9 zkzlql030(r@Mih3Ah4zb;DgT~yV)Qpd?CMKRV0AGKmgja1k6oP8%Xm}9v$Ef*7QT+ zLqMxYd>AYNkY4pF(F1v?y-XyLaSqx$J!7#q-zq7&h3Kr)*{OQmUgJq^|BweQvIgr}UzHAwucapcnZp>i7k(4+VBV2RNNZ+EMFR@jRJ-5I$%w!KrE zZ#BM|&B2eAKEQrDg7#^H=W}n=5uip;PbVkoiCni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VCdl|+0>h(;nPoXn@!d~0u*cl#n0n{vF<|^(uKQ2w-w}@ zol%D@vZl3;A61%~d_RcAtjga(3!-1qO)M5JUA$|r0lYzUWR|GBQ_W}HJTX3zDsPc* zk40Qxp4K}!+!Qix{QjM(rX65y4x*+~&N?vxuDdVZjaf3lmb^0DtfF&b@k(OBM z`CbPwfID=IoBoLke-qWYz0B7_L7MxnWA6%Zwqp{Xd#_xHXVw3PEq?LQ97T@!KC6TI z`Uu-_Q_*49%EG%m{lVymveTb8^=toqxR@1$e!i5W0}KiLD9iO);c(zg_KCLr6FH!& zFP8)ek+X0W42PMSK{fN+rvzwf5sMD=@}}1bPk8Z35>Tl2V>CkvK6sFY)H~9GrhcOF zJO@!cZ4av{&IT(W_j+GWYZKoMs20Swmt=qlhHu%P4+S8KL56J+nOPu$o1*gTr2*9I zL}g6U;4X?RFaPLW0TmX1`8bDUsk+77Jm4c~s)-_-Yda^0z;rfnzv6M0qZ1K)nJx-o=YYfe8M4S@a86soz;Y&KlCgiOQuRPS-NP zrK1*piX&Ae-L2bH^RIMa40hJh^EC>FPy||a%=i8+tk>kV?1PWhr zC4cap5!I-um)b9^HW2y9$Zbk{7c29X%h>F0WNHoDg z1dJJ#4E}#jj|CGd_i&_4znnUUc&ZIQRt%sZNOfAfU+lL>HUB{_xB=2_`R|kl08UT4 jRBc(QygA)}MKTSb{$;C5{(a;TwFS`8Fd)2BBR>5<4iI{B literal 0 HcmV?d00001 diff --git a/lib/bean/update_bean.dart b/lib/bean/update_bean.dart new file mode 100644 index 0000000..1851547 --- /dev/null +++ b/lib/bean/update_bean.dart @@ -0,0 +1,18 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'update_bean.g.dart'; + +@JsonSerializable(explicitToJson: true) +class UpdateBean { + bool? needUpdate; + bool? forceUpdate; + String? latestVersion; + String? downloadUrl; + String? updateDescription; + + UpdateBean(this.needUpdate, this.forceUpdate, this.latestVersion, this.downloadUrl, this.updateDescription); + + factory UpdateBean.fromJson(Map json) => _$UpdateBeanFromJson(json); + + Map toJson() => _$UpdateBeanToJson(this); +} diff --git a/lib/bean/update_bean.g.dart b/lib/bean/update_bean.g.dart new file mode 100644 index 0000000..153a739 --- /dev/null +++ b/lib/bean/update_bean.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'update_bean.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +UpdateBean _$UpdateBeanFromJson(Map json) => UpdateBean( + json['needUpdate'] as bool?, + json['forceUpdate'] as bool?, + json['latestVersion'] as String?, + json['downloadUrl'] as String?, + json['updateDescription'] as String?, + ); + +Map _$UpdateBeanToJson(UpdateBean instance) => + { + 'needUpdate': instance.needUpdate, + 'forceUpdate': instance.forceUpdate, + 'latestVersion': instance.latestVersion, + 'downloadUrl': instance.downloadUrl, + 'updateDescription': instance.updateDescription, + }; diff --git a/lib/dialog/add_note_dialog.dart b/lib/dialog/add_note_dialog.dart index 4ec8cef..04e348b 100644 --- a/lib/dialog/add_note_dialog.dart +++ b/lib/dialog/add_note_dialog.dart @@ -4,9 +4,9 @@ import 'package:flutter_easyloading/flutter_easyloading.dart'; import '../network/NetworkConfig.dart'; class AddNoteDialog extends StatefulWidget { - Function onTap; + final Function onTap; - AddNoteDialog({ + const AddNoteDialog({ super.key, required this.onTap, }); diff --git a/lib/dialog/modify_info_dialog.dart b/lib/dialog/modify_info_dialog.dart index a5d2b6f..3def8c9 100644 --- a/lib/dialog/modify_info_dialog.dart +++ b/lib/dialog/modify_info_dialog.dart @@ -12,10 +12,10 @@ import '../common/func.dart'; import 'add_note_dialog.dart'; class ModifyInfoDialog extends StatefulWidget { - Function onTap; - String id; + final Function onTap; + final String id; - ModifyInfoDialog({super.key, required this.onTap, required this.id}); + const ModifyInfoDialog({super.key, required this.onTap, required this.id}); @override State createState() => _ModifyInfoDialogState(); @@ -42,17 +42,12 @@ class _ModifyInfoDialogState extends State { bool isConnect = false; bool isLoad = false; - String businessName = ""; - String deviceModel = ""; - String businessType = ""; - String portNumber = ""; - // 用列表存储所有输入框的值,通过索引区分不同输入框 late List _controllers; final List _items = []; - // 添加新视图 + /// 添加新视图 void _addItem() { setState(() { _items.add(HistoryFaultBean("", "")); @@ -60,7 +55,7 @@ class _ModifyInfoDialogState extends State { }); } - // 移除指定视图 + /// 移除指定视图 void _removeItem(int index) { setState(() { _items.removeAt(index); @@ -86,7 +81,6 @@ class _ModifyInfoDialogState extends State { // TODO: implement initState super.initState(); - subscription = _viewmodel.streamController.stream.listen((event) { String code = event['code']; if (code.isNotEmpty) { @@ -150,7 +144,7 @@ class _ModifyInfoDialogState extends State { Future saveData() async { ///获取历史故障原因所有值. for (int i = 0; i < _controllers.length; i++) { - print('输入框的值: ${_controllers[i].text}'); + // print('输入框的值: ${_controllers[i].text}'); _items[i].faultReason = _controllers[i].text; } @@ -184,7 +178,6 @@ class _ModifyInfoDialogState extends State { scrollDirection: Axis.vertical, child: Container( width: 307, - // height: 500, color: Colors.white, padding: EdgeInsets.only(left: 5, right: 5, top: 5, bottom: bottomInset), child: isLoad @@ -192,7 +185,7 @@ class _ModifyInfoDialogState extends State { mainAxisSize: MainAxisSize.min, children: [ Container( - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10), + margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), child: Row( // crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -202,7 +195,7 @@ class _ModifyInfoDialogState extends State { children: [ Text( "位置:${odfDetailsBean.frameName}${odfDetailsBean.name}", - style: TextStyle(fontSize: 12), + style: const TextStyle(fontSize: 12), ), GestureDetector( onTap: () { @@ -211,14 +204,12 @@ class _ModifyInfoDialogState extends State { context, AddNoteDialog( onTap: (value1, value2, value3, value4) { - print("$value1-$value2-$value3-$value4"); + // print("$value1-$value2-$value3-$value4"); - appendTextWithNewline("$value1 $value2 $value3 $value4"); + // appendTextWithNewline("$value1 $value2 $value3 $value4"); + + _remarksController.text = "$value1 $value2 $value3 $value4"; - businessName = value1; - deviceModel = value2; - businessType = value3; - portNumber = value4; setState(() {}); }, ), @@ -227,14 +218,14 @@ class _ModifyInfoDialogState extends State { }, child: Container( alignment: Alignment.center, - margin: EdgeInsets.only(left: 10), + margin: const EdgeInsets.only(left: 10), width: 60, height: 20, - decoration: BoxDecoration( + decoration: const BoxDecoration( color: Colors.lightBlue, borderRadius: BorderRadius.all(Radius.circular(5)), ), - child: Text( + child: const Text( "添加备注", style: TextStyle(fontSize: 11, color: Colors.white), ), @@ -244,24 +235,22 @@ class _ModifyInfoDialogState extends State { ), Row( children: [ - Text( + const Text( "当前状态:", style: TextStyle(fontSize: 12), ), Container( width: 12, height: 12, - margin: EdgeInsets.only(left: 10, right: 5), + margin: const EdgeInsets.only(left: 10, right: 5), decoration: BoxDecoration( color: odfDetailsBean.status == 0 ? Colors.red : Colors.green, shape: BoxShape.circle, ), ), - Container( - child: Text( - odfDetailsBean.status == 0 ? "已断开" : "已连接", - style: TextStyle(fontSize: 12), - ), + Text( + odfDetailsBean.status == 0 ? "已断开" : "已连接", + style: const TextStyle(fontSize: 12), ) ], ), @@ -270,17 +259,15 @@ class _ModifyInfoDialogState extends State { ), Container( width: double.infinity, - - margin: EdgeInsets.only(left: 10, right: 10), - padding: EdgeInsets.symmetric(horizontal: 5, vertical: 5), - decoration: BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(7))), - + margin: const EdgeInsets.only(left: 10, right: 10), + padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 5), + decoration: const BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(7))), child: TextField( maxLines: 5, - cursorColor: Color(0xFF1A73EC), + cursorColor: const Color(0xFF1A73EC), controller: _remarksController, enabled: NetworkConfig.isPermission, - decoration: InputDecoration( + decoration: const InputDecoration( contentPadding: EdgeInsets.zero, hintText: '请输入备注说明', border: InputBorder.none, @@ -288,60 +275,28 @@ class _ModifyInfoDialogState extends State { focusedBorder: InputBorder.none, hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 12), ), - style: TextStyle(fontSize: 12), + style: const TextStyle(fontSize: 12), ), - // child: Column( - // children: [ - // Container( - // alignment: Alignment.centerLeft, - // child: Text( - // "业务名称:$businessName", - // style: TextStyle(fontSize: 12), - // ), - // ), - // Container( - // alignment: Alignment.centerLeft, - // child: Text( - // "设备型号:$deviceModel", - // style: TextStyle(fontSize: 12), - // ), - // ), - // Container( - // alignment: Alignment.centerLeft, - // child: Text( - // "业务类型:$businessType", - // style: TextStyle(fontSize: 12), - // ), - // ), - // Container( - // alignment: Alignment.centerLeft, - // child: Text( - // "端口号:$portNumber", - // style: TextStyle(fontSize: 12), - // ), - // ), - // ], - // ), ), Container( alignment: Alignment.centerLeft, - margin: EdgeInsets.all(10), - child: Text( + margin: const EdgeInsets.all(10), + child: const Text( "光衰信息", style: TextStyle(fontSize: 12), ), ), Container( - margin: EdgeInsets.only(left: 10, right: 10), - padding: EdgeInsets.symmetric(horizontal: 5), + margin: const EdgeInsets.only(left: 10, right: 10), + padding: const EdgeInsets.symmetric(horizontal: 5), alignment: Alignment.center, height: 35, - decoration: BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(7))), + decoration: const BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(7))), child: TextField( - cursorColor: Color(0xFF1A73EC), + cursorColor: const Color(0xFF1A73EC), controller: _opticalAttenuationController, enabled: NetworkConfig.isPermission, - decoration: InputDecoration( + decoration: const InputDecoration( isDense: true, contentPadding: EdgeInsets.zero, hintText: '请输入光衰信息', @@ -350,14 +305,14 @@ class _ModifyInfoDialogState extends State { focusedBorder: InputBorder.none, hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 12), ), - style: TextStyle(fontSize: 12), + style: const TextStyle(fontSize: 12), ), ), Container( alignment: Alignment.centerLeft, - margin: EdgeInsets.all(10), - child: Text( + margin: const EdgeInsets.all(10), + child: const Text( "历史障碍发生原因及时间", style: TextStyle(fontSize: 12), ), @@ -365,16 +320,18 @@ class _ModifyInfoDialogState extends State { ListView.builder( shrinkWrap: true, itemCount: _items.length, - physics: NeverScrollableScrollPhysics(), + physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { return _item(index, context, _items[index]); }), GestureDetector( onTap: () { - _addItem(); + if (NetworkConfig.isPermission) { + _addItem(); + } }, - child: Text( - "添加新纪录", + child: const Text( + "添加新记录", style: TextStyle(fontSize: 12, color: Colors.lightBlue), ), ), @@ -400,24 +357,24 @@ class _ModifyInfoDialogState extends State { // ), Container( alignment: Alignment.centerLeft, - margin: EdgeInsets.all(10), - child: Text( + margin: const EdgeInsets.all(10), + child: const Text( "光缆段信息", style: TextStyle(fontSize: 12), ), ), Container( - margin: EdgeInsets.only(left: 10, right: 10), - padding: EdgeInsets.symmetric(horizontal: 5), + margin: const EdgeInsets.only(left: 10, right: 10), + padding: const EdgeInsets.symmetric(horizontal: 5), height: 35, alignment: Alignment.center, - decoration: BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(10))), + decoration: const BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(10))), child: TextField( maxLines: 1, - cursorColor: Color(0xFF1A73EC), + cursorColor: const Color(0xFF1A73EC), controller: _opticalCableOffRemarksController, enabled: NetworkConfig.isPermission, - decoration: InputDecoration( + decoration: const InputDecoration( isDense: true, contentPadding: EdgeInsets.zero, hintText: '请输入光缆段信息', @@ -426,14 +383,14 @@ class _ModifyInfoDialogState extends State { focusedBorder: InputBorder.none, hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 12), ), - style: TextStyle(fontSize: 12), + style: const TextStyle(fontSize: 12), ), ), NetworkConfig.isPermission ? Container( alignment: Alignment.centerLeft, - margin: EdgeInsets.all(10), - child: Text( + margin: const EdgeInsets.all(10), + child: const Text( "改变状态", style: TextStyle(fontSize: 12), ), @@ -441,7 +398,7 @@ class _ModifyInfoDialogState extends State { : Container(), NetworkConfig.isPermission ? Container( - margin: EdgeInsets.symmetric(horizontal: 10), + margin: const EdgeInsets.symmetric(horizontal: 10), child: Row( children: [ Expanded( @@ -452,11 +409,11 @@ class _ModifyInfoDialogState extends State { }, child: Container( height: 40, - margin: EdgeInsets.only(right: 5), + margin: const EdgeInsets.only(right: 5), alignment: Alignment.center, decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(7)), - color: isConnect ? Color(0xFF13ED13) : Color(0xFFEBEBEB), + borderRadius: const BorderRadius.all(Radius.circular(7)), + color: isConnect ? const Color(0xFF13ED13) : const Color(0xFFEBEBEB), ), child: Text( "连接", @@ -472,11 +429,11 @@ class _ModifyInfoDialogState extends State { }, child: Container( height: 40, - margin: EdgeInsets.only(left: 5), + margin: const EdgeInsets.only(left: 5), alignment: Alignment.center, decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(7)), - color: !isConnect ? Color(0xFFFF0000) : Color(0xFFEBEBEB), + borderRadius: const BorderRadius.all(Radius.circular(7)), + color: !isConnect ? const Color(0xFFFF0000) : const Color(0xFFEBEBEB), ), child: Text( "断开", @@ -490,8 +447,8 @@ class _ModifyInfoDialogState extends State { : Container(), NetworkConfig.isPermission ? Container( - margin: EdgeInsets.symmetric(vertical: 5), - child: Text( + margin: const EdgeInsets.symmetric(vertical: 5), + child: const Text( "断开后只清空备注说明,其他内容不影响", style: TextStyle(fontSize: 10, color: Color(0xFF999999)), ), @@ -509,12 +466,12 @@ class _ModifyInfoDialogState extends State { child: Container( height: 32, alignment: Alignment.center, - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10), - decoration: BoxDecoration( + margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), + decoration: const BoxDecoration( color: Colors.grey, borderRadius: BorderRadius.all(Radius.circular(6)), ), - child: Text( + child: const Text( "取消", style: TextStyle(fontSize: 14, color: Colors.white), ), @@ -530,12 +487,12 @@ class _ModifyInfoDialogState extends State { child: Container( height: 32, alignment: Alignment.center, - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10), - decoration: BoxDecoration( + margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), + decoration: const BoxDecoration( color: Color(0xFF1A73EC), borderRadius: BorderRadius.all(Radius.circular(6)), ), - child: Text( + child: const Text( "提交", style: TextStyle(fontSize: 14, color: Colors.white), ), @@ -553,12 +510,12 @@ class _ModifyInfoDialogState extends State { child: Container( height: 32, alignment: Alignment.center, - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10), - decoration: BoxDecoration( + margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), + decoration: const BoxDecoration( color: Color(0xFF1A73EC), borderRadius: BorderRadius.all(Radius.circular(6)), ), - child: Text( + child: const Text( "关闭", style: TextStyle(fontSize: 14, color: Colors.white), ), @@ -574,12 +531,12 @@ class _ModifyInfoDialogState extends State { child: Container( height: 32, alignment: Alignment.center, - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10), - decoration: BoxDecoration( + margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), + decoration: const BoxDecoration( color: Colors.grey, borderRadius: BorderRadius.all(Radius.circular(6)), ), - child: Text( + child: const Text( "取消", style: TextStyle(fontSize: 14, color: Colors.white), ), @@ -594,10 +551,10 @@ class _ModifyInfoDialogState extends State { _item(index, context, dataItem) { return Container( - margin: EdgeInsets.only(left: 10, right: 10, bottom: 10), + margin: const EdgeInsets.only(left: 10, right: 10, bottom: 10), child: Column( children: [ - Container( + SizedBox( height: 35, child: Row( children: [ @@ -605,6 +562,9 @@ class _ModifyInfoDialogState extends State { flex: 5, child: GestureDetector( onTap: () { + if (!NetworkConfig.isPermission) { + return; + } DatePicker.showDatePicker( context, minDateTime: DateTime(1980), @@ -636,16 +596,16 @@ class _ModifyInfoDialogState extends State { }, child: Container( height: 35, - padding: EdgeInsets.symmetric(horizontal: 10), - decoration: BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(5))), + padding: const EdgeInsets.symmetric(horizontal: 10), + decoration: const BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(5))), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( "时间:${dataItem.faultTime}", - style: TextStyle(fontSize: 12), + style: const TextStyle(fontSize: 12), ), - Icon( + const Icon( Icons.arrow_drop_down, color: Colors.blue, size: 20, @@ -659,16 +619,18 @@ class _ModifyInfoDialogState extends State { flex: 1, child: GestureDetector( onTap: () { - _removeItem(index); + if (NetworkConfig.isPermission) { + _removeItem(index); + } }, child: Container( height: 30, decoration: BoxDecoration( border: Border.all(color: Colors.red, width: 1, style: BorderStyle.solid), - borderRadius: BorderRadius.all(Radius.circular(5))), - margin: EdgeInsets.only(left: 10), + borderRadius: const BorderRadius.all(Radius.circular(5))), + margin: const EdgeInsets.only(left: 10), alignment: Alignment.center, - child: Text( + child: const Text( "-", style: TextStyle( fontSize: 25, @@ -681,15 +643,15 @@ class _ModifyInfoDialogState extends State { ), ), Container( - margin: EdgeInsets.only(top: 10), - padding: EdgeInsets.symmetric(horizontal: 5, vertical: 5), - decoration: BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(10))), + margin: const EdgeInsets.only(top: 10), + padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 5), + decoration: const BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(10))), child: TextField( maxLines: 3, - cursorColor: Color(0xFF1A73EC), + cursorColor: const Color(0xFF1A73EC), controller: _controllers[index], enabled: NetworkConfig.isPermission, - decoration: InputDecoration( + decoration: const InputDecoration( contentPadding: EdgeInsets.zero, hintText: '请输入历史障碍发生原因及时间', border: InputBorder.none, @@ -697,7 +659,7 @@ class _ModifyInfoDialogState extends State { focusedBorder: InputBorder.none, hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 12), ), - style: TextStyle(fontSize: 12), + style: const TextStyle(fontSize: 12), ), ), ], diff --git a/lib/dialog/update_dialog.dart b/lib/dialog/update_dialog.dart new file mode 100644 index 0000000..75aad65 --- /dev/null +++ b/lib/dialog/update_dialog.dart @@ -0,0 +1,81 @@ +import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class UpdateDialog extends StatefulWidget { + final String downloadUrl; + + const UpdateDialog({super.key, required this.downloadUrl}); + + @override + State createState() => _UpdateDialogState(); +} + +// 打开外部浏览器的方法 +Future launchExternalBrowser(String url) async { + // 检查是否可以启动URL + if (await canLaunchUrl(Uri.parse(url))) { + // 启动URL,使用外部浏览器 + await launchUrl( + Uri.parse(url), + mode: LaunchMode.externalApplication, // 这会强制使用外部浏览器 + ); + } else { + // 如果无法启动URL,抛出异常或处理错误 + throw '无法打开 $url'; + } +} + +class _UpdateDialogState extends State { + @override + Widget build(BuildContext context) { + return Material( + type: MaterialType.transparency, + color: const Color(0x1A000000), + child: Center( + child: ClipRRect( + borderRadius: BorderRadius.circular(10), + child: Container( + width: 307, + color: Colors.white, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: EdgeInsets.only(top: 20), + child: Image( + width: 80, + height: 80, + image: AssetImage('assets/images/ic_update.png'), + ), + ), + Container( + margin: EdgeInsets.only(top: 20), + child: Text( + "有新版本请更新", + style: TextStyle(fontSize: 20), + ), + ), + GestureDetector( + onTap: () { + launchExternalBrowser(widget.downloadUrl); + }, + child: Container( + width: 160, + height: 50, + alignment: Alignment.center, + margin: EdgeInsets.symmetric(vertical: 20), + decoration: BoxDecoration(color: Colors.lightBlue, borderRadius: BorderRadius.all(Radius.circular(15))), + child: Text( + "去更新", + style: TextStyle(fontSize: 22, color: Colors.white), + ), + ), + ) + ], + ), + ), + ), + ), + ); + } +} diff --git a/lib/network/NetworkConfig.dart b/lib/network/NetworkConfig.dart index cff6ddc..4d97ade 100644 --- a/lib/network/NetworkConfig.dart +++ b/lib/network/NetworkConfig.dart @@ -57,4 +57,6 @@ class NetworkConfig { static const String odfPortsUnitType = "/system/dict/data/type/odf_ports_unit_type"; //设备型号 static const String odfPortsBusinessType = "/system/dict/data/type/odf_ports_business_type"; //业务类型 + + static const String checkAppVersion = "/webapi/CheckAppVersion"; //提示更新 } diff --git a/lib/tools/home/home_model.dart b/lib/tools/home/home_model.dart index 8002627..07cd49c 100644 --- a/lib/tools/home/home_model.dart +++ b/lib/tools/home/home_model.dart @@ -6,6 +6,7 @@ import 'package:odf/network/RequestCenter.dart'; import '../../bean/company_bean.dart'; import '../../bean/device_list_bean.dart'; +import '../../bean/update_bean.dart'; class HomeModel { StreamController streamController = StreamController.broadcast(); @@ -44,8 +45,6 @@ class HomeModel { }, (errorEntity) { print("errorEntity==${errorEntity.msg}"); }); - - } ///设备列表 @@ -77,4 +76,20 @@ class HomeModel { print("errorEntity==${errorEntity.msg}"); }); } + + ///业务类型 + Future checkAppVersion(version) async { + RequestCenter.instance.requestGet(NetworkConfig.checkAppVersion, {"version": version}, (dataEntity) { + if (dataEntity.code == 200) { + UpdateBean updateBean = UpdateBean.fromJson(dataEntity.data); + + streamController.sink.add({ + 'code': "checkAppVersion", //有数据 + 'data': updateBean, + }); + } + }, (errorEntity) { + print("errorEntity==${errorEntity.msg}"); + }); + } } diff --git a/lib/tools/home/home_page.dart b/lib/tools/home/home_page.dart index a2b97dc..9e4d261 100644 --- a/lib/tools/home/home_page.dart +++ b/lib/tools/home/home_page.dart @@ -2,8 +2,12 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:odf/tools/home/home_model.dart'; +import 'package:package_info_plus/package_info_plus.dart'; import '../../bean/company_bean.dart'; +import '../../bean/update_bean.dart'; +import '../../common/func.dart'; +import '../../dialog/update_dialog.dart'; import '../machine/region_page.dart'; class HomePage extends StatefulWidget { @@ -21,6 +25,8 @@ class _HomePageState extends State { List companyList = []; + late UpdateBean updateBean; + @override void initState() { // TODO: implement initState @@ -34,6 +40,20 @@ class _HomePageState extends State { isLoad = true; companyList = event['data']; break; + + case "checkAppVersion": + updateBean = event['data']; + + if (updateBean.needUpdate != null && updateBean.needUpdate!) { + FunctionUtil.popDialog2( + context, + UpdateDialog( + downloadUrl: "${updateBean.downloadUrl}", + ), + ); + } + + break; } } setState(() {}); @@ -42,6 +62,16 @@ class _HomePageState extends State { _viewmodel.getCompany(); _viewmodel.odfPortsUnitType(); _viewmodel.odfPortsBusinessType(); + getUpdate(); + } + + ///检查更新 + getUpdate() async { + final info = await PackageInfo.fromPlatform(); + String version = info.version; + + print("版本:version==$version"); + _viewmodel.checkAppVersion(version); } @override @@ -94,11 +124,15 @@ class _HomePageState extends State { image: const AssetImage('assets/images/ic_refresh.png'), ), ), - Container( - alignment: Alignment.center, - child: Text( - '公司列表', - style: TextStyle(fontSize: s20, fontWeight: FontWeight.w600), + + GestureDetector( + onTap: () {}, + child: Container( + alignment: Alignment.center, + child: Text( + '公司列表', + style: TextStyle(fontSize: s20, fontWeight: FontWeight.w600), + ), ), ), diff --git a/pubspec.yaml b/pubspec.yaml index 2537f6e..1d8456e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,6 +34,8 @@ dependencies: shared_preferences: ^2.2.3 json_annotation: ^4.9.0 flutter_cupertino_datetime_picker: ^3.0.0 + url_launcher: ^6.2.3 + package_info_plus: ^8.0.2 dev_dependencies: