Add setting - change tap to open popup menu.

This commit is contained in:
stonegate 2020-07-08 01:36:40 +08:00
parent 73d305e3e3
commit 3f2dba63c2
13 changed files with 171 additions and 406 deletions

View File

@ -260,6 +260,8 @@ class MessageLookup extends MessageLookupByLibrary {
"settingsStorageDes" : MessageLookupByLibrary.simpleMessage("Manange cache and download storage"),
"settingsSyncing" : MessageLookupByLibrary.simpleMessage("Syncing"),
"settingsSyncingDes" : MessageLookupByLibrary.simpleMessage("Refresh podcasts in the background"),
"settingsTapToOpenPopupMenu" : MessageLookupByLibrary.simpleMessage("Tap to open popup menu"),
"settingsTapToOpenPopupMenuDes" : MessageLookupByLibrary.simpleMessage("You need to long press to open episode page"),
"settingsTheme" : MessageLookupByLibrary.simpleMessage("Theme"),
"settingsUpdateInterval" : MessageLookupByLibrary.simpleMessage("Update interval"),
"settingsUpdateIntervalDes" : MessageLookupByLibrary.simpleMessage("Default 24 hours"),

View File

@ -260,6 +260,8 @@ class MessageLookup extends MessageLookupByLibrary {
"settingsStorageDes" : MessageLookupByLibrary.simpleMessage("管理缓存和下载空间"),
"settingsSyncing" : MessageLookupByLibrary.simpleMessage("同步"),
"settingsSyncingDes" : MessageLookupByLibrary.simpleMessage("在后台更新播客"),
"settingsTapToOpenPopupMenu" : MessageLookupByLibrary.simpleMessage("轻点打开弹出菜单"),
"settingsTapToOpenPopupMenuDes" : MessageLookupByLibrary.simpleMessage("开启后您需长按打开节目页"),
"settingsTheme" : MessageLookupByLibrary.simpleMessage("主题"),
"settingsUpdateInterval" : MessageLookupByLibrary.simpleMessage("更新频率"),
"settingsUpdateIntervalDes" : MessageLookupByLibrary.simpleMessage("默认 24 小时"),

View File

@ -1889,6 +1889,26 @@ class S {
);
}
/// `Tap to open popup menu`
String get settingsTapToOpenPopupMenu {
return Intl.message(
'Tap to open popup menu',
name: 'settingsTapToOpenPopupMenu',
desc: '',
args: [],
);
}
/// `You need to long press to open episode page`
String get settingsTapToOpenPopupMenuDes {
return Intl.message(
'You need to long press to open episode page',
name: 'settingsTapToOpenPopupMenuDes',
desc: '',
args: [],
);
}
/// `Theme`
String get settingsTheme {
return Intl.message(

View File

@ -493,13 +493,16 @@ class ShowEpisode extends StatelessWidget {
}
}
Future<Tuple4<int, bool, bool, List<int>>> _initData(
Future<Tuple5<int, bool, bool, bool, List<int>>> _initData(
EpisodeBrief episode) async {
List<int> menuList = await _getEpisodeMenu();
bool tapToOpen = await _getTapToOpenPopupMenu();
int listened = await _isListened(episode);
bool liked = await _isLiked(episode);
bool downloaded = await _isDownloaded(episode);
List<int> menuList = await _getEpisodeMenu();
return Tuple4(listened, liked, downloaded, menuList);
return Tuple5(listened, liked, downloaded, tapToOpen, menuList);
}
Future<int> _isListened(EpisodeBrief episode) async {
@ -523,6 +526,13 @@ class ShowEpisode extends StatelessWidget {
return await dbHelper.isDownloaded(episode.enclosureUrl);
}
Future<bool> _getTapToOpenPopupMenu() async {
KeyValueStorage tapToOpenPopupMenuStorage =
KeyValueStorage(tapToOpenPopupMenuKey);
int boo = await tapToOpenPopupMenuStorage.getInt(defaultValue: 0);
return boo == 1;
}
_markListened(EpisodeBrief episode) async {
DBHelper dbHelper = DBHelper();
bool marked = await dbHelper.checkMarked(episode);
@ -543,173 +553,6 @@ class ShowEpisode extends StatelessWidget {
await dbHelper.setUniked(url);
}
// _showPopupMenu(Offset offset, EpisodeBrief episode, BuildContext context,
// bool isPlaying, bool isInPlaylist) async {
// var audio = Provider.of<AudioPlayerNotifier>(context, listen: false);
// double left = offset.dx;
// double top = offset.dy;
// bool isLiked, isDownload;
// int isListened;
// var downloader = Provider.of<DownloadState>(context, listen: false);
// List<int> menuList = await _getEpisodeMenu();
// if (menuList.contains(3)) isListened = await _isListened(episode);
// if (menuList.contains(2)) isLiked = await _isLiked(episode);
// if (menuList.contains(4)) isDownload = await _isDownloaded(episode);
// await showMenu<int>(
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.all(Radius.circular(10))),
// context: context,
// position: RelativeRect.fromLTRB(left, top, context.width - left, 0),
// items: <PopupMenuEntry<int>>[
// PopupMenuItem(
// value: 0,
// child: Row(
// mainAxisAlignment: MainAxisAlignment.start,
// mainAxisSize: MainAxisSize.max,
// children: <Widget>[
// Icon(
// LineIcons.play_circle_solid,
// color: Theme.of(context).accentColor,
// ),
// Padding(
// padding: EdgeInsets.symmetric(horizontal: 2),
// ),
// !isPlaying ? Text('Play') : Text('Playing'),
// ],
// ),
// ),
// menuList.contains(1)
// ? PopupMenuItem(
// value: 1,
// child: Row(
// children: <Widget>[
// Icon(
// LineIcons.clock_solid,
// color: Colors.red,
// ),
// Padding(
// padding: EdgeInsets.symmetric(horizontal: 2),
// ),
// !isInPlaylist ? Text('Later') : Text('Remove')
// ],
// ))
// : null,
// menuList.contains(2)
// ? PopupMenuItem(
// value: 2,
// child: Row(
// children: <Widget>[
// Icon(LineIcons.heart, color: Colors.red, size: 21),
// Padding(
// padding: EdgeInsets.symmetric(horizontal: 2),
// ),
// isLiked
// ? Text(
// 'Unlike',
// )
// : Text('Like')
// ],
// ))
// : null,
// menuList.contains(3)
// ? PopupMenuItem(
// value: 3,
// child: Row(
// children: <Widget>[
// SizedBox(
// width: 23,
// height: 23,
// child: CustomPaint(
// painter:
// ListenedAllPainter(Colors.blue, stroke: 1.5)),
// ),
// Padding(
// padding: EdgeInsets.symmetric(horizontal: 2),
// ),
// isListened > 0
// ? Text('Listened',
// style: TextStyle(
// color: context.textColor.withOpacity(0.5)))
// : Text('Mark\nListened')
// ],
// ))
// : null,
// menuList.contains(4)
// ? PopupMenuItem(
// value: 4,
// child: Row(
// children: <Widget>[
// Icon(LineIcons.download_solid, color: Colors.green),
// Padding(
// padding: EdgeInsets.symmetric(horizontal: 2),
// ),
// isDownload
// ? Text('Downloaded',
// style: TextStyle(
// color: context.textColor.withOpacity(0.5)))
// : Text('Download')
// ],
// ))
// : null,
// ],
// elevation: 5.0,
// ).then((value) async {
// switch (value) {
// case 0:
// if (!isPlaying) audio.episodeLoad(episode);
// break;
// case 1:
// if (!isInPlaylist) {
// audio.addToPlaylist(episode);
// Fluttertoast.showToast(
// msg: 'Added to playlist',
// gravity: ToastGravity.BOTTOM,
// );
// } else {
// audio.delFromPlaylist(episode);
// Fluttertoast.showToast(
// msg: 'Removed from playlist',
// gravity: ToastGravity.BOTTOM,
// );
// }
// break;
// case 2:
// if (isLiked) {
// await _setUnliked(episode.enclosureUrl);
// audio.setEpisodeState = true;
// Fluttertoast.showToast(
// msg: 'Unliked',
// gravity: ToastGravity.BOTTOM,
// );
// } else {
// await _saveLiked(episode.enclosureUrl);
// audio.setEpisodeState = true;
// Fluttertoast.showToast(
// msg: 'Liked',
// gravity: ToastGravity.BOTTOM,
// );
// }
// break;
// case 3:
// if (isListened < 1) {
// await _markListened(episode);
// audio.setEpisodeState = true;
// Fluttertoast.showToast(
// msg: 'Mark listened',
// gravity: ToastGravity.BOTTOM,
// );
// }
// break;
//
// case 4:
// if (!isDownload) downloader.startTask(episode);
// break;
// default:
// break;
// }
// });
// }
//
@override
Widget build(BuildContext context) {
double _width = context.width;
@ -743,15 +586,16 @@ class ShowEpisode extends StatelessWidget {
.toList(),
),
builder: (_, data, __) => FutureBuilder<
Tuple4<int, bool, bool, List<int>>>(
Tuple5<int, bool, bool, bool, List<int>>>(
future: _initData(episodes[index]),
initialData: Tuple4(0, false, false, []),
initialData: Tuple5(0, false, false, false, []),
builder:
(BuildContext context, AsyncSnapshot snapshot) {
int isListened = snapshot.data.item1;
bool isLiked = snapshot.data.item2;
bool isDownloaded = snapshot.data.item3;
List<int> menuList = snapshot.data.item4;
bool tapToOpen = snapshot.data.item4;
List<int> menuList = snapshot.data.item5;
return Container(
decoration: BoxDecoration(
borderRadius:
@ -767,7 +611,9 @@ class ShowEpisode extends StatelessWidget {
borderRadius:
BorderRadius.all(Radius.circular(15.0))),
duration: Duration(milliseconds: 100),
tapMode: TapMode.onLongPress,
tapMode: tapToOpen
? TapMode.onTap
: TapMode.onLongPress,
animateMenuItems: false,
blurBackgroundColor:
context.brightness == Brightness.light

View File

@ -421,6 +421,10 @@
"@settingsSyncing": {},
"settingsSyncingDes": "Refresh podcasts in the background",
"@settingsSyncingDes": {},
"settingsTapToOpenPopupMenu": "Tap to open popup menu",
"@settingsTapToOpenPopupMenu": {},
"settingsTapToOpenPopupMenuDes": "You need to long press to open episode page",
"@settingsTapToOpenPopupMenuDes": {},
"settingsTheme": "Theme",
"@settingsTheme": {},
"settingStorage": "Storage",

View File

@ -421,6 +421,10 @@
"@settingsSyncing": {},
"settingsSyncingDes": "在后台更新播客",
"@settingsSyncingDes": {},
"settingsTapToOpenPopupMenu": "轻点打开弹出菜单",
"@settingsTapToOpenPopupMenu": {},
"settingsTapToOpenPopupMenuDes": "开启后您需长按打开节目页",
"@settingsTapToOpenPopupMenuDes": {},
"settingsTheme": "主题",
"@settingsTheme": {},
"settingStorage": "储存空间",

View File

@ -31,6 +31,7 @@ const String autoSleepTimerStartKey = 'autoSleepTimerStartKey';
const String autoSleepTimerEndKey = 'autoSleepTimerEndKey';
const String defaultSleepTimerKey = 'defaultSleepTimerKey';
const String autoSleepTimerModeKey = 'autoSleepTimerModeKey';
const String tapToOpenPopupMenuKey = 'tapToOpenPopupMenuKey';
class KeyValueStorage {
final String key;

View File

@ -22,7 +22,11 @@ class _LayoutSettingState extends State<LayoutSetting> {
}
Widget _gridOptions(BuildContext context,
{String key, Layout layout, Layout option, double scale}) =>
{String key,
Layout layout,
Layout option,
double scale,
BorderRadiusGeometry borderRadius}) =>
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: InkWell(
@ -31,13 +35,17 @@ class _LayoutSettingState extends State<LayoutSetting> {
await storage.saveInt(option.index);
setState(() {});
},
borderRadius: borderRadius,
child: AnimatedContainer(
duration: Duration(milliseconds: 400),
height: 30,
width: 50,
color: layout == option
? context.accentColor
: context.primaryColorDark,
decoration: BoxDecoration(
borderRadius: borderRadius,
color: layout == option
? context.accentColor
: context.primaryColorDark,
),
alignment: Alignment.center,
child: SizedBox(
height: 10,
@ -62,21 +70,31 @@ class _LayoutSettingState extends State<LayoutSetting> {
? Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
_gridOptions(context,
key: key,
layout: snapshot.data,
option: Layout.one,
scale: 4),
_gridOptions(context,
key: key,
layout: snapshot.data,
option: Layout.two,
scale: 1),
_gridOptions(
context,
key: key,
layout: snapshot.data,
option: Layout.one,
scale: 4,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(5),
topLeft: Radius.circular(5)),
),
_gridOptions(
context,
key: key,
layout: snapshot.data,
option: Layout.two,
scale: 1,
),
_gridOptions(context,
key: key,
layout: snapshot.data,
option: Layout.three,
scale: 0),
scale: 0,
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(5),
topRight: Radius.circular(5))),
],
)
: Center();

View File

@ -32,13 +32,20 @@ class PlaySetting extends StatelessWidget {
children: [
InkWell(
onTap: () => settings.setAutoSleepTimerMode = 0,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(5), topLeft: Radius.circular(5)),
child: Material(
color: Colors.transparent,
child: AnimatedContainer(
duration: Duration(milliseconds: 400),
color: data.item1 == 0
? context.accentColor
: context.primaryColorDark,
decoration: BoxDecoration(
color: data.item1 == 0
? context.accentColor
: context.primaryColorDark,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(5),
topLeft: Radius.circular(5)),
),
padding: const EdgeInsets.all(8.0),
child: Text(context.s.endOfEpisode,
style: TextStyle(
@ -48,13 +55,21 @@ class PlaySetting extends StatelessWidget {
),
InkWell(
onTap: () => settings.setAutoSleepTimerMode = 1,
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(5),
topRight: Radius.circular(5)),
child: Material(
color: Colors.transparent,
child: AnimatedContainer(
duration: Duration(milliseconds: 400),
color: data.item1 == 1
? context.accentColor
: context.primaryColorDark,
decoration: BoxDecoration(
color: data.item1 == 1
? context.accentColor
: context.primaryColorDark,
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(5),
topRight: Radius.circular(5)),
),
padding: const EdgeInsets.all(8.0),
child: Text(context.s.minsCount(data.item2),
style: TextStyle(
@ -130,10 +145,17 @@ class PlaySetting extends StatelessWidget {
],
);
},
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(5), topLeft: Radius.circular(5)),
child: Material(
color: Colors.transparent,
child: Container(
color: context.primaryColorDark,
decoration: BoxDecoration(
color: context.primaryColorDark,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(5),
topLeft: Radius.circular(5)),
),
padding: const EdgeInsets.all(8.0),
child: Text(s.from(stringForMins(data.item1))),
),
@ -189,11 +211,18 @@ class PlaySetting extends StatelessWidget {
],
);
},
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(5),
topRight: Radius.circular(5)),
child: Material(
color: Colors.transparent,
child: Container(
padding: const EdgeInsets.all(8.0),
color: Colors.black54,
decoration: BoxDecoration(
color: Colors.black54,
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(5),
topRight: Radius.circular(5))),
child: Text(s.to(stringForMins(data.item2)),
style: TextStyle(color: Colors.white)),
),

View File

@ -21,10 +21,24 @@ class _PopupMenuSettingState extends State<PopupMenuSetting> {
return list;
}
Future<bool> _getTapToOpenPopupMenu() async {
KeyValueStorage tapToOpenPopupMenuStorage =
KeyValueStorage(tapToOpenPopupMenuKey);
int boo = await tapToOpenPopupMenuStorage.getInt(defaultValue: 0);
return boo == 1;
}
_saveEpisodeMene(List<int> list) async {
KeyValueStorage popupMenuStorage = KeyValueStorage(episodePopupMenuKey);
await popupMenuStorage.saveMenu(list);
setState(() {});
if (mounted) setState(() {});
}
_saveTapToOpenPopupMenu(bool boo) async {
KeyValueStorage tapToOpenPopupMenuStorage =
KeyValueStorage(tapToOpenPopupMenuKey);
await tapToOpenPopupMenuStorage.saveInt(boo ? 1 : 0);
if (mounted) setState(() {});
}
Widget _popupMenuItem(List<int> menu, int e,
@ -116,6 +130,20 @@ class _PopupMenuSettingState extends State<PopupMenuSetting> {
.bodyText1
.copyWith(color: Theme.of(context).accentColor)),
),
FutureBuilder<bool>(
future: _getTapToOpenPopupMenu(),
initialData: false,
builder: (context, snapshot) => ListTile(
contentPadding:
EdgeInsets.only(left: 80, top: 10, bottom: 10, right: 30),
onTap: () => _saveTapToOpenPopupMenu(!snapshot.data),
title: Text(s.settingsTapToOpenPopupMenu),
subtitle: Text(s.settingsTapToOpenPopupMenuDes),
trailing: Switch(
value: snapshot.data,
onChanged: (bool boo) => _saveTapToOpenPopupMenu(boo)),
),
),
FutureBuilder<List<int>>(
future: _getEpisodeMenu(),
initialData: [0, 1, 12, 13, 14],

View File

@ -307,7 +307,7 @@ class _SettingsState extends State<Settings>
MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(width: 75),
SizedBox(width: 45),
_feedbackItem(
LineIcons.github,
s.feedbackGithub,

View File

@ -94,6 +94,8 @@ class SettingState extends ChangeNotifier {
KeyValueStorage(autoSleepTimerStartKey);
KeyValueStorage autoSleepTimerEndStorage =
KeyValueStorage(autoSleepTimerEndKey);
KeyValueStorage tapToOpenPopupMenuStorage =
KeyValueStorage(tapToOpenPopupMenuKey);
Future initData() async {
await _getTheme();

View File

@ -65,13 +65,14 @@ class EpisodeGrid extends StatelessWidget {
return await dbHelper.isListened(episode.enclosureUrl);
}
Future<Tuple4<int, bool, bool, List<int>>> _initData(
Future<Tuple5<int, bool, bool, bool, List<int>>> _initData(
EpisodeBrief episode) async {
List<int> menuList = await _getEpisodeMenu();
bool tapToOpen = await _getTapToOpenPopupMenu();
int listened = await _isListened(episode);
bool liked = await _isLiked(episode);
bool downloaded = await _isDownloaded(episode);
return Tuple4(listened, liked, downloaded, menuList);
return Tuple5(listened, liked, downloaded, tapToOpen, menuList);
}
Future<bool> _isLiked(EpisodeBrief episode) async {
@ -90,6 +91,13 @@ class EpisodeGrid extends StatelessWidget {
return await dbHelper.isDownloaded(episode.enclosureUrl);
}
Future<bool> _getTapToOpenPopupMenu() async {
KeyValueStorage tapToOpenPopupMenuStorage =
KeyValueStorage(tapToOpenPopupMenuKey);
int boo = await tapToOpenPopupMenuStorage.getInt(defaultValue: 0);
return boo == 1;
}
_markListened(EpisodeBrief episode) async {
DBHelper dbHelper = DBHelper();
bool marked = await dbHelper.checkMarked(episode);
@ -140,40 +148,6 @@ class EpisodeGrid extends StatelessWidget {
),
);
//Widget _listenIndicater(BuildContext context,
// {EpisodeBrief episode, int isListened}) =>
// Center();
// Selector<AudioPlayerNotifier, Tuple2<EpisodeBrief, bool>>(
// selector: (_, audio) => Tuple2(audio.episode, audio.playerRunning),
// builder: (_, data, __) {
// return (episode.enclosureUrl == data.item1?.enclosureUrl &&
// data.item2)
// ? Container(
// height: 20,
// width: 20,
// margin: EdgeInsets.symmetric(horizontal: 2),
// decoration: BoxDecoration(
// shape: BoxShape.circle,
// ),
// child: WaveLoader(color: context.accentColor))
// : layout != Layout.three && isListened > 0
// ? Container(
// height: 20,
// width: 20,
// margin: EdgeInsets.symmetric(horizontal: 2),
// padding: EdgeInsets.all(2),
// decoration: BoxDecoration(
// color: context.accentColor,
// shape: BoxShape.circle,
// ),
// child: CustomPaint(
// painter: ListenedAllPainter(
// Colors.white,
// )),
// )
// : Center();
// });
Widget _downloadIndicater(BuildContext context,
{EpisodeBrief episode, bool isDownloaded}) =>
showDownload || layout != Layout.three
@ -236,173 +210,6 @@ class EpisodeGrid extends StatelessWidget {
double _width = context.width;
var audio = Provider.of<AudioPlayerNotifier>(context, listen: false);
var downloader = Provider.of<DownloadState>(context, listen: false);
//Offset _offset;
//_showPopupMenu(Offset offset, EpisodeBrief episode, BuildContext context,
// {bool isPlaying, bool isInPlaylist}) async {
// bool isLiked, isDownload;
// int isListened;
// var audio = Provider.of<AudioPlayerNotifier>(context, listen: false);
// var downloader = Provider.of<DownloadState>(context, listen: false);
// double left = offset.dx;
// double top = offset.dy;
// List<int> menuList = await _getEpisodeMenu();
// if (menuList.contains(3)) isListened = await _isListened(episode);
// if (menuList.contains(2)) isLiked = await _isLiked(episode);
// if (menuList.contains(4)) isDownload = await _isDownloaded(episode);
// await showMenu<int>(
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.all(Radius.circular(10))),
// context: context,
// position: RelativeRect.fromLTRB(left, top, _width - left, 0),
// items: <PopupMenuEntry<int>>[
// PopupMenuItem(
// value: 0,
// child: Row(
// mainAxisAlignment: MainAxisAlignment.start,
// mainAxisSize: MainAxisSize.max,
// children: <Widget>[
// Icon(
// LineIcons.play_circle_solid,
// color: Theme.of(context).accentColor,
// ),
// Padding(
// padding: EdgeInsets.symmetric(horizontal: 2),
// ),
// !isPlaying ? Text('Play') : Text('Playing'),
// ],
// ),
// ),
// menuList.contains(1)
// ? PopupMenuItem(
// value: 1,
// child: Row(
// children: <Widget>[
// Icon(
// LineIcons.clock_solid,
// color: Colors.cyan,
// ),
// Padding(
// padding: EdgeInsets.symmetric(horizontal: 2),
// ),
// !isInPlaylist ? Text('Later') : Text('Remove')
// ],
// ))
// : null,
// menuList.contains(2)
// ? PopupMenuItem(
// value: 2,
// child: Row(
// children: <Widget>[
// Icon(LineIcons.heart, color: Colors.red, size: 21),
// Padding(
// padding: EdgeInsets.symmetric(horizontal: 2),
// ),
// isLiked
// ? Text(
// 'Unlike',
// )
// : Text('Like')
// ],
// ))
// : null,
// menuList.contains(3)
// ? PopupMenuItem(
// value: 3,
// child: Row(
// children: <Widget>[
// SizedBox(
// width: 23,
// height: 23,
// child: CustomPaint(
// painter:
// ListenedAllPainter(Colors.blue, stroke: 1.5)),
// ),
// Padding(
// padding: EdgeInsets.symmetric(horizontal: 2),
// ),
// isListened > 0
// ? Text('Listened',
// style: TextStyle(
// color: context.textColor.withOpacity(0.5)))
// : Text('Mark\nListened')
// ],
// ))
// : null,
// menuList.contains(4)
// ? PopupMenuItem(
// value: 4,
// child: Row(
// children: <Widget>[
// Icon(LineIcons.download_solid, color: Colors.green),
// Padding(
// padding: EdgeInsets.symmetric(horizontal: 2),
// ),
// isDownload
// ? Text('Downloaded',
// style: TextStyle(
// color: context.textColor.withOpacity(0.5)))
// : Text('Download')
// ],
// ))
// : null,
// ],
// elevation: 5.0,
// ).then((value) async {
// switch (value) {
// case 0:
// if (!isPlaying) audio.episodeLoad(episode);
// break;
// case 1:
// if (!isInPlaylist) {
// audio.addToPlaylist(episode);
// Fluttertoast.showToast(
// msg: 'Added to playlist',
// gravity: ToastGravity.BOTTOM,
// );
// } else {
// audio.delFromPlaylist(episode);
// Fluttertoast.showToast(
// msg: 'Removed from playlist',
// gravity: ToastGravity.BOTTOM,
// );
// }
// break;
// case 2:
// if (isLiked) {
// await _setUnliked(episode.enclosureUrl);
// audio.setEpisodeState = true;
// Fluttertoast.showToast(
// msg: 'Unliked',
// gravity: ToastGravity.BOTTOM,
// );
// } else {
// await _saveLiked(episode.enclosureUrl);
// audio.setEpisodeState = true;
// Fluttertoast.showToast(
// msg: 'Liked',
// gravity: ToastGravity.BOTTOM,
// );
// }
// break;
// case 3:
// if (isListened < 1) {
// await _markListened(episode);
// audio.setEpisodeState = true;
// Fluttertoast.showToast(
// msg: 'Mark listened',
// gravity: ToastGravity.BOTTOM,
// );
// }
// break;
// case 4:
// if (!isDownload) downloader.startTask(episode);
// break;
// default:
// break;
// }
// });
//}
final options = LiveOptions(
delay: Duration.zero,
showItemInterval: Duration(milliseconds: 50),
@ -443,14 +250,15 @@ class EpisodeGrid extends StatelessWidget {
builder: (_, data, __) => OpenContainerWrapper(
episode: episodes[index],
closedBuilder: (context, action, boo) => FutureBuilder<
Tuple4<int, bool, bool, List<int>>>(
Tuple5<int, bool, bool, bool, List<int>>>(
future: _initData(episodes[index]),
initialData: Tuple4(0, false, false, []),
initialData: Tuple5(0, false, false, false, []),
builder: (BuildContext context, AsyncSnapshot snapshot) {
int isListened = snapshot.data.item1;
bool isLiked = snapshot.data.item2;
bool isDownloaded = snapshot.data.item3;
List<int> menuList = snapshot.data.item4;
bool tapToOpen = snapshot.data.item4;
List<int> menuList = snapshot.data.item5;
return Container(
decoration: BoxDecoration(
borderRadius:
@ -489,7 +297,8 @@ class EpisodeGrid extends StatelessWidget {
borderRadius:
BorderRadius.all(Radius.circular(15.0))),
duration: Duration(milliseconds: 100),
tapMode: TapMode.onTap,
tapMode:
tapToOpen ? TapMode.onTap : TapMode.onLongPress,
animateMenuItems: false,
blurBackgroundColor:
context.brightness == Brightness.light