mirror of
https://github.com/stonega/tsacdop
synced 2025-02-17 20:10:37 +01:00
Multi select support.
This commit is contained in:
parent
2e0e65f41a
commit
c251791b48
@ -24,6 +24,7 @@ import '../util/custom_popupmenu.dart';
|
|||||||
import '../util/custom_widget.dart';
|
import '../util/custom_widget.dart';
|
||||||
import '../util/episodegrid.dart';
|
import '../util/episodegrid.dart';
|
||||||
import '../util/extension_helper.dart';
|
import '../util/extension_helper.dart';
|
||||||
|
import '../util/muiliselect_bar.dart';
|
||||||
import 'audioplayer.dart';
|
import 'audioplayer.dart';
|
||||||
import 'download_list.dart';
|
import 'download_list.dart';
|
||||||
import 'home_groups.dart';
|
import 'home_groups.dart';
|
||||||
@ -315,9 +316,8 @@ class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
|
|||||||
color: Colors.cyan[600],
|
color: Colors.cyan[600],
|
||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
child: Text(s.dismiss,
|
child: Text(s.dismiss,
|
||||||
style: Theme.of(context)
|
style: context
|
||||||
.textTheme
|
.textTheme.button
|
||||||
.button
|
|
||||||
.copyWith(
|
.copyWith(
|
||||||
color: Colors.white)),
|
color: Colors.white)),
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
@ -727,6 +727,13 @@ class _RecentUpdateState extends State<_RecentUpdate>
|
|||||||
Layout _layout;
|
Layout _layout;
|
||||||
bool _hideListened;
|
bool _hideListened;
|
||||||
bool _scroll;
|
bool _scroll;
|
||||||
|
|
||||||
|
///Selected episode list.
|
||||||
|
List<EpisodeBrief> _selectedEpisodes;
|
||||||
|
|
||||||
|
///Toggle for multi-select.
|
||||||
|
bool _multiSelect;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -734,9 +741,10 @@ class _RecentUpdateState extends State<_RecentUpdate>
|
|||||||
_groupName = 'All';
|
_groupName = 'All';
|
||||||
_group = [];
|
_group = [];
|
||||||
_scroll = false;
|
_scroll = false;
|
||||||
|
_multiSelect = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _updateRssItem() async {
|
Future<void> _updateRssItem() async {
|
||||||
final refreshWorker = context.read<RefreshWorker>();
|
final refreshWorker = context.read<RefreshWorker>();
|
||||||
refreshWorker.start(_group);
|
refreshWorker.start(_group);
|
||||||
await Future.delayed(Duration(seconds: 1));
|
await Future.delayed(Duration(seconds: 1));
|
||||||
@ -955,77 +963,198 @@ class _RecentUpdateState extends State<_RecentUpdate>
|
|||||||
backgroundColor: context.accentColor,
|
backgroundColor: context.accentColor,
|
||||||
semanticsLabel: s.refreshStarted,
|
semanticsLabel: s.refreshStarted,
|
||||||
onRefresh: _updateRssItem,
|
onRefresh: _updateRssItem,
|
||||||
child: CustomScrollView(
|
child: Stack(
|
||||||
key: PageStorageKey<String>('update'),
|
children: [
|
||||||
physics:
|
ScrollConfiguration(
|
||||||
const AlwaysScrollableScrollPhysics(),
|
behavior: NoGrowBehavior(),
|
||||||
slivers: <Widget>[
|
child: CustomScrollView(
|
||||||
SliverToBoxAdapter(
|
key: PageStorageKey<String>('update'),
|
||||||
child: Container(
|
physics:
|
||||||
height: 40,
|
const AlwaysScrollableScrollPhysics(),
|
||||||
color: context.primaryColor,
|
slivers: <Widget>[
|
||||||
child: Material(
|
SliverToBoxAdapter(
|
||||||
color: Colors.transparent,
|
child: SizedBox(
|
||||||
child: Row(
|
height: 40,
|
||||||
children: <Widget>[
|
// color: context.primaryColor,
|
||||||
_switchGroupButton(),
|
// child: Material(
|
||||||
Spacer(),
|
// color: Colors.transparent,
|
||||||
_addNewButton(),
|
// child: Row(
|
||||||
Material(
|
// children: <Widget>[
|
||||||
color: Colors.transparent,
|
// _switchGroupButton(),
|
||||||
child: IconButton(
|
// Spacer(),
|
||||||
tooltip:
|
// _addNewButton(),
|
||||||
s.hideListenedSetting,
|
// Material(
|
||||||
icon: SizedBox(
|
// color: Colors.transparent,
|
||||||
width: 30,
|
// child: IconButton(
|
||||||
height: 15,
|
// tooltip: s
|
||||||
child: HideListened(
|
// .hideListenedSetting,
|
||||||
hideListened:
|
// icon: SizedBox(
|
||||||
_hideListened ??
|
// width: 30,
|
||||||
false,
|
// height: 15,
|
||||||
),
|
// child: HideListened(
|
||||||
),
|
// hideListened:
|
||||||
onPressed: () {
|
// _hideListened ??
|
||||||
setState(() =>
|
// false,
|
||||||
_hideListened =
|
// ),
|
||||||
!_hideListened);
|
// ),
|
||||||
},
|
// onPressed: () {
|
||||||
),
|
// setState(() =>
|
||||||
),
|
// _hideListened =
|
||||||
Material(
|
// !_hideListened);
|
||||||
color: Colors.transparent,
|
// },
|
||||||
child: LayoutButton(
|
// ),
|
||||||
layout: _layout,
|
// ),
|
||||||
onPressed: (layout) =>
|
// Material(
|
||||||
setState(() {
|
// color: Colors.transparent,
|
||||||
_layout = layout;
|
// child: LayoutButton(
|
||||||
}),
|
// layout: _layout,
|
||||||
),
|
// onPressed: (layout) =>
|
||||||
),
|
// setState(() {
|
||||||
],
|
// _layout = layout;
|
||||||
|
// }),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// Material(
|
||||||
|
// color:
|
||||||
|
// Colors.transparent,
|
||||||
|
// clipBehavior:
|
||||||
|
// Clip.hardEdge,
|
||||||
|
// borderRadius:
|
||||||
|
// BorderRadius
|
||||||
|
// .circular(100),
|
||||||
|
// child: IconButton(
|
||||||
|
// icon: SizedBox(
|
||||||
|
// width: 20,
|
||||||
|
// height: 10,
|
||||||
|
// child: CustomPaint(
|
||||||
|
// painter: MultiSelectPainter(
|
||||||
|
// color: context
|
||||||
|
// .accentColor)),
|
||||||
|
// ),
|
||||||
|
// onPressed: () {
|
||||||
|
// setState(() {
|
||||||
|
// _selectedEpisodes =
|
||||||
|
// [];
|
||||||
|
// _multiSelect =
|
||||||
|
// true;
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// )),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
),
|
),
|
||||||
)),
|
),
|
||||||
),
|
EpisodeGrid(
|
||||||
EpisodeGrid(
|
episodes: snapshot.data,
|
||||||
episodes: snapshot.data,
|
layout: _layout,
|
||||||
layout: _layout,
|
initNum: _scroll ? 0 : 12,
|
||||||
initNum: _scroll ? 0 : 12,
|
multiSelect: _multiSelect,
|
||||||
),
|
selectedList:
|
||||||
SliverList(
|
_selectedEpisodes ?? [],
|
||||||
delegate: SliverChildBuilderDelegate(
|
onSelect: (value) => setState(() {
|
||||||
(context, index) {
|
_selectedEpisodes = value;
|
||||||
return _loadMore
|
}),
|
||||||
? Container(
|
),
|
||||||
height: 2,
|
SliverList(
|
||||||
child:
|
delegate:
|
||||||
LinearProgressIndicator())
|
SliverChildBuilderDelegate(
|
||||||
: Center();
|
(context, index) {
|
||||||
},
|
return _loadMore
|
||||||
childCount: 1,
|
? Container(
|
||||||
),
|
height: 2,
|
||||||
),
|
child:
|
||||||
]),
|
LinearProgressIndicator())
|
||||||
))
|
: Center();
|
||||||
|
},
|
||||||
|
childCount: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
if (!_multiSelect)
|
||||||
|
Container(
|
||||||
|
height: 40,
|
||||||
|
color: context.primaryColor,
|
||||||
|
child: Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
_switchGroupButton(),
|
||||||
|
Spacer(),
|
||||||
|
_addNewButton(),
|
||||||
|
Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: IconButton(
|
||||||
|
tooltip:
|
||||||
|
s.hideListenedSetting,
|
||||||
|
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;
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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,
|
||||||
|
onClose: (value) {
|
||||||
|
setState(() {
|
||||||
|
if (value) {
|
||||||
|
_multiSelect = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
: Center();
|
: Center();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -1122,122 +1251,127 @@ class _MyFavoriteState extends State<_MyFavorite>
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
child: CustomScrollView(
|
child: Stack(
|
||||||
key: PageStorageKey<String>('favorite'),
|
children: [
|
||||||
slivers: <Widget>[
|
ScrollConfiguration(
|
||||||
SliverToBoxAdapter(
|
behavior: NoGrowBehavior(),
|
||||||
child: Container(
|
child: CustomScrollView(
|
||||||
height: 40,
|
key: PageStorageKey<String>('favorite'),
|
||||||
color: context.primaryColor,
|
slivers: <Widget>[
|
||||||
child: Row(
|
SliverToBoxAdapter(
|
||||||
children: <Widget>[
|
child: SizedBox(height: 40)),
|
||||||
Material(
|
EpisodeGrid(
|
||||||
color: Colors.transparent,
|
episodes: snapshot.data,
|
||||||
child: PopupMenuButton<int>(
|
layout: _layout,
|
||||||
shape: RoundedRectangleBorder(
|
initNum: 0,
|
||||||
borderRadius: BorderRadius.all(
|
),
|
||||||
Radius.circular(10))),
|
SliverList(
|
||||||
elevation: 1,
|
delegate: SliverChildBuilderDelegate(
|
||||||
tooltip: s.homeSubMenuSortBy,
|
(context, index) {
|
||||||
child: Container(
|
return _loadMore
|
||||||
height: 50,
|
? Container(
|
||||||
padding: EdgeInsets.symmetric(
|
height: 2,
|
||||||
horizontal: 20),
|
child:
|
||||||
child: Row(
|
LinearProgressIndicator())
|
||||||
mainAxisSize:
|
: Center();
|
||||||
MainAxisSize.min,
|
},
|
||||||
children: <Widget>[
|
childCount: 1,
|
||||||
Text(s.homeSubMenuSortBy),
|
),
|
||||||
Padding(
|
),
|
||||||
padding:
|
],
|
||||||
EdgeInsets.symmetric(
|
),
|
||||||
horizontal: 5),
|
),
|
||||||
),
|
Container(
|
||||||
Icon(
|
height: 40,
|
||||||
LineIcons
|
color: context.primaryColor,
|
||||||
.hourglass_start_solid,
|
child: Row(
|
||||||
size: 18,
|
children: <Widget>[
|
||||||
)
|
Material(
|
||||||
],
|
color: Colors.transparent,
|
||||||
)),
|
child: PopupMenuButton<int>(
|
||||||
itemBuilder: (context) => [
|
shape: RoundedRectangleBorder(
|
||||||
PopupMenuItem(
|
borderRadius: BorderRadius.all(
|
||||||
value: 0,
|
Radius.circular(10))),
|
||||||
child: Row(
|
elevation: 1,
|
||||||
children: [
|
tooltip: s.homeSubMenuSortBy,
|
||||||
Text(s.updateDate),
|
child: Container(
|
||||||
Spacer(),
|
height: 50,
|
||||||
if (_sortBy == 0)
|
padding: EdgeInsets.symmetric(
|
||||||
DotIndicator()
|
horizontal: 20),
|
||||||
],
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
Text(s.homeSubMenuSortBy),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 5),
|
||||||
),
|
),
|
||||||
),
|
Icon(
|
||||||
PopupMenuItem(
|
LineIcons
|
||||||
value: 1,
|
.hourglass_start_solid,
|
||||||
child: Row(
|
size: 18,
|
||||||
children: [
|
)
|
||||||
Text(s.likeDate),
|
],
|
||||||
Spacer(),
|
)),
|
||||||
if (_sortBy == 1)
|
itemBuilder: (context) => [
|
||||||
DotIndicator()
|
PopupMenuItem(
|
||||||
],
|
value: 0,
|
||||||
),
|
child: Row(
|
||||||
)
|
children: [
|
||||||
],
|
Text(s.updateDate),
|
||||||
onSelected: (value) {
|
Spacer(),
|
||||||
if (value == 0) {
|
if (_sortBy == 0) DotIndicator()
|
||||||
setState(() => _sortBy = 0);
|
],
|
||||||
} else if (value == 1) {
|
|
||||||
setState(() => _sortBy = 1);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Spacer(),
|
|
||||||
Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: IconButton(
|
|
||||||
icon: SizedBox(
|
|
||||||
width: 30,
|
|
||||||
height: 15,
|
|
||||||
child: HideListened(
|
|
||||||
hideListened:
|
|
||||||
_hideListened ?? false,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
onPressed: () {
|
),
|
||||||
setState(() => _hideListened =
|
PopupMenuItem(
|
||||||
!_hideListened);
|
value: 1,
|
||||||
},
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(s.likeDate),
|
||||||
|
Spacer(),
|
||||||
|
if (_sortBy == 1) DotIndicator()
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
onSelected: (value) {
|
||||||
|
if (value == 0) {
|
||||||
|
setState(() => _sortBy = 0);
|
||||||
|
} else if (value == 1) {
|
||||||
|
setState(() => _sortBy = 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
|
Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: IconButton(
|
||||||
|
icon: SizedBox(
|
||||||
|
width: 30,
|
||||||
|
height: 15,
|
||||||
|
child: HideListened(
|
||||||
|
hideListened:
|
||||||
|
_hideListened ?? false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Material(
|
onPressed: () {
|
||||||
color: Colors.transparent,
|
setState(() =>
|
||||||
child: LayoutButton(
|
_hideListened = !_hideListened);
|
||||||
layout: _layout,
|
},
|
||||||
onPressed: (layout) => setState(() {
|
),
|
||||||
_layout = layout;
|
),
|
||||||
}),
|
Material(
|
||||||
),
|
color: Colors.transparent,
|
||||||
),
|
child: LayoutButton(
|
||||||
],
|
layout: _layout,
|
||||||
)),
|
onPressed: (layout) => setState(() {
|
||||||
),
|
_layout = layout;
|
||||||
EpisodeGrid(
|
}),
|
||||||
episodes: snapshot.data,
|
),
|
||||||
layout: _layout,
|
),
|
||||||
initNum: 0,
|
],
|
||||||
),
|
|
||||||
SliverList(
|
|
||||||
delegate: SliverChildBuilderDelegate(
|
|
||||||
(context, index) {
|
|
||||||
return _loadMore
|
|
||||||
? Container(
|
|
||||||
height: 2,
|
|
||||||
child: LinearProgressIndicator())
|
|
||||||
: Center();
|
|
||||||
},
|
|
||||||
childCount: 1,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -10,7 +10,6 @@ import 'package:flutter_linkify/flutter_linkify.dart';
|
|||||||
import 'package:fluttertoast/fluttertoast.dart';
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:html/parser.dart';
|
import 'package:html/parser.dart';
|
||||||
import 'package:line_icons/line_icons.dart';
|
import 'package:line_icons/line_icons.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
@ -21,13 +20,13 @@ import '../state/audio_state.dart';
|
|||||||
import '../state/download_state.dart';
|
import '../state/download_state.dart';
|
||||||
import '../type/episodebrief.dart';
|
import '../type/episodebrief.dart';
|
||||||
import '../type/fireside_data.dart';
|
import '../type/fireside_data.dart';
|
||||||
import '../type/play_histroy.dart';
|
|
||||||
import '../type/podcastlocal.dart';
|
import '../type/podcastlocal.dart';
|
||||||
import '../util/audiopanel.dart';
|
import '../util/audiopanel.dart';
|
||||||
import '../util/custom_widget.dart';
|
import '../util/custom_widget.dart';
|
||||||
import '../util/episodegrid.dart';
|
import '../util/episodegrid.dart';
|
||||||
import '../util/extension_helper.dart';
|
import '../util/extension_helper.dart';
|
||||||
import '../util/general_dialog.dart';
|
import '../util/general_dialog.dart';
|
||||||
|
import '../util/muiliselect_bar.dart';
|
||||||
import 'podcast_settings.dart';
|
import 'podcast_settings.dart';
|
||||||
|
|
||||||
class PodcastDetail extends StatefulWidget {
|
class PodcastDetail extends StatefulWidget {
|
||||||
@ -83,11 +82,8 @@ class _PodcastDetailState extends State<PodcastDetail> {
|
|||||||
|
|
||||||
///Toggle for multi-select.
|
///Toggle for multi-select.
|
||||||
bool _multiSelect;
|
bool _multiSelect;
|
||||||
|
|
||||||
bool _selectAll;
|
bool _selectAll;
|
||||||
|
|
||||||
bool _selectBefore;
|
bool _selectBefore;
|
||||||
|
|
||||||
bool _selectAfter;
|
bool _selectAfter;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -994,419 +990,6 @@ class _PodcastDetailState extends State<PodcastDetail> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MultiSelectMenuBar extends StatefulWidget {
|
|
||||||
MultiSelectMenuBar(
|
|
||||||
{this.selectedList,
|
|
||||||
this.selectAll,
|
|
||||||
this.onSelectAll,
|
|
||||||
this.onClose,
|
|
||||||
this.onSelectAfter,
|
|
||||||
this.onSelectBefore,
|
|
||||||
Key key})
|
|
||||||
: super(key: key);
|
|
||||||
final List<EpisodeBrief> selectedList;
|
|
||||||
final bool selectAll;
|
|
||||||
final ValueChanged<bool> onSelectAll;
|
|
||||||
final ValueChanged<bool> onClose;
|
|
||||||
final ValueChanged<bool> onSelectBefore;
|
|
||||||
final ValueChanged<bool> onSelectAfter;
|
|
||||||
|
|
||||||
@override
|
|
||||||
_MultiSelectMenuBarState createState() => _MultiSelectMenuBarState();
|
|
||||||
}
|
|
||||||
|
|
||||||
///Multi select menu bar.
|
|
||||||
class _MultiSelectMenuBarState extends State<MultiSelectMenuBar> {
|
|
||||||
bool _liked;
|
|
||||||
bool _marked;
|
|
||||||
bool _inPlaylist;
|
|
||||||
bool _downloaded;
|
|
||||||
final _dbHelper = DBHelper();
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_liked = false;
|
|
||||||
_marked = false;
|
|
||||||
_downloaded = false;
|
|
||||||
_inPlaylist = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didUpdateWidget(MultiSelectMenuBar oldWidget) {
|
|
||||||
if (oldWidget.selectedList != widget.selectedList) {
|
|
||||||
setState(() {
|
|
||||||
_liked = false;
|
|
||||||
_marked = false;
|
|
||||||
_downloaded = false;
|
|
||||||
_inPlaylist = false;
|
|
||||||
});
|
|
||||||
super.didUpdateWidget(oldWidget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _saveLiked() async {
|
|
||||||
for (var episode in widget.selectedList) {
|
|
||||||
await _dbHelper.setLiked(episode.enclosureUrl);
|
|
||||||
}
|
|
||||||
if (mounted) {
|
|
||||||
setState(() => _liked = true);
|
|
||||||
widget.onClose(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _setUnliked() async {
|
|
||||||
for (var episode in widget.selectedList) {
|
|
||||||
await _dbHelper.setUniked(episode.enclosureUrl);
|
|
||||||
}
|
|
||||||
if (mounted) {
|
|
||||||
setState(() => _liked = false);
|
|
||||||
widget.onClose(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _markListened() async {
|
|
||||||
for (var episode in widget.selectedList) {
|
|
||||||
final history = PlayHistory(episode.title, episode.enclosureUrl, 0, 1);
|
|
||||||
await _dbHelper.saveHistory(history);
|
|
||||||
}
|
|
||||||
if (mounted) {
|
|
||||||
setState(() => _marked = true);
|
|
||||||
widget.onClose(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _markNotListened() async {
|
|
||||||
for (var episode in widget.selectedList) {
|
|
||||||
await _dbHelper.markNotListened(episode.enclosureUrl);
|
|
||||||
}
|
|
||||||
if (mounted) {
|
|
||||||
setState(() => _marked = false);
|
|
||||||
widget.onClose(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _requestDownload() async {
|
|
||||||
final permissionReady = await _checkPermmison();
|
|
||||||
final downloadUsingData = await KeyValueStorage(downloadUsingDataKey)
|
|
||||||
.getBool(defaultValue: true, reverse: true);
|
|
||||||
var dataConfirm = true;
|
|
||||||
final result = await Connectivity().checkConnectivity();
|
|
||||||
final usingData = result == ConnectivityResult.mobile;
|
|
||||||
if (permissionReady) {
|
|
||||||
if (downloadUsingData && usingData) {
|
|
||||||
dataConfirm = await _useDataConfirm();
|
|
||||||
}
|
|
||||||
if (dataConfirm) {
|
|
||||||
for (var episode in widget.selectedList) {
|
|
||||||
Provider.of<DownloadState>(context, listen: false).startTask(episode);
|
|
||||||
}
|
|
||||||
if (mounted) {
|
|
||||||
setState(() {
|
|
||||||
_downloaded = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<bool> _useDataConfirm() async {
|
|
||||||
var ifUseData = false;
|
|
||||||
final s = context.s;
|
|
||||||
await generalDialog(
|
|
||||||
context,
|
|
||||||
title: Text(s.cellularConfirm),
|
|
||||||
content: Text(s.cellularConfirmDes),
|
|
||||||
actions: <Widget>[
|
|
||||||
FlatButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
s.cancel,
|
|
||||||
style: TextStyle(color: Colors.grey[600]),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
FlatButton(
|
|
||||||
onPressed: () {
|
|
||||||
ifUseData = true;
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
s.confirm,
|
|
||||||
style: TextStyle(color: Colors.red),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
return ifUseData;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<bool> _checkPermmison() async {
|
|
||||||
var permission = await Permission.storage.status;
|
|
||||||
if (permission != PermissionStatus.granted) {
|
|
||||||
var permissions = await [Permission.storage].request();
|
|
||||||
if (permissions[Permission.storage] == PermissionStatus.granted) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buttonOnMenu({Widget child, VoidCallback onTap}) => Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: InkWell(
|
|
||||||
onTap: onTap,
|
|
||||||
child: SizedBox(
|
|
||||||
height: 50,
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 15.0), child: child),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
OverlayEntry _createOverlayEntry() {
|
|
||||||
RenderBox renderBox = context.findRenderObject();
|
|
||||||
var offset = renderBox.localToGlobal(Offset.zero);
|
|
||||||
return OverlayEntry(
|
|
||||||
builder: (constext) => Positioned(
|
|
||||||
left: offset.dx + 50,
|
|
||||||
top: offset.dy - 60,
|
|
||||||
child: Container(
|
|
||||||
width: 70,
|
|
||||||
height: 100,
|
|
||||||
//color: Colors.grey[200],
|
|
||||||
child: HeartOpen(width: 50, height: 80)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final s = context.s;
|
|
||||||
var audio = context.watch<AudioPlayerNotifier>();
|
|
||||||
return TweenAnimationBuilder(
|
|
||||||
tween: Tween<double>(begin: 0, end: 1),
|
|
||||||
duration: Duration(milliseconds: 500),
|
|
||||||
builder: (context, value, child) => Container(
|
|
||||||
height: 90.0 * value,
|
|
||||||
decoration: BoxDecoration(color: context.primaryColor),
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
height: 40,
|
|
||||||
child: Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20.0),
|
|
||||||
child: Text('${widget.selectedList.length} selected',
|
|
||||||
style: context.textTheme.headline6
|
|
||||||
.copyWith(color: context.accentColor))),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Spacer(),
|
|
||||||
if (widget.selectedList.length == 1)
|
|
||||||
SizedBox(
|
|
||||||
height: 25,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 5),
|
|
||||||
child: OutlinedButton(
|
|
||||||
style: OutlinedButton.styleFrom(
|
|
||||||
side: BorderSide(color: context.accentColor),
|
|
||||||
primary: context.textColor,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.all(
|
|
||||||
Radius.circular(100)))),
|
|
||||||
onPressed: () {
|
|
||||||
widget.onSelectBefore(true);
|
|
||||||
},
|
|
||||||
child: Text('Before')),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (widget.selectedList.length == 1)
|
|
||||||
SizedBox(
|
|
||||||
height: 25,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 5),
|
|
||||||
child: OutlinedButton(
|
|
||||||
style: OutlinedButton.styleFrom(
|
|
||||||
side: BorderSide(color: context.accentColor),
|
|
||||||
primary: context.textColor,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.all(
|
|
||||||
Radius.circular(100)))),
|
|
||||||
onPressed: () {
|
|
||||||
widget.onSelectAfter(true);
|
|
||||||
},
|
|
||||||
child: Text('After')),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 25,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 5),
|
|
||||||
child: OutlinedButton(
|
|
||||||
style: OutlinedButton.styleFrom(
|
|
||||||
side: BorderSide(color: context.accentColor),
|
|
||||||
backgroundColor:
|
|
||||||
widget.selectAll ? context.accentColor : null,
|
|
||||||
primary: widget.selectAll
|
|
||||||
? Colors.white
|
|
||||||
: context.textColor,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius.all(Radius.circular(100)))),
|
|
||||||
onPressed: () {
|
|
||||||
widget.onSelectAll(!widget.selectAll);
|
|
||||||
},
|
|
||||||
child: Text('All')),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
_buttonOnMenu(
|
|
||||||
child: _liked
|
|
||||||
? Icon(Icons.favorite, color: Colors.red)
|
|
||||||
: Icon(
|
|
||||||
Icons.favorite_border,
|
|
||||||
color: Colors.grey[700],
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
if (widget.selectedList.isNotEmpty) {
|
|
||||||
if (!_liked) {
|
|
||||||
await _saveLiked();
|
|
||||||
Fluttertoast.showToast(
|
|
||||||
msg: s.liked,
|
|
||||||
gravity: ToastGravity.BOTTOM,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
await _setUnliked();
|
|
||||||
Fluttertoast.showToast(
|
|
||||||
msg: s.unliked,
|
|
||||||
gravity: ToastGravity.BOTTOM,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// OverlayEntry _overlayEntry;
|
|
||||||
// _overlayEntry = _createOverlayEntry();
|
|
||||||
// Overlay.of(context).insert(_overlayEntry);
|
|
||||||
// await Future.delayed(Duration(seconds: 2));
|
|
||||||
// _overlayEntry?.remove();
|
|
||||||
}),
|
|
||||||
_buttonOnMenu(
|
|
||||||
child: _downloaded
|
|
||||||
? Center(
|
|
||||||
child: SizedBox(
|
|
||||||
height: 20,
|
|
||||||
width: 20,
|
|
||||||
child: CustomPaint(
|
|
||||||
painter: DownloadPainter(
|
|
||||||
color: context.accentColor,
|
|
||||||
fraction: 1,
|
|
||||||
progressColor: context.accentColor,
|
|
||||||
progress: 1),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Center(
|
|
||||||
child: SizedBox(
|
|
||||||
height: 20,
|
|
||||||
width: 20,
|
|
||||||
child: CustomPaint(
|
|
||||||
painter: DownloadPainter(
|
|
||||||
color: Colors.grey[700],
|
|
||||||
fraction: 0,
|
|
||||||
progressColor: context.accentColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
if (widget.selectedList.isNotEmpty) {
|
|
||||||
if (!_downloaded) _requestDownload();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
_buttonOnMenu(
|
|
||||||
child: _inPlaylist
|
|
||||||
? Icon(Icons.playlist_add_check,
|
|
||||||
color: context.accentColor)
|
|
||||||
: Icon(
|
|
||||||
Icons.playlist_add,
|
|
||||||
color: Colors.grey[700],
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
if (widget.selectedList.isNotEmpty) {
|
|
||||||
if (!_inPlaylist) {
|
|
||||||
for (var episode in widget.selectedList) {
|
|
||||||
audio.addToPlaylist(episode);
|
|
||||||
Fluttertoast.showToast(
|
|
||||||
msg: s.toastAddPlaylist,
|
|
||||||
gravity: ToastGravity.BOTTOM,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
setState(() => _inPlaylist = true);
|
|
||||||
} else {
|
|
||||||
for (var episode in widget.selectedList) {
|
|
||||||
audio.delFromPlaylist(episode);
|
|
||||||
Fluttertoast.showToast(
|
|
||||||
msg: s.toastRemovePlaylist,
|
|
||||||
gravity: ToastGravity.BOTTOM,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
setState(() => _inPlaylist = false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
_buttonOnMenu(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 12),
|
|
||||||
child: CustomPaint(
|
|
||||||
size: Size(25, 20),
|
|
||||||
painter: ListenedAllPainter(
|
|
||||||
_marked ? context.accentColor : Colors.grey[700],
|
|
||||||
stroke: 2.0),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
if (widget.selectedList.isNotEmpty) {
|
|
||||||
if (!_marked) {
|
|
||||||
await _markListened();
|
|
||||||
Fluttertoast.showToast(
|
|
||||||
msg: s.markListened,
|
|
||||||
gravity: ToastGravity.BOTTOM,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
await _markNotListened();
|
|
||||||
Fluttertoast.showToast(
|
|
||||||
msg: s.markNotListened,
|
|
||||||
gravity: ToastGravity.BOTTOM,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
Spacer(),
|
|
||||||
_buttonOnMenu(
|
|
||||||
child: Icon(Icons.close),
|
|
||||||
onTap: () => widget.onClose(true))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class AboutPodcast extends StatefulWidget {
|
class AboutPodcast extends StatefulWidget {
|
||||||
final PodcastLocal podcastLocal;
|
final PodcastLocal podcastLocal;
|
||||||
AboutPodcast({this.podcastLocal, Key key}) : super(key: key);
|
AboutPodcast({this.podcastLocal, Key key}) : super(key: key);
|
||||||
|
445
lib/util/muiliselect_bar.dart
Normal file
445
lib/util/muiliselect_bar.dart
Normal file
@ -0,0 +1,445 @@
|
|||||||
|
import 'package:connectivity/connectivity.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../local_storage/key_value_storage.dart';
|
||||||
|
import '../local_storage/sqflite_localpodcast.dart';
|
||||||
|
import '../state/audio_state.dart';
|
||||||
|
import '../state/download_state.dart';
|
||||||
|
import '../type/episodebrief.dart';
|
||||||
|
import '../type/play_histroy.dart';
|
||||||
|
import 'custom_widget.dart';
|
||||||
|
import 'extension_helper.dart';
|
||||||
|
import 'general_dialog.dart';
|
||||||
|
|
||||||
|
class MultiSelectMenuBar extends StatefulWidget {
|
||||||
|
MultiSelectMenuBar(
|
||||||
|
{this.selectedList,
|
||||||
|
this.selectAll,
|
||||||
|
this.onSelectAll,
|
||||||
|
this.onClose,
|
||||||
|
this.onSelectAfter,
|
||||||
|
this.onSelectBefore,
|
||||||
|
Key key})
|
||||||
|
: assert(onClose != null),
|
||||||
|
super(key: key);
|
||||||
|
final List<EpisodeBrief> selectedList;
|
||||||
|
final bool selectAll;
|
||||||
|
final ValueChanged<bool> onSelectAll;
|
||||||
|
final ValueChanged<bool> onClose;
|
||||||
|
final ValueChanged<bool> onSelectBefore;
|
||||||
|
final ValueChanged<bool> onSelectAfter;
|
||||||
|
|
||||||
|
@override
|
||||||
|
_MultiSelectMenuBarState createState() => _MultiSelectMenuBarState();
|
||||||
|
}
|
||||||
|
|
||||||
|
///Multi select menu bar.
|
||||||
|
class _MultiSelectMenuBarState extends State<MultiSelectMenuBar> {
|
||||||
|
bool _liked;
|
||||||
|
bool _marked;
|
||||||
|
bool _inPlaylist;
|
||||||
|
bool _downloaded;
|
||||||
|
final _dbHelper = DBHelper();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_liked = false;
|
||||||
|
_marked = false;
|
||||||
|
_downloaded = false;
|
||||||
|
_inPlaylist = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(MultiSelectMenuBar oldWidget) {
|
||||||
|
if (oldWidget.selectedList != widget.selectedList) {
|
||||||
|
setState(() {
|
||||||
|
_liked = false;
|
||||||
|
_marked = false;
|
||||||
|
_downloaded = false;
|
||||||
|
_inPlaylist = false;
|
||||||
|
});
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _saveLiked() async {
|
||||||
|
for (var episode in widget.selectedList) {
|
||||||
|
await _dbHelper.setLiked(episode.enclosureUrl);
|
||||||
|
}
|
||||||
|
if (mounted) {
|
||||||
|
setState(() => _liked = true);
|
||||||
|
widget.onClose(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _setUnliked() async {
|
||||||
|
for (var episode in widget.selectedList) {
|
||||||
|
await _dbHelper.setUniked(episode.enclosureUrl);
|
||||||
|
}
|
||||||
|
if (mounted) {
|
||||||
|
setState(() => _liked = false);
|
||||||
|
widget.onClose(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _markListened() async {
|
||||||
|
for (var episode in widget.selectedList) {
|
||||||
|
final history = PlayHistory(episode.title, episode.enclosureUrl, 0, 1);
|
||||||
|
await _dbHelper.saveHistory(history);
|
||||||
|
}
|
||||||
|
if (mounted) {
|
||||||
|
setState(() => _marked = true);
|
||||||
|
widget.onClose(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _markNotListened() async {
|
||||||
|
for (var episode in widget.selectedList) {
|
||||||
|
await _dbHelper.markNotListened(episode.enclosureUrl);
|
||||||
|
}
|
||||||
|
if (mounted) {
|
||||||
|
setState(() => _marked = false);
|
||||||
|
widget.onClose(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _requestDownload() async {
|
||||||
|
final permissionReady = await _checkPermmison();
|
||||||
|
final downloadUsingData = await KeyValueStorage(downloadUsingDataKey)
|
||||||
|
.getBool(defaultValue: true, reverse: true);
|
||||||
|
var dataConfirm = true;
|
||||||
|
final result = await Connectivity().checkConnectivity();
|
||||||
|
final usingData = result == ConnectivityResult.mobile;
|
||||||
|
if (permissionReady) {
|
||||||
|
if (downloadUsingData && usingData) {
|
||||||
|
dataConfirm = await _useDataConfirm();
|
||||||
|
}
|
||||||
|
if (dataConfirm) {
|
||||||
|
for (var episode in widget.selectedList) {
|
||||||
|
Provider.of<DownloadState>(context, listen: false).startTask(episode);
|
||||||
|
}
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
_downloaded = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> _useDataConfirm() async {
|
||||||
|
var ifUseData = false;
|
||||||
|
final s = context.s;
|
||||||
|
await generalDialog(
|
||||||
|
context,
|
||||||
|
title: Text(s.cellularConfirm),
|
||||||
|
content: Text(s.cellularConfirmDes),
|
||||||
|
actions: <Widget>[
|
||||||
|
FlatButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
s.cancel,
|
||||||
|
style: TextStyle(color: Colors.grey[600]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
FlatButton(
|
||||||
|
onPressed: () {
|
||||||
|
ifUseData = true;
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
s.confirm,
|
||||||
|
style: TextStyle(color: Colors.red),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
return ifUseData;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> _checkPermmison() async {
|
||||||
|
var permission = await Permission.storage.status;
|
||||||
|
if (permission != PermissionStatus.granted) {
|
||||||
|
var permissions = await [Permission.storage].request();
|
||||||
|
if (permissions[Permission.storage] == PermissionStatus.granted) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buttonOnMenu({Widget child, VoidCallback onTap}) => Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: onTap,
|
||||||
|
child: SizedBox(
|
||||||
|
height: 40,
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 12.0), child: child),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
OverlayEntry _createOverlayEntry() {
|
||||||
|
RenderBox renderBox = context.findRenderObject();
|
||||||
|
var offset = renderBox.localToGlobal(Offset.zero);
|
||||||
|
return OverlayEntry(
|
||||||
|
builder: (constext) => Positioned(
|
||||||
|
left: offset.dx + 50,
|
||||||
|
top: offset.dy - 60,
|
||||||
|
child: Container(
|
||||||
|
width: 70,
|
||||||
|
height: 100,
|
||||||
|
//color: Colors.grey[200],
|
||||||
|
child: HeartOpen(width: 50, height: 80)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final s = context.s;
|
||||||
|
var audio = context.watch<AudioPlayerNotifier>();
|
||||||
|
return TweenAnimationBuilder(
|
||||||
|
tween: Tween<double>(begin: 0, end: 1),
|
||||||
|
duration: Duration(milliseconds: 500),
|
||||||
|
builder: (context, value, child) => Container(
|
||||||
|
height: widget.selectAll == null ? 40 : 90.0 * value,
|
||||||
|
decoration: BoxDecoration(color: context.primaryColor),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
if (widget.selectAll != null)
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 40,
|
||||||
|
child: Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
|
child: Text(
|
||||||
|
'${widget.selectedList.length} selected',
|
||||||
|
style: context.textTheme.headline6
|
||||||
|
.copyWith(color: context.accentColor))),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
|
if (widget.selectedList.length == 1)
|
||||||
|
SizedBox(
|
||||||
|
height: 25,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 5),
|
||||||
|
child: OutlinedButton(
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
side: BorderSide(color: context.accentColor),
|
||||||
|
primary: context.textColor,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(100)))),
|
||||||
|
onPressed: () {
|
||||||
|
widget.onSelectBefore(true);
|
||||||
|
},
|
||||||
|
child: Text('Before')),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (widget.selectedList.length == 1)
|
||||||
|
SizedBox(
|
||||||
|
height: 25,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 5),
|
||||||
|
child: OutlinedButton(
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
side: BorderSide(color: context.accentColor),
|
||||||
|
primary: context.textColor,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(100)))),
|
||||||
|
onPressed: () {
|
||||||
|
widget.onSelectAfter(true);
|
||||||
|
},
|
||||||
|
child: Text('After')),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 25,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 5),
|
||||||
|
child: OutlinedButton(
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
side: BorderSide(color: context.accentColor),
|
||||||
|
backgroundColor: widget.selectAll
|
||||||
|
? context.accentColor
|
||||||
|
: null,
|
||||||
|
primary: widget.selectAll
|
||||||
|
? Colors.white
|
||||||
|
: context.textColor,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(100)))),
|
||||||
|
onPressed: () {
|
||||||
|
widget.onSelectAll(!widget.selectAll);
|
||||||
|
},
|
||||||
|
child: Text('All')),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
_buttonOnMenu(
|
||||||
|
child: _liked
|
||||||
|
? Icon(Icons.favorite, color: Colors.red)
|
||||||
|
: Icon(
|
||||||
|
Icons.favorite_border,
|
||||||
|
color: Colors.grey[700],
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
if (widget.selectedList.isNotEmpty) {
|
||||||
|
if (!_liked) {
|
||||||
|
await _saveLiked();
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: s.liked,
|
||||||
|
gravity: ToastGravity.BOTTOM,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await _setUnliked();
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: s.unliked,
|
||||||
|
gravity: ToastGravity.BOTTOM,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
audio.setEpisodeState = true;
|
||||||
|
}
|
||||||
|
// OverlayEntry _overlayEntry;
|
||||||
|
// _overlayEntry = _createOverlayEntry();
|
||||||
|
// Overlay.of(context).insert(_overlayEntry);
|
||||||
|
// await Future.delayed(Duration(seconds: 2));
|
||||||
|
// _overlayEntry?.remove();
|
||||||
|
}),
|
||||||
|
_buttonOnMenu(
|
||||||
|
child: _downloaded
|
||||||
|
? Center(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 20,
|
||||||
|
width: 20,
|
||||||
|
child: CustomPaint(
|
||||||
|
painter: DownloadPainter(
|
||||||
|
color: context.accentColor,
|
||||||
|
fraction: 1,
|
||||||
|
progressColor: context.accentColor,
|
||||||
|
progress: 1),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Center(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 20,
|
||||||
|
width: 20,
|
||||||
|
child: CustomPaint(
|
||||||
|
painter: DownloadPainter(
|
||||||
|
color: Colors.grey[700],
|
||||||
|
fraction: 0,
|
||||||
|
progressColor: context.accentColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
if (widget.selectedList.isNotEmpty) {
|
||||||
|
if (!_downloaded) _requestDownload();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
_buttonOnMenu(
|
||||||
|
child: _inPlaylist
|
||||||
|
? Icon(Icons.playlist_add_check,
|
||||||
|
color: context.accentColor)
|
||||||
|
: Icon(
|
||||||
|
Icons.playlist_add,
|
||||||
|
color: Colors.grey[700],
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
if (widget.selectedList.isNotEmpty) {
|
||||||
|
if (!_inPlaylist) {
|
||||||
|
for (var episode in widget.selectedList) {
|
||||||
|
audio.addToPlaylist(episode);
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: s.toastAddPlaylist,
|
||||||
|
gravity: ToastGravity.BOTTOM,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
setState(() => _inPlaylist = true);
|
||||||
|
} else {
|
||||||
|
for (var episode in widget.selectedList) {
|
||||||
|
audio.delFromPlaylist(episode);
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: s.toastRemovePlaylist,
|
||||||
|
gravity: ToastGravity.BOTTOM,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
setState(() => _inPlaylist = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
_buttonOnMenu(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 8),
|
||||||
|
child: CustomPaint(
|
||||||
|
size: Size(25, 25),
|
||||||
|
painter: ListenedAllPainter(
|
||||||
|
_marked ? context.accentColor : Colors.grey[700],
|
||||||
|
stroke: 2.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
if (widget.selectedList.isNotEmpty) {
|
||||||
|
if (!_marked) {
|
||||||
|
await _markListened();
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: s.markListened,
|
||||||
|
gravity: ToastGravity.BOTTOM,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await _markNotListened();
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: s.markNotListened,
|
||||||
|
gravity: ToastGravity.BOTTOM,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
Spacer(),
|
||||||
|
if (widget.selectAll == null)
|
||||||
|
SizedBox(
|
||||||
|
height: 40,
|
||||||
|
child: Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
||||||
|
child: Text(
|
||||||
|
'${widget.selectedList.length} selected',
|
||||||
|
style: context.textTheme.headline6
|
||||||
|
.copyWith(color: context.accentColor))),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_buttonOnMenu(
|
||||||
|
child: Icon(Icons.close),
|
||||||
|
onTap: () => widget.onClose(true))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user