From e1ab01a97f6d769c96c41a16ec43665b990edfd5 Mon Sep 17 00:00:00 2001 From: Kingtous Date: Mon, 19 Sep 2022 19:18:05 +0800 Subject: [PATCH 1/2] opt: use custom scroll feature --- flutter/lib/consts.dart | 2 +- flutter/lib/desktop/widgets/peer_widget.dart | 1 + flutter/lib/desktop/widgets/scroll_wrapper.dart | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/flutter/lib/consts.dart b/flutter/lib/consts.dart index 0d93df778..3ed080206 100644 --- a/flutter/lib/consts.dart +++ b/flutter/lib/consts.dart @@ -16,7 +16,7 @@ const int kDesktopDefaultDisplayWidth = 1080; const int kDesktopDefaultDisplayHeight = 720; /// [kDefaultScrollAmountMultiplier] indicates how many rows can be scrolled after a minimum scroll action of mouse -const kDefaultScrollAmountMultiplier = 3.0; +const kDefaultScrollAmountMultiplier = 10.0; const kFullScreenEdgeSize = 1.0; const kWindowEdgeSize = 4.0; diff --git a/flutter/lib/desktop/widgets/peer_widget.dart b/flutter/lib/desktop/widgets/peer_widget.dart index 07a621add..1b0626198 100644 --- a/flutter/lib/desktop/widgets/peer_widget.dart +++ b/flutter/lib/desktop/widgets/peer_widget.dart @@ -89,6 +89,7 @@ class _PeerWidgetState extends State<_PeerWidget> with WindowListener { : DesktopScrollWrapper( scrollController: _scrollController, child: SingleChildScrollView( + physics: const NeverScrollableScrollPhysics(), controller: _scrollController, child: ObxValue((searchText) { return FutureBuilder>( diff --git a/flutter/lib/desktop/widgets/scroll_wrapper.dart b/flutter/lib/desktop/widgets/scroll_wrapper.dart index 96eb9f735..6ad63b99c 100644 --- a/flutter/lib/desktop/widgets/scroll_wrapper.dart +++ b/flutter/lib/desktop/widgets/scroll_wrapper.dart @@ -13,7 +13,7 @@ class DesktopScrollWrapper extends StatelessWidget { Widget build(BuildContext context) { return ImprovedScrolling( scrollController: scrollController, - enableCustomMouseWheelScrolling: false, + enableCustomMouseWheelScrolling: true, customMouseWheelScrollConfig: const CustomMouseWheelScrollConfig( scrollAmountMultiplier: kDefaultScrollAmountMultiplier), child: child, From df5a2ab5569cae8ad9c8a29c49631f5dc96b5a5e Mon Sep 17 00:00:00 2001 From: Kingtous Date: Mon, 19 Sep 2022 21:09:54 +0800 Subject: [PATCH 2/2] opt: custom scroll for better scroll and add trackpad support --- flutter/lib/consts.dart | 4 +++- flutter/lib/desktop/pages/connection_page.dart | 4 +++- flutter/lib/desktop/widgets/peer_widget.dart | 2 +- flutter/lib/desktop/widgets/scroll_wrapper.dart | 6 +++++- flutter/pubspec.yaml | 5 ++++- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/flutter/lib/consts.dart b/flutter/lib/consts.dart index 3ed080206..e7c506ecc 100644 --- a/flutter/lib/consts.dart +++ b/flutter/lib/consts.dart @@ -16,7 +16,9 @@ const int kDesktopDefaultDisplayWidth = 1080; const int kDesktopDefaultDisplayHeight = 720; /// [kDefaultScrollAmountMultiplier] indicates how many rows can be scrolled after a minimum scroll action of mouse -const kDefaultScrollAmountMultiplier = 10.0; +const kDefaultScrollAmountMultiplier = 5.0; +const kDefaultScrollDuration = Duration(milliseconds: 50); +const kDefaultMouseWhellThrottleDuration = Duration(milliseconds: 50); const kFullScreenEdgeSize = 1.0; const kWindowEdgeSize = 4.0; diff --git a/flutter/lib/desktop/pages/connection_page.dart b/flutter/lib/desktop/pages/connection_page.dart index e857df271..3c7994861 100644 --- a/flutter/lib/desktop/pages/connection_page.dart +++ b/flutter/lib/desktop/pages/connection_page.dart @@ -852,7 +852,9 @@ class _PeerTabbedPageState extends State<_PeerTabbedPage> Widget _createTabBarView() { return Expanded( child: PageView( - controller: _pageController, children: super.widget.children) + physics: NeverScrollableScrollPhysics(), + controller: _pageController, + children: super.widget.children) .marginSymmetric(vertical: 12)); } diff --git a/flutter/lib/desktop/widgets/peer_widget.dart b/flutter/lib/desktop/widgets/peer_widget.dart index 1b0626198..a7edc0b93 100644 --- a/flutter/lib/desktop/widgets/peer_widget.dart +++ b/flutter/lib/desktop/widgets/peer_widget.dart @@ -89,7 +89,7 @@ class _PeerWidgetState extends State<_PeerWidget> with WindowListener { : DesktopScrollWrapper( scrollController: _scrollController, child: SingleChildScrollView( - physics: const NeverScrollableScrollPhysics(), + physics: NeverScrollableScrollPhysics(), controller: _scrollController, child: ObxValue((searchText) { return FutureBuilder>( diff --git a/flutter/lib/desktop/widgets/scroll_wrapper.dart b/flutter/lib/desktop/widgets/scroll_wrapper.dart index 6ad63b99c..aaa3aa403 100644 --- a/flutter/lib/desktop/widgets/scroll_wrapper.dart +++ b/flutter/lib/desktop/widgets/scroll_wrapper.dart @@ -14,7 +14,11 @@ class DesktopScrollWrapper extends StatelessWidget { return ImprovedScrolling( scrollController: scrollController, enableCustomMouseWheelScrolling: true, - customMouseWheelScrollConfig: const CustomMouseWheelScrollConfig( + customMouseWheelScrollConfig: CustomMouseWheelScrollConfig( + scrollDuration: kDefaultScrollDuration, + scrollCurve: Curves.linearToEaseOut, + mouseWheelTurnsThrottleTimeMs: + kDefaultMouseWhellThrottleDuration.inMilliseconds, scrollAmountMultiplier: kDefaultScrollAmountMultiplier), child: child, ); diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index 9bc8816ef..696f2a5d2 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -80,7 +80,10 @@ dependencies: desktop_drop: ^0.3.3 scroll_pos: ^0.3.0 rxdart: ^0.27.5 - flutter_improved_scrolling: ^0.0.3 + flutter_improved_scrolling: + git: + url: https://github.com/Kingtous/flutter_improved_scrolling + ref: 62f09545149f320616467c306c8c5f71714a18e6 dev_dependencies: icons_launcher: ^2.0.4