更新
This commit is contained in:
parent
6fd6403bdb
commit
d884436dcf
BIN
assets/images/ic_update.png
Normal file
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
18
lib/bean/update_bean.dart
Normal 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);
|
||||
}
|
||||
24
lib/bean/update_bean.g.dart
Normal file
24
lib/bean/update_bean.g.dart
Normal 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,
|
||||
};
|
||||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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<ModifyInfoDialog> createState() => _ModifyInfoDialogState();
|
||||
|
|
@ -42,17 +42,12 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
|
|||
bool isConnect = false;
|
||||
bool isLoad = false;
|
||||
|
||||
String businessName = "";
|
||||
String deviceModel = "";
|
||||
String businessType = "";
|
||||
String portNumber = "";
|
||||
|
||||
// 用列表存储所有输入框的值,通过索引区分不同输入框
|
||||
late List<TextEditingController> _controllers;
|
||||
|
||||
final List<HistoryFaultBean> _items = [];
|
||||
|
||||
// 添加新视图
|
||||
/// 添加新视图
|
||||
void _addItem() {
|
||||
setState(() {
|
||||
_items.add(HistoryFaultBean("", ""));
|
||||
|
|
@ -60,7 +55,7 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
|
|||
});
|
||||
}
|
||||
|
||||
// 移除指定视图
|
||||
/// 移除指定视图
|
||||
void _removeItem(int index) {
|
||||
setState(() {
|
||||
_items.removeAt(index);
|
||||
|
|
@ -86,7 +81,6 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
|
|||
// 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<ModifyInfoDialog> {
|
|||
Future<void> 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<ModifyInfoDialog> {
|
|||
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<ModifyInfoDialog> {
|
|||
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<ModifyInfoDialog> {
|
|||
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<ModifyInfoDialog> {
|
|||
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<ModifyInfoDialog> {
|
|||
},
|
||||
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<ModifyInfoDialog> {
|
|||
),
|
||||
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<ModifyInfoDialog> {
|
|||
),
|
||||
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<ModifyInfoDialog> {
|
|||
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<ModifyInfoDialog> {
|
|||
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<ModifyInfoDialog> {
|
|||
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<ModifyInfoDialog> {
|
|||
// ),
|
||||
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<ModifyInfoDialog> {
|
|||
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<ModifyInfoDialog> {
|
|||
: 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<ModifyInfoDialog> {
|
|||
},
|
||||
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<ModifyInfoDialog> {
|
|||
},
|
||||
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<ModifyInfoDialog> {
|
|||
: 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<ModifyInfoDialog> {
|
|||
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<ModifyInfoDialog> {
|
|||
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<ModifyInfoDialog> {
|
|||
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<ModifyInfoDialog> {
|
|||
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<ModifyInfoDialog> {
|
|||
|
||||
_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<ModifyInfoDialog> {
|
|||
flex: 5,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (!NetworkConfig.isPermission) {
|
||||
return;
|
||||
}
|
||||
DatePicker.showDatePicker(
|
||||
context,
|
||||
minDateTime: DateTime(1980),
|
||||
|
|
@ -636,16 +596,16 @@ class _ModifyInfoDialogState extends State<ModifyInfoDialog> {
|
|||
},
|
||||
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<ModifyInfoDialog> {
|
|||
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<ModifyInfoDialog> {
|
|||
),
|
||||
),
|
||||
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<ModifyInfoDialog> {
|
|||
focusedBorder: InputBorder.none,
|
||||
hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 12),
|
||||
),
|
||||
style: TextStyle(fontSize: 12),
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
81
lib/dialog/update_dialog.dart
Normal file
81
lib/dialog/update_dialog.dart
Normal 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),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -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"; //提示更新
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<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}");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<HomePage> {
|
|||
|
||||
List<CompanyBean> companyList = [];
|
||||
|
||||
late UpdateBean updateBean;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
|
|
@ -34,6 +40,20 @@ class _HomePageState extends State<HomePage> {
|
|||
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<HomePage> {
|
|||
_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<HomePage> {
|
|||
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),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user