mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-13 12:12:20 -06:00
Small refactorings to inbox
This commit is contained in:
@@ -20,7 +20,7 @@ import 'package:paperless_mobile/features/document_upload/view/document_upload_p
|
|||||||
import 'package:paperless_mobile/features/documents/bloc/documents_cubit.dart';
|
import 'package:paperless_mobile/features/documents/bloc/documents_cubit.dart';
|
||||||
import 'package:paperless_mobile/features/documents/view/pages/documents_page.dart';
|
import 'package:paperless_mobile/features/documents/view/pages/documents_page.dart';
|
||||||
import 'package:paperless_mobile/features/home/view/route_description.dart';
|
import 'package:paperless_mobile/features/home/view/route_description.dart';
|
||||||
import 'package:paperless_mobile/features/home/view/widget/app_drawer.dart';
|
import 'package:paperless_mobile/features/home/view/widget/_app_drawer.dart';
|
||||||
import 'package:paperless_mobile/features/inbox/bloc/inbox_cubit.dart';
|
import 'package:paperless_mobile/features/inbox/bloc/inbox_cubit.dart';
|
||||||
import 'package:paperless_mobile/features/inbox/view/pages/inbox_page.dart';
|
import 'package:paperless_mobile/features/inbox/view/pages/inbox_page.dart';
|
||||||
import 'package:paperless_mobile/features/labels/view/pages/labels_page.dart';
|
import 'package:paperless_mobile/features/labels/view/pages/labels_page.dart';
|
||||||
@@ -59,6 +59,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
context.read(),
|
context.read(),
|
||||||
context.read(),
|
context.read(),
|
||||||
context.read(),
|
context.read(),
|
||||||
|
context.read(),
|
||||||
);
|
);
|
||||||
context.read<ConnectivityCubit>().reload();
|
context.read<ConnectivityCubit>().reload();
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||||
@@ -271,7 +272,6 @@ class _HomePageState extends State<HomePage> {
|
|||||||
destinations:
|
destinations:
|
||||||
destinations.map((e) => e.toNavigationDestination()).toList(),
|
destinations.map((e) => e.toNavigationDestination()).toList(),
|
||||||
),
|
),
|
||||||
drawer: const AppDrawer(),
|
|
||||||
body: routes[_currentIndex],
|
body: routes[_currentIndex],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
320
lib/features/home/view/widget/_app_drawer.dart
Normal file
320
lib/features/home/view/widget/_app_drawer.dart
Normal file
@@ -0,0 +1,320 @@
|
|||||||
|
// import 'package:flutter/material.dart';
|
||||||
|
// import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
// import 'package:hydrated_bloc/hydrated_bloc.dart';
|
||||||
|
// import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
// import 'package:paperless_api/paperless_api.dart';
|
||||||
|
// import 'package:paperless_mobile/core/bloc/paperless_server_information_cubit.dart';
|
||||||
|
// import 'package:paperless_mobile/core/bloc/paperless_server_information_state.dart';
|
||||||
|
// import 'package:paperless_mobile/core/repository/label_repository.dart';
|
||||||
|
// import 'package:paperless_mobile/core/repository/provider/label_repositories_provider.dart';
|
||||||
|
// import 'package:paperless_mobile/core/repository/saved_view_repository.dart';
|
||||||
|
// import 'package:paperless_mobile/core/repository/state/impl/correspondent_repository_state.dart';
|
||||||
|
// import 'package:paperless_mobile/core/repository/state/impl/document_type_repository_state.dart';
|
||||||
|
// import 'package:paperless_mobile/core/repository/state/impl/storage_path_repository_state.dart';
|
||||||
|
// import 'package:paperless_mobile/core/repository/state/impl/tag_repository_state.dart';
|
||||||
|
// import 'package:paperless_mobile/extensions/flutter_extensions.dart';
|
||||||
|
// import 'package:paperless_mobile/features/inbox/bloc/inbox_cubit.dart';
|
||||||
|
// import 'package:paperless_mobile/features/inbox/view/pages/inbox_page.dart';
|
||||||
|
// import 'package:paperless_mobile/features/login/bloc/authentication_cubit.dart';
|
||||||
|
// import 'package:paperless_mobile/features/settings/bloc/application_settings_cubit.dart';
|
||||||
|
// import 'package:paperless_mobile/features/settings/view/settings_page.dart';
|
||||||
|
// import 'package:paperless_mobile/generated/l10n.dart';
|
||||||
|
// import 'package:paperless_mobile/helpers/message_helpers.dart';
|
||||||
|
// import 'package:paperless_mobile/constants.dart';
|
||||||
|
// import 'package:url_launcher/link.dart';
|
||||||
|
// import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
|
||||||
|
// class AppDrawer extends StatefulWidget {
|
||||||
|
// final VoidCallback? afterInboxClosed;
|
||||||
|
|
||||||
|
// const AppDrawer({Key? key, this.afterInboxClosed}) : super(key: key);
|
||||||
|
|
||||||
|
// @override
|
||||||
|
// State<AppDrawer> createState() => _AppDrawerState();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // enum NavigationDestinations {
|
||||||
|
// // inbox,
|
||||||
|
// // settings,
|
||||||
|
// // reportBug,
|
||||||
|
// // about,
|
||||||
|
// // logout;
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// class _AppDrawerState extends State<AppDrawer> {
|
||||||
|
// @override
|
||||||
|
// void initState() {
|
||||||
|
// super.initState();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @override
|
||||||
|
// Widget build(BuildContext context) {
|
||||||
|
// final listtTileShape = RoundedRectangleBorder(
|
||||||
|
// borderRadius: BorderRadius.circular(32),
|
||||||
|
// );
|
||||||
|
// // return NavigationDrawer(
|
||||||
|
// // selectedIndex: -1,
|
||||||
|
// // children: [
|
||||||
|
// // Text(
|
||||||
|
// // "",
|
||||||
|
// // style: Theme.of(context).textTheme.titleSmall,
|
||||||
|
// // ).padded(16),
|
||||||
|
// // NavigationDrawerDestination(
|
||||||
|
// // icon: const Icon(Icons.inbox),
|
||||||
|
// // label: Text(S.of(context).bottomNavInboxPageLabel),
|
||||||
|
// // ),
|
||||||
|
// // NavigationDrawerDestination(
|
||||||
|
// // icon: const Icon(Icons.settings),
|
||||||
|
// // label: Text(S.of(context).appDrawerSettingsLabel),
|
||||||
|
// // ),
|
||||||
|
// // const Divider(
|
||||||
|
// // indent: 16,
|
||||||
|
// // ),
|
||||||
|
// // NavigationDrawerDestination(
|
||||||
|
// // icon: const Icon(Icons.bug_report),
|
||||||
|
// // label: Text(S.of(context).appDrawerReportBugLabel),
|
||||||
|
// // ),
|
||||||
|
// // NavigationDrawerDestination(
|
||||||
|
// // icon: const Icon(Icons.info_outline),
|
||||||
|
// // label: Text(S.of(context).appDrawerAboutLabel),
|
||||||
|
// // ),
|
||||||
|
// // ],
|
||||||
|
// // onDestinationSelected: (idx) {
|
||||||
|
// // final val = NavigationDestinations.values[idx - 1];
|
||||||
|
// // switch (val) {
|
||||||
|
// // case NavigationDestinations.inbox:
|
||||||
|
// // _onOpenInbox();
|
||||||
|
// // break;
|
||||||
|
// // case NavigationDestinations.settings:
|
||||||
|
// // _onOpenSettings();
|
||||||
|
// // break;
|
||||||
|
// // case NavigationDestinations.reportBug:
|
||||||
|
// // launchUrlString(
|
||||||
|
// // 'https://github.com/astubenbord/paperless-mobile/issues/new',
|
||||||
|
// // );
|
||||||
|
// // break;
|
||||||
|
// // case NavigationDestinations.about:
|
||||||
|
// // _onShowAboutDialog();
|
||||||
|
// // break;
|
||||||
|
// // case NavigationDestinations.logout:
|
||||||
|
// // _onLogout();
|
||||||
|
// // break;
|
||||||
|
// // }
|
||||||
|
// // },
|
||||||
|
// // );
|
||||||
|
// return SafeArea(
|
||||||
|
// top: true,
|
||||||
|
// child: ClipRRect(
|
||||||
|
// borderRadius: const BorderRadius.only(
|
||||||
|
// topRight: Radius.circular(16.0),
|
||||||
|
// bottomRight: Radius.circular(16.0),
|
||||||
|
// ),
|
||||||
|
// child: Drawer(
|
||||||
|
// shape: const RoundedRectangleBorder(
|
||||||
|
// borderRadius: BorderRadius.only(
|
||||||
|
// topRight: Radius.circular(16.0),
|
||||||
|
// bottomRight: Radius.circular(16.0),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// child: ListView(
|
||||||
|
// children: [
|
||||||
|
// DrawerHeader(
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// color: Theme.of(context).colorScheme.secondaryContainer,
|
||||||
|
// ),
|
||||||
|
// padding: const EdgeInsets.only(
|
||||||
|
// top: 8,
|
||||||
|
// left: 8,
|
||||||
|
// bottom: 0,
|
||||||
|
// right: 8,
|
||||||
|
// ),
|
||||||
|
// child: Column(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// children: [
|
||||||
|
// Row(
|
||||||
|
// children: [
|
||||||
|
// Image.asset(
|
||||||
|
// 'assets/logos/paperless_logo_white.png',
|
||||||
|
// height: 32,
|
||||||
|
// width: 32,
|
||||||
|
// color:
|
||||||
|
// Theme.of(context).colorScheme.onPrimaryContainer,
|
||||||
|
// ).paddedOnly(right: 8.0),
|
||||||
|
// Text(
|
||||||
|
// S.of(context).appTitleText,
|
||||||
|
// style: Theme.of(context)
|
||||||
|
// .textTheme
|
||||||
|
// .headlineSmall
|
||||||
|
// ?.copyWith(
|
||||||
|
// color: Theme.of(context)
|
||||||
|
// .colorScheme
|
||||||
|
// .onPrimaryContainer,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// Align(
|
||||||
|
// alignment: Alignment.bottomRight,
|
||||||
|
// child: BlocBuilder<PaperlessServerInformationCubit,
|
||||||
|
// PaperlessServerInformationState>(
|
||||||
|
// builder: (context, state) {
|
||||||
|
// if (!state.isLoaded) {
|
||||||
|
// return Container();
|
||||||
|
// }
|
||||||
|
// final info = state.information!;
|
||||||
|
// return Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
// children: [
|
||||||
|
// ListTile(
|
||||||
|
// contentPadding: EdgeInsets.zero,
|
||||||
|
// dense: true,
|
||||||
|
// title: Text(
|
||||||
|
// S.of(context).appDrawerHeaderLoggedInAsText +
|
||||||
|
// (info.username ?? '?'),
|
||||||
|
// style: Theme.of(context).textTheme.bodyMedium,
|
||||||
|
// overflow: TextOverflow.ellipsis,
|
||||||
|
// textAlign: TextAlign.end,
|
||||||
|
// maxLines: 1,
|
||||||
|
// ),
|
||||||
|
// subtitle: Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
// children: [
|
||||||
|
// Text(
|
||||||
|
// state.information!.host ?? '',
|
||||||
|
// style: Theme.of(context)
|
||||||
|
// .textTheme
|
||||||
|
// .bodyMedium,
|
||||||
|
// overflow: TextOverflow.ellipsis,
|
||||||
|
// textAlign: TextAlign.end,
|
||||||
|
// maxLines: 1,
|
||||||
|
// ),
|
||||||
|
// Text(
|
||||||
|
// '${S.of(context).serverInformationPaperlessVersionText} ${info.version} (API v${info.apiVersion})',
|
||||||
|
// style:
|
||||||
|
// Theme.of(context).textTheme.bodySmall,
|
||||||
|
// overflow: TextOverflow.ellipsis,
|
||||||
|
// textAlign: TextAlign.end,
|
||||||
|
// maxLines: 1,
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// isThreeLine: true,
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ...[
|
||||||
|
// ListTile(
|
||||||
|
// title: Text(S.of(context).bottomNavInboxPageLabel),
|
||||||
|
// leading: const Icon(Icons.inbox),
|
||||||
|
// onTap: () => _onOpenInbox(),
|
||||||
|
// shape: listtTileShape,
|
||||||
|
// ),
|
||||||
|
// ListTile(
|
||||||
|
// leading: const Icon(Icons.settings),
|
||||||
|
// shape: listtTileShape,
|
||||||
|
// title: Text(
|
||||||
|
// S.of(context).appDrawerSettingsLabel,
|
||||||
|
// ),
|
||||||
|
// onTap: () => Navigator.of(context).push(
|
||||||
|
// MaterialPageRoute(
|
||||||
|
// builder: (context) => BlocProvider.value(
|
||||||
|
// value: context.read<ApplicationSettingsCubit>(),
|
||||||
|
// child: const SettingsPage(),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const Divider(
|
||||||
|
// indent: 16,
|
||||||
|
// endIndent: 16,
|
||||||
|
// ),
|
||||||
|
// ListTile(
|
||||||
|
// leading: const Icon(Icons.bug_report),
|
||||||
|
// title: Text(S.of(context).appDrawerReportBugLabel),
|
||||||
|
// onTap: () {
|
||||||
|
// launchUrlString(
|
||||||
|
// 'https://github.com/astubenbord/paperless-mobile/issues/new');
|
||||||
|
// },
|
||||||
|
// shape: listtTileShape,
|
||||||
|
// ),
|
||||||
|
// ListTile(
|
||||||
|
// title: Text(S.of(context).appDrawerAboutLabel),
|
||||||
|
// leading: Icon(Icons.info_outline_rounded),
|
||||||
|
// onTap: _onShowAboutDialog,
|
||||||
|
// shape: listtTileShape,
|
||||||
|
// ),
|
||||||
|
// ListTile(
|
||||||
|
// leading: const Icon(Icons.logout),
|
||||||
|
// title: Text(S.of(context).appDrawerLogoutLabel),
|
||||||
|
// shape: listtTileShape,
|
||||||
|
// onTap: () {
|
||||||
|
// _onLogout();
|
||||||
|
// },
|
||||||
|
// )
|
||||||
|
// ],
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void _onLogout() async {
|
||||||
|
// try {
|
||||||
|
// await context.read<AuthenticationCubit>().logout();
|
||||||
|
// await context.read<ApplicationSettingsCubit>().clear();
|
||||||
|
// await context.read<LabelRepository<Tag, TagRepositoryState>>().clear();
|
||||||
|
// await context
|
||||||
|
// .read<LabelRepository<Correspondent, CorrespondentRepositoryState>>()
|
||||||
|
// .clear();
|
||||||
|
// await context
|
||||||
|
// .read<LabelRepository<DocumentType, DocumentTypeRepositoryState>>()
|
||||||
|
// .clear();
|
||||||
|
// await context
|
||||||
|
// .read<LabelRepository<StoragePath, StoragePathRepositoryState>>()
|
||||||
|
// .clear();
|
||||||
|
// await context.read<SavedViewRepository>().clear();
|
||||||
|
// await HydratedBloc.storage.clear();
|
||||||
|
// } on PaperlessServerException catch (error, stackTrace) {
|
||||||
|
// showErrorMessage(context, error, stackTrace);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Future<void> _onOpenInbox() async {
|
||||||
|
// await Navigator.of(context).push(
|
||||||
|
// MaterialPageRoute(
|
||||||
|
// builder: (_) => LabelRepositoriesProvider(
|
||||||
|
// child: BlocProvider(
|
||||||
|
// create: (context) => InboxCubit(
|
||||||
|
// context.read(),
|
||||||
|
// context.read(),
|
||||||
|
// context.read(),
|
||||||
|
// context.read(),
|
||||||
|
// )..initializeInbox(),
|
||||||
|
// child: const InboxPage(),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// widget.afterInboxClosed?.call();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void _onOpenSettings() {
|
||||||
|
// Navigator.of(context).push(
|
||||||
|
// MaterialPageRoute(
|
||||||
|
// builder: (context) => BlocProvider.value(
|
||||||
|
// value: context.read<ApplicationSettingsCubit>(),
|
||||||
|
// child: const SettingsPage(),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// void _onShowAboutDialog() {}
|
||||||
|
// }
|
||||||
@@ -1,321 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:hydrated_bloc/hydrated_bloc.dart';
|
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
|
||||||
import 'package:paperless_api/paperless_api.dart';
|
|
||||||
import 'package:paperless_mobile/core/bloc/paperless_server_information_cubit.dart';
|
|
||||||
import 'package:paperless_mobile/core/bloc/paperless_server_information_state.dart';
|
|
||||||
import 'package:paperless_mobile/core/repository/label_repository.dart';
|
|
||||||
import 'package:paperless_mobile/core/repository/provider/label_repositories_provider.dart';
|
|
||||||
import 'package:paperless_mobile/core/repository/saved_view_repository.dart';
|
|
||||||
import 'package:paperless_mobile/core/repository/state/impl/correspondent_repository_state.dart';
|
|
||||||
import 'package:paperless_mobile/core/repository/state/impl/document_type_repository_state.dart';
|
|
||||||
import 'package:paperless_mobile/core/repository/state/impl/storage_path_repository_state.dart';
|
|
||||||
import 'package:paperless_mobile/core/repository/state/impl/tag_repository_state.dart';
|
|
||||||
import 'package:paperless_mobile/extensions/flutter_extensions.dart';
|
|
||||||
import 'package:paperless_mobile/features/inbox/bloc/inbox_cubit.dart';
|
|
||||||
import 'package:paperless_mobile/features/inbox/view/pages/inbox_page.dart';
|
|
||||||
import 'package:paperless_mobile/features/login/bloc/authentication_cubit.dart';
|
|
||||||
import 'package:paperless_mobile/features/settings/bloc/application_settings_cubit.dart';
|
|
||||||
import 'package:paperless_mobile/features/settings/view/settings_page.dart';
|
|
||||||
import 'package:paperless_mobile/generated/l10n.dart';
|
|
||||||
import 'package:paperless_mobile/helpers/message_helpers.dart';
|
|
||||||
import 'package:paperless_mobile/constants.dart';
|
|
||||||
import 'package:url_launcher/link.dart';
|
|
||||||
import 'package:url_launcher/url_launcher_string.dart';
|
|
||||||
|
|
||||||
class AppDrawer extends StatefulWidget {
|
|
||||||
final VoidCallback? afterInboxClosed;
|
|
||||||
|
|
||||||
const AppDrawer({Key? key, this.afterInboxClosed}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<AppDrawer> createState() => _AppDrawerState();
|
|
||||||
}
|
|
||||||
|
|
||||||
// enum NavigationDestinations {
|
|
||||||
// inbox,
|
|
||||||
// settings,
|
|
||||||
// reportBug,
|
|
||||||
// about,
|
|
||||||
// logout;
|
|
||||||
// }
|
|
||||||
|
|
||||||
class _AppDrawerState extends State<AppDrawer> {
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final listtTileShape = RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(32),
|
|
||||||
);
|
|
||||||
// return NavigationDrawer(
|
|
||||||
// selectedIndex: -1,
|
|
||||||
// children: [
|
|
||||||
// Text(
|
|
||||||
// "",
|
|
||||||
// style: Theme.of(context).textTheme.titleSmall,
|
|
||||||
// ).padded(16),
|
|
||||||
// NavigationDrawerDestination(
|
|
||||||
// icon: const Icon(Icons.inbox),
|
|
||||||
// label: Text(S.of(context).bottomNavInboxPageLabel),
|
|
||||||
// ),
|
|
||||||
// NavigationDrawerDestination(
|
|
||||||
// icon: const Icon(Icons.settings),
|
|
||||||
// label: Text(S.of(context).appDrawerSettingsLabel),
|
|
||||||
// ),
|
|
||||||
// const Divider(
|
|
||||||
// indent: 16,
|
|
||||||
// ),
|
|
||||||
// NavigationDrawerDestination(
|
|
||||||
// icon: const Icon(Icons.bug_report),
|
|
||||||
// label: Text(S.of(context).appDrawerReportBugLabel),
|
|
||||||
// ),
|
|
||||||
// NavigationDrawerDestination(
|
|
||||||
// icon: const Icon(Icons.info_outline),
|
|
||||||
// label: Text(S.of(context).appDrawerAboutLabel),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// onDestinationSelected: (idx) {
|
|
||||||
// final val = NavigationDestinations.values[idx - 1];
|
|
||||||
// switch (val) {
|
|
||||||
// case NavigationDestinations.inbox:
|
|
||||||
// _onOpenInbox();
|
|
||||||
// break;
|
|
||||||
// case NavigationDestinations.settings:
|
|
||||||
// _onOpenSettings();
|
|
||||||
// break;
|
|
||||||
// case NavigationDestinations.reportBug:
|
|
||||||
// launchUrlString(
|
|
||||||
// 'https://github.com/astubenbord/paperless-mobile/issues/new',
|
|
||||||
// );
|
|
||||||
// break;
|
|
||||||
// case NavigationDestinations.about:
|
|
||||||
// _onShowAboutDialog();
|
|
||||||
// break;
|
|
||||||
// case NavigationDestinations.logout:
|
|
||||||
// _onLogout();
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
return SafeArea(
|
|
||||||
top: true,
|
|
||||||
child: ClipRRect(
|
|
||||||
borderRadius: const BorderRadius.only(
|
|
||||||
topRight: Radius.circular(16.0),
|
|
||||||
bottomRight: Radius.circular(16.0),
|
|
||||||
),
|
|
||||||
child: Drawer(
|
|
||||||
shape: const RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.only(
|
|
||||||
topRight: Radius.circular(16.0),
|
|
||||||
bottomRight: Radius.circular(16.0),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: ListView(
|
|
||||||
children: [
|
|
||||||
DrawerHeader(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Theme.of(context).colorScheme.secondaryContainer,
|
|
||||||
),
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
top: 8,
|
|
||||||
left: 8,
|
|
||||||
bottom: 0,
|
|
||||||
right: 8,
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Image.asset(
|
|
||||||
'assets/logos/paperless_logo_white.png',
|
|
||||||
height: 32,
|
|
||||||
width: 32,
|
|
||||||
color:
|
|
||||||
Theme.of(context).colorScheme.onPrimaryContainer,
|
|
||||||
).paddedOnly(right: 8.0),
|
|
||||||
Text(
|
|
||||||
S.of(context).appTitleText,
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.headlineSmall
|
|
||||||
?.copyWith(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onPrimaryContainer,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.bottomRight,
|
|
||||||
child: BlocBuilder<PaperlessServerInformationCubit,
|
|
||||||
PaperlessServerInformationState>(
|
|
||||||
builder: (context, state) {
|
|
||||||
if (!state.isLoaded) {
|
|
||||||
return Container();
|
|
||||||
}
|
|
||||||
final info = state.information!;
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
ListTile(
|
|
||||||
contentPadding: EdgeInsets.zero,
|
|
||||||
dense: true,
|
|
||||||
title: Text(
|
|
||||||
S.of(context).appDrawerHeaderLoggedInAsText +
|
|
||||||
(info.username ?? '?'),
|
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
textAlign: TextAlign.end,
|
|
||||||
maxLines: 1,
|
|
||||||
),
|
|
||||||
subtitle: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
state.information!.host ?? '',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodyMedium,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
textAlign: TextAlign.end,
|
|
||||||
maxLines: 1,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'${S.of(context).serverInformationPaperlessVersionText} ${info.version} (API v${info.apiVersion})',
|
|
||||||
style:
|
|
||||||
Theme.of(context).textTheme.bodySmall,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
textAlign: TextAlign.end,
|
|
||||||
maxLines: 1,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
isThreeLine: true,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
...[
|
|
||||||
ListTile(
|
|
||||||
title: Text(S.of(context).bottomNavInboxPageLabel),
|
|
||||||
leading: const Icon(Icons.inbox),
|
|
||||||
onTap: () => _onOpenInbox(),
|
|
||||||
shape: listtTileShape,
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(Icons.settings),
|
|
||||||
shape: listtTileShape,
|
|
||||||
title: Text(
|
|
||||||
S.of(context).appDrawerSettingsLabel,
|
|
||||||
),
|
|
||||||
onTap: () => Navigator.of(context).push(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => BlocProvider.value(
|
|
||||||
value: context.read<ApplicationSettingsCubit>(),
|
|
||||||
child: const SettingsPage(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Divider(
|
|
||||||
indent: 16,
|
|
||||||
endIndent: 16,
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(Icons.bug_report),
|
|
||||||
title: Text(S.of(context).appDrawerReportBugLabel),
|
|
||||||
onTap: () {
|
|
||||||
launchUrlString(
|
|
||||||
'https://github.com/astubenbord/paperless-mobile/issues/new');
|
|
||||||
},
|
|
||||||
shape: listtTileShape,
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(S.of(context).appDrawerAboutLabel),
|
|
||||||
leading: Icon(Icons.info_outline_rounded),
|
|
||||||
onTap: _onShowAboutDialog,
|
|
||||||
shape: listtTileShape,
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(Icons.logout),
|
|
||||||
title: Text(S.of(context).appDrawerLogoutLabel),
|
|
||||||
shape: listtTileShape,
|
|
||||||
onTap: () {
|
|
||||||
_onLogout();
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onLogout() async {
|
|
||||||
try {
|
|
||||||
await context.read<AuthenticationCubit>().logout();
|
|
||||||
await context.read<ApplicationSettingsCubit>().clear();
|
|
||||||
await context.read<LabelRepository<Tag, TagRepositoryState>>().clear();
|
|
||||||
await context
|
|
||||||
.read<LabelRepository<Correspondent, CorrespondentRepositoryState>>()
|
|
||||||
.clear();
|
|
||||||
await context
|
|
||||||
.read<LabelRepository<DocumentType, DocumentTypeRepositoryState>>()
|
|
||||||
.clear();
|
|
||||||
await context
|
|
||||||
.read<LabelRepository<StoragePath, StoragePathRepositoryState>>()
|
|
||||||
.clear();
|
|
||||||
await context.read<SavedViewRepository>().clear();
|
|
||||||
await HydratedBloc.storage.clear();
|
|
||||||
} on PaperlessServerException catch (error, stackTrace) {
|
|
||||||
showErrorMessage(context, error, stackTrace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onOpenInbox() async {
|
|
||||||
await Navigator.of(context).push(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (_) => LabelRepositoriesProvider(
|
|
||||||
child: BlocProvider(
|
|
||||||
create: (context) => InboxCubit(
|
|
||||||
context.read(),
|
|
||||||
context.read(),
|
|
||||||
context.read(),
|
|
||||||
context.read(),
|
|
||||||
)..initializeInbox(),
|
|
||||||
child: const InboxPage(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
widget.afterInboxClosed?.call();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onOpenSettings() {
|
|
||||||
Navigator.of(context).push(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => BlocProvider.value(
|
|
||||||
value: context.read<ApplicationSettingsCubit>(),
|
|
||||||
child: const SettingsPage(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onShowAboutDialog() {}
|
|
||||||
}
|
|
||||||
@@ -18,16 +18,20 @@ class InboxCubit extends HydratedCubit<InboxState> with PagedDocumentsMixin {
|
|||||||
|
|
||||||
final PaperlessDocumentsApi _documentsApi;
|
final PaperlessDocumentsApi _documentsApi;
|
||||||
|
|
||||||
|
final PaperlessServerStatsApi _statsApi;
|
||||||
|
|
||||||
final List<StreamSubscription> _subscriptions = [];
|
final List<StreamSubscription> _subscriptions = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
PaperlessDocumentsApi get api => _documentsApi;
|
PaperlessDocumentsApi get api => _documentsApi;
|
||||||
|
|
||||||
|
Timer? _taskTimer;
|
||||||
InboxCubit(
|
InboxCubit(
|
||||||
this._tagsRepository,
|
this._tagsRepository,
|
||||||
this._documentsApi,
|
this._documentsApi,
|
||||||
this._correspondentRepository,
|
this._correspondentRepository,
|
||||||
this._documentTypeRepository,
|
this._documentTypeRepository,
|
||||||
|
this._statsApi,
|
||||||
) : super(
|
) : super(
|
||||||
InboxState(
|
InboxState(
|
||||||
availableCorrespondents:
|
availableCorrespondents:
|
||||||
@@ -60,6 +64,15 @@ class InboxCubit extends HydratedCubit<InboxState> with PagedDocumentsMixin {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
//TODO: Do this properly in a background task.
|
||||||
|
_taskTimer = Timer.periodic(const Duration(seconds: 5), (timer) {
|
||||||
|
refreshItemsInInboxCount();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void refreshItemsInInboxCount() async {
|
||||||
|
final stats = await _statsApi.getServerStatistics();
|
||||||
|
emit(state.copyWith(itemsInInboxCount: stats.documentsInInbox));
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -175,9 +188,10 @@ class InboxCubit extends HydratedCubit<InboxState> with PagedDocumentsMixin {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> close() {
|
Future<void> close() {
|
||||||
_subscriptions.forEach((element) {
|
_taskTimer?.cancel();
|
||||||
element.cancel();
|
for (var sub in _subscriptions) {
|
||||||
});
|
sub.cancel();
|
||||||
|
}
|
||||||
return super.close();
|
return super.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ class InboxState extends PagedDocumentsState {
|
|||||||
|
|
||||||
final Map<int, Correspondent> availableCorrespondents;
|
final Map<int, Correspondent> availableCorrespondents;
|
||||||
|
|
||||||
|
final int itemsInInboxCount;
|
||||||
|
|
||||||
@JsonKey()
|
@JsonKey()
|
||||||
final bool isHintAcknowledged;
|
final bool isHintAcknowledged;
|
||||||
|
|
||||||
@@ -29,6 +31,7 @@ class InboxState extends PagedDocumentsState {
|
|||||||
this.availableTags = const {},
|
this.availableTags = const {},
|
||||||
this.availableDocumentTypes = const {},
|
this.availableDocumentTypes = const {},
|
||||||
this.availableCorrespondents = const {},
|
this.availableCorrespondents = const {},
|
||||||
|
this.itemsInInboxCount = 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -43,6 +46,7 @@ class InboxState extends PagedDocumentsState {
|
|||||||
availableTags,
|
availableTags,
|
||||||
availableDocumentTypes,
|
availableDocumentTypes,
|
||||||
availableCorrespondents,
|
availableCorrespondents,
|
||||||
|
itemsInInboxCount,
|
||||||
];
|
];
|
||||||
|
|
||||||
InboxState copyWith({
|
InboxState copyWith({
|
||||||
@@ -56,6 +60,7 @@ class InboxState extends PagedDocumentsState {
|
|||||||
Map<int, Correspondent>? availableCorrespondents,
|
Map<int, Correspondent>? availableCorrespondents,
|
||||||
Map<int, DocumentType>? availableDocumentTypes,
|
Map<int, DocumentType>? availableDocumentTypes,
|
||||||
Map<int, FieldSuggestions>? suggestions,
|
Map<int, FieldSuggestions>? suggestions,
|
||||||
|
int? itemsInInboxCount,
|
||||||
}) {
|
}) {
|
||||||
return InboxState(
|
return InboxState(
|
||||||
hasLoaded: hasLoaded ?? super.hasLoaded,
|
hasLoaded: hasLoaded ?? super.hasLoaded,
|
||||||
@@ -69,6 +74,7 @@ class InboxState extends PagedDocumentsState {
|
|||||||
availableDocumentTypes ?? this.availableDocumentTypes,
|
availableDocumentTypes ?? this.availableDocumentTypes,
|
||||||
availableTags: availableTags ?? this.availableTags,
|
availableTags: availableTags ?? this.availableTags,
|
||||||
filter: filter ?? super.filter,
|
filter: filter ?? super.filter,
|
||||||
|
itemsInInboxCount: itemsInInboxCount ?? this.itemsInInboxCount,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,9 +79,8 @@ class _InboxPageState extends State<InboxPage> {
|
|||||||
body: NestedScrollView(
|
body: NestedScrollView(
|
||||||
headerSliverBuilder: (context, innerBoxIsScrolled) => [
|
headerSliverBuilder: (context, innerBoxIsScrolled) => [
|
||||||
SearchAppBar(
|
SearchAppBar(
|
||||||
hintText: "Search documents",
|
hintText: "Search documents",
|
||||||
onOpenSearch: showDocumentSearchPage,
|
onOpenSearch: showDocumentSearchPage),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
body: BlocBuilder<InboxCubit, InboxState>(
|
body: BlocBuilder<InboxCubit, InboxState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
|||||||
Reference in New Issue
Block a user