Add scrollbar to lists in library

This commit is contained in:
kilowatt 2020-11-01 19:47:04 +03:00
parent 29484b4af6
commit f7694741ee
2 changed files with 334 additions and 308 deletions

View File

@ -13,6 +13,7 @@ import 'package:freezer/ui/error.dart';
import 'package:freezer/ui/importer_screen.dart'; import 'package:freezer/ui/importer_screen.dart';
import 'package:freezer/ui/tiles.dart'; import 'package:freezer/ui/tiles.dart';
import 'package:freezer/translations.i18n.dart'; import 'package:freezer/translations.i18n.dart';
import 'package:draggable_scrollbar/draggable_scrollbar.dart';
import 'menu.dart'; import 'menu.dart';
import 'settings_screen.dart'; import 'settings_screen.dart';
@ -399,7 +400,10 @@ class _LibraryTracksState extends State<LibraryTracks> {
Container(width: 8.0), Container(width: 8.0),
], ],
), ),
body: ListView( body: DraggableScrollbar.rrect(
controller: _scrollController,
backgroundColor: Theme.of(context).primaryColor,
child: ListView(
controller: _scrollController, controller: _scrollController,
children: <Widget>[ children: <Widget>[
Container( Container(
@ -489,7 +493,7 @@ class _LibraryTracksState extends State<LibraryTracks> {
}) })
], ],
) )
); ));
} }
} }
@ -510,6 +514,7 @@ class _LibraryAlbumsState extends State<LibraryAlbums> {
List<Album> _albums; List<Album> _albums;
AlbumSortType _sort = AlbumSortType.DEFAULT; AlbumSortType _sort = AlbumSortType.DEFAULT;
ScrollController _scrollController = ScrollController();
List<Album> get _sorted { List<Album> get _sorted {
List<Album> albums = List.from(_albums); List<Album> albums = List.from(_albums);
@ -581,7 +586,11 @@ class _LibraryAlbumsState extends State<LibraryAlbums> {
Container(width: 8.0), Container(width: 8.0),
], ],
), ),
body: ListView( body: DraggableScrollbar.rrect(
controller: _scrollController,
backgroundColor: Theme.of(context).primaryColor,
child: ListView(
controller: _scrollController,
children: <Widget>[ children: <Widget>[
Container(height: 8.0,), Container(height: 8.0,),
if (!settings.offlineMode && _albums == null) if (!settings.offlineMode && _albums == null)
@ -654,7 +663,7 @@ class _LibraryAlbumsState extends State<LibraryAlbums> {
) )
], ],
), ),
); ));
} }
} }
@ -676,6 +685,7 @@ class _LibraryArtistsState extends State<LibraryArtists> {
ArtistSortType _sort = ArtistSortType.DEFAULT; ArtistSortType _sort = ArtistSortType.DEFAULT;
bool _loading = true; bool _loading = true;
bool _error = false; bool _error = false;
ScrollController _scrollController = ScrollController();
List<Artist> get _sorted { List<Artist> get _sorted {
List<Artist> artists = List.from(_artists); List<Artist> artists = List.from(_artists);
@ -757,7 +767,11 @@ class _LibraryArtistsState extends State<LibraryArtists> {
Container(width: 8.0), Container(width: 8.0),
], ],
), ),
body: ListView( body: DraggableScrollbar.rrect(
controller: _scrollController,
backgroundColor: Theme.of(context).primaryColor,
child: ListView(
controller: _scrollController,
children: <Widget>[ children: <Widget>[
if (_loading) if (_loading)
Padding( Padding(
@ -793,7 +807,7 @@ class _LibraryArtistsState extends State<LibraryArtists> {
}), }),
], ],
), ),
); ));
} }
} }
@ -814,6 +828,7 @@ class _LibraryPlaylistsState extends State<LibraryPlaylists> {
List<Playlist> _playlists; List<Playlist> _playlists;
PlaylistSortType _sort = PlaylistSortType.DEFAULT; PlaylistSortType _sort = PlaylistSortType.DEFAULT;
ScrollController _scrollController = ScrollController();
List<Playlist> get _sorted { List<Playlist> get _sorted {
List<Playlist> playlists = List.from(_playlists); List<Playlist> playlists = List.from(_playlists);
@ -902,7 +917,11 @@ class _LibraryPlaylistsState extends State<LibraryPlaylists> {
Container(width: 8.0), Container(width: 8.0),
], ],
), ),
body: ListView( body: DraggableScrollbar.rrect(
controller: _scrollController,
backgroundColor: Theme.of(context).primaryColor,
child: ListView(
controller: _scrollController,
children: <Widget>[ children: <Widget>[
ListTile( ListTile(
title: Text('Create new playlist'.i18n), title: Text('Create new playlist'.i18n),
@ -1006,7 +1025,7 @@ class _LibraryPlaylistsState extends State<LibraryPlaylists> {
], ],
), ),
); ));
} }
} }
@ -1016,6 +1035,7 @@ class HistoryScreen extends StatefulWidget {
} }
class _HistoryScreenState extends State<HistoryScreen> { class _HistoryScreenState extends State<HistoryScreen> {
ScrollController _scrollController = ScrollController();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -1031,7 +1051,11 @@ class _HistoryScreenState extends State<HistoryScreen> {
) )
], ],
), ),
body: ListView.builder( body: DraggableScrollbar.rrect(
controller: _scrollController,
backgroundColor: Theme.of(context).primaryColor,
child: ListView.builder(
controller: _scrollController,
itemCount: (cache.history??[]).length, itemCount: (cache.history??[]).length,
itemBuilder: (BuildContext context, int i) { itemBuilder: (BuildContext context, int i) {
Track t = cache.history[cache.history.length - i - 1]; Track t = cache.history[cache.history.length - i - 1];
@ -1050,6 +1074,7 @@ class _HistoryScreenState extends State<HistoryScreen> {
}, },
); );
}, },
)
), ),
); );
} }

View File

@ -70,6 +70,7 @@ dependencies:
numberpicker: ^1.2.1 numberpicker: ^1.2.1
quick_actions: ^0.4.0+10 quick_actions: ^0.4.0+10
photo_view: ^0.10.2 photo_view: ^0.10.2
draggable_scrollbar: 0.0.4
audio_session: ^0.0.9 audio_session: ^0.0.9
audio_service: audio_service: