fix(ui): enable mouse/trackpad drag scrolling on desktop
Flutter disables pointer-drag on scrollables/PageViews on desktop by default, so the small photo carousel (and lists) couldn't be swiped with a mouse. Add an app-wide ScrollBehavior that includes mouse/trackpad/stylus drag devices. 54 tests green; Linux runs.
This commit is contained in:
parent
c789cd1027
commit
06aed2a586
1 changed files with 19 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
|
|
@ -62,6 +63,10 @@ class TaneApp extends StatelessWidget {
|
|||
onGenerateTitle: (context) => context.t.app.title,
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: buildTaneTheme(),
|
||||
// Let scrollables & PageViews be dragged with a mouse/trackpad on
|
||||
// desktop (Flutter disables that by default), so the photo carousel and
|
||||
// lists swipe there too.
|
||||
scrollBehavior: const _DragScrollBehavior(),
|
||||
locale: TranslationProvider.of(context).flutterLocale,
|
||||
supportedLocales: AppLocaleUtils.supportedLocales,
|
||||
localizationsDelegates: const [
|
||||
|
|
@ -74,3 +79,17 @@ class TaneApp extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Enables mouse/trackpad drag scrolling (off by default on desktop) so the
|
||||
/// photo carousel and lists can be swiped with a pointer.
|
||||
class _DragScrollBehavior extends MaterialScrollBehavior {
|
||||
const _DragScrollBehavior();
|
||||
|
||||
@override
|
||||
Set<PointerDeviceKind> get dragDevices => {
|
||||
PointerDeviceKind.touch,
|
||||
PointerDeviceKind.mouse,
|
||||
PointerDeviceKind.trackpad,
|
||||
PointerDeviceKind.stylus,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue