Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/src/manager/state/layout_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ abstract class ILayoutState {

double get scrollOffsetByFrozenColumn;

bool get needsVerticalScrollbarSpace;

bool get needsHorizontalScrollbarSpace;

TextDirection get textDirection;

bool get isLTR;
Expand Down
15 changes: 14 additions & 1 deletion lib/src/ui/pluto_body_columns.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ class PlutoBodyColumnsState extends PlutoStateWithChange<PlutoBodyColumns> {

@override
Widget build(BuildContext context) {
return SingleChildScrollView(
final scrollbarConfig = stateManager.configuration.scrollbar;

Widget header = SingleChildScrollView(
controller: _scroll,
scrollDirection: Axis.horizontal,
physics: const ClampingScrollPhysics(),
Expand All @@ -125,6 +127,17 @@ class PlutoBodyColumnsState extends PlutoStateWithChange<PlutoBodyColumns> {
: _columns.map(_makeColumn).toList(growable: false),
),
);

if (scrollbarConfig.draggableScrollbar) {
header = Padding(
padding: EdgeInsetsDirectional.only(
end: scrollbarConfig.hoverWidth,
),
child: header,
);
}

return header;
}
}

Expand Down
15 changes: 14 additions & 1 deletion lib/src/ui/pluto_body_columns_footer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ class PlutoBodyColumnsFooterState

@override
Widget build(BuildContext context) {
return SingleChildScrollView(
final scrollbarConfig = stateManager.configuration.scrollbar;

Widget footer = SingleChildScrollView(
controller: _scroll,
scrollDirection: Axis.horizontal,
physics: const ClampingScrollPhysics(),
Expand All @@ -88,6 +90,17 @@ class PlutoBodyColumnsFooterState
children: _columns.map(_makeFooter).toList(growable: false),
),
);

if (scrollbarConfig.draggableScrollbar) {
footer = Padding(
padding: EdgeInsetsDirectional.only(
end: scrollbarConfig.hoverWidth,
),
child: footer,
);
}

return footer;
}
}

Expand Down
30 changes: 28 additions & 2 deletions lib/src/widgets/pluto_scrollbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class PlutoScrollbar extends StatefulWidget {
this.radius = defaultRadius,
this.radiusWhileDragging = defaultRadiusWhileDragging,
required this.child,
this.reserveSpaceForVerticalScroll = false,
this.reserveSpaceForHorizontalScroll = false,
}) : assert(thickness < double.infinity),
assert(thicknessWhileDragging < double.infinity),
assert(!isAlwaysShown ||
Expand Down Expand Up @@ -95,6 +97,10 @@ class PlutoScrollbar extends StatefulWidget {

final Widget child;

final bool reserveSpaceForVerticalScroll;

final bool reserveSpaceForHorizontalScroll;

static const double defaultThickness = 3;

static const double defaultThicknessWhileDragging = 8.0;
Expand Down Expand Up @@ -578,10 +584,30 @@ class PlutoGridCupertinoScrollbarState extends State<PlutoScrollbar>

@override
Widget build(BuildContext context) {
Widget child = CustomPaint(
final bool hasVerticalScrollbar = widget.verticalController != null;

final bool hasHorizontalScrollbar = widget.horizontalController != null;

Widget child = widget.child;

final double endPadding = hasVerticalScrollbar ? widget.hoverWidth : 0.0;
final double bottomPadding =
hasHorizontalScrollbar ? widget.hoverWidth : 0.0;

if (endPadding > 0 || bottomPadding > 0) {
child = Padding(
padding: EdgeInsetsDirectional.only(
end: endPadding,
bottom: bottomPadding,
),
child: child,
);
}

child = CustomPaint(
key: _customPaintKey,
foregroundPainter: _painter,
child: RepaintBoundary(child: widget.child),
child: RepaintBoundary(child: child),
);

if (widget.enableHover) {
Expand Down
Loading