This commit is contained in:
18631081161 2025-09-25 22:29:50 +08:00
parent 6fd6403bdb
commit d884436dcf
10 changed files with 279 additions and 141 deletions

BIN
assets/images/ic_update.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

18
lib/bean/update_bean.dart Normal file
View File

@ -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<String, dynamic> json) => _$UpdateBeanFromJson(json);
Map<String, dynamic> toJson() => _$UpdateBeanToJson(this);
}

View File

@ -0,0 +1,24 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'update_bean.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
UpdateBean _$UpdateBeanFromJson(Map<String, dynamic> json) => UpdateBean(
json['needUpdate'] as bool?,
json['forceUpdate'] as bool?,
json['latestVersion'] as String?,
json['downloadUrl'] as String?,
json['updateDescription'] as String?,
);
Map<String, dynamic> _$UpdateBeanToJson(UpdateBean instance) =>
<String, dynamic>{
'needUpdate': instance.needUpdate,
'forceUpdate': instance.forceUpdate,
'latestVersion': instance.latestVersion,
'downloadUrl': instance.downloadUrl,
'updateDescription': instance.updateDescription,
};

View File

@ -4,9 +4,9 @@ import 'package:flutter_easyloading/flutter_easyloading.dart';
import '../network/NetworkConfig.dart'; import '../network/NetworkConfig.dart';
class AddNoteDialog extends StatefulWidget { class AddNoteDialog extends StatefulWidget {
Function onTap; final Function onTap;
AddNoteDialog({ const AddNoteDialog({
super.key, super.key,
required this.onTap, required this.onTap,
}); });

View File

@ -12,10 +12,10 @@ import '../common/func.dart';
import 'add_note_dialog.dart'; import 'add_note_dialog.dart';
class ModifyInfoDialog extends StatefulWidget { class ModifyInfoDialog extends StatefulWidget {
Function onTap; final Function onTap;
String id; final String id;
ModifyInfoDialog({super.key, required this.onTap, required this.id}); const ModifyInfoDialog({super.key, required this.onTap, required this.id});
@override @override
State<ModifyInfoDialog> createState() => _ModifyInfoDialogState(); State<ModifyInfoDialog> createState() => _ModifyInfoDialogState();
@ -42,17 +42,12 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
bool isConnect = false; bool isConnect = false;
bool isLoad = false; bool isLoad = false;
String businessName = "";
String deviceModel = "";
String businessType = "";
String portNumber = "";
// //
late List<TextEditingController> _controllers; late List<TextEditingController> _controllers;
final List<HistoryFaultBean> _items = []; final List<HistoryFaultBean> _items = [];
// ///
void _addItem() { void _addItem() {
setState(() { setState(() {
_items.add(HistoryFaultBean("", "")); _items.add(HistoryFaultBean("", ""));
@ -60,7 +55,7 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
}); });
} }
// ///
void _removeItem(int index) { void _removeItem(int index) {
setState(() { setState(() {
_items.removeAt(index); _items.removeAt(index);
@ -86,7 +81,6 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
// TODO: implement initState // TODO: implement initState
super.initState(); super.initState();
subscription = _viewmodel.streamController.stream.listen((event) { subscription = _viewmodel.streamController.stream.listen((event) {
String code = event['code']; String code = event['code'];
if (code.isNotEmpty) { if (code.isNotEmpty) {
@ -150,7 +144,7 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
Future<void> saveData() async { Future<void> saveData() async {
///. ///.
for (int i = 0; i < _controllers.length; i++) { for (int i = 0; i < _controllers.length; i++) {
print('输入框的值: ${_controllers[i].text}'); // print('输入框的值: ${_controllers[i].text}');
_items[i].faultReason = _controllers[i].text; _items[i].faultReason = _controllers[i].text;
} }
@ -184,7 +178,6 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
child: Container( child: Container(
width: 307, width: 307,
// height: 500,
color: Colors.white, color: Colors.white,
padding: EdgeInsets.only(left: 5, right: 5, top: 5, bottom: bottomInset), padding: EdgeInsets.only(left: 5, right: 5, top: 5, bottom: bottomInset),
child: isLoad child: isLoad
@ -192,7 +185,7 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Container( Container(
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10), margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
child: Row( child: Row(
// crossAxisAlignment: CrossAxisAlignment.center, // crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -202,7 +195,7 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
children: [ children: [
Text( Text(
"位置:${odfDetailsBean.frameName}${odfDetailsBean.name}", "位置:${odfDetailsBean.frameName}${odfDetailsBean.name}",
style: TextStyle(fontSize: 12), style: const TextStyle(fontSize: 12),
), ),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
@ -211,14 +204,12 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
context, context,
AddNoteDialog( AddNoteDialog(
onTap: (value1, value2, value3, value4) { 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(() {}); setState(() {});
}, },
), ),
@ -227,14 +218,14 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
}, },
child: Container( child: Container(
alignment: Alignment.center, alignment: Alignment.center,
margin: EdgeInsets.only(left: 10), margin: const EdgeInsets.only(left: 10),
width: 60, width: 60,
height: 20, height: 20,
decoration: BoxDecoration( decoration: const BoxDecoration(
color: Colors.lightBlue, color: Colors.lightBlue,
borderRadius: BorderRadius.all(Radius.circular(5)), borderRadius: BorderRadius.all(Radius.circular(5)),
), ),
child: Text( child: const Text(
"添加备注", "添加备注",
style: TextStyle(fontSize: 11, color: Colors.white), style: TextStyle(fontSize: 11, color: Colors.white),
), ),
@ -244,24 +235,22 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
), ),
Row( Row(
children: [ children: [
Text( const Text(
"当前状态:", "当前状态:",
style: TextStyle(fontSize: 12), style: TextStyle(fontSize: 12),
), ),
Container( Container(
width: 12, width: 12,
height: 12, height: 12,
margin: EdgeInsets.only(left: 10, right: 5), margin: const EdgeInsets.only(left: 10, right: 5),
decoration: BoxDecoration( decoration: BoxDecoration(
color: odfDetailsBean.status == 0 ? Colors.red : Colors.green, color: odfDetailsBean.status == 0 ? Colors.red : Colors.green,
shape: BoxShape.circle, shape: BoxShape.circle,
), ),
), ),
Container( Text(
child: Text( odfDetailsBean.status == 0 ? "已断开" : "已连接",
odfDetailsBean.status == 0 ? "已断开" : "已连接", style: const TextStyle(fontSize: 12),
style: TextStyle(fontSize: 12),
),
) )
], ],
), ),
@ -270,17 +259,15 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
), ),
Container( Container(
width: double.infinity, width: double.infinity,
margin: const EdgeInsets.only(left: 10, right: 10),
margin: EdgeInsets.only(left: 10, right: 10), padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 5),
padding: EdgeInsets.symmetric(horizontal: 5, vertical: 5), decoration: const BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(7))),
decoration: BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(7))),
child: TextField( child: TextField(
maxLines: 5, maxLines: 5,
cursorColor: Color(0xFF1A73EC), cursorColor: const Color(0xFF1A73EC),
controller: _remarksController, controller: _remarksController,
enabled: NetworkConfig.isPermission, enabled: NetworkConfig.isPermission,
decoration: InputDecoration( decoration: const InputDecoration(
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
hintText: '请输入备注说明', hintText: '请输入备注说明',
border: InputBorder.none, border: InputBorder.none,
@ -288,60 +275,28 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
focusedBorder: InputBorder.none, focusedBorder: InputBorder.none,
hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 12), 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( Container(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
margin: EdgeInsets.all(10), margin: const EdgeInsets.all(10),
child: Text( child: const Text(
"光衰信息", "光衰信息",
style: TextStyle(fontSize: 12), style: TextStyle(fontSize: 12),
), ),
), ),
Container( Container(
margin: EdgeInsets.only(left: 10, right: 10), margin: const EdgeInsets.only(left: 10, right: 10),
padding: EdgeInsets.symmetric(horizontal: 5), padding: const EdgeInsets.symmetric(horizontal: 5),
alignment: Alignment.center, alignment: Alignment.center,
height: 35, 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( child: TextField(
cursorColor: Color(0xFF1A73EC), cursorColor: const Color(0xFF1A73EC),
controller: _opticalAttenuationController, controller: _opticalAttenuationController,
enabled: NetworkConfig.isPermission, enabled: NetworkConfig.isPermission,
decoration: InputDecoration( decoration: const InputDecoration(
isDense: true, isDense: true,
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
hintText: '请输入光衰信息', hintText: '请输入光衰信息',
@ -350,14 +305,14 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
focusedBorder: InputBorder.none, focusedBorder: InputBorder.none,
hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 12), hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 12),
), ),
style: TextStyle(fontSize: 12), style: const TextStyle(fontSize: 12),
), ),
), ),
Container( Container(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
margin: EdgeInsets.all(10), margin: const EdgeInsets.all(10),
child: Text( child: const Text(
"历史障碍发生原因及时间", "历史障碍发生原因及时间",
style: TextStyle(fontSize: 12), style: TextStyle(fontSize: 12),
), ),
@ -365,16 +320,18 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
ListView.builder( ListView.builder(
shrinkWrap: true, shrinkWrap: true,
itemCount: _items.length, itemCount: _items.length,
physics: NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) { itemBuilder: (context, index) {
return _item(index, context, _items[index]); return _item(index, context, _items[index]);
}), }),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
_addItem(); if (NetworkConfig.isPermission) {
_addItem();
}
}, },
child: Text( child: const Text(
"添加新", "添加新",
style: TextStyle(fontSize: 12, color: Colors.lightBlue), style: TextStyle(fontSize: 12, color: Colors.lightBlue),
), ),
), ),
@ -400,24 +357,24 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
// ), // ),
Container( Container(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
margin: EdgeInsets.all(10), margin: const EdgeInsets.all(10),
child: Text( child: const Text(
"光缆段信息", "光缆段信息",
style: TextStyle(fontSize: 12), style: TextStyle(fontSize: 12),
), ),
), ),
Container( Container(
margin: EdgeInsets.only(left: 10, right: 10), margin: const EdgeInsets.only(left: 10, right: 10),
padding: EdgeInsets.symmetric(horizontal: 5), padding: const EdgeInsets.symmetric(horizontal: 5),
height: 35, height: 35,
alignment: Alignment.center, 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( child: TextField(
maxLines: 1, maxLines: 1,
cursorColor: Color(0xFF1A73EC), cursorColor: const Color(0xFF1A73EC),
controller: _opticalCableOffRemarksController, controller: _opticalCableOffRemarksController,
enabled: NetworkConfig.isPermission, enabled: NetworkConfig.isPermission,
decoration: InputDecoration( decoration: const InputDecoration(
isDense: true, isDense: true,
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
hintText: '请输入光缆段信息', hintText: '请输入光缆段信息',
@ -426,14 +383,14 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
focusedBorder: InputBorder.none, focusedBorder: InputBorder.none,
hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 12), hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 12),
), ),
style: TextStyle(fontSize: 12), style: const TextStyle(fontSize: 12),
), ),
), ),
NetworkConfig.isPermission NetworkConfig.isPermission
? Container( ? Container(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
margin: EdgeInsets.all(10), margin: const EdgeInsets.all(10),
child: Text( child: const Text(
"改变状态", "改变状态",
style: TextStyle(fontSize: 12), style: TextStyle(fontSize: 12),
), ),
@ -441,7 +398,7 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
: Container(), : Container(),
NetworkConfig.isPermission NetworkConfig.isPermission
? Container( ? Container(
margin: EdgeInsets.symmetric(horizontal: 10), margin: const EdgeInsets.symmetric(horizontal: 10),
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
@ -452,11 +409,11 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
}, },
child: Container( child: Container(
height: 40, height: 40,
margin: EdgeInsets.only(right: 5), margin: const EdgeInsets.only(right: 5),
alignment: Alignment.center, alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(7)), borderRadius: const BorderRadius.all(Radius.circular(7)),
color: isConnect ? Color(0xFF13ED13) : Color(0xFFEBEBEB), color: isConnect ? const Color(0xFF13ED13) : const Color(0xFFEBEBEB),
), ),
child: Text( child: Text(
"连接", "连接",
@ -472,11 +429,11 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
}, },
child: Container( child: Container(
height: 40, height: 40,
margin: EdgeInsets.only(left: 5), margin: const EdgeInsets.only(left: 5),
alignment: Alignment.center, alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(7)), borderRadius: const BorderRadius.all(Radius.circular(7)),
color: !isConnect ? Color(0xFFFF0000) : Color(0xFFEBEBEB), color: !isConnect ? const Color(0xFFFF0000) : const Color(0xFFEBEBEB),
), ),
child: Text( child: Text(
"断开", "断开",
@ -490,8 +447,8 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
: Container(), : Container(),
NetworkConfig.isPermission NetworkConfig.isPermission
? Container( ? Container(
margin: EdgeInsets.symmetric(vertical: 5), margin: const EdgeInsets.symmetric(vertical: 5),
child: Text( child: const Text(
"断开后只清空备注说明,其他内容不影响", "断开后只清空备注说明,其他内容不影响",
style: TextStyle(fontSize: 10, color: Color(0xFF999999)), style: TextStyle(fontSize: 10, color: Color(0xFF999999)),
), ),
@ -509,12 +466,12 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
child: Container( child: Container(
height: 32, height: 32,
alignment: Alignment.center, alignment: Alignment.center,
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10), margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
decoration: BoxDecoration( decoration: const BoxDecoration(
color: Colors.grey, color: Colors.grey,
borderRadius: BorderRadius.all(Radius.circular(6)), borderRadius: BorderRadius.all(Radius.circular(6)),
), ),
child: Text( child: const Text(
"取消", "取消",
style: TextStyle(fontSize: 14, color: Colors.white), style: TextStyle(fontSize: 14, color: Colors.white),
), ),
@ -530,12 +487,12 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
child: Container( child: Container(
height: 32, height: 32,
alignment: Alignment.center, alignment: Alignment.center,
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10), margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
decoration: BoxDecoration( decoration: const BoxDecoration(
color: Color(0xFF1A73EC), color: Color(0xFF1A73EC),
borderRadius: BorderRadius.all(Radius.circular(6)), borderRadius: BorderRadius.all(Radius.circular(6)),
), ),
child: Text( child: const Text(
"提交", "提交",
style: TextStyle(fontSize: 14, color: Colors.white), style: TextStyle(fontSize: 14, color: Colors.white),
), ),
@ -553,12 +510,12 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
child: Container( child: Container(
height: 32, height: 32,
alignment: Alignment.center, alignment: Alignment.center,
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10), margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
decoration: BoxDecoration( decoration: const BoxDecoration(
color: Color(0xFF1A73EC), color: Color(0xFF1A73EC),
borderRadius: BorderRadius.all(Radius.circular(6)), borderRadius: BorderRadius.all(Radius.circular(6)),
), ),
child: Text( child: const Text(
"关闭", "关闭",
style: TextStyle(fontSize: 14, color: Colors.white), style: TextStyle(fontSize: 14, color: Colors.white),
), ),
@ -574,12 +531,12 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
child: Container( child: Container(
height: 32, height: 32,
alignment: Alignment.center, alignment: Alignment.center,
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10), margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
decoration: BoxDecoration( decoration: const BoxDecoration(
color: Colors.grey, color: Colors.grey,
borderRadius: BorderRadius.all(Radius.circular(6)), borderRadius: BorderRadius.all(Radius.circular(6)),
), ),
child: Text( child: const Text(
"取消", "取消",
style: TextStyle(fontSize: 14, color: Colors.white), style: TextStyle(fontSize: 14, color: Colors.white),
), ),
@ -594,10 +551,10 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
_item(index, context, dataItem) { _item(index, context, dataItem) {
return Container( return Container(
margin: EdgeInsets.only(left: 10, right: 10, bottom: 10), margin: const EdgeInsets.only(left: 10, right: 10, bottom: 10),
child: Column( child: Column(
children: [ children: [
Container( SizedBox(
height: 35, height: 35,
child: Row( child: Row(
children: [ children: [
@ -605,6 +562,9 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
flex: 5, flex: 5,
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
if (!NetworkConfig.isPermission) {
return;
}
DatePicker.showDatePicker( DatePicker.showDatePicker(
context, context,
minDateTime: DateTime(1980), minDateTime: DateTime(1980),
@ -636,16 +596,16 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
}, },
child: Container( child: Container(
height: 35, height: 35,
padding: EdgeInsets.symmetric(horizontal: 10), padding: const EdgeInsets.symmetric(horizontal: 10),
decoration: BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(5))), decoration: const BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(5))),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
"时间:${dataItem.faultTime}", "时间:${dataItem.faultTime}",
style: TextStyle(fontSize: 12), style: const TextStyle(fontSize: 12),
), ),
Icon( const Icon(
Icons.arrow_drop_down, Icons.arrow_drop_down,
color: Colors.blue, color: Colors.blue,
size: 20, size: 20,
@ -659,16 +619,18 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
flex: 1, flex: 1,
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
_removeItem(index); if (NetworkConfig.isPermission) {
_removeItem(index);
}
}, },
child: Container( child: Container(
height: 30, height: 30,
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: Colors.red, width: 1, style: BorderStyle.solid), border: Border.all(color: Colors.red, width: 1, style: BorderStyle.solid),
borderRadius: BorderRadius.all(Radius.circular(5))), borderRadius: const BorderRadius.all(Radius.circular(5))),
margin: EdgeInsets.only(left: 10), margin: const EdgeInsets.only(left: 10),
alignment: Alignment.center, alignment: Alignment.center,
child: Text( child: const Text(
"-", "-",
style: TextStyle( style: TextStyle(
fontSize: 25, fontSize: 25,
@ -681,15 +643,15 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
), ),
), ),
Container( Container(
margin: EdgeInsets.only(top: 10), margin: const EdgeInsets.only(top: 10),
padding: EdgeInsets.symmetric(horizontal: 5, vertical: 5), padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 5),
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( child: TextField(
maxLines: 3, maxLines: 3,
cursorColor: Color(0xFF1A73EC), cursorColor: const Color(0xFF1A73EC),
controller: _controllers[index], controller: _controllers[index],
enabled: NetworkConfig.isPermission, enabled: NetworkConfig.isPermission,
decoration: InputDecoration( decoration: const InputDecoration(
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
hintText: '请输入历史障碍发生原因及时间', hintText: '请输入历史障碍发生原因及时间',
border: InputBorder.none, border: InputBorder.none,
@ -697,7 +659,7 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
focusedBorder: InputBorder.none, focusedBorder: InputBorder.none,
hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 12), hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 12),
), ),
style: TextStyle(fontSize: 12), style: const TextStyle(fontSize: 12),
), ),
), ),
], ],

View File

@ -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<UpdateDialog> createState() => _UpdateDialogState();
}
//
Future<void> 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<UpdateDialog> {
@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),
),
),
)
],
),
),
),
),
);
}
}

View File

@ -57,4 +57,6 @@ class NetworkConfig {
static const String odfPortsUnitType = "/system/dict/data/type/odf_ports_unit_type"; // 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 odfPortsBusinessType = "/system/dict/data/type/odf_ports_business_type"; //
static const String checkAppVersion = "/webapi/CheckAppVersion"; //
} }

View File

@ -6,6 +6,7 @@ import 'package:odf/network/RequestCenter.dart';
import '../../bean/company_bean.dart'; import '../../bean/company_bean.dart';
import '../../bean/device_list_bean.dart'; import '../../bean/device_list_bean.dart';
import '../../bean/update_bean.dart';
class HomeModel { class HomeModel {
StreamController streamController = StreamController.broadcast(); StreamController streamController = StreamController.broadcast();
@ -44,8 +45,6 @@ class HomeModel {
}, (errorEntity) { }, (errorEntity) {
print("errorEntity==${errorEntity.msg}"); print("errorEntity==${errorEntity.msg}");
}); });
} }
/// ///
@ -77,4 +76,20 @@ class HomeModel {
print("errorEntity==${errorEntity.msg}"); print("errorEntity==${errorEntity.msg}");
}); });
} }
///
Future<void> 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}");
});
}
} }

