Minor change.

This commit is contained in:
Stonegate 2021-01-02 20:38:30 +08:00
parent 196f48e7a9
commit ac2cace335
3 changed files with 11 additions and 53 deletions

View File

@ -29,6 +29,7 @@ class _PlaylistDetailState extends State<PlaylistDetail> {
@override
Widget build(BuildContext context) {
final s = context.s;
return Scaffold(
appBar: AppBar(
leading: IconButton(
@ -40,7 +41,7 @@ class _PlaylistDetailState extends State<PlaylistDetail> {
},
),
title: Text(_selectedEpisodes.isEmpty
? widget.playlist.name
? widget.playlist.isQueue ? s.queue :widget.playlist.name
: '${_selectedEpisodes.length} selected'),
actions: [
if (_selectedEpisodes.isNotEmpty)
@ -79,35 +80,6 @@ class _PlaylistDetailState extends State<PlaylistDetail> {
setState(() {});
}),
),
//SizedBox(
// height: 40,
// width: 40,
// child: Material(
// color: Colors.transparent,
// borderRadius: BorderRadius.circular(100),
// clipBehavior: Clip.hardEdge,
// child: SizedBox(
// height: 40,
// width: 40,
// child: PopupMenuButton<int>(
// icon: Icon(Icons.more_vert),
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(10)),
// elevation: 1,
// tooltip: s.menu,
// itemBuilder: (context) => [
// PopupMenuItem(value: 1, child: Text('Clear all')),
// ],
// onSelected: (value) {
// if (value == 1) {
// context
// .read<AudioPlayerNotifier>()
// .clearPlaylist(widget.playlist);
// }
// }),
// ),
// ),
//)
],
),
body: Selector<AudioPlayerNotifier, List<Playlist>>(
@ -389,7 +361,7 @@ class __PlaylistSettingState extends State<_PlaylistSetting> {
children: [
Icon(Icons.delete, color: Colors.red, size: 18),
SizedBox(width: 20),
Text('Remove playlist',
Text(s.remove,
style: textStyle.copyWith(
color: Colors.red, fontWeight: FontWeight.bold)),
],

View File

@ -1,18 +0,0 @@
import 'package:state_notifier/state_notifier.dart';
import '../local_storage/key_value_storage.dart';
import '../type/playlist.dart';
class PlaylistProvider extends StateNotifier<List<Playlist>> {
PlaylistProvider() : super([]);
Future<void> loadPlaylist() async {
var storage = KeyValueStorage(playlistsAllKey);
var playlistEntities = await storage.getPlaylists();
var initState = [...playlistEntities.map(Playlist.fromEntity).toList()];
for (var playlist in initState) {
await playlist.getPlaylist();
}
state = initState;
}
}

View File

@ -34,11 +34,11 @@ class Playlist extends Equatable {
/// Eposides in playlist.
final List<EpisodeBrief> episodes;
bool get isEmpty => episodes.isEmpty && episodeList.isEmpty;
bool get isEmpty => episodeList.isEmpty;
bool get isNotEmpty => episodes.isNotEmpty && episodeList.isNotEmpty;
bool get isNotEmpty => episodeList.isNotEmpty;
int get length => episodes.length;
int get length => episodeList.length;
bool get isQueue => name == 'Queue';
@ -71,7 +71,11 @@ class Playlist extends Equatable {
if (episodeList.isNotEmpty) {
for (var url in episodeList) {
var episode = await _dbHelper.getRssItemWithUrl(url);
if (episode != null) episodes.add(episode);
if (episode != null) {
episodes.add(episode);
} else {
episodeList.remove(url);
}
}
}
}