From 84a4bcd948ab459489aaf6f39d6954776c3401d7 Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Sat, 30 Sep 2023 22:03:16 +0600 Subject: [PATCH] feat: thicken the scrollbars & make 'em interactive for mobile (#764) --- .../shared/track_table/tracks_table_view.dart | 29 ++++++++++++------- lib/themes/theme.dart | 10 +++++++ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/lib/components/shared/track_table/tracks_table_view.dart b/lib/components/shared/track_table/tracks_table_view.dart index 2ad6d3847..d03e92d78 100644 --- a/lib/components/shared/track_table/tracks_table_view.dart +++ b/lib/components/shared/track_table/tracks_table_view.dart @@ -71,6 +71,8 @@ class TracksTableView extends HookConsumerWidget { final searchController = useTextEditingController(); final searchFocus = useFocusNode(); + final controller = useScrollController(); + // this will trigger update on each change in searchController useValueListenable(searchController); @@ -210,14 +212,16 @@ class TracksTableView extends HookConsumerWidget { } case "add-to-playlist": { - await showDialog( - context: context, - builder: (context) { - return PlaylistAddTrackDialog( - tracks: selectedTracks.toList(), - ); - }, - ); + if (context.mounted) { + await showDialog( + context: context, + builder: (context) { + return PlaylistAddTrackDialog( + tracks: selectedTracks.toList(), + ); + }, + ); + } break; } case "play-next": @@ -348,11 +352,16 @@ class TracksTableView extends HookConsumerWidget { if (isSliver) { return SliverSafeArea( top: false, - sliver: SliverList(delegate: SliverChildListDelegate(children)), + sliver: SliverList( + delegate: SliverChildListDelegate(children), + ), ); } return SafeArea( - child: ListView(children: children), + child: ListView( + controller: controller, + children: children, + ), ); } } diff --git a/lib/themes/theme.dart b/lib/themes/theme.dart index 57a0beb68..a4077ba73 100644 --- a/lib/themes/theme.dart +++ b/lib/themes/theme.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; ThemeData theme(Color seed, Brightness brightness, bool isAmoled) { final scheme = ColorScheme.fromSeed( @@ -68,5 +69,14 @@ ThemeData theme(Color seed, Brightness brightness, bool isAmoled) { ), ), ), + scrollbarTheme: DesktopTools.platform.isMobile + ? const ScrollbarThemeData( + interactive: true, + thickness: MaterialStatePropertyAll(18), + minThumbLength: 20, + ) + : const ScrollbarThemeData( + thickness: MaterialStatePropertyAll(14), + ), ); }