Browse Source

neon_news: simplify FolderFeedsWrapper interface

pull/380/head
Nikolas Rimikis 2 years ago
parent
commit
be71e9ce43
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 2
      packages/neon/neon_news/lib/sort/folders.dart
  2. 9
      packages/neon/neon_news/lib/widgets/folders_view.dart

2
packages/neon/neon_news/lib/sort/folders.dart

@ -11,4 +11,4 @@ final foldersSortBox = SortBox<FoldersSortProperty, FolderFeedsWrapper>(
}, },
); );
typedef FolderFeedsWrapper = (NextcloudNewsFolder folder, List<NextcloudNewsFeed> feeds, int unreadCount); typedef FolderFeedsWrapper = (NextcloudNewsFolder folder, int feedCount, int unreadCount);

9
packages/neon/neon_news/lib/widgets/folders_view.dart

@ -20,10 +20,11 @@ class NewsFoldersView extends StatelessWidget {
input: feeds.data == null input: feeds.data == null
? null ? null
: folders.data?.map((final folder) { : folders.data?.map((final folder) {
final feedsInFolder = feeds.data!.where((final feed) => feed.folderId == folder.id).toList(); final feedsInFolder = feeds.data!.where((final feed) => feed.folderId == folder.id);
final feedCount = feedsInFolder.length;
final unreadCount = feedsInFolder.fold(0, (final a, final b) => a + b.unreadCount!); final unreadCount = feedsInFolder.fold(0, (final a, final b) => a + b.unreadCount!);
return (folder, feedsInFolder, unreadCount); return (folder, feedCount, unreadCount);
}).toList(), }).toList(),
builder: (final context, final sorted) => NeonListView<FolderFeedsWrapper>( builder: (final context, final sorted) => NeonListView<FolderFeedsWrapper>(
scrollKey: 'news-folders', scrollKey: 'news-folders',
@ -42,7 +43,7 @@ class NewsFoldersView extends StatelessWidget {
final BuildContext context, final BuildContext context,
final FolderFeedsWrapper folderFeedsWrapper, final FolderFeedsWrapper folderFeedsWrapper,
) { ) {
final (folder, feeds, unreadCount) = folderFeedsWrapper; final (folder, feedCount, unreadCount) = folderFeedsWrapper;
return ListTile( return ListTile(
title: Text( title: Text(
folder.name, folder.name,
@ -66,7 +67,7 @@ class NewsFoldersView extends StatelessWidget {
), ),
Center( Center(
child: Text( child: Text(
feeds.length.toString(), feedCount.toString(),
style: TextStyle( style: TextStyle(
color: Theme.of(context).colorScheme.onPrimary, color: Theme.of(context).colorScheme.onPrimary,
), ),

Loading…
Cancel
Save