Browse Source

neon: AppImplementation provide default getUnreadCounter

neon: simplify AppImplementation.getUnreadCounter interface
pull/387/head
Nikolas Rimikis 2 years ago
parent
commit
ffbfd191e0
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 3
      packages/neon/neon/lib/src/pages/home.dart
  2. 2
      packages/neon/neon/lib/src/utils/app_implementation.dart
  3. 3
      packages/neon/neon_files/lib/neon_files.dart
  4. 2
      packages/neon/neon_news/lib/neon_news.dart
  5. 3
      packages/neon/neon_notes/lib/neon_notes.dart
  6. 3
      packages/neon/neon_notifications/lib/neon_notifications.dart

3
packages/neon/neon/lib/src/pages/home.dart

@ -461,7 +461,8 @@ class _HomePageState extends State<HomePage> {
actions: [ actions: [
if (notificationsAppImplementation.data != null) ...[ if (notificationsAppImplementation.data != null) ...[
StreamBuilder<int>( StreamBuilder<int>(
stream: notificationsAppImplementation.data!.getUnreadCounter(_appsBloc), stream: notificationsAppImplementation.data!
.getUnreadCounter(notificationsAppImplementation.data!.getBloc(account)),
builder: (final context, final unreadCounterSnapshot) { builder: (final context, final unreadCounterSnapshot) {
final unreadCount = unreadCounterSnapshot.data ?? 0; final unreadCount = unreadCounterSnapshot.data ?? 0;
return IconButton( return IconButton(

2
packages/neon/neon/lib/src/utils/app_implementation.dart

@ -37,7 +37,7 @@ abstract class AppImplementation<T extends Bloc, R extends NextcloudAppSpecificO
}, },
); );
BehaviorSubject<int>? getUnreadCounter(final AppsBloc appsBloc); BehaviorSubject<int>? getUnreadCounter(final T bloc) => null;
Widget get page; Widget get page;

3
packages/neon/neon_files/lib/neon_files.dart

@ -63,7 +63,4 @@ class FilesApp extends AppImplementation<FilesBloc, FilesAppSpecificOptions> {
@override @override
Widget get page => const FilesMainPage(); Widget get page => const FilesMainPage();
@override
BehaviorSubject<int>? getUnreadCounter(final AppsBloc appsBloc) => null;
} }

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

@ -71,5 +71,5 @@ class NewsApp extends AppImplementation<NewsBloc, NewsAppSpecificOptions> {
Widget get page => const NewsMainPage(); Widget get page => const NewsMainPage();
@override @override
BehaviorSubject<int> getUnreadCounter(final AppsBloc appsBloc) => appsBloc.getAppBloc<NewsBloc>(this).unreadCounter; BehaviorSubject<int> getUnreadCounter(final NewsBloc bloc) => bloc.unreadCounter;
} }

3
packages/neon/neon_notes/lib/neon_notes.dart

@ -60,7 +60,4 @@ class NotesApp extends AppImplementation<NotesBloc, NotesAppSpecificOptions> {
@override @override
Widget get page => const NotesMainPage(); Widget get page => const NotesMainPage();
@override
BehaviorSubject<int>? getUnreadCounter(final AppsBloc appsBloc) => null;
} }

3
packages/neon/neon_notifications/lib/neon_notifications.dart

@ -41,6 +41,5 @@ class NotificationsApp extends AppImplementation<NotificationsBloc, Notification
Widget get page => const NotificationsMainPage(); Widget get page => const NotificationsMainPage();
@override @override
BehaviorSubject<int> getUnreadCounter(final AppsBloc appsBloc) => BehaviorSubject<int> getUnreadCounter(final NotificationsBloc bloc) => bloc.unreadCounter;
appsBloc.getAppBloc<NotificationsBloc>(this).unreadCounter;
} }

Loading…
Cancel
Save