2020-02-20 10:09:21 +01:00
|
|
|
import 'dart:io';
|
2020-02-09 13:29:09 +01:00
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
2020-02-22 13:25:06 +01:00
|
|
|
import 'package:flutter/services.dart';
|
2020-02-09 13:29:09 +01:00
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:flutter_html/flutter_html.dart';
|
2020-02-25 10:57:12 +01:00
|
|
|
import 'package:tsacdop/home/audioplayer.dart';
|
2020-02-09 13:29:09 +01:00
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
2020-02-13 03:51:46 +01:00
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
2020-02-21 16:04:02 +01:00
|
|
|
import 'package:intl/intl.dart';
|
2020-02-25 10:57:12 +01:00
|
|
|
import 'package:tuple/tuple.dart';
|
2020-03-14 04:14:24 +01:00
|
|
|
import 'package:audio_service/audio_service.dart';
|
2020-03-21 17:14:10 +01:00
|
|
|
import 'package:flutter_linkify/flutter_linkify.dart';
|
2020-04-18 06:48:02 +02:00
|
|
|
import 'package:google_fonts/google_fonts.dart';
|
2020-03-21 17:14:10 +01:00
|
|
|
|
2020-02-11 14:48:11 +01:00
|
|
|
import 'package:tsacdop/class/audiostate.dart';
|
|
|
|
import 'package:tsacdop/class/episodebrief.dart';
|
2020-02-20 10:09:21 +01:00
|
|
|
import 'package:tsacdop/local_storage/sqflite_localpodcast.dart';
|
2020-04-02 11:52:26 +02:00
|
|
|
import 'package:tsacdop/util/context_extension.dart';
|
2020-04-11 19:23:12 +02:00
|
|
|
import 'package:tsacdop/util/custompaint.dart';
|
2020-02-09 13:29:09 +01:00
|
|
|
import 'episodedownload.dart';
|
|
|
|
|
|
|
|
class EpisodeDetail extends StatefulWidget {
|
|
|
|
final EpisodeBrief episodeItem;
|
|
|
|
final String heroTag;
|
2020-03-22 18:03:53 +01:00
|
|
|
final bool hide;
|
2020-04-02 11:52:26 +02:00
|
|
|
EpisodeDetail(
|
|
|
|
{this.episodeItem, this.heroTag = '', this.hide = false, Key key})
|
|
|
|
: super(key: key);
|
2020-02-09 13:29:09 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
_EpisodeDetailState createState() => _EpisodeDetailState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _EpisodeDetailState extends State<EpisodeDetail> {
|
|
|
|
final textstyle = TextStyle(fontSize: 15.0, color: Colors.black);
|
|
|
|
double downloadProgress;
|
|
|
|
bool _loaddes;
|
2020-03-01 13:17:06 +01:00
|
|
|
bool _showMenu;
|
2020-02-20 10:09:21 +01:00
|
|
|
String path;
|
2020-03-21 17:14:10 +01:00
|
|
|
String _description;
|
2020-02-20 16:44:42 +01:00
|
|
|
Future getSDescription(String url) async {
|
2020-02-09 13:29:09 +01:00
|
|
|
var dbHelper = DBHelper();
|
2020-03-21 17:14:10 +01:00
|
|
|
_description = (await dbHelper.getDescription(url))
|
2020-04-02 11:52:26 +02:00
|
|
|
.replaceAll(RegExp(r'\s?<p>(<br>)?</p>\s?'), '')
|
|
|
|
.replaceAll('\r', '');
|
2020-02-09 13:29:09 +01:00
|
|
|
if (mounted)
|
|
|
|
setState(() {
|
|
|
|
_loaddes = true;
|
|
|
|
});
|
|
|
|
}
|
2020-02-11 14:01:57 +01:00
|
|
|
|
2020-03-01 13:17:06 +01:00
|
|
|
ScrollController _controller;
|
|
|
|
_scrollListener() {
|
|
|
|
if (_controller.offset > _controller.position.maxScrollExtent * 0.8) {
|
|
|
|
setState(() {
|
|
|
|
_showMenu = true;
|
|
|
|
});
|
|
|
|
} else
|
|
|
|
setState(() {
|
|
|
|
_showMenu = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-02-09 13:29:09 +01:00
|
|
|
_launchUrl(String url) async {
|
2020-02-11 14:01:57 +01:00
|
|
|
if (await canLaunch(url)) {
|
|
|
|
await launch(url);
|
|
|
|
} else {
|
|
|
|
throw 'Could not launch $url';
|
|
|
|
}
|
2020-02-09 13:29:09 +01:00
|
|
|
}
|
2020-02-11 14:01:57 +01:00
|
|
|
|
2020-02-09 13:29:09 +01:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_loaddes = false;
|
2020-03-01 13:17:06 +01:00
|
|
|
_showMenu = false;
|
2020-02-20 16:44:42 +01:00
|
|
|
getSDescription(widget.episodeItem.enclosureUrl);
|
2020-03-01 13:17:06 +01:00
|
|
|
_controller = ScrollController();
|
|
|
|
_controller.addListener(_scrollListener);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_controller.dispose();
|
|
|
|
super.dispose();
|
2020-02-09 13:29:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-02-22 13:25:06 +01:00
|
|
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
|
|
|
value: SystemUiOverlayStyle(
|
|
|
|
statusBarIconBrightness: Theme.of(context).accentColorBrightness,
|
|
|
|
systemNavigationBarColor: Theme.of(context).primaryColor,
|
2020-03-19 20:58:30 +01:00
|
|
|
systemNavigationBarIconBrightness:
|
|
|
|
Theme.of(context).accentColorBrightness,
|
2020-02-09 13:29:09 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
child: Scaffold(
|
|
|
|
backgroundColor: Theme.of(context).primaryColor,
|
|
|
|
appBar: AppBar(
|
2020-04-02 11:52:26 +02:00
|
|
|
// title: Text(widget.episodeItem.feedTitle),
|
2020-03-19 20:58:30 +01:00
|
|
|
centerTitle: true,
|
|
|
|
),
|
|
|
|
body: Stack(
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 20.0),
|
|
|
|
alignment: Alignment.topLeft,
|
|
|
|
child: Text(
|
|
|
|
widget.episodeItem.title,
|
|
|
|
style: Theme.of(context).textTheme.headline5,
|
2020-02-25 10:57:12 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 20.0),
|
|
|
|
height: 30.0,
|
|
|
|
child: Text(
|
|
|
|
'Published ' +
|
|
|
|
DateFormat.yMMMd().format(
|
|
|
|
DateTime.fromMillisecondsSinceEpoch(
|
|
|
|
widget.episodeItem.pubDate)),
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).accentColor)),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 20.0),
|
|
|
|
height: 50.0,
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
(widget.episodeItem.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)))
|
|
|
|
: Center(),
|
|
|
|
widget.episodeItem.duration != 0
|
|
|
|
? Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.cyan[300],
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
Radius.circular(15.0))),
|
|
|
|
height: 25.0,
|
|
|
|
margin: EdgeInsets.only(right: 10.0),
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: 10.0),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Text(
|
2020-04-11 19:23:12 +02:00
|
|
|
(widget.episodeItem.duration ~/ 60)
|
2020-03-19 20:58:30 +01:00
|
|
|
.toString() +
|
2020-04-18 06:48:02 +02:00
|
|
|
'min',
|
2020-03-19 20:58:30 +01:00
|
|
|
style: textstyle),
|
2020-02-25 10:57:12 +01:00
|
|
|
)
|
2020-03-19 20:58:30 +01:00
|
|
|
: Center(),
|
2020-03-21 17:14:10 +01:00
|
|
|
widget.episodeItem.enclosureLength != null &&
|
|
|
|
widget.episodeItem.enclosureLength != 0
|
2020-03-19 20:58:30 +01:00
|
|
|
? Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.lightBlue[300],
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
Radius.circular(15.0))),
|
|
|
|
height: 25.0,
|
|
|
|
margin: EdgeInsets.only(right: 10.0),
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: 10.0),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Text(
|
|
|
|
((widget.episodeItem
|
|
|
|
.enclosureLength) ~/
|
|
|
|
1000000)
|
|
|
|
.toString() +
|
|
|
|
'MB',
|
|
|
|
style: textstyle),
|
|
|
|
)
|
|
|
|
: Center(),
|
|
|
|
],
|
|
|
|
),
|
2020-02-09 13:29:09 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.only(top: 5.0),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
controller: _controller,
|
|
|
|
child: _loaddes
|
2020-03-21 17:14:10 +01:00
|
|
|
? (_description.contains('<'))
|
2020-03-19 20:58:30 +01:00
|
|
|
? Html(
|
2020-04-02 11:52:26 +02:00
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: 20.0, right: 20, bottom: 10),
|
2020-04-18 06:48:02 +02:00
|
|
|
defaultTextStyle:
|
|
|
|
GoogleFonts.libreBaskerville(
|
|
|
|
textStyle: TextStyle(
|
|
|
|
height: 1.8,
|
|
|
|
),
|
|
|
|
),
|
2020-03-21 17:14:10 +01:00
|
|
|
data: _description,
|
2020-03-19 20:58:30 +01:00
|
|
|
linkStyle: TextStyle(
|
|
|
|
color: Theme.of(context).accentColor,
|
|
|
|
decoration: TextDecoration.underline,
|
|
|
|
textBaseline: TextBaseline.ideographic),
|
|
|
|
onLinkTap: (url) {
|
|
|
|
_launchUrl(url);
|
|
|
|
},
|
|
|
|
useRichText: true,
|
|
|
|
)
|
2020-04-02 11:52:26 +02:00
|
|
|
: _description.length > 0
|
|
|
|
? Container(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: 20.0,
|
|
|
|
right: 20.0,
|
|
|
|
bottom: 10.0),
|
|
|
|
alignment: Alignment.topLeft,
|
|
|
|
child: SelectableLinkify(
|
|
|
|
onOpen: (link) {
|
|
|
|
_launchUrl(link.url);
|
|
|
|
},
|
|
|
|
text: _description,
|
2020-04-18 06:48:02 +02:00
|
|
|
style: GoogleFonts.libreBaskerville(
|
|
|
|
textStyle: TextStyle(
|
|
|
|
height: 1.8,
|
|
|
|
),
|
2020-04-02 11:52:26 +02:00
|
|
|
),
|
|
|
|
linkStyle: TextStyle(
|
|
|
|
color:
|
|
|
|
Theme.of(context).accentColor,
|
|
|
|
decoration:
|
|
|
|
TextDecoration.underline,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: Container(
|
|
|
|
height: context.width,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
Image(
|
|
|
|
image: AssetImage(
|
|
|
|
'assets/shownote.png'),
|
|
|
|
height: 100.0,
|
|
|
|
),
|
2020-04-11 19:23:12 +02:00
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.all(5.0)),
|
2020-04-02 11:52:26 +02:00
|
|
|
Text(
|
2020-04-11 19:23:12 +02:00
|
|
|
'Still no shownote received\n for this episode.',
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.textTheme
|
|
|
|
.bodyText1.color
|
|
|
|
.withOpacity(0.5))),
|
2020-04-02 11:52:26 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
2020-03-19 20:58:30 +01:00
|
|
|
: Center(),
|
2020-02-22 13:25:06 +01:00
|
|
|
),
|
2020-02-09 13:29:09 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
|
|
|
Selector<AudioPlayerNotifier, bool>(
|
|
|
|
selector: (_, audio) => audio.playerRunning,
|
|
|
|
builder: (_, data, __) {
|
|
|
|
return Padding(
|
|
|
|
padding: EdgeInsets.only(bottom: data ? 60.0 : 0),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
],
|
2020-02-25 10:57:12 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
|
|
|
Selector<AudioPlayerNotifier, bool>(
|
|
|
|
selector: (_, audio) => audio.playerRunning,
|
|
|
|
builder: (_, data, __) {
|
|
|
|
return Container(
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
padding: EdgeInsets.only(bottom: data ? 60.0 : 0),
|
|
|
|
child: AnimatedContainer(
|
|
|
|
duration: Duration(milliseconds: 400),
|
|
|
|
height: !_showMenu ? 50 : 0,
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
child: MenuBar(
|
2020-04-02 11:52:26 +02:00
|
|
|
episodeItem: widget.episodeItem,
|
|
|
|
heroTag: widget.heroTag,
|
|
|
|
hide: widget.hide),
|
2020-02-25 10:57:12 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
Container(child: PlayerWidget()),
|
|
|
|
],
|
2020-02-09 13:29:09 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MenuBar extends StatefulWidget {
|
|
|
|
final EpisodeBrief episodeItem;
|
|
|
|
final String heroTag;
|
2020-03-22 18:03:53 +01:00
|
|
|
final bool hide;
|
2020-04-02 11:52:26 +02:00
|
|
|
MenuBar({this.episodeItem, this.heroTag, this.hide, Key key})
|
|
|
|
: super(key: key);
|
2020-02-09 13:29:09 +01:00
|
|
|
@override
|
|
|
|
_MenuBarState createState() => _MenuBarState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MenuBarState extends State<MenuBar> {
|
|
|
|
bool _liked;
|
2020-04-11 19:23:12 +02:00
|
|
|
|
|
|
|
Future<PlayHistory> getPosition(EpisodeBrief episode) async {
|
|
|
|
var dbHelper = DBHelper();
|
|
|
|
return await dbHelper.getPosition(episode);
|
|
|
|
}
|
2020-02-09 13:29:09 +01:00
|
|
|
|
2020-02-20 16:44:42 +01:00
|
|
|
Future<int> saveLiked(String url) async {
|
2020-02-09 13:29:09 +01:00
|
|
|
var dbHelper = DBHelper();
|
2020-02-20 16:44:42 +01:00
|
|
|
int result = await dbHelper.setLiked(url);
|
2020-02-09 13:29:09 +01:00
|
|
|
if (result == 1 && mounted) setState(() => _liked = true);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-02-20 16:44:42 +01:00
|
|
|
Future<int> setUnliked(String url) async {
|
2020-02-09 13:29:09 +01:00
|
|
|
var dbHelper = DBHelper();
|
2020-02-20 16:44:42 +01:00
|
|
|
int result = await dbHelper.setUniked(url);
|
2020-02-09 13:29:09 +01:00
|
|
|
if (result == 1 && mounted)
|
|
|
|
setState(() {
|
|
|
|
_liked = false;
|
2020-04-11 19:23:12 +02:00
|
|
|
// _like = 0;
|
2020-02-09 13:29:09 +01:00
|
|
|
});
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-04-11 19:23:12 +02:00
|
|
|
Future<bool> _isLiked(EpisodeBrief episode) async {
|
|
|
|
DBHelper dbHelper = DBHelper();
|
|
|
|
return await dbHelper.isLiked(episode.enclosureUrl);
|
|
|
|
}
|
|
|
|
|
|
|
|
static String _stringForSeconds(double seconds) {
|
|
|
|
if (seconds == null) return null;
|
|
|
|
return '${(seconds ~/ 60)}:${(seconds.truncate() % 60).toString().padLeft(2, '0')}';
|
|
|
|
}
|
|
|
|
|
2020-02-09 13:29:09 +01:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_liked = false;
|
|
|
|
}
|
|
|
|
|
2020-02-20 10:09:21 +01:00
|
|
|
Widget _buttonOnMenu(Widget widget, VoidCallback onTap) => Material(
|
2020-02-13 03:51:46 +01:00
|
|
|
color: Colors.transparent,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
|
|
|
height: 50.0,
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 15.0),
|
|
|
|
child: widget),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2020-02-09 13:29:09 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-03-14 04:14:24 +01:00
|
|
|
var audio = Provider.of<AudioPlayerNotifier>(context, listen: false);
|
2020-02-22 13:25:06 +01:00
|
|
|
return Container(
|
|
|
|
height: 50.0,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
2020-02-25 10:57:12 +01:00
|
|
|
border: Border.all(
|
|
|
|
color: Theme.of(context).brightness == Brightness.light
|
|
|
|
? Colors.grey[200]
|
2020-02-26 10:54:59 +01:00
|
|
|
: Theme.of(context).primaryColor,
|
2020-02-25 10:57:12 +01:00
|
|
|
),
|
2020-02-22 13:25:06 +01:00
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
2020-02-25 10:57:12 +01:00
|
|
|
Hero(
|
|
|
|
tag: widget.episodeItem.enclosureUrl + widget.heroTag,
|
|
|
|
child: Container(
|
2020-02-25 13:28:48 +01:00
|
|
|
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
2020-03-01 13:17:06 +01:00
|
|
|
child: Container(
|
|
|
|
height: 30.0,
|
|
|
|
width: 30.0,
|
|
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
2020-04-02 11:52:26 +02:00
|
|
|
child: widget.hide
|
|
|
|
? Center()
|
|
|
|
: CircleAvatar(
|
|
|
|
backgroundImage:
|
|
|
|
FileImage(File("${widget.episodeItem.imagePath}"))),
|
2020-02-25 10:57:12 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2020-04-11 19:23:12 +02:00
|
|
|
FutureBuilder<bool>(
|
|
|
|
future: _isLiked(widget.episodeItem),
|
|
|
|
initialData: false,
|
|
|
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
|
|
|
return (!snapshot.data && !_liked)
|
2020-02-25 10:57:12 +01:00
|
|
|
? _buttonOnMenu(
|
|
|
|
Icon(
|
2020-04-11 19:23:12 +02:00
|
|
|
Icons.favorite_border,
|
|
|
|
color: Colors.grey[700],
|
2020-02-25 10:57:12 +01:00
|
|
|
),
|
2020-04-11 19:23:12 +02:00
|
|
|
() => saveLiked(widget.episodeItem.enclosureUrl))
|
|
|
|
: (snapshot.data && !_liked)
|
|
|
|
? _buttonOnMenu(
|
|
|
|
Icon(
|
|
|
|
Icons.favorite,
|
|
|
|
color: Colors.red,
|
|
|
|
),
|
|
|
|
() => setUnliked(widget.episodeItem.enclosureUrl))
|
|
|
|
: Stack(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
LoveOpen(),
|
|
|
|
_buttonOnMenu(
|
|
|
|
Icon(
|
|
|
|
Icons.favorite,
|
|
|
|
color: Colors.red,
|
|
|
|
),
|
|
|
|
() => setUnliked(
|
|
|
|
widget.episodeItem.enclosureUrl)),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2020-03-31 18:36:20 +02:00
|
|
|
DownloadButton(episode: widget.episodeItem),
|
2020-03-14 04:14:24 +01:00
|
|
|
Selector<AudioPlayerNotifier, List<String>>(
|
2020-03-01 13:17:06 +01:00
|
|
|
selector: (_, audio) =>
|
|
|
|
audio.queue.playlist.map((e) => e.enclosureUrl).toList(),
|
2020-02-25 13:28:48 +01:00
|
|
|
builder: (_, data, __) {
|
|
|
|
return data.contains(widget.episodeItem.enclosureUrl)
|
|
|
|
? _buttonOnMenu(
|
2020-03-01 13:17:06 +01:00
|
|
|
Icon(Icons.playlist_add_check,
|
2020-04-11 19:23:12 +02:00
|
|
|
color: Theme.of(context).accentColor), () {
|
|
|
|
audio.delFromPlaylist(widget.episodeItem);
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
msg: 'Removed from playlist',
|
|
|
|
gravity: ToastGravity.BOTTOM,
|
|
|
|
);
|
|
|
|
})
|
2020-02-25 13:28:48 +01:00
|
|
|
: _buttonOnMenu(
|
|
|
|
Icon(Icons.playlist_add, color: Colors.grey[700]), () {
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
msg: 'Added to playlist',
|
|
|
|
gravity: ToastGravity.BOTTOM,
|
|
|
|
);
|
|
|
|
audio.addToPlaylist(widget.episodeItem);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
2020-04-11 19:23:12 +02:00
|
|
|
FutureBuilder<PlayHistory>(
|
|
|
|
future: getPosition(widget.episodeItem),
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (snapshot.hasError) print(snapshot.error);
|
|
|
|
return snapshot.hasData
|
|
|
|
? snapshot.data.seekValue > 0.95
|
|
|
|
? Container(
|
2020-04-11 19:59:52 +02:00
|
|
|
height: 20,
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 15),
|
|
|
|
child: SizedBox(
|
2020-04-11 19:23:12 +02:00
|
|
|
width: 20,
|
|
|
|
height: 20,
|
|
|
|
child: CustomPaint(
|
|
|
|
painter: ListenedPainter(context.accentColor,
|
|
|
|
stroke: 2.0),
|
|
|
|
),
|
|
|
|
),
|
2020-04-11 19:59:52 +02:00
|
|
|
)
|
2020-04-11 19:23:12 +02:00
|
|
|
: snapshot.data.seconds < 0.1
|
|
|
|
? Center()
|
2020-04-11 19:59:52 +02:00
|
|
|
: Material(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () => audio.episodeLoad(
|
|
|
|
widget.episodeItem,
|
|
|
|
startPosition:
|
|
|
|
(snapshot.data.seconds * 1000)
|
|
|
|
.toInt()),
|
|
|
|
child: Container(
|
|
|
|
height: 50,
|
|
|
|
padding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 15),
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
SizedBox(
|
|
|
|
width: 20,
|
|
|
|
height: 20,
|
|
|
|
child: CustomPaint(
|
|
|
|
painter: ListenedPainter(
|
|
|
|
context.accentColor,
|
|
|
|
stroke: 2.0),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: 2)),
|
|
|
|
Container(
|
|
|
|
height: 20,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: 5),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
Radius.circular(10.0)),
|
|
|
|
color: context.accentColor,
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
_stringForSeconds(
|
|
|
|
snapshot.data.seconds),
|
|
|
|
style:
|
|
|
|
TextStyle(color: Colors.white),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2020-04-11 19:23:12 +02:00
|
|
|
),
|
2020-04-11 19:59:52 +02:00
|
|
|
),
|
2020-04-11 19:23:12 +02:00
|
|
|
),
|
2020-04-11 19:59:52 +02:00
|
|
|
)
|
2020-04-11 19:23:12 +02:00
|
|
|
: Center();
|
|
|
|
}),
|
2020-02-22 13:25:06 +01:00
|
|
|
Spacer(),
|
2020-03-19 20:58:30 +01:00
|
|
|
Selector<AudioPlayerNotifier,
|
|
|
|
Tuple2<EpisodeBrief, BasicPlaybackState>>(
|
|
|
|
selector: (_, audio) => Tuple2(audio.episode, audio.audioState),
|
2020-02-25 10:57:12 +01:00
|
|
|
builder: (_, data, __) {
|
|
|
|
return (widget.episodeItem.title != data.item1?.title)
|
|
|
|
? Material(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
audio.episodeLoad(widget.episodeItem);
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
height: 50.0,
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 20.0),
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Text('Play Now',
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).accentColor,
|
|
|
|
fontSize: 15,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
)),
|
|
|
|
Icon(
|
|
|
|
Icons.play_arrow,
|
2020-02-22 13:25:06 +01:00
|
|
|
color: Theme.of(context).accentColor,
|
2020-02-25 10:57:12 +01:00
|
|
|
),
|
|
|
|
],
|
2020-02-22 13:25:06 +01:00
|
|
|
),
|
2020-02-25 10:57:12 +01:00
|
|
|
),
|
2020-02-09 13:29:09 +01:00
|
|
|
),
|
2020-02-25 10:57:12 +01:00
|
|
|
)
|
2020-04-11 19:23:12 +02:00
|
|
|
: Container(
|
|
|
|
padding: EdgeInsets.only(right: 30),
|
|
|
|
child: SizedBox(
|
|
|
|
width: 20,
|
|
|
|
height: 15,
|
|
|
|
child: WaveLoader(color: context.accentColor)));
|
2020-02-25 10:57:12 +01:00
|
|
|
},
|
|
|
|
),
|
2020-02-22 13:25:06 +01:00
|
|
|
],
|
|
|
|
),
|
2020-02-09 13:29:09 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|