add custom scroll view to access managment screen and devices screen

This commit is contained in:
ashrafzarkanisala
2024-08-27 03:29:35 +03:00
parent 7d700f47dd
commit 56edcaf788
8 changed files with 403 additions and 425 deletions

View File

@ -47,11 +47,9 @@ class _DynamicTableState extends State<DynamicTable> {
void _toggleRowSelection(int index) {
setState(() {
// Deselect all rows
for (int i = 0; i < _selected.length; i++) {
_selected[i] = false;
}
// Select the clicked row
_selected[index] = true;
if (widget.onRowSelected != null) {
@ -64,85 +62,80 @@ class _DynamicTableState extends State<DynamicTable> {
Widget build(BuildContext context) {
return Container(
decoration: widget.cellDecoration,
child: Padding(
padding: const EdgeInsets.all(2.0),
child: ListView(
scrollDirection: Axis.horizontal,
children: [
SizedBox(
width: widget.size.width,
child: Column(
children: [
Container(
decoration: widget.headerDecoration ??
BoxDecoration(color: Colors.grey[200]),
child: Row(
children: [
if (widget.withCheckBox) _buildSelectAllCheckbox(),
...widget.headers
.map((header) => _buildTableHeaderCell(header))
.toList(),
],
),
),
widget.isEmpty
? Expanded(
child: Column(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: SizedBox(
width: widget.size.width,
child: Column(
children: [
Container(
decoration: widget.headerDecoration ??
BoxDecoration(color: Colors.grey[200]),
child: Row(
children: [
if (widget.withCheckBox) _buildSelectAllCheckbox(),
...widget.headers
.map((header) => _buildTableHeaderCell(header))
.toList(),
],
),
),
widget.isEmpty
? Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
Column(
children: [
Column(
children: [
SvgPicture.asset(Assets.emptyTable),
const SizedBox(
height: 15,
),
Text(
'No Devices',
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(
color: ColorsManager.grayColor),
)
],
SvgPicture.asset(Assets.emptyTable),
const SizedBox(
height: 15,
),
Text(
'No Devices',
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(
color: ColorsManager.grayColor),
)
],
),
],
),
)
: Expanded(
child: Container(
color: Colors.white,
child: ListView.builder(
shrinkWrap: true,
itemCount: widget.data.length,
itemBuilder: (context, index) {
final row = widget.data[index];
return Row(
children: [
if (widget.withCheckBox)
_buildRowCheckbox(
index, widget.size.height * 0.10),
...row
.map((cell) => _buildTableCell(
cell.toString(),
widget.size.height * 0.10))
.toList(),
],
);
},
),
),
],
),
)
: Expanded(
child: Container(
color: Colors.white,
child: ListView.builder(
shrinkWrap: true,
itemCount: widget.data.length,
itemBuilder: (context, index) {
final row = widget.data[index];
return Row(
children: [
if (widget.withCheckBox)
_buildRowCheckbox(
index, widget.size.height * 0.10),
...row
.map((cell) => _buildTableCell(
cell.toString(),
widget.size.height * 0.10))
.toList(),
],
);
},
),
],
),
),
],
),
),
],
),
),
),
);
@ -150,7 +143,7 @@ class _DynamicTableState extends State<DynamicTable> {
Widget _buildSelectAllCheckbox() {
return Container(
width: 50, // Fixed width to align with the checkbox column
width: 50,
padding: const EdgeInsets.all(8.0),
decoration: const BoxDecoration(
border: Border.symmetric(
@ -159,14 +152,14 @@ class _DynamicTableState extends State<DynamicTable> {
),
child: Checkbox(
value: _selected.every((element) => element == true),
onChanged: null, // Disabling the toggle as we're not using select all
onChanged: null,
),
);
}
Widget _buildRowCheckbox(int index, double size) {
return Container(
width: 50, // Fixed width to align with the checkbox column
width: 50,
padding: const EdgeInsets.all(8.0),
height: size,
decoration: const BoxDecoration(
@ -214,7 +207,6 @@ class _DynamicTableState extends State<DynamicTable> {
}
Widget _buildTableCell(String content, double size) {
// Check if the content is a battery level percentage
bool isBatteryLevel = content.endsWith('%');
double? batteryLevel;