From b5aac0952a590e6d1639b46c77022d49a7d940a7 Mon Sep 17 00:00:00 2001 From: Garrit Franke Date: Wed, 17 Feb 2021 16:04:27 +0100 Subject: [PATCH] feat: feed title --- lib/main.dart | 9 --------- lib/miniflux.dart | 18 ++++++++++++++++-- lib/views/unread_view.dart | 6 ++++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 67dcea1..2d0a181 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -70,15 +70,6 @@ class _MyHomePageState extends State { }); } - void _readArticle(FeedEntry entry) async { - if (await canLaunch(entry.url)) { - MinifluxApi.instance.markAsRead(entry.id); - launch(entry.url); - } else { - throw 'Could not launch ${entry.url}'; - } - } - @override void initState() { checkConfig().then((success) { diff --git a/lib/miniflux.dart b/lib/miniflux.dart index cd248f7..4ffaa37 100644 --- a/lib/miniflux.dart +++ b/lib/miniflux.dart @@ -5,20 +5,34 @@ import 'package:localstorage/localstorage.dart'; import 'config.dart'; import 'package:http/http.dart' as http; +class Feed { + int id; + String url; + String title; + + Feed({this.id, this.url, this.title}); + + factory Feed.fromJson(Map json) { + return Feed(id: json["id"], url: json["url"], title: json["title"]); + } +} + class FeedEntry { int id; String status; String title; String url; + Feed feed; - FeedEntry({this.id, this.status, this.title, this.url}); + FeedEntry({this.id, this.status, this.title, this.url, this.feed}); factory FeedEntry.fromJson(Map json) { return FeedEntry( id: json["id"], status: json["status"], title: json["title"], - url: json["url"]); + url: json["url"], + feed: Feed.fromJson(json["feed"])); } } diff --git a/lib/views/unread_view.dart b/lib/views/unread_view.dart index 55f6bbc..9b09719 100644 --- a/lib/views/unread_view.dart +++ b/lib/views/unread_view.dart @@ -41,6 +41,9 @@ class _UnreadViewState extends State { if (await canLaunch(entry.url)) { MinifluxApi.instance.markAsRead(entry.id); launch(entry.url); + setState(() { + unreadPosts.remove(entry); + }); } else { throw 'Could not launch ${entry.url}'; } @@ -57,8 +60,6 @@ class _UnreadViewState extends State { super.initState(); } - static const List _widgetOptions = []; - @override Widget build(BuildContext context) { return Container( @@ -82,6 +83,7 @@ class _UnreadViewState extends State { child: ListTile( key: UniqueKey(), title: Text(entry.title), + subtitle: Text(entry.feed.title), onTap: () => _readArticle(entry), ), ), -- 2.45.2