mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-08 04:07:51 -06:00
Implemented inbox (still WIP)
This commit is contained in:
@@ -1,18 +1,24 @@
|
||||
import 'dart:developer';
|
||||
import 'dart:isolate';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
||||
import 'package:paperless_mobile/core/bloc/connectivity_cubit.dart';
|
||||
import 'package:paperless_mobile/core/bloc/paperless_server_information_cubit.dart';
|
||||
import 'package:paperless_mobile/core/bloc/paperless_statistics_cubit.dart';
|
||||
import 'package:paperless_mobile/core/model/error_message.dart';
|
||||
import 'package:paperless_mobile/core/widgets/offline_banner.dart';
|
||||
import 'package:paperless_mobile/di_initializer.dart';
|
||||
import 'package:paperless_mobile/features/documents/bloc/documents_cubit.dart';
|
||||
import 'package:paperless_mobile/features/documents/bloc/saved_view_cubit.dart';
|
||||
import 'package:paperless_mobile/features/documents/repository/document_repository.dart';
|
||||
import 'package:paperless_mobile/features/documents/repository/document_repository_impl.dart';
|
||||
import 'package:paperless_mobile/features/documents/view/pages/documents_page.dart';
|
||||
import 'package:paperless_mobile/features/home/view/widget/bottom_navigation_bar.dart';
|
||||
import 'package:paperless_mobile/features/home/view/widget/info_drawer.dart';
|
||||
import 'package:paperless_mobile/features/inbox/view/inbox_page.dart';
|
||||
import 'package:paperless_mobile/features/labels/bloc/label_bloc_provider.dart';
|
||||
import 'package:paperless_mobile/features/labels/correspondent/bloc/correspondents_cubit.dart';
|
||||
import 'package:paperless_mobile/features/labels/document_type/bloc/document_type_cubit.dart';
|
||||
import 'package:paperless_mobile/features/labels/storage_path/bloc/storage_path_cubit.dart';
|
||||
@@ -20,6 +26,7 @@ import 'package:paperless_mobile/features/labels/tags/bloc/tags_cubit.dart';
|
||||
import 'package:paperless_mobile/features/labels/view/pages/labels_page.dart';
|
||||
import 'package:paperless_mobile/features/scan/bloc/document_scanner_cubit.dart';
|
||||
import 'package:paperless_mobile/features/scan/view/scanner_page.dart';
|
||||
import 'package:paperless_mobile/features/settings/bloc/application_settings_cubit.dart';
|
||||
import 'package:paperless_mobile/util.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
@@ -35,7 +42,30 @@ class _HomePageState extends State<HomePage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initializeData(context);
|
||||
_initializeData(context).then(
|
||||
(_) async {
|
||||
FlutterNativeSplash.remove();
|
||||
if (BlocProvider.of<ApplicationSettingsCubit>(context)
|
||||
.state
|
||||
.showInboxOnStartup) {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => BlocProvider.value(
|
||||
value: getIt<PaperlessStatisticsCubit>(),
|
||||
child: LabelBlocProvider(
|
||||
child: BlocProvider.value(
|
||||
value: DocumentsCubit(getIt<DocumentRepository>()),
|
||||
child: const InboxPage(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
getIt<DocumentsCubit>().reloadDocuments();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -59,10 +89,6 @@ class _HomePageState extends State<HomePage> {
|
||||
),
|
||||
drawer: const InfoDrawer(),
|
||||
body: [
|
||||
BlocProvider.value(
|
||||
value: DocumentsCubit(getIt<DocumentRepository>()),
|
||||
child: const InboxPage(),
|
||||
),
|
||||
BlocProvider.value(
|
||||
value: getIt<DocumentsCubit>(),
|
||||
child: const DocumentsPage(),
|
||||
@@ -78,17 +104,21 @@ class _HomePageState extends State<HomePage> {
|
||||
);
|
||||
}
|
||||
|
||||
_initializeData(BuildContext context) async {
|
||||
Future<void> _initializeData(BuildContext context) {
|
||||
try {
|
||||
await BlocProvider.of<PaperlessServerInformationCubit>(context)
|
||||
.updateStatus();
|
||||
BlocProvider.of<DocumentTypeCubit>(context).initialize();
|
||||
BlocProvider.of<CorrespondentCubit>(context).initialize();
|
||||
BlocProvider.of<TagCubit>(context).initialize();
|
||||
BlocProvider.of<StoragePathCubit>(context).initialize();
|
||||
BlocProvider.of<SavedViewCubit>(context).initialize();
|
||||
return Future.wait([
|
||||
BlocProvider.of<PaperlessServerInformationCubit>(context)
|
||||
.updateInformtion(),
|
||||
BlocProvider.of<PaperlessStatisticsCubit>(context).updateStatistics(),
|
||||
BlocProvider.of<DocumentTypeCubit>(context).initialize(),
|
||||
BlocProvider.of<CorrespondentCubit>(context).initialize(),
|
||||
BlocProvider.of<TagCubit>(context).initialize(),
|
||||
BlocProvider.of<StoragePathCubit>(context).initialize(),
|
||||
BlocProvider.of<SavedViewCubit>(context).initialize(),
|
||||
]);
|
||||
} on ErrorMessage catch (error, stackTrace) {
|
||||
showErrorMessage(context, error, stackTrace);
|
||||
return Future.error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,6 @@ class BottomNavBar extends StatelessWidget {
|
||||
onDestinationSelected: onNavigationChanged,
|
||||
selectedIndex: selectedIndex,
|
||||
destinations: [
|
||||
NavigationDestination(
|
||||
icon: const Icon(Icons.inbox_outlined),
|
||||
selectedIcon: Icon(
|
||||
Icons.inbox,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
label: S.of(context).bottomNavInboxPageLabel,
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: const Icon(Icons.description_outlined),
|
||||
selectedIcon: Icon(
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import 'package:badges/badges.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:paperless_mobile/core/bloc/label_bloc_provider.dart';
|
||||
import 'package:paperless_mobile/core/bloc/paperless_statistics_cubit.dart';
|
||||
import 'package:paperless_mobile/core/model/paperless_statistics_state.dart';
|
||||
import 'package:paperless_mobile/features/labels/bloc/label_bloc_provider.dart';
|
||||
import 'package:paperless_mobile/core/bloc/paperless_server_information_cubit.dart';
|
||||
import 'package:paperless_mobile/core/model/error_message.dart';
|
||||
import 'package:paperless_mobile/core/model/paperless_server_information.dart';
|
||||
@@ -57,7 +59,7 @@ class InfoDrawer extends StatelessWidget {
|
||||
).padded(const EdgeInsets.only(right: 8.0)),
|
||||
Text(
|
||||
S.of(context).appTitleText,
|
||||
style: Theme.of(context).textTheme.headline5!.copyWith(
|
||||
style: Theme.of(context).textTheme.headline5?.copyWith(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onPrimaryContainer,
|
||||
@@ -104,18 +106,6 @@ class InfoDrawer extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
// title: RichText(
|
||||
|
||||
// text: TextSpan(
|
||||
// children: [
|
||||
// TextSpan(
|
||||
// text:
|
||||
// style:
|
||||
// Theme.of(context).textTheme.bodyText2,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
isThreeLine: true,
|
||||
),
|
||||
],
|
||||
@@ -129,27 +119,32 @@ class InfoDrawer extends StatelessWidget {
|
||||
color: Theme.of(context).colorScheme.primaryContainer,
|
||||
),
|
||||
),
|
||||
FutureBuilder<PaperlessStatistics>(
|
||||
future: getIt<PaperlessStatisticsService>().getStatistics(),
|
||||
builder: (context, snapshot) {
|
||||
BlocBuilder<PaperlessStatisticsCubit, PaperlessStatisticsState>(
|
||||
builder: (context, state) {
|
||||
return ListTile(
|
||||
title: Text("Inbox"),
|
||||
title: Text(S.of(context).bottomNavInboxPageLabel),
|
||||
leading: const Icon(Icons.inbox),
|
||||
trailing: snapshot.hasData
|
||||
? Text(
|
||||
snapshot.data!.documentsInInbox.toString(),
|
||||
)
|
||||
trailing: state.isLoaded
|
||||
? Text(state.statistics!.documentsInInbox.toString())
|
||||
: null,
|
||||
onTap: () => Navigator.push(
|
||||
onTap: () async {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => LabelBlocProvider(
|
||||
child: BlocProvider.value(
|
||||
value: DocumentsCubit(getIt<DocumentRepository>()),
|
||||
child: const InboxPage(),
|
||||
builder: (context) => BlocProvider.value(
|
||||
value: getIt<PaperlessStatisticsCubit>(),
|
||||
child: LabelBlocProvider(
|
||||
child: BlocProvider.value(
|
||||
value:
|
||||
DocumentsCubit(getIt<DocumentRepository>()),
|
||||
child: const InboxPage(),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
),
|
||||
);
|
||||
getIt<DocumentsCubit>().reloadDocuments();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user