Minor change.

This commit is contained in:
Stonegate 2021-01-01 02:08:46 +08:00
parent b3e1d4cb42
commit a7a3fc7845
3 changed files with 202 additions and 96 deletions

View File

@ -456,24 +456,24 @@ class __PlaylistButtonState extends State<_PlaylistButton> {
PopupMenuDivider(
height: 1,
),
PopupMenuItem(
value: 2,
child: Container(
padding: EdgeInsets.only(left: 10),
child: Row(
children: <Widget>[
Icon(Icons.history),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 5.0),
),
Text(s.settingsHistory),
],
),
),
),
PopupMenuDivider(
height: 1,
),
// PopupMenuItem(
// value: 2,
// child: Container(
// padding: EdgeInsets.only(left: 10),
// child: Row(
// children: <Widget>[
// Icon(Icons.history),
// Padding(
// padding: const EdgeInsets.symmetric(horizontal: 5.0),
// ),
// Text(s.settingsHistory),
// ],
// ),
// ),
// ),
// PopupMenuDivider(
// height: 1,
// ),
],
onSelected: (value) {
if (value == 0) {

View File

@ -280,7 +280,8 @@ class AudioPlayerNotifier extends ChangeNotifier {
if (state[1] != '') {
_episode = await _dbHelper.getRssItemWithUrl(state[1]);
} else {
_episode = _queue.episodes.isNotEmpty ? _queue.episodes.first : null;
_episode =
_playlist.episodes.isNotEmpty ? _playlist.episodes.first : null;
}
_lastPostion = int.parse(state[2] ?? '0');
@ -338,18 +339,19 @@ class AudioPlayerNotifier extends ChangeNotifier {
final history = PlayHistory(_episode.title, _episode.enclosureUrl,
backgroundAudioPosition ~/ 1000, seekSliderValue);
await _dbHelper.saveHistory(history);
_queue.addToPlayListAt(episodeNew, 0);
await updatePlaylist(_queue);
if (_playlist.name != 'Queue') {
AudioService.customAction('setIsQueue', true);
AudioService.customAction('changeQueue', [
for (var e in _queue.episodes) jsonEncode(e.toMediaItem().toJson())
]);
_playlist = _queue;
}
await AudioService.addQueueItemAt(episodeNew.toMediaItem(), 0);
if (startPosition > 0) {
await AudioService.seekTo(Duration(milliseconds: startPosition));
}
_queue.addToPlayListAt(episodeNew, 0);
await updatePlaylist(_queue);
_remoteErrorMessage = null;
notifyListeners();
if (episodeNew.isNew == 1) {
@ -357,7 +359,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
}
} else {
await _queue.getPlaylist();
await _queue.addToPlayListAt(episodeNew, 0);
_queue.addToPlayListAt(episodeNew, 0);
_backgroundAudioDuration = 0;
_backgroundAudioPosition = 0;
_seekSliderValue = 0;
@ -375,7 +377,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
}
}
Future<void> _startAudioService(playlist,
Future<void> _startAudioService(Playlist playlist,
{int index = 0, int position = 0}) async {
_stopOnComplete = false;
_sleepTimerMode = SleepTimerMode.undefined;

View File

@ -99,24 +99,122 @@ class _DismissibleContainerState extends State<DismissibleContainer> {
}),
));
},
child: SizedBox(
height: 90.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Expanded(
child: ListTile(
contentPadding: EdgeInsets.symmetric(vertical: 8),
child: EpisodeCard(
widget.episode,
isPlaying: false,
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,
// ),
// ],
// ),
// ),
),
);
}
}
class EpisodeCard extends StatelessWidget {
final EpisodeBrief episode;
final Color tileColor;
final VoidCallback onTap;
final bool isPlaying;
const EpisodeCard(this.episode,
{this.tileColor, this.onTap, this.isPlaying, Key key})
: super(key: key);
@override
Widget build(BuildContext context) {
final s = context.s;
final c = episode.backgroudColor(context);
return SizedBox(
height: 90.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Expanded(
child: ListTile(
tileColor: tileColor,
contentPadding: EdgeInsets.symmetric(vertical: 8),
onTap: onTap,
title: Container(
padding: EdgeInsets.fromLTRB(0, 5.0, 20.0, 5.0),
child: Text(
widget.episode.title,
episode.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
@ -126,10 +224,11 @@ class _DismissibleContainerState extends State<DismissibleContainer> {
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.unfold_more, color: c),
// Icon(Icons.unfold_more, color: c),
SizedBox(width: 24),
CircleAvatar(
backgroundColor: c.withOpacity(0.5),
backgroundImage: widget.episode.avatarImage),
backgroundImage: episode.avatarImage),
],
),
subtitle: Container(
@ -137,43 +236,48 @@ class _DismissibleContainerState extends State<DismissibleContainer> {
height: 35,
child: Row(
children: <Widget>[
if (widget.episode.explicit == 1)
if (episode.explicit == 1)
Container(
decoration: BoxDecoration(
color: Colors.red[800],
shape: BoxShape.circle),
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)
child:
Text('E', style: TextStyle(color: Colors.white))),
if (episode.duration != 0)
episodeTag(
widget.episode.duration == 0
episode.duration == 0
? ''
: s.minsCount(
widget.episode.duration ~/ 60),
: s.minsCount(episode.duration ~/ 60),
Colors.cyan[300]),
if (widget.episode.enclosureLength != null)
if (episode.enclosureLength != null)
episodeTag(
widget.episode.enclosureLength == 0
episode.enclosureLength == 0
? ''
: '${(widget.episode.enclosureLength) ~/ 1000000}MB',
: '${(episode.enclosureLength) ~/ 1000000}MB',
Colors.lightBlue[300]),
],
),
),
//trailing: Icon(Icons.menu),
trailing: isPlaying
? Container(
height: 20,
width: 20,
margin: EdgeInsets.symmetric(horizontal: 20),
decoration: BoxDecoration(
shape: BoxShape.circle,
),
child: WaveLoader(color: context.accentColor))
: SizedBox(width: 1),
),
),
Divider(
height: 2,
height: 1,
),
],
),
),
),
);
}
}