95 lines
2.7 KiB
Dart
95 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class DeviceManagementDialog extends StatelessWidget {
|
|
const DeviceManagementDialog({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// 定义CAN设备ID、CAN通道和波特率的选项列表
|
|
final List<String> canDeviceIds = ['ID1', 'ID2', 'ID3'];
|
|
final List<String> canChannels = ['通道1', '通道2'];
|
|
final List<String> baudRates = ['500K', '115200', '250000'];
|
|
|
|
// 定义选中的值的状态变量
|
|
String selectedCanDeviceId = canDeviceIds[0];
|
|
String selectedCanChannel = canChannels[0];
|
|
String selectedBaudRate = baudRates[0];
|
|
|
|
return AlertDialog(
|
|
title: const Text('设备管理'),
|
|
content: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
// CAN设备ID下拉框
|
|
DropdownButton<String>(
|
|
value: selectedCanDeviceId,
|
|
onChanged: (newValue) {
|
|
if (newValue != null) {
|
|
selectedCanDeviceId = newValue;
|
|
}
|
|
},
|
|
items: canDeviceIds.map<DropdownMenuItem<String>>((String value) {
|
|
return DropdownMenuItem<String>(
|
|
value: value,
|
|
child: Text(value),
|
|
);
|
|
}).toList(),
|
|
),
|
|
// CAN通道下拉框
|
|
DropdownButton<String>(
|
|
value: selectedCanChannel,
|
|
onChanged: (newValue) {
|
|
if (newValue != null) {
|
|
selectedCanChannel = newValue;
|
|
}
|
|
},
|
|
items: canChannels.map<DropdownMenuItem<String>>((String value) {
|
|
return DropdownMenuItem<String>(
|
|
value: value,
|
|
child: Text(value),
|
|
);
|
|
}).toList(),
|
|
),
|
|
// 波特率下拉框
|
|
DropdownButton<String>(
|
|
value: selectedBaudRate,
|
|
onChanged: (newValue) {
|
|
if (newValue != null) {
|
|
selectedBaudRate = newValue;
|
|
}
|
|
},
|
|
items: baudRates.map<DropdownMenuItem<String>>((String value) {
|
|
return DropdownMenuItem<String>(
|
|
value: value,
|
|
child: Text(value),
|
|
);
|
|
}).toList(),
|
|
),
|
|
],
|
|
),
|
|
actions: <Widget>[
|
|
// 刷新按钮
|
|
TextButton(
|
|
child: const Text('刷新'),
|
|
onPressed: () {
|
|
// 这里可以添加刷新的逻辑
|
|
},
|
|
),
|
|
// 连接按钮
|
|
TextButton(
|
|
child: const Text('连接'),
|
|
onPressed: () {
|
|
// 这里可以添加连接的逻辑
|
|
},
|
|
),
|
|
// 关闭按钮
|
|
TextButton(
|
|
child: const Text('关闭'),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
],
|
|
);
|
|
}
|
|
} |