View File

@ -2,8 +2,12 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:odf/tools/home/home_model.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/company_bean.dart';
import '../../bean/update_bean.dart';
import '../../common/func.dart';
import '../../dialog/update_dialog.dart';
import '../machine/region_page.dart'; import '../machine/region_page.dart';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
@ -21,6 +25,8 @@ class _HomePageState extends State<HomePage> {
List<CompanyBean> companyList = []; List<CompanyBean> companyList = [];
late UpdateBean updateBean;
@override @override
void initState() { void initState() {
// TODO: implement initState // TODO: implement initState
@ -34,6 +40,20 @@ class _HomePageState extends State<HomePage> {
isLoad = true; isLoad = true;
companyList = event['data']; companyList = event['data'];
break; break;
case "checkAppVersion":
updateBean = event['data'];
if (updateBean.needUpdate != null && updateBean.needUpdate!) {
FunctionUtil.popDialog2(
context,
UpdateDialog(
downloadUrl: "${updateBean.downloadUrl}",
),
);
}
break;
} }
} }
setState(() {}); setState(() {});
@ -42,6 +62,16 @@ class _HomePageState extends State<HomePage> {
_viewmodel.getCompany(); _viewmodel.getCompany();
_viewmodel.odfPortsUnitType(); _viewmodel.odfPortsUnitType();
_viewmodel.odfPortsBusinessType(); _viewmodel.odfPortsBusinessType();
getUpdate();
}
///
getUpdate() async {
final info = await PackageInfo.fromPlatform();
String version = info.version;
print("版本:version==$version");
_viewmodel.checkAppVersion(version);
} }
@override @override
@ -94,11 +124,15 @@ class _HomePageState extends State<HomePage> {
image: const AssetImage('assets/images/ic_refresh.png'), image: const AssetImage('assets/images/ic_refresh.png'),
), ),
), ),
Container(
alignment: Alignment.center, GestureDetector(
child: Text( onTap: () {},
'公司列表', child: Container(
style: TextStyle(fontSize: s20, fontWeight: FontWeight.w600), alignment: Alignment.center,
child: Text(
'公司列表',
style: TextStyle(fontSize: s20, fontWeight: FontWeight.w600),
),
), ),
), ),

View File

@ -34,6 +34,8 @@ dependencies:
shared_preferences: ^2.2.3 shared_preferences: ^2.2.3
json_annotation: ^4.9.0 json_annotation: ^4.9.0
flutter_cupertino_datetime_picker: ^3.0.0 flutter_cupertino_datetime_picker: ^3.0.0
url_launcher: ^6.2.3
package_info_plus: ^8.0.2
dev_dependencies: dev_dependencies: