mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
Sp 1612 fe user cannot see the horizontal scroll on any of the tables they have to hover over it but it s not obvious that they can do that (#274)
<!-- Thanks for contributing! Provide a description of your changes below and a general summary in the title Please look at the following checklist to ensure that your PR can be accepted quickly: --> ## Jira Ticket [SP-1612](https://syncrow.atlassian.net/browse/SP-1612) ## Description PROBLEM IS SOLVED before but i added comment to insure that ## Type of Change <!--- Put an `x` in all the boxes that apply: --> - [ ] ✨ New feature (non-breaking change which adds functionality) - [x] 🛠️ Bug fix (non-breaking change which fixes an issue) - [ ] ❌ Breaking change (fix or feature that would cause existing functionality to change) - [ ] 🧹 Code refactor - [ ] ✅ Build configuration change - [ ] 📝 Documentation - [ ] 🗑️ Chore [SP-1612]: https://syncrow.atlassian.net/browse/SP-1612?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
This commit is contained in:
@ -50,20 +50,11 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
bool _selectAll = false;
|
bool _selectAll = false;
|
||||||
final ScrollController _verticalScrollController = ScrollController();
|
final ScrollController _verticalScrollController = ScrollController();
|
||||||
final ScrollController _horizontalScrollController = ScrollController();
|
final ScrollController _horizontalScrollController = ScrollController();
|
||||||
late ScrollController _horizontalHeaderScrollController;
|
|
||||||
late ScrollController _horizontalBodyScrollController;
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_initializeSelection();
|
_initializeSelection();
|
||||||
_horizontalHeaderScrollController = ScrollController();
|
|
||||||
_horizontalBodyScrollController = ScrollController();
|
|
||||||
|
|
||||||
// Synchronize horizontal scrolling
|
|
||||||
_horizontalBodyScrollController.addListener(() {
|
|
||||||
_horizontalHeaderScrollController
|
|
||||||
.jumpTo(_horizontalBodyScrollController.offset);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -113,108 +104,78 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
context.read<DeviceManagementBloc>().add(UpdateSelection(_selectedRows));
|
context.read<DeviceManagementBloc>().add(UpdateSelection(_selectedRows));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_horizontalHeaderScrollController.dispose();
|
|
||||||
_horizontalBodyScrollController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: widget.cellDecoration,
|
decoration: widget.cellDecoration,
|
||||||
child: Column(
|
child: Scrollbar(
|
||||||
children: [
|
controller: _verticalScrollController,
|
||||||
Container(
|
thumbVisibility: true,
|
||||||
decoration: widget.headerDecoration ??
|
trackVisibility: true,
|
||||||
const BoxDecoration(color: ColorsManager.boxColor),
|
child: Scrollbar(
|
||||||
|
//fixed the horizontal scrollbar issue
|
||||||
|
controller: _horizontalScrollController,
|
||||||
|
thumbVisibility: true,
|
||||||
|
trackVisibility: true,
|
||||||
|
notificationPredicate: (notif) => notif.depth == 1,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
controller: _verticalScrollController,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
|
controller: _horizontalScrollController,
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
controller: _horizontalHeaderScrollController,
|
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: widget.size.width,
|
width: widget.size.width,
|
||||||
child: Row(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
if (widget.withCheckBox) _buildSelectAllCheckbox(),
|
Container(
|
||||||
...List.generate(widget.headers.length, (index) {
|
decoration: widget.headerDecoration ??
|
||||||
return _buildTableHeaderCell(
|
const BoxDecoration(
|
||||||
widget.headers[index], index);
|
color: ColorsManager.boxColor,
|
||||||
}),
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
if (widget.withCheckBox) _buildSelectAllCheckbox(),
|
||||||
|
...List.generate(widget.headers.length, (index) {
|
||||||
|
return _buildTableHeaderCell(
|
||||||
|
widget.headers[index], index);
|
||||||
|
})
|
||||||
|
//...widget.headers.map((header) => _buildTableHeaderCell(header)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: widget.size.width,
|
||||||
|
child: widget.isEmpty
|
||||||
|
? _buildEmptyState()
|
||||||
|
: Column(
|
||||||
|
children:
|
||||||
|
List.generate(widget.data.length, (rowIndex) {
|
||||||
|
final row = widget.data[rowIndex];
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
if (widget.withCheckBox)
|
||||||
|
_buildRowCheckbox(
|
||||||
|
rowIndex, widget.size.height * 0.08),
|
||||||
|
...row.asMap().entries.map((entry) {
|
||||||
|
return _buildTableCell(
|
||||||
|
entry.value.toString(),
|
||||||
|
widget.size.height * 0.08,
|
||||||
|
rowIndex: rowIndex,
|
||||||
|
columnIndex: entry.key,
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
|
||||||
child: Scrollbar(
|
|
||||||
controller: _verticalScrollController,
|
|
||||||
thumbVisibility: true,
|
|
||||||
trackVisibility: true,
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
controller: _verticalScrollController,
|
|
||||||
child: Scrollbar(
|
|
||||||
controller: _horizontalBodyScrollController,
|
|
||||||
thumbVisibility: false,
|
|
||||||
trackVisibility: false,
|
|
||||||
notificationPredicate: (notif) => notif.depth == 1,
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
controller: _horizontalBodyScrollController,
|
|
||||||
child: Container(
|
|
||||||
color: ColorsManager.whiteColors,
|
|
||||||
child: SizedBox(
|
|
||||||
width: widget.size.width,
|
|
||||||
child: widget.isEmpty
|
|
||||||
? _buildEmptyState()
|
|
||||||
: Column(
|
|
||||||
children: List.generate(widget.data.length,
|
|
||||||
(rowIndex) {
|
|
||||||
final row = widget.data[rowIndex];
|
|
||||||
return Row(
|
|
||||||
children: [
|
|
||||||
if (widget.withCheckBox)
|
|
||||||
_buildRowCheckbox(rowIndex,
|
|
||||||
widget.size.height * 0.08),
|
|
||||||
...row.asMap().entries.map((entry) {
|
|
||||||
return _buildTableCell(
|
|
||||||
entry.value.toString(),
|
|
||||||
widget.size.height * 0.08,
|
|
||||||
rowIndex: rowIndex,
|
|
||||||
columnIndex: entry.key,
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildSelectAllCheckbox() {
|
|
||||||
return Container(
|
|
||||||
width: 50,
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
border: Border.symmetric(
|
|
||||||
vertical: BorderSide(color: ColorsManager.boxDivider),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Checkbox(
|
|
||||||
value: _selectAll,
|
|
||||||
onChanged: widget.withSelectAll && widget.data.isNotEmpty
|
|
||||||
? _toggleSelectAll
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,6 +205,23 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
Widget _buildSelectAllCheckbox() {
|
||||||
|
return Container(
|
||||||
|
width: 50,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
border: Border.symmetric(
|
||||||
|
vertical: BorderSide(color: ColorsManager.boxDivider),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Checkbox(
|
||||||
|
value: _selectAll,
|
||||||
|
onChanged: widget.withSelectAll && widget.data.isNotEmpty
|
||||||
|
? _toggleSelectAll
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildRowCheckbox(int index, double size) {
|
Widget _buildRowCheckbox(int index, double size) {
|
||||||
return Container(
|
return Container(
|
||||||
width: 50,
|
width: 50,
|
||||||
@ -298,12 +276,8 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildTableCell(
|
Widget _buildTableCell(String content, double size,
|
||||||
String content,
|
{required int rowIndex, required int columnIndex}) {
|
||||||
double size, {
|
|
||||||
required int rowIndex,
|
|
||||||
required int columnIndex,
|
|
||||||
}) {
|
|
||||||
bool isBatteryLevel = content.endsWith('%');
|
bool isBatteryLevel = content.endsWith('%');
|
||||||
double? batteryLevel;
|
double? batteryLevel;
|
||||||
|
|
||||||
@ -311,7 +285,6 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
batteryLevel = double.tryParse(content.replaceAll('%', '').trim());
|
batteryLevel = double.tryParse(content.replaceAll('%', '').trim());
|
||||||
}
|
}
|
||||||
bool isSettingsColumn = widget.headers[columnIndex] == 'Settings';
|
bool isSettingsColumn = widget.headers[columnIndex] == 'Settings';
|
||||||
|
|
||||||
if (isSettingsColumn) {
|
if (isSettingsColumn) {
|
||||||
return buildSettingsIcon(
|
return buildSettingsIcon(
|
||||||
width: 120,
|
width: 120,
|
||||||
@ -416,11 +389,10 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.settings, // ضع المسار الصحيح هنا
|
Assets.settings,
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 22,
|
height: 22,
|
||||||
color: ColorsManager
|
color: ColorsManager.primaryColor,
|
||||||
.primaryColor, // نفس لون الأيقونة في الصورة
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user