modified: lib/episodes/episodedetail.dart

modified:   lib/episodes/episodedownload.dart
	modified:   lib/podcasts/podcastdetail.dart
Added bottom menu ripple
This commit is contained in:
stonegate 2020-02-13 10:51:46 +08:00
parent a123d1dfa7
commit 0d1d8a9222
3 changed files with 122 additions and 93 deletions

View File

@ -5,6 +5,7 @@ import 'package:provider/provider.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:tsacdop/class/audiostate.dart';
import 'package:tsacdop/class/episodebrief.dart';
import 'package:tsacdop/class/sqflite_localpodcast.dart';
@ -204,6 +205,17 @@ class _MenuBarState extends State<MenuBar> {
_like = widget.episodeItem.liked;
}
Widget _buttonOnMenu(Widget widget, Function() onTap) => Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
child: Container(
height: 50.0,
padding: EdgeInsets.symmetric(horizontal: 15.0),
child: widget),
),
);
@override
Widget build(BuildContext context) {
final urlChange = Provider.of<Urlchange>(context);
@ -241,44 +253,50 @@ class _MenuBarState extends State<MenuBar> {
),
),
(_like == 0 && !_liked)
? InkWell(
onTap: () => saveLiked(widget.episodeItem.title),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.0),
child: Icon(
Icons.favorite_border,
color: Colors.grey[700],
),
),
)
: InkWell(
onTap: () => setUnliked(widget.episodeItem.title),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.0),
child: Icon(
Icons.favorite,
color: Colors.red,
),
),
),
DownloadButton(episodeBrief: widget.episodeItem),
IconButton(
icon: Icon(Icons.playlist_add, color: Colors.grey[700]),
onPressed: () {/*TODO*/},
),
Spacer(),
(widget.episodeItem.title != urlchange.title)
? IconButton(
icon: Icon(
Icons.play_arrow,
? _buttonOnMenu(
Icon(
Icons.favorite_border,
color: Colors.grey[700],
),
onPressed: () {
urlChange.audioUrl = widget.episodeItem.enclosureUrl;
urlChange.rssTitle = widget.episodeItem.title;
urlChange.feedTitle = widget.episodeItem.feedTitle;
urlChange.imageUrl = widget.episodeItem.imageUrl;
},
() => saveLiked(widget.episodeItem.title))
: _buttonOnMenu(
Icon(
Icons.favorite,
color: Colors.red,
),
() => setUnliked(widget.episodeItem.title)),
DownloadButton(episodeBrief: widget.episodeItem),
_buttonOnMenu(Icon(Icons.playlist_add, color: Colors.grey[700]),
() {
Fluttertoast.showToast(
msg: 'Not support yet',
gravity: ToastGravity.BOTTOM,
);
/*TODO*/
}),
Spacer(),
(widget.episodeItem.title != urlchange.title)
? Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.only(
topRight: Radius.circular(5.0),
bottomRight: Radius.circular(5.0)),
onTap: () {
urlChange.audioUrl = widget.episodeItem.enclosureUrl;
urlChange.rssTitle = widget.episodeItem.title;
urlChange.feedTitle = widget.episodeItem.feedTitle;
urlChange.imageUrl = widget.episodeItem.imageUrl;
},
child: Container(
height: 50.0,
padding: EdgeInsets.symmetric(horizontal: 20.0),
child: Icon(
Icons.play_arrow,
color: Colors.grey[700],
),
),
),
)
: (widget.episodeItem.title == urlchange.title &&
urlchange.audioState == AudioState.play)

View File

