1
0
mirror of https://github.com/stonega/tsacdop synced 2025-02-10 00:20:49 +01:00

Add mark as listened

This commit is contained in:
stonegate 2020-06-06 12:51:34 +08:00
parent ab6910d9c6
commit 3371b1c614
4 changed files with 139 additions and 5 deletions

View File

@ -69,6 +69,13 @@ class _EpisodeDetailState extends State<EpisodeDetail> {
} }
} }
_markListened(EpisodeBrief episode) async {
DBHelper dbHelper = DBHelper();
final PlayHistory history =
PlayHistory(episode.title, episode.enclosureUrl, 0, 1);
await dbHelper.saveHistory(history);
}
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -99,6 +106,53 @@ class _EpisodeDetailState extends State<EpisodeDetail> {
appBar: AppBar( appBar: AppBar(
// title: Text(widget.episodeItem.feedTitle), // title: Text(widget.episodeItem.feedTitle),
centerTitle: true, centerTitle: true,
actions: [
PopupMenuButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10))),
elevation: 1,
tooltip: 'Menu',
itemBuilder: (context) => [
PopupMenuItem(
value: 0,
child: Container(
padding: EdgeInsets.only(left: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 25,
height: 25,
child: CustomPaint(
painter: ListenedAllPainter(
context.textTheme.bodyText1.color,
stroke: 1.5)),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 5.0),
),
Text(
'Mark listened',
),
],
),
),
),
],
onSelected: (int value) async {
switch (value) {
case 0:
await _markListened(widget.episodeItem);
setState(() {});
Fluttertoast.showToast(
msg: 'Mark as listened',
gravity: ToastGravity.BOTTOM,
);
break;
}
},
),
],
), ),
body: Stack( body: Stack(
children: <Widget>[ children: <Widget>[
@ -280,8 +334,7 @@ class _EpisodeDetailState extends State<EpisodeDetail> {
selector: (_, audio) => audio.playerRunning, selector: (_, audio) => audio.playerRunning,
builder: (_, data, __) { builder: (_, data, __) {
return Padding( return Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(bottom: data ? 60.0 : 0),
bottom: data ? 60.0 : 0),
); );
}), }),
], ],
@ -360,6 +413,13 @@ class _MenuBarState extends State<MenuBar> {
return '${(seconds ~/ 60)}:${(seconds.truncate() % 60).toString().padLeft(2, '0')}'; return '${(seconds ~/ 60)}:${(seconds.truncate() % 60).toString().padLeft(2, '0')}';
} }
_markListened(EpisodeBrief episode) async {
DBHelper dbHelper = DBHelper();
final PlayHistory history =
PlayHistory(episode.title, episode.enclosureUrl, 0, 1);
await dbHelper.saveHistory(history);
}
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -505,6 +565,36 @@ class _MenuBarState extends State<MenuBar> {
), ),
) )
: snapshot.data.seconds < 0.1 : snapshot.data.seconds < 0.1
// ? Material(
// color: Colors.transparent,
// child: InkWell(
// onTap: () async {
// await _markListened(widget.episodeItem);
// setState(() {});
// Fluttertoast.showToast(
// msg: 'Mark as listened',
// gravity: ToastGravity.BOTTOM,
// );
// },
// child: Container(
// height: 50,
// padding: EdgeInsets.only(
// left: 15,
// right: 15,
// top: 12,
// bottom: 12),
// child: SizedBox(
// width: 22,
// height: 22,
// child: CustomPaint(
// painter: MarkListenedPainter(
// Colors.grey[700],
// stroke: 2.0),
// ),
// ),
// ),
// ),
// )
? Center() ? Center()
: Material( : Material(
color: Colors.transparent, color: Colors.transparent,

View File

@ -267,8 +267,16 @@ class _PlayedHistoryState extends State<PlayedHistory>
10))), 10))),
padding: EdgeInsets.all(2), padding: EdgeInsets.all(2),
child: Text( child: Text(
_stringForSeconds(snapshot snapshot.data[index]
.data[index].seconds), .seconds ==
0 &&
snapshot.data[index]
.seekValue ==
1
? 'Mark'
: _stringForSeconds(
snapshot.data[index]
.seconds),
style: TextStyle( style: TextStyle(
color: Colors.white), color: Colors.white),
), ),

View File

@ -156,6 +156,41 @@ class ListenedAllPainter extends CustomPainter {
} }
} }
//Mark Listened indicator
class MarkListenedPainter extends CustomPainter {
Color _color;
double stroke;
MarkListenedPainter(this._color, {this.stroke = 1.0});
@override
void paint(Canvas canvas, Size size) {
Paint _paint = Paint()
..color = _color
..strokeWidth = stroke
..strokeCap = StrokeCap.round
..style = PaintingStyle.stroke;
Path _path = Path();
_path.moveTo(size.width / 6, size.height * 3 / 8);
_path.lineTo(size.width / 6, size.height * 5 / 8);
_path.moveTo(size.width / 3, size.height / 4);
_path.lineTo(size.width / 3, size.height * 3 / 4);
_path.moveTo(size.width / 2, size.height * 3 / 8);
_path.lineTo(size.width / 2, size.height * 5 / 8);
// _path.moveTo(size.width * 2 / 3, size.height * 4 / 9);
// _path.lineTo(size.width * 2 / 3, size.height * 5 / 9);
_path.moveTo(size.width / 2, size.height * 13 / 18);
_path.lineTo(size.width * 5 / 6, size.height * 13 / 18);
_path.moveTo(size.width * 2 / 3, size.height * 5 / 9);
_path.lineTo(size.width * 2 / 3, size.height * 8 / 9);
canvas.drawPath(_path, _paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}
//Add new episode to palylist //Add new episode to palylist
class AddToPlaylistPainter extends CustomPainter { class AddToPlaylistPainter extends CustomPainter {
Color _color; Color _color;

View File

@ -96,11 +96,12 @@ class EpisodeGrid extends StatelessWidget {
shape: BoxShape.circle, shape: BoxShape.circle,
), ),
child: WaveLoader(color: context.accentColor)) child: WaveLoader(color: context.accentColor))
: layout == Layout.two && isListened > 0 : layout != Layout.three && isListened > 0
? Container( ? Container(
height: 20, height: 20,
width: 20, width: 20,
margin: EdgeInsets.symmetric(horizontal: 2), margin: EdgeInsets.symmetric(horizontal: 2),
padding: EdgeInsets.all(2),
decoration: BoxDecoration( decoration: BoxDecoration(
color: context.accentColor, color: context.accentColor,
shape: BoxShape.circle, shape: BoxShape.circle,