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:
raf-dev1
2025-06-22 08:43:13 +03:00
committed by GitHub

View File

@ -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,70 +104,58 @@ 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: Scrollbar(
controller: _verticalScrollController,
thumbVisibility: true,
trackVisibility: true,
child: Scrollbar(
//fixed the horizontal scrollbar issue
controller: _horizontalScrollController,
thumbVisibility: true,
trackVisibility: true,
notificationPredicate: (notif) => notif.depth == 1,
child: SingleChildScrollView(
controller: _verticalScrollController,
child: SingleChildScrollView(
controller: _horizontalScrollController,
scrollDirection: Axis.horizontal,
child: SizedBox(
width: widget.size.width,
child: Column( child: Column(
children: [ children: [
Container( Container(
decoration: widget.headerDecoration ?? decoration: widget.headerDecoration ??
const BoxDecoration(color: ColorsManager.boxColor), const BoxDecoration(
child: SingleChildScrollView( color: ColorsManager.boxColor,
scrollDirection: Axis.horizontal, ),
physics: const NeverScrollableScrollPhysics(),
controller: _horizontalHeaderScrollController,
child: SizedBox(
width: widget.size.width,
child: Row( child: Row(
children: [ children: [
if (widget.withCheckBox) _buildSelectAllCheckbox(), if (widget.withCheckBox) _buildSelectAllCheckbox(),
...List.generate(widget.headers.length, (index) { ...List.generate(widget.headers.length, (index) {
return _buildTableHeaderCell( return _buildTableHeaderCell(
widget.headers[index], index); widget.headers[index], index);
}), })
//...widget.headers.map((header) => _buildTableHeaderCell(header)),
], ],
), ),
), ),
), SizedBox(
),
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, width: widget.size.width,
child: widget.isEmpty child: widget.isEmpty
? _buildEmptyState() ? _buildEmptyState()
: Column( : Column(
children: List.generate(widget.data.length, children:
(rowIndex) { List.generate(widget.data.length, (rowIndex) {
final row = widget.data[rowIndex]; final row = widget.data[rowIndex];
return Row( return Row(
children: [ children: [
if (widget.withCheckBox) if (widget.withCheckBox)
_buildRowCheckbox(rowIndex, _buildRowCheckbox(
widget.size.height * 0.08), rowIndex, widget.size.height * 0.08),
...row.asMap().entries.map((entry) { ...row.asMap().entries.map((entry) {
return _buildTableCell( return _buildTableCell(
entry.value.toString(), entry.value.toString(),
@ -190,30 +169,12 @@ 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,
), ),
); );
} }
@ -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, // نفس لون الأيقونة في الصورة
), ),
), ),
), ),