Merge pull request #5829 from 21pages/scrollbar

desktop touch pad scroll
This commit is contained in:
RustDesk 2023-09-27 10:53:55 +08:00 committed by GitHub
commit 34d64fbcaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 22 deletions

View File

@ -273,11 +273,29 @@ class MyTheme {
: EdgeInsets.only(left: dialogPadding / 3);
static ScrollbarThemeData scrollbarTheme = ScrollbarThemeData(
thickness: MaterialStateProperty.all(kScrollbarThickness),
thickness: MaterialStateProperty.all(6),
thumbColor: MaterialStateProperty.resolveWith<Color?>((states) {
if (states.contains(MaterialState.dragged)) {
return Colors.grey[900];
} else if (states.contains(MaterialState.hovered)) {
return Colors.grey[700];
} else {
return Colors.grey[500];
}
}),
crossAxisMargin: 4,
);
static ScrollbarThemeData scrollbarThemeDark = scrollbarTheme.copyWith(
thumbColor: MaterialStateProperty.all(Colors.grey[500]),
thumbColor: MaterialStateProperty.resolveWith<Color?>((states) {
if (states.contains(MaterialState.dragged)) {
return Colors.grey[100];
} else if (states.contains(MaterialState.hovered)) {
return Colors.grey[300];
} else {
return Colors.grey[500];
}
}),
);
static ThemeData lightTheme = ThemeData(

View File

@ -4,6 +4,7 @@ import 'dart:collection';
import 'package:dynamic_layouts/dynamic_layouts.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hbb/desktop/widgets/scroll_wrapper.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
import 'package:visibility_detector/visibility_detector.dart';
@ -95,6 +96,8 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
return width;
}();
final _scrollController = ScrollController();
_PeersViewState() {
_startCheckOnlines();
}
@ -197,7 +200,9 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
: SizedBox(width: mobileWidth, child: visibilityChild);
}
final child = DynamicGridView.builder(
final Widget child;
if (isMobile) {
child = DynamicGridView.builder(
gridDelegate: SliverGridDelegateWithWrapping(
mainAxisSpacing: space / 2, crossAxisSpacing: space),
itemCount: peers.length,
@ -205,6 +210,21 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
return buildOnePeer(peers[index]);
},
);
} else {
child = DesktopScrollWrapper(
scrollController: _scrollController,
child: DynamicGridView.builder(
controller: _scrollController,
physics: DraggableNeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithWrapping(
mainAxisSpacing: space / 2, crossAxisSpacing: space),
itemCount: peers.length,
itemBuilder: (BuildContext context, int index) {
return buildOnePeer(peers[index]);
}),
);
}
if (updateEvent == UpdateEvent.load) {
_curPeers.clear();
_curPeers.addAll(peers.map((e) => e.id));

View File

@ -88,6 +88,11 @@ class _DesktopSettingPageState extends State<DesktopSettingPage>
Get.put<RxInt>(selectedIndex, tag: _kSettingPageIndexTag);
controller = PageController(initialPage: widget.initialPage);
Get.put<PageController>(controller, tag: _kSettingPageControllerTag);
controller.addListener(() {
if (controller.page != null) {
selectedIndex.value = controller.page!.toInt();
}
});
}
@override
@ -154,7 +159,7 @@ class _DesktopSettingPageState extends State<DesktopSettingPage>
scrollController: controller,
child: PageView(
controller: controller,
physics: DraggableNeverScrollableScrollPhysics(),
physics: NeverScrollableScrollPhysics(),
children: _children(),
)),
),
@ -330,8 +335,10 @@ class _GeneralState extends State<_General> {
child: _OptionCheckBox(context, "Always use software rendering",
'allow-always-software-render'),
));
children.add(
_OptionCheckBox(context, 'Check for software update on startup','enable-check-update',
children.add(_OptionCheckBox(
context,
'Check for software update on startup',
'enable-check-update',
isServer: false,
));
if (bind.mainShowOption(key: 'allow-linux-headless')) {

View File

@ -399,12 +399,12 @@ packages:
dynamic_layouts:
dependency: "direct main"
description:
path: "packages/dynamic_layouts"
ref: "74cc4b495dcf3a4cb8df38d9ecc89f53f074a2c6"
resolved-ref: "74cc4b495dcf3a4cb8df38d9ecc89f53f074a2c6"
url: "https://github.com/21pages/packages.git"
path: "."
ref: "24cb88413fa5181d949ddacbb30a65d5c459e7d9"
resolved-ref: "24cb88413fa5181d949ddacbb30a65d5c459e7d9"
url: "https://github.com/21pages/dynamic_layouts.git"
source: git
version: "0.0.1+2"
version: "0.0.1+1"
event_bus:
dependency: transitive
description:

View File

@ -102,9 +102,8 @@ dependencies:
flex_color_picker: ^3.3.0
dynamic_layouts:
git:
url: https://github.com/21pages/packages.git
path: packages/dynamic_layouts
ref: 74cc4b495dcf3a4cb8df38d9ecc89f53f074a2c6
url: https://github.com/21pages/dynamic_layouts.git
ref: 24cb88413fa5181d949ddacbb30a65d5c459e7d9
dev_dependencies:
icons_launcher: ^2.0.4