mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-10 06:07:57 -06:00
Started removing tight coupling
This commit is contained in:
@@ -6,7 +6,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:paperless_mobile/core/bloc/paperless_statistics_cubit.dart';
|
||||
import 'package:paperless_mobile/features/labels/bloc/label_bloc_provider.dart';
|
||||
import 'package:paperless_mobile/features/labels/bloc/global_state_bloc_provider.dart';
|
||||
import 'package:paperless_mobile/core/logic/error_code_localization_mapper.dart';
|
||||
import 'package:paperless_mobile/core/model/error_message.dart';
|
||||
import 'package:paperless_mobile/core/widgets/highlighted_text.dart';
|
||||
@@ -52,7 +52,6 @@ class _DocumentDetailsPageState extends State<DocumentDetailsPage> {
|
||||
DateFormat("MMM d, yyyy HH:mm:ss");
|
||||
|
||||
bool _isDownloadPending = false;
|
||||
bool _isAssignAsnPending = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -350,7 +349,7 @@ class _DocumentDetailsPageState extends State<DocumentDetailsPage> {
|
||||
final wasUpdated = await Navigator.push<bool>(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => LabelBlocProvider(
|
||||
builder: (_) => GlobalStateBlocProvider(
|
||||
child: DocumentEditPage(document: document),
|
||||
),
|
||||
maintainState: true,
|
||||
@@ -412,7 +411,7 @@ class _DocumentDetailsPageState extends State<DocumentDetailsPage> {
|
||||
false;
|
||||
if (delete) {
|
||||
try {
|
||||
await BlocProvider.of<DocumentsCubit>(context).removeDocument(document);
|
||||
await BlocProvider.of<DocumentsCubit>(context).remove(document);
|
||||
showSnackBar(context, S.of(context).documentDeleteSuccessMessage);
|
||||
} on ErrorMessage catch (error, stackTrace) {
|
||||
showErrorMessage(context, error, stackTrace);
|
||||
|
||||
@@ -83,7 +83,7 @@ class _DocumentEditPageState extends State<DocumentEditPage> {
|
||||
});
|
||||
bool wasUpdated = false;
|
||||
try {
|
||||
await getIt<DocumentsCubit>().updateDocument(updatedDocument);
|
||||
await getIt<DocumentsCubit>().update(updatedDocument);
|
||||
showSnackBar(context, S.of(context).documentUpdateErrorMessage);
|
||||
wasUpdated = true;
|
||||
} on ErrorMessage catch (error, stackTrace) {
|
||||
|
||||
@@ -44,15 +44,13 @@ class _DocumentsPageState extends State<DocumentsPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (!BlocProvider.of<DocumentsCubit>(context).state.isLoaded) {
|
||||
_initDocuments();
|
||||
}
|
||||
_initDocuments();
|
||||
_pagingController.addPageRequestListener(_loadNewPage);
|
||||
}
|
||||
|
||||
Future<void> _initDocuments() async {
|
||||
try {
|
||||
BlocProvider.of<DocumentsCubit>(context).loadDocuments();
|
||||
BlocProvider.of<DocumentsCubit>(context).load();
|
||||
} on ErrorMessage catch (error, stackTrace) {
|
||||
showErrorMessage(context, error, stackTrace);
|
||||
}
|
||||
@@ -113,7 +111,7 @@ class _DocumentsPageState extends State<DocumentsPage> {
|
||||
previous != ConnectivityState.connected &&
|
||||
current == ConnectivityState.connected,
|
||||
listener: (context, state) {
|
||||
BlocProvider.of<DocumentsCubit>(context).loadDocuments();
|
||||
BlocProvider.of<DocumentsCubit>(context).load();
|
||||
},
|
||||
builder: (context, connectivityState) {
|
||||
return Scaffold(
|
||||
@@ -241,9 +239,7 @@ class _DocumentsPageState extends State<DocumentsPage> {
|
||||
BlocProvider.value(
|
||||
value: BlocProvider.of<PaperlessStatisticsCubit>(context)),
|
||||
],
|
||||
child: DocumentDetailsPage(
|
||||
documentId: model.id,
|
||||
),
|
||||
child: DocumentDetailsPage(documentId: model.id),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user