Multi select for favorite page.

This commit is contained in:
stonegate 2020-10-13 00:40:51 +08:00
parent e8708535ee
commit 67d57c5334
1 changed files with 203 additions and 143 deletions

View File

@ -1204,11 +1204,19 @@ class _MyFavoriteState extends State<_MyFavorite>
Layout _layout;
int _sortBy;
bool _hideListened;
///Selected episode list.
List<EpisodeBrief> _selectedEpisodes;
///Toggle for multi-select.
bool _multiSelect;
@override
void initState() {
super.initState();
_loadMore = false;
_sortBy = 0;
_multiSelect = false;
}
@override
@ -1264,6 +1272,11 @@ class _MyFavoriteState extends State<_MyFavorite>
episodes: snapshot.data,
layout: _layout,
initNum: 0,
multiSelect: _multiSelect,
selectedList: _selectedEpisodes ?? [],
onSelect: (value) => setState(() {
_selectedEpisodes = value;
}),
),
SliverList(
delegate: SliverChildBuilderDelegate(
@ -1281,6 +1294,9 @@ class _MyFavoriteState extends State<_MyFavorite>
],
),
),
Column(
children: [
if (!_multiSelect)
Container(
height: 40,
color: context.primaryColor,
@ -1290,7 +1306,8 @@ class _MyFavoriteState extends State<_MyFavorite>
color: Colors.transparent,
child: PopupMenuButton<int>(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
borderRadius:
BorderRadius.all(
Radius.circular(10))),
elevation: 1,
tooltip: s.homeSubMenuSortBy,
@ -1299,11 +1316,13 @@ class _MyFavoriteState extends State<_MyFavorite>
padding: EdgeInsets.symmetric(
horizontal: 20),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisSize:
MainAxisSize.min,
children: <Widget>[
Text(s.homeSubMenuSortBy),
Padding(
padding: EdgeInsets.symmetric(
padding: EdgeInsets
.symmetric(
horizontal: 5),
),
Icon(
@ -1320,7 +1339,8 @@ class _MyFavoriteState extends State<_MyFavorite>
children: [
Text(s.updateDate),
Spacer(),
if (_sortBy == 0) DotIndicator()
if (_sortBy == 0)
DotIndicator()
],
),
),
@ -1330,7 +1350,8 @@ class _MyFavoriteState extends State<_MyFavorite>
children: [
Text(s.likeDate),
Spacer(),
if (_sortBy == 1) DotIndicator()
if (_sortBy == 1)
DotIndicator()
],
),
)
@ -1357,8 +1378,8 @@ class _MyFavoriteState extends State<_MyFavorite>
),
),
onPressed: () {
setState(() =>
_hideListened = !_hideListened);
setState(() => _hideListened =
!_hideListened);
},
),
),
@ -1366,14 +1387,48 @@ class _MyFavoriteState extends State<_MyFavorite>
color: Colors.transparent,
child: LayoutButton(
layout: _layout,
onPressed: (layout) => setState(() {
onPressed: (layout) =>
setState(() {
_layout = layout;
}),
),
),
Material(
color: Colors.transparent,
child: IconButton(
icon: SizedBox(
width: 20,
height: 10,
child: CustomPaint(
painter:
MultiSelectPainter(
color: context
.accentColor)),
),
onPressed: () {
setState(() {
_selectedEpisodes = [];
_multiSelect = true;
});
},
)),
],
),
),
if (_multiSelect)
MultiSelectMenuBar(
selectedList: _selectedEpisodes,
hideFavorite: true,
onClose: (value) {
setState(() {
if (value) {
_multiSelect = false;
}
});
},
),
],
),
],
),
)
@ -1427,7 +1482,9 @@ class _MyDownloadState extends State<_MyDownload>
future: _getDownloadedEpisodes(_sortBy, hideListened: _hideListened),
builder: (context, snapshot) {
var episodes = snapshot.data ?? [];
return CustomScrollView(
return ScrollConfiguration(
behavior: NoGrowBehavior(),
child: CustomScrollView(
key: PageStorageKey<String>('download_list'),
slivers: <Widget>[
DownloadList(),
@ -1452,7 +1509,8 @@ class _MyDownloadState extends State<_MyDownload>
),
),
onPressed: () {
setState(() => _hideListened = !_hideListened);
setState(
() => _hideListened = !_hideListened);
},
),
),
@ -1478,7 +1536,8 @@ class _MyDownloadState extends State<_MyDownload>
Icon(LineIcons.download_solid,
size: 80, color: Colors.grey[500]),
Padding(
padding: EdgeInsets.symmetric(vertical: 10)),
padding:
EdgeInsets.symmetric(vertical: 10)),
Text(
s.noEpisodeDownload,
style: TextStyle(color: Colors.grey[500]),
@ -1493,6 +1552,7 @@ class _MyDownloadState extends State<_MyDownload>
initNum: 0,
),
],
),
);
}),
);