@ -140,7 +140,7 @@ class _DownloadButtonState extends State<DownloadButton> {
task.taskId = newTaskId;
var dbHelper = DBHelper();
await dbHelper.saveDownloaded(task.taskId, task.link);
Fluttertoast.showToast(
Fluttertoast.showToast(
msg: 'Download again',
gravity: ToastGravity.BOTTOM,
);
@ -190,6 +190,17 @@ class _DownloadButtonState extends State<DownloadButton> {
}
}
Widget _buttonOnMenu(Widget widget, Function() onTap) => Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
child: Container(
height: 50.0,
padding: EdgeInsets.symmetric(horizontal: 15.0),
child: widget),
),
);
@override
Widget build(BuildContext context) {
return _downloadButton(_task);
@ -199,72 +210,70 @@ class _DownloadButtonState extends State<DownloadButton> {
if (_isLoading)
return Center();
else if (task.status == DownloadTaskStatus.undefined) {
return IconButton(
onPressed: () {
_requestDownload(task);
},
icon: Icon(
Icons.arrow_downward,
color: Colors.grey[700],
),
);
return _buttonOnMenu(
Icon(
Icons.arrow_downward,
color: Colors.grey[700],
),
() => _requestDownload(task));
} else if (task.status == DownloadTaskStatus.running) {
return InkWell(
onTap: () {
_pauseDownload(task);
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 18),
child: SizedBox(
height: 18,
width: 18,
child: CircularProgressIndicator(
backgroundColor: Colors.grey[200],
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(Colors.blue),
value: task.progress / 100,
return Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
_pauseDownload(task);
},
child: Container(
height: 50.0,
alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: 18.0),
child: SizedBox(
height: 18,
width: 18,
child: CircularProgressIndicator(
backgroundColor: Colors.grey[500],
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(Colors.blue),
value: task.progress / 100,
),
),
),
),
);
} else if (task.status == DownloadTaskStatus.paused) {
return InkWell(
onTap: () {
_resumeDownload(task);
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 18),
child: SizedBox(
height: 18,
width: 18,
child: CircularProgressIndicator(
backgroundColor: Colors.grey[200],
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(Colors.red),
value: task.progress / 100,
return Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
_resumeDownload(task);
},
child: Container(
height: 50.0,
alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: 18),
child: SizedBox(
height: 18,
width: 18,
child: CircularProgressIndicator(
backgroundColor: Colors.grey[500],
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(Colors.red),
value: task.progress / 100,
),
),
),
),
);
} else if (task.status == DownloadTaskStatus.complete) {
return IconButton(
icon: Icon(
Icons.done_all,
color: Colors.blue,
),
onPressed: () {
_deleteDownload(task);
},
);
return _buttonOnMenu(
Icon(
Icons.done_all,
color: Colors.blue,
),
() => _deleteDownload(task));
} else if (task.status == DownloadTaskStatus.failed) {
return IconButton(
icon: Icon(Icons.refresh, color: Colors.red),
onPressed: () {
_retryDownload(task);
},
);
return _buttonOnMenu(
Icon(Icons.refresh, color: Colors.red), () => _retryDownload(task));
}
return Center();
}
@ -279,4 +288,4 @@ class _TaskInfo {
DownloadTaskStatus status = DownloadTaskStatus.undefined;
_TaskInfo({this.name, this.link});
}
}

View File

@ -7,6 +7,7 @@ import 'package:tsacdop/class/podcastlocal.dart';
import 'package:tsacdop/class/episodebrief.dart';
import 'package:tsacdop/class/sqflite_localpodcast.dart';
import 'package:tsacdop/util/episodegrid.dart';
import 'package:tsacdop/webfeed/webfeed.dart';
class PodcastDetail extends StatefulWidget {
PodcastDetail({Key key, this.podcastLocal}) : super(key: key);
@ -22,7 +23,8 @@ class _PodcastDetailState extends State<PodcastDetail> {
Future _updateRssItem(PodcastLocal podcastLocal) async {
var dbHelper = DBHelper();
final response = await Dio().get(podcastLocal.rssUrl);
final result = await dbHelper.savePodcastRss(response.data);
var _p = RssFeed.parse(response.data);
final result = await dbHelper.savePodcastRss(_p);
if (result == 0 && mounted) setState(() {});
}