mirror of
https://github.com/stonega/tsacdop
synced 2025-01-20 19:10:48 +01:00
Bug fix.
This commit is contained in:
parent
e098ff07c5
commit
d985b0a197
@ -425,14 +425,14 @@ class _MenuBarState extends State<MenuBar> {
|
||||
return await dbHelper.isLiked(episode.enclosureUrl);
|
||||
}
|
||||
|
||||
Widget _buttonOnMenu(Widget widget, VoidCallback onTap) => Material(
|
||||
Widget _buttonOnMenu({Widget child, VoidCallback onTap}) => Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
height: 50.0,
|
||||
padding: EdgeInsets.symmetric(horizontal: 15.0),
|
||||
child: widget),
|
||||
child: child),
|
||||
),
|
||||
);
|
||||
|
||||
@ -499,49 +499,55 @@ class _MenuBarState extends State<MenuBar> {
|
||||
builder: (context, snapshot) {
|
||||
return (!snapshot.data)
|
||||
? _buttonOnMenu(
|
||||
Icon(
|
||||
child: Icon(
|
||||
Icons.favorite_border,
|
||||
color: Colors.grey[700],
|
||||
), () async {
|
||||
await saveLiked(widget.episodeItem.enclosureUrl);
|
||||
OverlayEntry _overlayEntry;
|
||||
_overlayEntry = _createOverlayEntry();
|
||||
Overlay.of(context).insert(_overlayEntry);
|
||||
await Future.delayed(Duration(seconds: 2));
|
||||
_overlayEntry?.remove();
|
||||
})
|
||||
),
|
||||
onTap: () async {
|
||||
await saveLiked(
|
||||
widget.episodeItem.enclosureUrl);
|
||||
OverlayEntry _overlayEntry;
|
||||
_overlayEntry = _createOverlayEntry();
|
||||
Overlay.of(context).insert(_overlayEntry);
|
||||
await Future.delayed(Duration(seconds: 2));
|
||||
_overlayEntry?.remove();
|
||||
})
|
||||
: _buttonOnMenu(
|
||||
Icon(
|
||||
child: Icon(
|
||||
Icons.favorite,
|
||||
color: Colors.red,
|
||||
),
|
||||
() =>
|
||||
onTap: () =>
|
||||
setUnliked(widget.episodeItem.enclosureUrl));
|
||||
},
|
||||
),
|
||||
DownloadButton(episode: widget.episodeItem),
|
||||
Selector<AudioPlayerNotifier, List<EpisodeBrief>>(
|
||||
selector: (_, audio) => audio.queue.playlist,
|
||||
Selector<AudioPlayerNotifier,
|
||||
Tuple2<List<EpisodeBrief>, bool>>(
|
||||
selector: (_, audio) =>
|
||||
Tuple2(audio.queue.playlist, audio.queueUpdate),
|
||||
builder: (_, data, __) {
|
||||
return data.contains(widget.episodeItem)
|
||||
return data.item1.contains(widget.episodeItem)
|
||||
? _buttonOnMenu(
|
||||
Icon(Icons.playlist_add_check,
|
||||
color: context.accentColor), () {
|
||||
audio.delFromPlaylist(widget.episodeItem);
|
||||
Fluttertoast.showToast(
|
||||
msg: s.toastRemovePlaylist,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
})
|
||||
child: Icon(Icons.playlist_add_check,
|
||||
color: context.accentColor),
|
||||
onTap: () {
|
||||
audio.delFromPlaylist(widget.episodeItem);
|
||||
Fluttertoast.showToast(
|
||||
msg: s.toastRemovePlaylist,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
})
|
||||
: _buttonOnMenu(
|
||||
Icon(Icons.playlist_add, color: Colors.grey[700]),
|
||||
() {
|
||||
Fluttertoast.showToast(
|
||||
msg: s.toastAddPlaylist,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
audio.addToPlaylist(widget.episodeItem);
|
||||
});
|
||||
child: Icon(Icons.playlist_add,
|
||||
color: Colors.grey[700]),
|
||||
onTap: () {
|
||||
audio.addToPlaylist(widget.episodeItem);
|
||||
Fluttertoast.showToast(
|
||||
msg: s.toastAddPlaylist,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
FutureBuilder<PlayHistory>(
|
||||
|
@ -982,7 +982,7 @@ class DBHelper {
|
||||
await txn.rawUpdate(
|
||||
"UPDATE Episodes SET is_new = 0 WHERE enclosure_url = ?", [url]);
|
||||
});
|
||||
print('remove new episode');
|
||||
print('remove new episode $url');
|
||||
}
|
||||
|
||||
Future<List<EpisodeBrief>> getLikedRssItem(int i, int sortBy) async {
|
||||
|
@ -464,6 +464,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||
await AudioService.addQueueItem(episodeNew.toMediaItem());
|
||||
}
|
||||
await _queue.addToPlayList(episodeNew);
|
||||
_queueUpdate = !_queueUpdate;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,7 @@ import 'episodebrief.dart';
|
||||
class Playlist {
|
||||
String name;
|
||||
DBHelper dbHelper = DBHelper();
|
||||
|
||||
List<EpisodeBrief> _playlist;
|
||||
|
||||
List<EpisodeBrief> get playlist => _playlist;
|
||||
KeyValueStorage storage = KeyValueStorage('playlist');
|
||||
|
||||
@ -17,7 +15,6 @@ class Playlist {
|
||||
_playlist = [];
|
||||
} else {
|
||||
_playlist = [];
|
||||
|
||||
for (var url in urls) {
|
||||
var episode = await dbHelper.getRssItemWithUrl(url);
|
||||
if (episode != null) _playlist.add(episode);
|
||||
@ -35,7 +32,9 @@ class Playlist {
|
||||
if (!_playlist.contains(episodeBrief)) {
|
||||
_playlist.add(episodeBrief);
|
||||
await savePlaylist();
|
||||
dbHelper.removeEpisodeNewMark(episodeBrief.enclosureUrl);
|
||||
if (episodeBrief.isNew == 1) {
|
||||
await dbHelper.removeEpisodeNewMark(episodeBrief.enclosureUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +42,9 @@ class Playlist {
|
||||
if (!_playlist.contains(episodeBrief)) {
|
||||
_playlist.insert(index, episodeBrief);
|
||||
await savePlaylist();
|
||||
dbHelper.removeEpisodeNewMark(episodeBrief.enclosureUrl);
|
||||
if (episodeBrief.isNew == 1) {
|
||||
await dbHelper.removeEpisodeNewMark(episodeBrief.enclosureUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,9 @@ extension IntExtension on int {
|
||||
final s = context.s;
|
||||
var date = DateTime.fromMillisecondsSinceEpoch(this, isUtc: true);
|
||||
var difference = DateTime.now().toUtc().difference(date);
|
||||
if (difference.inHours < 24) {
|
||||
if (difference.inMinutes < 30) {
|
||||
return s.hoursAgo(0);
|
||||
} else if (difference.inHours < 24) {
|
||||
return s.hoursAgo(difference.inHours);
|
||||
} else if (difference.inDays < 7) {
|
||||
return s.daysAgo(difference.inDays);
|
||||
|
Loading…
Reference in New Issue
Block a user