temporary solution for Android AccessibilityService can't not control RustDesk itself

This commit is contained in:
csf 2022-04-13 23:05:17 +08:00
parent ba2b30f488
commit c5a601a5a3
5 changed files with 29 additions and 1 deletions

View File

@ -40,6 +40,9 @@ class ChatPage extends StatelessWidget implements PageShape {
})
];
@override
final scrollController = FFI.chatModel.scroller;
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider.value(

View File

@ -21,6 +21,9 @@ class ConnectionPage extends StatefulWidget implements PageShape {
@override
final appBarActions = isWeb ? <Widget>[WebMenu()] : <Widget>[];
@override
final scrollController = ScrollController();
@override
_ConnectionPageState createState() => _ConnectionPageState();
}
@ -46,6 +49,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
Provider.of<FfiModel>(context);
if (_idController.text.isEmpty) _idController.text = FFI.getId();
return SingleChildScrollView(
controller: widget.scrollController,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,

View File

@ -9,6 +9,7 @@ abstract class PageShape extends Widget {
final String title = "";
final Icon icon = Icon(null);
final List<Widget> appBarActions = [];
final ScrollController? scrollController = null;
}
class HomePage extends StatefulWidget {
@ -74,7 +75,20 @@ class _HomePageState extends State<HomePage> {
_selectedIndex = index;
}),
),
body: _pages.elementAt(_selectedIndex),
body: Listener(
onPointerMove: (evt) {
final page = _pages.elementAt(_selectedIndex);
/// Flutter can't not catch PointerMoveEvent when size is 1
/// This will happen in Android AccessibilityService Input
/// android can't init dispatching size yet ,see: https://stackoverflow.com/questions/59960451/android-accessibility-dispatchgesture-is-it-possible-to-specify-pressure-for-a
/// use this temporary solution until flutter or android fixes the bug
if (evt.size == 1 && page.scrollController != null) {
final offset = page.scrollController!.offset.toDouble();
page.scrollController!.jumpTo(offset - evt.delta.dy);
}
},
child: _pages.elementAt(_selectedIndex)),
));
}
}

View File

@ -57,6 +57,9 @@ class ServerPage extends StatelessWidget implements PageShape {
})
];
@override
final scrollController = ScrollController();
@override
Widget build(BuildContext context) {
checkService();
@ -64,6 +67,7 @@ class ServerPage extends StatelessWidget implements PageShape {
value: FFI.serverModel,
child: Consumer<ServerModel>(
builder: (context, serverModel, child) => SingleChildScrollView(
controller: scrollController,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,

View File

@ -20,6 +20,9 @@ class SettingsPage extends StatefulWidget implements PageShape {
@override
final appBarActions = [];
@override
final scrollController = null;
@override
_SettingsState createState() => _SettingsState();
}