Bug fixs, playlist item was wrongly deleted
This commit is contained in:
parent
17c3fbdbb7
commit
f219ac9d3f
|
@ -273,71 +273,73 @@ class __QueueState extends State<_Queue> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<AudioPlayerNotifier, Tuple3<Playlist, bool, EpisodeBrief>>(
|
||||
selector: (_, audio) =>
|
||||
Tuple3(audio.playlist, audio.playerRunning, audio.episode),
|
||||
builder: (_, data, __) {
|
||||
var episodes = data.item1?.episodes?.toSet()?.toList();
|
||||
var queue = data.item1;
|
||||
var running = data.item2;
|
||||
return queue == null
|
||||
? Center()
|
||||
: queue?.name == 'Queue'
|
||||
? ReorderableListView(
|
||||
onReorder: (oldIndex, newIndex) {
|
||||
context
|
||||
.read<AudioPlayerNotifier>()
|
||||
.reorderPlaylist(oldIndex, newIndex);
|
||||
setState(() {});
|
||||
},
|
||||
scrollDirection: Axis.vertical,
|
||||
children: data.item2
|
||||
? episodes.map<Widget>((episode) {
|
||||
if (episode.enclosureUrl !=
|
||||
episodes.first.enclosureUrl) {
|
||||
return DismissibleContainer(
|
||||
selector: (_, audio) =>
|
||||
Tuple3(audio.playlist, audio.playerRunning, audio.episode),
|
||||
builder: (_, data, __) {
|
||||
var episodes = data.item1?.episodes?.toSet()?.toList();
|
||||
var queue = data.item1;
|
||||
var running = data.item2;
|
||||
return queue == null
|
||||
? Center()
|
||||
: queue.isQueue
|
||||
? ReorderableListView(
|
||||
onReorder: (oldIndex, newIndex) {
|
||||
context
|
||||
.read<AudioPlayerNotifier>()
|
||||
.reorderPlaylist(oldIndex, newIndex);
|
||||
setState(() {});
|
||||
},
|
||||
scrollDirection: Axis.vertical,
|
||||
children: data.item2
|
||||
? episodes.map<Widget>((episode) {
|
||||
if (episode.enclosureUrl !=
|
||||
episodes.first.enclosureUrl) {
|
||||
return DismissibleContainer(
|
||||
episode: episode,
|
||||
onRemove: (value) => setState(() {}),
|
||||
key: ValueKey(episode.enclosureUrl),
|
||||
);
|
||||
} else {
|
||||
return EpisodeCard(episode,
|
||||
key: ValueKey('playing'),
|
||||
isPlaying: true,
|
||||
canReorder: true,
|
||||
tileColor: context.primaryColorDark);
|
||||
}
|
||||
}).toList()
|
||||
: episodes
|
||||
.map<Widget>((episode) => DismissibleContainer(
|
||||
episode: episode,
|
||||
onRemove: (value) => setState(() {}),
|
||||
key: ValueKey(episode.enclosureUrl),
|
||||
);
|
||||
} else {
|
||||
return EpisodeCard(episode,
|
||||
key: ValueKey('playing'),
|
||||
isPlaying: true,
|
||||
canReorder: true,
|
||||
tileColor: context.primaryColorDark);
|
||||
}
|
||||
}).toList()
|
||||
: episodes
|
||||
.map<Widget>((episode) => DismissibleContainer(
|
||||
episode: episode,
|
||||
onRemove: (value) => setState(() {}),
|
||||
key: ValueKey(episode.enclosureUrl),
|
||||
))
|
||||
.toList())
|
||||
: ListView.builder(
|
||||
itemCount: queue?.length,
|
||||
itemBuilder: (context, index) {
|
||||
final episode =
|
||||
queue != null ? queue.episodes[index] : null;
|
||||
final isPlaying =
|
||||
data.item3 != null && data.item3 == episode;
|
||||
return episode == null
|
||||
? Center()
|
||||
: EpisodeCard(
|
||||
episode,
|
||||
isPlaying: isPlaying && running,
|
||||
tileColor:
|
||||
isPlaying ? context.primaryColorDark : null,
|
||||
onTap: () async {
|
||||
if (!isPlaying) {
|
||||
await context
|
||||
.read<AudioPlayerNotifier>()
|
||||
.loadEpisodeFromPlaylist(episode);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
))
|
||||
.toList())
|
||||
: ListView.builder(
|
||||
itemCount: queue?.length,
|
||||
itemBuilder: (context, index) {
|
||||
final episode =
|
||||
queue != null ? queue.episodes[index] : null;
|
||||
final isPlaying =
|
||||
data.item3 != null && data.item3 == episode;
|
||||
return episode == null
|
||||
? Center()
|
||||
: EpisodeCard(
|
||||
episode,
|
||||
isPlaying: isPlaying && running,
|
||||
tileColor:
|
||||
isPlaying ? context.primaryColorDark : null,
|
||||
onTap: () async {
|
||||
if (!isPlaying) {
|
||||
await context
|
||||
.read<AudioPlayerNotifier>()
|
||||
.loadEpisodeFromPlaylist(episode);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,157 +33,91 @@ class _DismissibleContainerState extends State<DismissibleContainer> {
|
|||
duration: Duration(milliseconds: 300),
|
||||
curve: Curves.easeInSine,
|
||||
alignment: Alignment.center,
|
||||
height: _delete ? 0 : 90.0,
|
||||
height: _delete ? 0 : 91.0,
|
||||
child: _delete
|
||||
? Container(
|
||||
color: Colors.transparent,
|
||||
)
|
||||
: Dismissible(
|
||||
key: ValueKey('${widget.episode.enclosureUrl}dis'),
|
||||
background: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle, color: Colors.red),
|
||||
padding: EdgeInsets.all(5),
|
||||
alignment: Alignment.center,
|
||||
child: Icon(
|
||||
LineIcons.trash_alt_solid,
|
||||
color: Colors.white,
|
||||
size: 15,
|
||||
: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Dismissible(
|
||||
key: ValueKey('${widget.episode.enclosureUrl}dis'),
|
||||
background: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20.0),
|
||||
height: 30,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle, color: Colors.red),
|
||||
padding: EdgeInsets.all(5),
|
||||
alignment: Alignment.center,
|
||||
child: Icon(
|
||||
LineIcons.trash_alt_solid,
|
||||
color: Colors.white,
|
||||
size: 15,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle, color: Colors.red),
|
||||
padding: EdgeInsets.all(5),
|
||||
alignment: Alignment.center,
|
||||
child: Icon(
|
||||
LineIcons.trash_alt_solid,
|
||||
color: Colors.white,
|
||||
size: 15,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle, color: Colors.red),
|
||||
padding: EdgeInsets.all(5),
|
||||
alignment: Alignment.center,
|
||||
child: Icon(
|
||||
LineIcons.trash_alt_solid,
|
||||
color: Colors.white,
|
||||
size: 15,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
height: 30,
|
||||
color: context.accentColor,
|
||||
),
|
||||
onDismissed: (direction) async {
|
||||
setState(() {
|
||||
_delete = true;
|
||||
});
|
||||
var index = await context
|
||||
.read<AudioPlayerNotifier>()
|
||||
.delFromPlaylist(widget.episode);
|
||||
widget.onRemove(true);
|
||||
final episodeRemove = widget.episode;
|
||||
Scaffold.of(context).removeCurrentSnackBar();
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
behavior: SnackBarBehavior.floating,
|
||||
backgroundColor: Colors.grey[800],
|
||||
content: Text(s.toastRemovePlaylist,
|
||||
style: TextStyle(color: Colors.white)),
|
||||
action: SnackBarAction(
|
||||
textColor: context.accentColor,
|
||||
label: s.undo,
|
||||
onPressed: () async {
|
||||
onDismissed: (direction) async {
|
||||
setState(() {
|
||||
_delete = true;
|
||||
});
|
||||
var index = await context
|
||||
.read<AudioPlayerNotifier>()
|
||||
.delFromPlaylist(widget.episode);
|
||||
widget.onRemove(true);
|
||||
final episodeRemove = widget.episode;
|
||||
Scaffold.of(context).removeCurrentSnackBar();
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
behavior: SnackBarBehavior.floating,
|
||||
backgroundColor: Colors.grey[800],
|
||||
content: Text(s.toastRemovePlaylist,
|
||||
style: TextStyle(color: Colors.white)),
|
||||
action: SnackBarAction(
|
||||
textColor: context.accentColor,
|
||||
label: s.undo,
|
||||
onPressed: () async {
|
||||
await context
|
||||
.read<AudioPlayerNotifier>()
|
||||
.addToPlaylistAt(episodeRemove, index);
|
||||
widget.onRemove(false);
|
||||
}),
|
||||
));
|
||||
},
|
||||
child: EpisodeCard(
|
||||
widget.episode,
|
||||
isPlaying: false,
|
||||
canReorder: true,
|
||||
showDivider: false,
|
||||
onTap: () async {
|
||||
await context
|
||||
.read<AudioPlayerNotifier>()
|
||||
.addToPlaylistAt(episodeRemove, index);
|
||||
widget.onRemove(false);
|
||||
}),
|
||||
));
|
||||
},
|
||||
child: EpisodeCard(
|
||||
widget.episode,
|
||||
isPlaying: false,
|
||||
canReorder: true,
|
||||
onTap: () async {
|
||||
await context
|
||||
.read<AudioPlayerNotifier>()
|
||||
.episodeLoad(widget.episode);
|
||||
widget.onRemove(true);
|
||||
},
|
||||
),
|
||||
// SizedBox(
|
||||
// height: 90.0,
|
||||
// child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
// children: <Widget>[
|
||||
// Expanded(
|
||||
// child: ListTile(
|
||||
// contentPadding: EdgeInsets.symmetric(vertical: 8),
|
||||
// onTap: () async {
|
||||
// await context
|
||||
// .read<AudioPlayerNotifier>()
|
||||
// .episodeLoad(widget.episode);
|
||||
// widget.onRemove(true);
|
||||
// },
|
||||
// title: Container(
|
||||
// padding: EdgeInsets.fromLTRB(0, 5.0, 20.0, 5.0),
|
||||
// child: Text(
|
||||
// widget.episode.title,
|
||||
// maxLines: 1,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// ),
|
||||
// ),
|
||||
// leading: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// Icon(Icons.unfold_more, color: c),
|
||||
// CircleAvatar(
|
||||
// backgroundColor: c.withOpacity(0.5),
|
||||
// backgroundImage: widget.episode.avatarImage),
|
||||
// ],
|
||||
// ),
|
||||
// subtitle: Container(
|
||||
// padding: EdgeInsets.only(top: 5, bottom: 5),
|
||||
// height: 35,
|
||||
// child: Row(
|
||||
// children: <Widget>[
|
||||
// if (widget.episode.explicit == 1)
|
||||
// Container(
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.red[800],
|
||||
// shape: BoxShape.circle),
|
||||
// height: 25.0,
|
||||
// width: 25.0,
|
||||
// margin: EdgeInsets.only(right: 10.0),
|
||||
// alignment: Alignment.center,
|
||||
// child: Text('E',
|
||||
// style: TextStyle(color: Colors.white))),
|
||||
// if (widget.episode.duration != 0)
|
||||
// episodeTag(
|
||||
// widget.episode.duration == 0
|
||||
// ? ''
|
||||
// : s.minsCount(
|
||||
// widget.episode.duration ~/ 60),
|
||||
// Colors.cyan[300]),
|
||||
// if (widget.episode.enclosureLength != null)
|
||||
// episodeTag(
|
||||
// widget.episode.enclosureLength == 0
|
||||
// ? ''
|
||||
// : '${(widget.episode.enclosureLength) ~/ 1000000}MB',
|
||||
// Colors.lightBlue[300]),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// //trailing: Icon(Icons.menu),
|
||||
// ),
|
||||
// ),
|
||||
// Divider(
|
||||
// height: 2,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
),
|
||||
.episodeLoad(widget.episode);
|
||||
widget.onRemove(true);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(height: 1)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -194,13 +128,16 @@ class EpisodeCard extends StatelessWidget {
|
|||
final VoidCallback onTap;
|
||||
final bool isPlaying;
|
||||
final bool canReorder;
|
||||
final bool showDivider;
|
||||
const EpisodeCard(this.episode,
|
||||
{this.tileColor,
|
||||
this.onTap,
|
||||
this.isPlaying,
|
||||
this.canReorder = false,
|
||||
this.showDivider = true,
|
||||
Key key})
|
||||
: assert(episode != null), super(key: key);
|
||||
: assert(episode != null),
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -278,9 +215,7 @@ class EpisodeCard extends StatelessWidget {
|
|||
: SizedBox(width: 1),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
height: 1,
|
||||
),
|
||||
if (showDivider) Divider(height: 1),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue