Updated onboarding, reformatted files, improved referenced documents view, updated error handling

This commit is contained in:
Anton Stubenbord
2022-11-03 22:15:36 +01:00
parent 2f2312d5f3
commit 40133b6e0e
117 changed files with 1788 additions and 1021 deletions

View File

@@ -76,7 +76,8 @@ class _AddSavedViewPageState extends State<AddSavedViewPage> {
SavedView.fromDocumentFilter(
widget.currentFilter,
name: _formKey.currentState?.value[fkName] as String,
showOnDashboard: _formKey.currentState?.value[fkShowOnDashboard] as bool,
showOnDashboard:
_formKey.currentState?.value[fkShowOnDashboard] as bool,
showInSidebar: _formKey.currentState?.value[fkShowInSidebar] as bool,
),
);

View File

@@ -6,7 +6,8 @@ import 'package:paperless_mobile/generated/l10n.dart';
class BulkDeleteConfirmationDialog extends StatelessWidget {
static const _bulletPoint = "\u2022";
final DocumentsState state;
const BulkDeleteConfirmationDialog({Key? key, required this.state}) : super(key: key);
const BulkDeleteConfirmationDialog({Key? key, required this.state})
: super(key: key);
@override
Widget build(BuildContext context) {
@@ -19,8 +20,12 @@ class BulkDeleteConfirmationDialog extends StatelessWidget {
Text(
//TODO: use plurals, didn't use because of crash... investigate later.
state.selection.length == 1
? S.of(context).documentsPageSelectionBulkDeleteDialogWarningTextOne
: S.of(context).documentsPageSelectionBulkDeleteDialogWarningTextMany,
? S
.of(context)
.documentsPageSelectionBulkDeleteDialogWarningTextOne
: S
.of(context)
.documentsPageSelectionBulkDeleteDialogWarningTextMany,
),
const SizedBox(height: 16),
ConstrainedBox(
@@ -31,7 +36,8 @@ class BulkDeleteConfirmationDialog extends StatelessWidget {
),
),
const SizedBox(height: 16),
Text(S.of(context).documentsPageSelectionBulkDeleteDialogContinueText),
Text(
S.of(context).documentsPageSelectionBulkDeleteDialogContinueText),
],
),
actions: [
@@ -41,7 +47,8 @@ class BulkDeleteConfirmationDialog extends StatelessWidget {
),
TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all(Theme.of(context).colorScheme.error),
foregroundColor:
MaterialStateProperty.all(Theme.of(context).colorScheme.error),
),
onPressed: () {
Navigator.pop(context, true);

View File

@@ -36,10 +36,11 @@ class _DocumentsPageAppBarState extends State<DocumentsPageAppBar> {
expandedHeight: kToolbarHeight,
leading: IconButton(
icon: const Icon(Icons.close),
onPressed: () => BlocProvider.of<DocumentsCubit>(context).resetSelection(),
onPressed: () =>
BlocProvider.of<DocumentsCubit>(context).resetSelection(),
),
title:
Text('${documentsState.selection.length} ${S.of(context).documentsSelectedText}'),
title: Text(
'${documentsState.selection.length} ${S.of(context).documentsSelectedText}'),
actions: [
IconButton(
icon: const Icon(Icons.delete),
@@ -79,9 +80,8 @@ class _DocumentsPageAppBarState extends State<DocumentsPageAppBar> {
if (shouldDelete ?? false) {
BlocProvider.of<DocumentsCubit>(context)
.bulkRemoveDocuments(documentsState.selection)
.then((_) => showSnackBar(context, S.of(context).documentsPageBulkDeleteSuccessfulText))
.onError<ErrorMessage>(
(error, _) => showSnackBar(context, translateError(context, error.code)));
.then((_) => showSnackBar(
context, S.of(context).documentsPageBulkDeleteSuccessfulText));
}
}

View File

@@ -44,7 +44,8 @@ class SavedViewSelectionWidget extends StatelessWidget {
child: FilterChip(
label: Text(state.value.values.toList()[index].name),
selected: view.id == state.selectedSavedViewId,
onSelected: (isSelected) => _onSelected(isSelected, context, view),
onSelected: (isSelected) =>
_onSelected(isSelected, context, view),
),
);
},
@@ -76,21 +77,19 @@ class SavedViewSelectionWidget extends StatelessWidget {
void _onCreatePressed(BuildContext context) async {
final newView = await Navigator.of(context).push<SavedView?>(
MaterialPageRoute(
builder: (context) => AddSavedViewPage(currentFilter: getIt<DocumentsCubit>().state.filter),
builder: (context) => AddSavedViewPage(
currentFilter: getIt<DocumentsCubit>().state.filter),
),
);
if (newView != null) {
try {
BlocProvider.of<SavedViewCubit>(context).add(newView);
} on ErrorMessage catch (error) {
showError(context, error);
}
BlocProvider.of<SavedViewCubit>(context).add(newView);
}
}
void _onSelected(bool isSelected, BuildContext context, SavedView view) {
if (isSelected) {
BlocProvider.of<DocumentsCubit>(context).updateFilter(filter: view.toDocumentFilter());
BlocProvider.of<DocumentsCubit>(context)
.updateFilter(filter: view.toDocumentFilter());
BlocProvider.of<SavedViewCubit>(context).selectView(view);
} else {
BlocProvider.of<DocumentsCubit>(context).updateFilter();
@@ -106,11 +105,7 @@ class SavedViewSelectionWidget extends StatelessWidget {
) ??
false;
if (delete) {
try {
BlocProvider.of<SavedViewCubit>(context).remove(view);
} on ErrorMessage catch (error) {
showError(context, error);
}
BlocProvider.of<SavedViewCubit>(context).remove(view);
}
}
}