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:
vjrj 2026-07-08 14:18:10 +02:00
parent c789cd1027
commit 06aed2a586

View file

@ -1,3 +1,4 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
@ -62,6 +63,10 @@ class TaneApp extends StatelessWidget {
onGenerateTitle: (context) => context.t.app.title, onGenerateTitle: (context) => context.t.app.title,
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
theme: buildTaneTheme(), 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, locale: TranslationProvider.of(context).flutterLocale,
supportedLocales: AppLocaleUtils.supportedLocales, supportedLocales: AppLocaleUtils.supportedLocales,
localizationsDelegates: const [ 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,
};
}