mirror of
https://github.com/stonega/tsacdop
synced 2025-02-09 08:08:46 +01:00
✨ Add mark as listened
This commit is contained in:
parent
ab6910d9c6
commit
3371b1c614
@ -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
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -99,6 +106,53 @@ class _EpisodeDetailState extends State<EpisodeDetail> {
|
||||
appBar: AppBar(
|
||||
// title: Text(widget.episodeItem.feedTitle),
|
||||
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(
|
||||
children: <Widget>[
|
||||
@ -280,8 +334,7 @@ class _EpisodeDetailState extends State<EpisodeDetail> {
|
||||
selector: (_, audio) => audio.playerRunning,
|
||||
builder: (_, data, __) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: data ? 60.0 : 0),
|
||||
padding: EdgeInsets.only(bottom: data ? 60.0 : 0),
|
||||
);
|
||||
}),
|
||||
],
|
||||
@ -360,6 +413,13 @@ class _MenuBarState extends State<MenuBar> {
|
||||
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
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -505,6 +565,36 @@ class _MenuBarState extends State<MenuBar> {
|
||||
),
|
||||
)
|
||||
: 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()
|
||||
: Material(
|
||||
color: Colors.transparent,
|
||||
|
@ -267,8 +267,16 @@ class _PlayedHistoryState extends State<PlayedHistory>
|
||||
10))),
|
||||
padding: EdgeInsets.all(2),
|
||||
child: Text(
|
||||
_stringForSeconds(snapshot
|
||||
.data[index].seconds),
|
||||
snapshot.data[index]
|
||||
.seconds ==
|
||||
0 &&
|
||||
snapshot.data[index]
|
||||
.seekValue ==
|
||||
1
|
||||
? 'Mark'
|
||||
: _stringForSeconds(
|
||||
snapshot.data[index]
|
||||
.seconds),
|
||||
style: TextStyle(
|
||||
color: Colors.white),
|
||||
),
|
||||
|
@ -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
|
||||
class AddToPlaylistPainter extends CustomPainter {
|
||||
Color _color;
|
||||
|
@ -96,11 +96,12 @@ class EpisodeGrid extends StatelessWidget {
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: WaveLoader(color: context.accentColor))
|
||||
: layout == Layout.two && isListened > 0
|
||||
: layout != Layout.three && isListened > 0
|
||||
? Container(
|
||||
height: 20,
|
||||
width: 20,
|
||||
margin: EdgeInsets.symmetric(horizontal: 2),
|
||||
padding: EdgeInsets.all(2),
|
||||
decoration: BoxDecoration(
|
||||
color: context.accentColor,
|
||||
shape: BoxShape.circle,
|
||||
|
Loading…
x
Reference in New Issue
Block a user