Skip to content

Commit

Permalink
add trackVisibilityScrollbar parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccardo Baldassa committed May 13, 2024
1 parent afbd0b6 commit b66a36b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [2.0.2] - 2024-03-29
#### [@RichiB20](https://github.com/RichiB20)
- Fixed vertical Scrollbar and added horizontal Scrollbar.
- Added `trackVisibilityScrollbar` parameter.
- Fixed table size.

## [2.0.1] - 2023-09-04
Expand Down
2 changes: 2 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class _MyHomePageState extends State<MyHomePage> {
scrollShadowColor: accentColor,
rows: rows,
visibleScrollbar: true,
trackVisibilityScrollbar: true,
);
}

Expand Down Expand Up @@ -201,6 +202,7 @@ class _MyHomePageState extends State<MyHomePage> {
firstColumnWidth: 250,
scrollShadowColor: accentColor,
visibleScrollbar: true,
trackVisibilityScrollbar: true,
);
}

Expand Down
14 changes: 14 additions & 0 deletions lib/src/class/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ class ExpandableTableController extends ChangeNotifier {
notifyListeners();
}

bool _trackVisibilityScrollbar = false;

/// [trackVisibilityScrollbar] indicates that the scrollbar track should be visible.
///
/// Default: [false]
bool get trackVisibilityScrollbar => _trackVisibilityScrollbar;

set trackVisibilityScrollbar(bool value) {
_trackVisibilityScrollbar = value;
notifyListeners();
}

/// [duration] determines duration rendered animation of Rows/Columns expansion.
///
/// Default: [500ms]
Expand Down Expand Up @@ -148,6 +160,7 @@ class ExpandableTableController extends ChangeNotifier {
required List<ExpandableTableHeader> headers,
required List<ExpandableTableRow> rows,
bool visibleScrollbar = false,
bool trackVisibilityScrollbar = false,
this.duration = const Duration(milliseconds: 500),
this.curve = Curves.fastOutSlowIn,
this.scrollShadowDuration = const Duration(milliseconds: 500),
Expand All @@ -168,6 +181,7 @@ class ExpandableTableController extends ChangeNotifier {
_headers = headers;
_rows = rows;
_visibleScrollbar = visibleScrollbar;
_trackVisibilityScrollbar = trackVisibilityScrollbar;
_addHeadersListener();
_addRowsListener();
}
Expand Down
7 changes: 7 additions & 0 deletions lib/src/widget/table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ class ExpandableTable extends StatefulWidget {
/// Default: [false]
final bool visibleScrollbar;

/// [trackVisibilityScrollbar] indicates that the scrollbar track should be visible.
///
/// Default: [false]
final bool trackVisibilityScrollbar;

/// [controller] specifies the external controller of the table, allows
/// you to dynamically manage the data in the table externally.
/// Do not use if [firstHeaderCell], [headers] and [rows] are passed
Expand Down Expand Up @@ -123,6 +128,7 @@ class ExpandableTable extends StatefulWidget {
this.scrollShadowColor = Colors.transparent,
this.scrollShadowSize = 10,
this.visibleScrollbar = false,
this.trackVisibilityScrollbar = false,
}) : assert((firstHeaderCell != null && rows != null && headers != null) ||
controller != null);

Expand Down Expand Up @@ -169,6 +175,7 @@ class _ExpandableTableState extends State<ExpandableTable> {
defaultsRowHeight: widget.defaultsRowHeight,
headerHeight: widget.headerHeight,
visibleScrollbar: widget.visibleScrollbar,
trackVisibilityScrollbar: widget.trackVisibilityScrollbar,
),
builder: (context, child) => const InternalTable(),
);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/widget_internal/table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ class InternalTableState extends State<InternalTable> {
? Scrollbar(
controller: _horizontalBodyController,
thumbVisibility: true,
trackVisibility: true,
trackVisibility: data.trackVisibilityScrollbar,
child: Scrollbar(
controller: _restColumnsController,
thumbVisibility: true,
trackVisibility: true,
trackVisibility: data.trackVisibilityScrollbar,
notificationPredicate: (notification) =>
notification.depth >= 0,
child: child,
Expand Down

0 comments on commit b66a36b

Please sign in to comment.