Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
bosskmk committed Nov 29, 2022
2 parents 0e50ffd + badbf6a commit 52fd10a
Show file tree
Hide file tree
Showing 8 changed files with 395 additions and 18 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [5.4.4] - 2022. 11. 29

* Add hovered scrollbar.
https://pluto.weblaze.dev/scrollbar-and-scroll-behavior

## [5.4.3] - 2022. 11. 21

* Add iterateRowType to PlutoAggregateColumnFooter.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## PlutoGrid for flutter - v5.4.3
## PlutoGrid for flutter - v5.4.4

[![Awesome Flutter](https://img.shields.io/badge/Awesome-Flutter-blue.svg)](https://github.com/Solido/awesome-flutter)
[![codecov](https://codecov.io/gh/bosskmk/pluto_grid/branch/master/graph/badge.svg)](https://codecov.io/gh/bosskmk/pluto_grid)
Expand Down
44 changes: 37 additions & 7 deletions lib/src/pluto_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:intl/date_symbol_data_local.dart';
import 'package:intl/intl.dart' show Intl;
import 'package:pluto_grid/pluto_grid.dart';

import 'helper/platform_helper.dart';
import 'ui/ui.dart';

typedef PlutoOnLoadedEventCallback = void Function(
Expand Down Expand Up @@ -1211,8 +1212,9 @@ class _GridContainer extends StatelessWidget {
return Focus(
focusNode: stateManager.gridFocusNode,
child: ScrollConfiguration(
behavior: const PlutoScrollBehavior().copyWith(
scrollbars: false,
behavior: PlutoScrollBehavior(
isMobile: PlatformHelper.isMobile,
userDragDevices: stateManager.configuration.scrollbar.dragDevices,
),
child: DecoratedBox(
decoration: BoxDecoration(
Expand Down Expand Up @@ -1467,13 +1469,41 @@ class PlutoRowColorContext {

/// Extension class for [ScrollConfiguration.behavior] of [PlutoGrid].
class PlutoScrollBehavior extends MaterialScrollBehavior {
const PlutoScrollBehavior() : super();
const PlutoScrollBehavior({
required this.isMobile,
Set<PointerDeviceKind>? userDragDevices,
}) : _dragDevices = userDragDevices ??
(isMobile ? _mobileDragDevices : _desktopDragDevices),
super();

final bool isMobile;

@override
Set<PointerDeviceKind> get dragDevices => {
PointerDeviceKind.touch,
PointerDeviceKind.mouse,
};
Set<PointerDeviceKind> get dragDevices => _dragDevices;

final Set<PointerDeviceKind> _dragDevices;

static const Set<PointerDeviceKind> _mobileDragDevices = {
PointerDeviceKind.touch,
PointerDeviceKind.stylus,
PointerDeviceKind.invertedStylus,
PointerDeviceKind.unknown,
};

static const Set<PointerDeviceKind> _desktopDragDevices = {
PointerDeviceKind.mouse,
PointerDeviceKind.trackpad,
PointerDeviceKind.unknown,
};

@override
Widget buildScrollbar(
BuildContext context,
Widget child,
ScrollableDetails details,
) {
return child;
}
}

/// A class for changing the value of a nullable property in a method such as [copyWith].
Expand Down
14 changes: 13 additions & 1 deletion lib/src/pluto_grid_configuration.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:collection/collection.dart' show IterableExtension;
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:pluto_grid/pluto_grid.dart';

Expand Down Expand Up @@ -662,13 +663,15 @@ class PlutoGridScrollbarConfig {
this.scrollbarThickness = PlutoScrollbar.defaultThickness,
this.scrollbarThicknessWhileDragging =
PlutoScrollbar.defaultThicknessWhileDragging,
this.hoverWidth = PlutoScrollbar.defaultScrollbarHoverWidth,
this.mainAxisMargin,
this.crossAxisMargin,
this.scrollBarColor,
this.scrollBarTrackColor,
this.scrollbarRadius = PlutoScrollbar.defaultRadius,
this.scrollbarRadiusWhileDragging =
PlutoScrollbar.defaultRadiusWhileDragging,
this.dragDevices,
});

final bool draggableScrollbar;
Expand All @@ -682,6 +685,8 @@ class PlutoGridScrollbarConfig {

final double scrollbarThicknessWhileDragging;

final double hoverWidth;

final double? mainAxisMargin;

final double? crossAxisMargin;
Expand All @@ -696,6 +701,8 @@ class PlutoGridScrollbarConfig {

final Radius scrollbarRadiusWhileDragging;

final Set<PointerDeviceKind>? dragDevices;

@override
bool operator ==(covariant Object other) {
return identical(this, other) ||
Expand All @@ -707,12 +714,15 @@ class PlutoGridScrollbarConfig {
scrollbarThickness == other.scrollbarThickness &&
scrollbarThicknessWhileDragging ==
other.scrollbarThicknessWhileDragging &&
hoverWidth == other.hoverWidth &&
mainAxisMargin == other.mainAxisMargin &&
crossAxisMargin == other.crossAxisMargin &&
scrollBarColor == other.scrollBarColor &&
scrollBarTrackColor == other.scrollBarTrackColor &&
scrollbarRadius == other.scrollbarRadius &&
scrollbarRadiusWhileDragging == other.scrollbarRadiusWhileDragging;
scrollbarRadiusWhileDragging ==
other.scrollbarRadiusWhileDragging &&
dragDevices == other.dragDevices;
}

@override
Expand All @@ -722,12 +732,14 @@ class PlutoGridScrollbarConfig {
onlyDraggingThumb,
scrollbarThickness,
scrollbarThicknessWhileDragging,
hoverWidth,
mainAxisMargin,
crossAxisMargin,
scrollBarColor,
scrollBarTrackColor,
scrollbarRadius,
scrollbarRadiusWhileDragging,
dragDevices,
);
}

Expand Down
3 changes: 3 additions & 0 deletions lib/src/ui/pluto_body_rows.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:pluto_grid/pluto_grid.dart';

import '../helper/platform_helper.dart';
import 'ui.dart';

class PlutoBodyRows extends PlutoStatefulWidget {
Expand Down Expand Up @@ -80,8 +81,10 @@ class PlutoBodyRowsState extends PlutoStateWithChange<PlutoBodyRows> {
scrollbarConfig.draggableScrollbar ? _horizontalScroll : null,
isAlwaysShown: scrollbarConfig.isAlwaysShown,
onlyDraggingThumb: scrollbarConfig.onlyDraggingThumb,
enableHover: PlatformHelper.isDesktop,
thickness: scrollbarConfig.scrollbarThickness,
thicknessWhileDragging: scrollbarConfig.scrollbarThicknessWhileDragging,
hoverWidth: scrollbarConfig.hoverWidth,
mainAxisMargin: scrollbarConfig.mainAxisMargin,
crossAxisMargin: scrollbarConfig.crossAxisMargin,
scrollBarColor: scrollbarConfig.scrollBarColor,
Expand Down
Loading

0 comments on commit 52fd10a

Please sign in to comment.