Add remove new mark in podcast page.
This commit is contained in:
parent
bcaab84b8f
commit
378bdd5ba5
|
@ -180,6 +180,15 @@ class DBHelper {
|
|||
return 0;
|
||||
}
|
||||
|
||||
Future<void> removePodcastNewMark(String id) async {
|
||||
var dbClient = await database;
|
||||
await dbClient.transaction((txn) async {
|
||||
await txn.rawUpdate(
|
||||
"UPDATE Episodes SET is_new = 0 WHERE feed_id = ? AND is_new = 1",
|
||||
[id]);
|
||||
});
|
||||
}
|
||||
|
||||
Future<bool> getNeverUpdate(String id) async {
|
||||
var dbClient = await database;
|
||||
List<Map> list = await dbClient
|
||||
|
@ -414,11 +423,12 @@ class DBHelper {
|
|||
ORDER BY add_date DESC""");
|
||||
return list
|
||||
.map((record) => SubHistory(
|
||||
DateTime.fromMillisecondsSinceEpoch(record['remove_date']),
|
||||
DateTime.fromMillisecondsSinceEpoch(record['add_date']),
|
||||
record['rss_url'],
|
||||
record['title'],
|
||||
status: record['status'] == 0 ? true : false,))
|
||||
DateTime.fromMillisecondsSinceEpoch(record['remove_date']),
|
||||
DateTime.fromMillisecondsSinceEpoch(record['add_date']),
|
||||
record['rss_url'],
|
||||
record['title'],
|
||||
status: record['status'] == 0 ? true : false,
|
||||
))
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
@ -1131,8 +1141,7 @@ class DBHelper {
|
|||
P.imagePath, P.primaryColor FROM Episodes E INNER JOIN PodcastLocal P ON E.feed_id = P.id
|
||||
LEFT JOIN PlayHistory H ON E.enclosure_url = H.enclosure_url
|
||||
GROUP BY E.enclosure_url HAVING SUM(H.listen_time) is null
|
||||
OR SUM(H.listen_time) = 0 ORDER BY RANDOM() LIMIT ? """,
|
||||
[random]);
|
||||
OR SUM(H.listen_time) = 0 ORDER BY RANDOM() LIMIT ? """, [random]);
|
||||
} else {
|
||||
list = await dbClient.rawQuery(
|
||||
"""SELECT E.title, E.enclosure_url, E.enclosure_length, E.is_new,
|
||||
|
|
|
@ -113,7 +113,8 @@ class _PodcastDetailState extends State<PodcastDetail> {
|
|||
super.dispose();
|
||||
}
|
||||
|
||||
Future _updateRssItem(BuildContext context, PodcastLocal podcastLocal) async {
|
||||
Future<void> _updateRssItem(
|
||||
BuildContext context, PodcastLocal podcastLocal) async {
|
||||
final result = await _dbHelper.updatePodcastRss(podcastLocal);
|
||||
if (result >= 0) {
|
||||
Fluttertoast.showToast(
|
||||
|
@ -204,6 +205,14 @@ class _PodcastDetailState extends State<PodcastDetail> {
|
|||
}
|
||||
}
|
||||
|
||||
Future<int> _getNewCount() async {
|
||||
return await _dbHelper.getPodcastUpdateCounts(widget.podcastLocal.id);
|
||||
}
|
||||
|
||||
Future<void> _removePodcastNewMark() async {
|
||||
await _dbHelper.removePodcastNewMark(widget.podcastLocal.id);
|
||||
}
|
||||
|
||||
Widget _podcastInfo(BuildContext context) {
|
||||
return Container(
|
||||
height: 170,
|
||||
|
@ -471,7 +480,7 @@ class _PodcastDetailState extends State<PodcastDetail> {
|
|||
|
||||
Widget _actionBar(BuildContext context) {
|
||||
final s = context.s;
|
||||
return Container(
|
||||
return SizedBox(
|
||||
height: 30,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
|
@ -612,6 +621,40 @@ class _PodcastDetailState extends State<PodcastDetail> {
|
|||
}
|
||||
}),
|
||||
Spacer(),
|
||||
FutureBuilder<int>(
|
||||
future: _getNewCount(),
|
||||
initialData: 0,
|
||||
builder: (context, snapshot) {
|
||||
return snapshot.data != 0
|
||||
? Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
child: SizedBox(
|
||||
width: 30,
|
||||
child: IconButton(
|
||||
padding: EdgeInsets.only(bottom: 5),
|
||||
tooltip: s.removeNewMark,
|
||||
icon: Container(
|
||||
height: 18,
|
||||
width: 18,
|
||||
child: CustomPaint(
|
||||
painter: RemoveNewFlagPainter(
|
||||
context.textTheme.bodyText1.color,
|
||||
Colors.red))),
|
||||
onPressed: () async {
|
||||
await _removePodcastNewMark();
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}),
|
||||
),
|
||||
),
|
||||
)
|
||||
: Center();
|
||||
}),
|
||||
if (!widget.hide)
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
|
|
Loading…
Reference in New Issue