Create better plug overview
This commit is contained in:
parent
7639eb7bc0
commit
ff40fc3662
2 changed files with 117 additions and 62 deletions
|
@ -64,7 +64,7 @@ class Category {
|
||||||
}
|
}
|
||||||
|
|
||||||
class CategoryWidget extends StatelessWidget {
|
class CategoryWidget extends StatelessWidget {
|
||||||
Category category;
|
final Category category;
|
||||||
|
|
||||||
CategoryWidget({super.key, required this.category});
|
CategoryWidget({super.key, required this.category});
|
||||||
|
|
||||||
|
@ -75,50 +75,99 @@ class CategoryWidget extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var list = category.devices
|
final double header_height = 40;
|
||||||
.map((device) => TableRow(children: [
|
final double info_height = 30;
|
||||||
Text(
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
device.device_descriptor ?? device.device_id),
|
|
||||||
DeviceLed(
|
|
||||||
device_id: device.device_id, led_state: device.led_state),
|
|
||||||
DevicePower(
|
|
||||||
device_id: device.device_id,
|
|
||||||
power_state: device.power_state,
|
|
||||||
power_control: device.power_control),
|
|
||||||
Text(textAlign: TextAlign.center, "${device.power_draw} W")
|
|
||||||
]))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
list.insert(
|
|
||||||
0,
|
|
||||||
const TableRow(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.blueGrey,
|
|
||||||
),
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
"Name"),
|
|
||||||
Text(
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
"LED"),
|
|
||||||
Text(
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
"Power"),
|
|
||||||
Text(
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
"Power Draw"),
|
|
||||||
]));
|
|
||||||
|
|
||||||
|
return Wrap(
|
||||||
|
spacing: 25,
|
||||||
|
runSpacing: 25,
|
||||||
|
children: category.devices.map((device) {
|
||||||
return Table(
|
return Table(
|
||||||
border: TableBorder.all(),
|
border: TableBorder.all(),
|
||||||
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
|
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
|
||||||
children: list);
|
columnWidths: const {
|
||||||
|
0: FixedColumnWidth(200.0),
|
||||||
|
1: FixedColumnWidth(200.0),
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
TableRow(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: Colors.blueGrey,
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: header_height,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Align(
|
||||||
|
child: Text(
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
device.device_descriptor ??
|
||||||
|
device.device_id)),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: IconButton(
|
||||||
|
onPressed: () {},
|
||||||
|
icon: const Icon(Icons.settings)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
))
|
||||||
|
]),
|
||||||
|
TableRow(children: [
|
||||||
|
SizedBox(
|
||||||
|
height: info_height,
|
||||||
|
child: Stack(children: [
|
||||||
|
const Align(
|
||||||
|
alignment: Alignment(-0.9, 0.0),
|
||||||
|
child: Text(
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
"LED")),
|
||||||
|
Align(
|
||||||
|
alignment: const Alignment(0.5, 0.0),
|
||||||
|
child: DeviceLed(
|
||||||
|
device_id: device.device_id,
|
||||||
|
led_state: device.led_state)),
|
||||||
|
]))
|
||||||
|
]),
|
||||||
|
TableRow(children: [
|
||||||
|
SizedBox(
|
||||||
|
height: info_height,
|
||||||
|
child: Stack(children: [
|
||||||
|
const Align(
|
||||||
|
alignment: Alignment(-0.9, 0.0),
|
||||||
|
child: Text(
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
"Power")),
|
||||||
|
Align(
|
||||||
|
alignment: const Alignment(0.4, 0.0),
|
||||||
|
child: DevicePower(
|
||||||
|
device_id: device.device_id,
|
||||||
|
power_state: device.power_state,
|
||||||
|
power_control: device.power_control)),
|
||||||
|
]))
|
||||||
|
]),
|
||||||
|
TableRow(children: [
|
||||||
|
SizedBox(
|
||||||
|
height: info_height,
|
||||||
|
child: Stack(children: [
|
||||||
|
const Align(
|
||||||
|
alignment: Alignment(-0.9, 0.0),
|
||||||
|
child: Text(
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
"Power Draw")),
|
||||||
|
Align(
|
||||||
|
alignment: const Alignment(0.5, 0.0),
|
||||||
|
child: Text(
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
"${device.power_draw} W"))
|
||||||
|
]))
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
}).toList(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,10 +64,13 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
title: Text(widget.title),
|
title: Text(widget.title),
|
||||||
),
|
),
|
||||||
body: Column(children: [
|
body: Column(children: [
|
||||||
ExpansionPanelList(
|
Container(
|
||||||
expansionCallback: (int index, bool isExpanded) {
|
margin: const EdgeInsets.all(15.0),
|
||||||
|
padding: const EdgeInsets.all(15.0),
|
||||||
|
child: ExpansionPanelList(
|
||||||
|
expansionCallback: (int index, bool expand) {
|
||||||
setState(() {
|
setState(() {
|
||||||
expanded[index] = isExpanded;
|
expanded[index] = expand;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
children: data.asMap().entries.map(
|
children: data.asMap().entries.map(
|
||||||
|
@ -81,9 +84,12 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
return ListTile(title: Text(widget.Name()));
|
return ListTile(title: Text(widget.Name()));
|
||||||
},
|
},
|
||||||
body: widget,
|
body: widget,
|
||||||
isExpanded: expanded[category.key]);
|
isExpanded: expanded[category.key],
|
||||||
|
backgroundColor: Colors.grey[200],
|
||||||
|
canTapOnHeader: true,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
).toList())
|
).toList()))
|
||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue