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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Selector<AudioPlayerNotifier, Tuple3<Playlist, bool, EpisodeBrief>>(
|
return Selector<AudioPlayerNotifier, Tuple3<Playlist, bool, EpisodeBrief>>(
|
||||||
selector: (_, audio) =>
|
selector: (_, audio) =>
|
||||||
Tuple3(audio.playlist, audio.playerRunning, audio.episode),
|
Tuple3(audio.playlist, audio.playerRunning, audio.episode),
|
||||||
builder: (_, data, __) {
|
builder: (_, data, __) {
|
||||||
var episodes = data.item1?.episodes?.toSet()?.toList();
|
var episodes = data.item1?.episodes?.toSet()?.toList();
|
||||||
var queue = data.item1;
|
var queue = data.item1;
|
||||||
var running = data.item2;
|
var running = data.item2;
|
||||||
return queue == null
|
return queue == null
|
||||||
? Center()
|
? Center()
|
||||||
: queue?.name == 'Queue'
|
: queue.isQueue
|
||||||
? ReorderableListView(
|
? ReorderableListView(
|
||||||
onReorder: (oldIndex, newIndex) {
|
onReorder: (oldIndex, newIndex) {
|
||||||
context
|
context
|
||||||
.read<AudioPlayerNotifier>()
|
.read<AudioPlayerNotifier>()
|
||||||
.reorderPlaylist(oldIndex, newIndex);
|
.reorderPlaylist(oldIndex, newIndex);
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
scrollDirection: Axis.vertical,
|
scrollDirection: Axis.vertical,
|
||||||
children: data.item2
|
children: data.item2
|
||||||
? episodes.map<Widget>((episode) {
|
? episodes.map<Widget>((episode) {
|
||||||
if (episode.enclosureUrl !=
|
if (episode.enclosureUrl !=
|
||||||
episodes.first.enclosureUrl) {
|
episodes.first.enclosureUrl) {
|
||||||
return DismissibleContainer(
|
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,
|
episode: episode,
|
||||||
onRemove: (value) => setState(() {}),
|
onRemove: (value) => setState(() {}),
|
||||||
key: ValueKey(episode.enclosureUrl),
|
key: ValueKey(episode.enclosureUrl),
|
||||||
);
|
))
|
||||||
} else {
|
.toList())
|
||||||
return EpisodeCard(episode,
|
: ListView.builder(
|
||||||
key: ValueKey('playing'),
|
itemCount: queue?.length,
|
||||||
isPlaying: true,
|
itemBuilder: (context, index) {
|
||||||
canReorder: true,
|
final episode =
|
||||||
tileColor: context.primaryColorDark);
|
queue != null ? queue.episodes[index] : null;
|
||||||
}
|
final isPlaying =
|
||||||
}).toList()
|
data.item3 != null && data.item3 == episode;
|
||||||
: episodes
|
return episode == null
|
||||||
.map<Widget>((episode) => DismissibleContainer(
|
? Center()
|
||||||
episode: episode,
|
: EpisodeCard(
|
||||||
onRemove: (value) => setState(() {}),
|
episode,
|
||||||
key: ValueKey(episode.enclosureUrl),
|
isPlaying: isPlaying && running,
|
||||||
))
|
tileColor:
|
||||||
.toList())
|
isPlaying ? context.primaryColorDark : null,
|
||||||
: ListView.builder(
|
onTap: () async {
|
||||||
itemCount: queue?.length,
|
if (!isPlaying) {
|
||||||
itemBuilder: (context, index) {
|
await context
|
||||||
final episode =
|
.read<AudioPlayerNotifier>()
|
||||||
queue != null ? queue.episodes[index] : null;
|
.loadEpisodeFromPlaylist(episode);
|
||||||
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),
|
duration: Duration(milliseconds: 300),
|
||||||
curve: Curves.easeInSine,
|
curve: Curves.easeInSine,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
height: _delete ? 0 : 90.0,
|
height: _delete ? 0 : 91.0,
|
||||||
child: _delete
|
child: _delete
|
||||||
? Container(
|
? Container(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
)
|
)
|
||||||
: Dismissible(
|
: Column(
|
||||||
key: ValueKey('${widget.episode.enclosureUrl}dis'),
|
children: [
|
||||||
background: Container(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20.0),
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||||
child: Row(
|
child: Dismissible(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
key: ValueKey('${widget.episode.enclosureUrl}dis'),
|
||||||
children: <Widget>[
|
background: Container(
|
||||||
Container(
|
padding: EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
decoration: BoxDecoration(
|
height: 30,
|
||||||
shape: BoxShape.circle, color: Colors.red),
|
child: Row(
|
||||||
padding: EdgeInsets.all(5),
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
alignment: Alignment.center,
|
children: <Widget>[
|
||||||
child: Icon(
|
Container(
|
||||||
LineIcons.trash_alt_solid,
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
shape: BoxShape.circle, color: Colors.red),
|
||||||
size: 15,
|
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(
|
onDismissed: (direction) async {
|
||||||
decoration: BoxDecoration(
|
setState(() {
|
||||||
shape: BoxShape.circle, color: Colors.red),
|
_delete = true;
|
||||||
padding: EdgeInsets.all(5),
|
});
|
||||||
alignment: Alignment.center,
|
var index = await context
|
||||||
child: Icon(
|
.read<AudioPlayerNotifier>()
|
||||||
LineIcons.trash_alt_solid,
|
.delFromPlaylist(widget.episode);
|
||||||
color: Colors.white,
|
widget.onRemove(true);
|
||||||
size: 15,
|
final episodeRemove = widget.episode;
|
||||||
),
|
Scaffold.of(context).removeCurrentSnackBar();
|
||||||
),
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
],
|
behavior: SnackBarBehavior.floating,
|
||||||
),
|
backgroundColor: Colors.grey[800],
|
||||||
height: 30,
|
content: Text(s.toastRemovePlaylist,
|
||||||
color: context.accentColor,
|
style: TextStyle(color: Colors.white)),
|
||||||
),
|
action: SnackBarAction(
|
||||||
onDismissed: (direction) async {
|
textColor: context.accentColor,
|
||||||
setState(() {
|
label: s.undo,
|
||||||
_delete = true;
|
onPressed: () async {
|
||||||
});
|
await context
|
||||||
var index = await context
|
.read<AudioPlayerNotifier>()
|
||||||
.read<AudioPlayerNotifier>()
|
.addToPlaylistAt(episodeRemove, index);
|
||||||
.delFromPlaylist(widget.episode);
|
widget.onRemove(false);
|
||||||
widget.onRemove(true);
|
}),
|
||||||
final episodeRemove = widget.episode;
|
));
|
||||||
Scaffold.of(context).removeCurrentSnackBar();
|
},
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
child: EpisodeCard(
|
||||||
behavior: SnackBarBehavior.floating,
|
widget.episode,
|
||||||
backgroundColor: Colors.grey[800],
|
isPlaying: false,
|
||||||
content: Text(s.toastRemovePlaylist,
|
canReorder: true,
|
||||||
style: TextStyle(color: Colors.white)),
|
showDivider: false,
|
||||||
action: SnackBarAction(
|
onTap: () async {
|
||||||
textColor: context.accentColor,
|
|
||||||
label: s.undo,
|
|
||||||
onPressed: () async {
|
|
||||||
await context
|
await context
|
||||||
.read<AudioPlayerNotifier>()
|
.read<AudioPlayerNotifier>()
|
||||||
.addToPlaylistAt(episodeRemove, index);
|
.episodeLoad(widget.episode);
|
||||||
widget.onRemove(false);
|
widget.onRemove(true);
|
||||||
}),
|
},
|
||||||
));
|
),
|
||||||
},
|
),
|
||||||
child: EpisodeCard(
|
),
|
||||||
widget.episode,
|
Divider(height: 1)
|
||||||
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,
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,13 +128,16 @@ class EpisodeCard extends StatelessWidget {
|
||||||
final VoidCallback onTap;
|
final VoidCallback onTap;
|
||||||
final bool isPlaying;
|
final bool isPlaying;
|
||||||
final bool canReorder;
|
final bool canReorder;
|
||||||
|
final bool showDivider;
|
||||||
const EpisodeCard(this.episode,
|
const EpisodeCard(this.episode,
|
||||||
{this.tileColor,
|
{this.tileColor,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
this.isPlaying,
|
this.isPlaying,
|
||||||
this.canReorder = false,
|
this.canReorder = false,
|
||||||
|
this.showDivider = true,
|
||||||
Key key})
|
Key key})
|
||||||
: assert(episode != null), super(key: key);
|
: assert(episode != null),
|
||||||
|
super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -278,9 +215,7 @@ class EpisodeCard extends StatelessWidget {
|
||||||
: SizedBox(width: 1),
|
: SizedBox(width: 1),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Divider(
|
if (showDivider) Divider(height: 1),
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue