Multi select for favorite page.
This commit is contained in:
parent
e8708535ee
commit
67d57c5334
|
@ -1204,11 +1204,19 @@ class _MyFavoriteState extends State<_MyFavorite>
|
||||||
Layout _layout;
|
Layout _layout;
|
||||||
int _sortBy;
|
int _sortBy;
|
||||||
bool _hideListened;
|
bool _hideListened;
|
||||||
|
|
||||||
|
///Selected episode list.
|
||||||
|
List<EpisodeBrief> _selectedEpisodes;
|
||||||
|
|
||||||
|
///Toggle for multi-select.
|
||||||
|
bool _multiSelect;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_loadMore = false;
|
_loadMore = false;
|
||||||
_sortBy = 0;
|
_sortBy = 0;
|
||||||
|
_multiSelect = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -1264,6 +1272,11 @@ class _MyFavoriteState extends State<_MyFavorite>
|
||||||
episodes: snapshot.data,
|
episodes: snapshot.data,
|
||||||
layout: _layout,
|
layout: _layout,
|
||||||
initNum: 0,
|
initNum: 0,
|
||||||
|
multiSelect: _multiSelect,
|
||||||
|
selectedList: _selectedEpisodes ?? [],
|
||||||
|
onSelect: (value) => setState(() {
|
||||||
|
_selectedEpisodes = value;
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
SliverList(
|
SliverList(
|
||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
|
@ -1281,98 +1294,140 @@ class _MyFavoriteState extends State<_MyFavorite>
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Column(
|
||||||
height: 40,
|
children: [
|
||||||
color: context.primaryColor,
|
if (!_multiSelect)
|
||||||
child: Row(
|
Container(
|
||||||
children: <Widget>[
|
height: 40,
|
||||||
Material(
|
color: context.primaryColor,
|
||||||
color: Colors.transparent,
|
child: Row(
|
||||||
child: PopupMenuButton<int>(
|
children: <Widget>[
|
||||||
shape: RoundedRectangleBorder(
|
Material(
|
||||||
borderRadius: BorderRadius.all(
|
color: Colors.transparent,
|
||||||
Radius.circular(10))),
|
child: PopupMenuButton<int>(
|
||||||
elevation: 1,
|
shape: RoundedRectangleBorder(
|
||||||
tooltip: s.homeSubMenuSortBy,
|
borderRadius:
|
||||||
child: Container(
|
BorderRadius.all(
|
||||||
height: 50,
|
Radius.circular(10))),
|
||||||
padding: EdgeInsets.symmetric(
|
elevation: 1,
|
||||||
horizontal: 20),
|
tooltip: s.homeSubMenuSortBy,
|
||||||
child: Row(
|
child: Container(
|
||||||
mainAxisSize: MainAxisSize.min,
|
height: 50,
|
||||||
children: <Widget>[
|
|
||||||
Text(s.homeSubMenuSortBy),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
horizontal: 5),
|
horizontal: 20),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize:
|
||||||
|
MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
Text(s.homeSubMenuSortBy),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets
|
||||||
|
.symmetric(
|
||||||
|
horizontal: 5),
|
||||||
|
),
|
||||||
|
Icon(
|
||||||
|
LineIcons
|
||||||
|
.hourglass_start_solid,
|
||||||
|
size: 18,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
itemBuilder: (context) => [
|
||||||
|
PopupMenuItem(
|
||||||
|
value: 0,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(s.updateDate),
|
||||||
|
Spacer(),
|
||||||
|
if (_sortBy == 0)
|
||||||
|
DotIndicator()
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Icon(
|
PopupMenuItem(
|
||||||
LineIcons
|
value: 1,
|
||||||
.hourglass_start_solid,
|
child: Row(
|
||||||
size: 18,
|
children: [
|
||||||
|
Text(s.likeDate),
|
||||||
|
Spacer(),
|
||||||
|
if (_sortBy == 1)
|
||||||
|
DotIndicator()
|
||||||
|
],
|
||||||
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)),
|
onSelected: (value) {
|
||||||
itemBuilder: (context) => [
|
if (value == 0) {
|
||||||
PopupMenuItem(
|
setState(() => _sortBy = 0);
|
||||||
value: 0,
|
} else if (value == 1) {
|
||||||
child: Row(
|
setState(() => _sortBy = 1);
|
||||||
children: [
|
}
|
||||||
Text(s.updateDate),
|
},
|
||||||
Spacer(),
|
|
||||||
if (_sortBy == 0) DotIndicator()
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
Spacer(),
|
||||||
value: 1,
|
Material(
|
||||||
child: Row(
|
color: Colors.transparent,
|
||||||
children: [
|
child: IconButton(
|
||||||
Text(s.likeDate),
|
icon: SizedBox(
|
||||||
Spacer(),
|
width: 30,
|
||||||
if (_sortBy == 1) DotIndicator()
|
height: 15,
|
||||||
],
|
child: HideListened(
|
||||||
|
hideListened:
|
||||||
|
_hideListened ?? false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() => _hideListened =
|
||||||
|
!_hideListened);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
|
Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: LayoutButton(
|
||||||
|
layout: _layout,
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)),
|
||||||
],
|
],
|
||||||
onSelected: (value) {
|
),
|
||||||
if (value == 0) {
|
),
|
||||||
setState(() => _sortBy = 0);
|
if (_multiSelect)
|
||||||
} else if (value == 1) {
|
MultiSelectMenuBar(
|
||||||
setState(() => _sortBy = 1);
|
selectedList: _selectedEpisodes,
|
||||||
|
hideFavorite: true,
|
||||||
|
onClose: (value) {
|
||||||
|
setState(() {
|
||||||
|
if (value) {
|
||||||
|
_multiSelect = false;
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
Spacer(),
|
],
|
||||||
Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: IconButton(
|
|
||||||
icon: SizedBox(
|
|
||||||
width: 30,
|
|
||||||
height: 15,
|
|
||||||
child: HideListened(
|
|
||||||
hideListened:
|
|
||||||
_hideListened ?? false,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
setState(() =>
|
|
||||||
_hideListened = !_hideListened);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: LayoutButton(
|
|
||||||
layout: _layout,
|
|
||||||
onPressed: (layout) => setState(() {
|
|
||||||
_layout = layout;
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -1427,72 +1482,77 @@ class _MyDownloadState extends State<_MyDownload>
|
||||||
future: _getDownloadedEpisodes(_sortBy, hideListened: _hideListened),
|
future: _getDownloadedEpisodes(_sortBy, hideListened: _hideListened),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
var episodes = snapshot.data ?? [];
|
var episodes = snapshot.data ?? [];
|
||||||
return CustomScrollView(
|
return ScrollConfiguration(
|
||||||
key: PageStorageKey<String>('download_list'),
|
behavior: NoGrowBehavior(),
|
||||||
slivers: <Widget>[
|
child: CustomScrollView(
|
||||||
DownloadList(),
|
key: PageStorageKey<String>('download_list'),
|
||||||
SliverToBoxAdapter(
|
slivers: <Widget>[
|
||||||
child: Container(
|
DownloadList(),
|
||||||
height: 40,
|
SliverToBoxAdapter(
|
||||||
color: context.primaryColor,
|
child: Container(
|
||||||
child: Row(
|
height: 40,
|
||||||
children: <Widget>[
|
color: context.primaryColor,
|
||||||
Container(
|
child: Row(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
children: <Widget>[
|
||||||
child: Text(s.downloaded)),
|
Container(
|
||||||
Spacer(),
|
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||||
Material(
|
child: Text(s.downloaded)),
|
||||||
color: Colors.transparent,
|
Spacer(),
|
||||||
child: IconButton(
|
Material(
|
||||||
icon: SizedBox(
|
color: Colors.transparent,
|
||||||
width: 30,
|
child: IconButton(
|
||||||
height: 15,
|
icon: SizedBox(
|
||||||
child: HideListened(
|
width: 30,
|
||||||
hideListened: _hideListened ?? false,
|
height: 15,
|
||||||
|
child: HideListened(
|
||||||
|
hideListened: _hideListened ?? false,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
onPressed: () {
|
||||||
|
setState(
|
||||||
|
() => _hideListened = !_hideListened);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
onPressed: () {
|
),
|
||||||
setState(() => _hideListened = !_hideListened);
|
Material(
|
||||||
},
|
color: Colors.transparent,
|
||||||
|
child: LayoutButton(
|
||||||
|
layout: _layout ?? Layout.one,
|
||||||
|
onPressed: (layout) => setState(() {
|
||||||
|
_layout = layout;
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
episodes.length == 0
|
||||||
|
? SliverToBoxAdapter(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 110),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Icon(LineIcons.download_solid,
|
||||||
|
size: 80, color: Colors.grey[500]),
|
||||||
|
Padding(
|
||||||
|
padding:
|
||||||
|
EdgeInsets.symmetric(vertical: 10)),
|
||||||
|
Text(
|
||||||
|
s.noEpisodeDownload,
|
||||||
|
style: TextStyle(color: Colors.grey[500]),
|
||||||
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Material(
|
)
|
||||||
color: Colors.transparent,
|
: EpisodeGrid(
|
||||||
child: LayoutButton(
|
episodes: episodes,
|
||||||
layout: _layout ?? Layout.one,
|
layout: _layout,
|
||||||
onPressed: (layout) => setState(() {
|
initNum: 0,
|
||||||
_layout = layout;
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
episodes.length == 0
|
|
||||||
? SliverToBoxAdapter(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 110),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Icon(LineIcons.download_solid,
|
|
||||||
size: 80, color: Colors.grey[500]),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 10)),
|
|
||||||
Text(
|
|
||||||
s.noEpisodeDownload,
|
|
||||||
style: TextStyle(color: Colors.grey[500]),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
],
|
||||||
: EpisodeGrid(
|
),
|
||||||
episodes: episodes,
|
|
||||||
layout: _layout,
|
|
||||||
initNum: 0,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue