diff --git a/lib/home/home.dart b/lib/home/home.dart index 8cd5a95..d58aea6 100644 --- a/lib/home/home.dart +++ b/lib/home/home.dart @@ -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: [ - 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: [ + // Icon(Icons.history), + // Padding( + // padding: const EdgeInsets.symmetric(horizontal: 5.0), + // ), + // Text(s.settingsHistory), + // ], + // ), + // ), + // ), + // PopupMenuDivider( + // height: 1, + // ), ], onSelected: (value) { if (value == 0) { diff --git a/lib/state/audio_state.dart b/lib/state/audio_state.dart index 07f1a69..2feff49 100644 --- a/lib/state/audio_state.dart +++ b/lib/state/audio_state.dart @@ -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 _startAudioService(playlist, + Future _startAudioService(Playlist playlist, {int index = 0, int position = 0}) async { _stopOnComplete = false; _sleepTimerMode = SleepTimerMode.undefined; diff --git a/lib/widgets/dismissible_container.dart b/lib/widgets/dismissible_container.dart index 129b9db..6500cdf 100644 --- a/lib/widgets/dismissible_container.dart +++ b/lib/widgets/dismissible_container.dart @@ -99,81 +99,185 @@ class _DismissibleContainerState extends State { }), )); }, - child: SizedBox( - height: 90.0, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Expanded( - child: ListTile( - contentPadding: EdgeInsets.symmetric(vertical: 8), - onTap: () async { - await context - .read() - .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: [ - 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, - ), - ], - ), + child: EpisodeCard( + widget.episode, + isPlaying: false, + onTap: () async { + await context + .read() + .episodeLoad(widget.episode); + widget.onRemove(true); + }, ), + // SizedBox( + // height: 90.0, + // child: Column( + // mainAxisAlignment: MainAxisAlignment.spaceAround, + // children: [ + // Expanded( + // child: ListTile( + // contentPadding: EdgeInsets.symmetric(vertical: 8), + // onTap: () async { + // await context + // .read() + // .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: [ + // 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: [ + 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( + 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), + SizedBox(width: 24), + CircleAvatar( + backgroundColor: c.withOpacity(0.5), + backgroundImage: episode.avatarImage), + ], + ), + subtitle: Container( + padding: EdgeInsets.only(top: 5, bottom: 5), + height: 35, + child: Row( + children: [ + if (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 (episode.duration != 0) + episodeTag( + episode.duration == 0 + ? '' + : s.minsCount(episode.duration ~/ 60), + Colors.cyan[300]), + if (episode.enclosureLength != null) + episodeTag( + episode.enclosureLength == 0 + ? '' + : '${(episode.enclosureLength) ~/ 1000000}MB', + Colors.lightBlue[300]), + ], + ), + ), + 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: 1, + ), + ], + ), + ); + } +}