mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-09 10:08:00 -06:00
fix: Add providers to document upload, fix text color in about dialog
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||||
@@ -13,8 +15,11 @@ import 'package:paperless_mobile/core/repository/user_repository.dart';
|
|||||||
import 'package:paperless_mobile/features/document_bulk_action/cubit/document_bulk_action_cubit.dart';
|
import 'package:paperless_mobile/features/document_bulk_action/cubit/document_bulk_action_cubit.dart';
|
||||||
import 'package:paperless_mobile/features/document_bulk_action/view/widgets/fullscreen_bulk_edit_label_page.dart';
|
import 'package:paperless_mobile/features/document_bulk_action/view/widgets/fullscreen_bulk_edit_label_page.dart';
|
||||||
import 'package:paperless_mobile/features/document_bulk_action/view/widgets/fullscreen_bulk_edit_tags_widget.dart';
|
import 'package:paperless_mobile/features/document_bulk_action/view/widgets/fullscreen_bulk_edit_tags_widget.dart';
|
||||||
|
import 'package:paperless_mobile/features/document_scan/view/scanner_page.dart';
|
||||||
import 'package:paperless_mobile/features/document_search/cubit/document_search_cubit.dart';
|
import 'package:paperless_mobile/features/document_search/cubit/document_search_cubit.dart';
|
||||||
import 'package:paperless_mobile/features/document_search/view/document_search_page.dart';
|
import 'package:paperless_mobile/features/document_search/view/document_search_page.dart';
|
||||||
|
import 'package:paperless_mobile/features/document_upload/cubit/document_upload_cubit.dart';
|
||||||
|
import 'package:paperless_mobile/features/document_upload/view/document_upload_preparation_page.dart';
|
||||||
import 'package:paperless_mobile/features/home/view/model/api_version.dart';
|
import 'package:paperless_mobile/features/home/view/model/api_version.dart';
|
||||||
import 'package:paperless_mobile/features/linked_documents/cubit/linked_documents_cubit.dart';
|
import 'package:paperless_mobile/features/linked_documents/cubit/linked_documents_cubit.dart';
|
||||||
import 'package:paperless_mobile/features/linked_documents/view/linked_documents_page.dart';
|
import 'package:paperless_mobile/features/linked_documents/view/linked_documents_page.dart';
|
||||||
@@ -322,6 +327,39 @@ Future<void> pushBulkEditDocumentTypeRoute(BuildContext context,
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<DocumentUploadResult?> pushDocumentUploadPreparationPage(
|
||||||
|
BuildContext context, {
|
||||||
|
required Uint8List bytes,
|
||||||
|
String? filename,
|
||||||
|
String? fileExtension,
|
||||||
|
String? title,
|
||||||
|
}) {
|
||||||
|
final labelRepo = context.read<LabelRepository>();
|
||||||
|
final docsApi = context.read<PaperlessDocumentsApi>();
|
||||||
|
return Navigator.of(context).push<DocumentUploadResult>(
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (_) => MultiProvider(
|
||||||
|
providers: [
|
||||||
|
Provider.value(value: labelRepo),
|
||||||
|
Provider.value(value: docsApi),
|
||||||
|
],
|
||||||
|
builder: (_, child) => BlocProvider(
|
||||||
|
create: (_) => DocumentUploadCubit(
|
||||||
|
context.read(),
|
||||||
|
context.read(),
|
||||||
|
),
|
||||||
|
child: DocumentUploadPreparationPage(
|
||||||
|
fileBytes: bytes,
|
||||||
|
fileExtension: fileExtension,
|
||||||
|
filename: filename,
|
||||||
|
title: title,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
List<Provider> _getRequiredBulkEditProviders(BuildContext context) {
|
List<Provider> _getRequiredBulkEditProviders(BuildContext context) {
|
||||||
return [
|
return [
|
||||||
Provider.value(value: context.read<PaperlessDocumentsApi>()),
|
Provider.value(value: context.read<PaperlessDocumentsApi>()),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
@@ -105,6 +106,8 @@ class AppDrawer extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _showAboutDialog(BuildContext context) {
|
void _showAboutDialog(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
final colorScheme = theme.colorScheme;
|
||||||
showAboutDialog(
|
showAboutDialog(
|
||||||
context: context,
|
context: context,
|
||||||
applicationIcon: const ImageIcon(
|
applicationIcon: const ImageIcon(
|
||||||
@@ -117,10 +120,11 @@ class AppDrawer extends StatelessWidget {
|
|||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
"Source Code",
|
"Source Code",
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
style: theme.textTheme.titleMedium,
|
||||||
),
|
),
|
||||||
RichText(
|
RichText(
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
|
style: theme.textTheme.bodyMedium?.copyWith(color: colorScheme.onSurface),
|
||||||
children: [
|
children: [
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: S.of(context)!.findTheSourceCodeOn,
|
text: S.of(context)!.findTheSourceCodeOn,
|
||||||
@@ -143,9 +147,30 @@ class AppDrawer extends StatelessWidget {
|
|||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
'Credits',
|
'Credits',
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
style: theme.textTheme.titleMedium?.copyWith(color: colorScheme.onSurface),
|
||||||
|
),
|
||||||
|
RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
style: theme.textTheme.bodyMedium?.copyWith(color: colorScheme.onSurface),
|
||||||
|
children: [
|
||||||
|
const TextSpan(
|
||||||
|
text: 'Onboarding images by ',
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: 'pch.vector',
|
||||||
|
style: const TextStyle(color: Colors.blue),
|
||||||
|
recognizer: TapGestureRecognizer()
|
||||||
|
..onTap = () {
|
||||||
|
launchUrlString(
|
||||||
|
'https://www.freepik.com/free-vector/business-team-working-cogwheel-mechanism-together_8270974.htm#query=setting&position=4&from_view=author');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const TextSpan(
|
||||||
|
text: ' on Freepik.',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
_buildOnboardingImageCredits(),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import 'package:paperless_api/paperless_api.dart';
|
|||||||
import 'package:paperless_mobile/core/bloc/connectivity_cubit.dart';
|
import 'package:paperless_mobile/core/bloc/connectivity_cubit.dart';
|
||||||
import 'package:paperless_mobile/core/delegate/customizable_sliver_persistent_header_delegate.dart';
|
import 'package:paperless_mobile/core/delegate/customizable_sliver_persistent_header_delegate.dart';
|
||||||
import 'package:paperless_mobile/core/global/constants.dart';
|
import 'package:paperless_mobile/core/global/constants.dart';
|
||||||
|
import 'package:paperless_mobile/core/navigation/push_routes.dart';
|
||||||
import 'package:paperless_mobile/core/service/file_description.dart';
|
import 'package:paperless_mobile/core/service/file_description.dart';
|
||||||
import 'package:paperless_mobile/core/service/file_service.dart';
|
import 'package:paperless_mobile/core/service/file_service.dart';
|
||||||
import 'package:paperless_mobile/features/app_drawer/view/app_drawer.dart';
|
import 'package:paperless_mobile/features/app_drawer/view/app_drawer.dart';
|
||||||
@@ -189,19 +190,10 @@ class _ScannerPageState extends State<ScannerPage> with SingleTickerProviderStat
|
|||||||
final file = await _assembleFileBytes(
|
final file = await _assembleFileBytes(
|
||||||
context.read<DocumentScannerCubit>().state,
|
context.read<DocumentScannerCubit>().state,
|
||||||
);
|
);
|
||||||
final uploadResult = await Navigator.of(context).push<DocumentUploadResult>(
|
final uploadResult = await pushDocumentUploadPreparationPage(
|
||||||
MaterialPageRoute(
|
context,
|
||||||
builder: (_) => BlocProvider(
|
bytes: file.bytes,
|
||||||
create: (_) => DocumentUploadCubit(
|
|
||||||
context.read(),
|
|
||||||
context.read(),
|
|
||||||
),
|
|
||||||
child: DocumentUploadPreparationPage(
|
|
||||||
fileBytes: file.bytes,
|
|
||||||
fileExtension: file.extension,
|
fileExtension: file.extension,
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
if ((uploadResult?.success ?? false) && uploadResult?.taskId != null) {
|
if ((uploadResult?.success ?? false) && uploadResult?.taskId != null) {
|
||||||
// For paperless version older than 1.11.3, task id will always be null!
|
// For paperless version older than 1.11.3, task id will always be null!
|
||||||
@@ -299,21 +291,12 @@ class _ScannerPageState extends State<ScannerPage> with SingleTickerProviderStat
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Navigator.of(context).push(
|
pushDocumentUploadPreparationPage(
|
||||||
MaterialPageRoute(
|
context,
|
||||||
builder: (_) => BlocProvider(
|
bytes: file.readAsBytesSync(),
|
||||||
create: (context) => DocumentUploadCubit(
|
|
||||||
context.read(),
|
|
||||||
context.read(),
|
|
||||||
),
|
|
||||||
child: DocumentUploadPreparationPage(
|
|
||||||
fileBytes: file.readAsBytesSync(),
|
|
||||||
filename: fileDescription.filename,
|
filename: fileDescription.filename,
|
||||||
title: fileDescription.filename,
|
title: fileDescription.filename,
|
||||||
fileExtension: fileDescription.extension,
|
fileExtension: fileDescription.extension,
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class _DocumentSearchBarState extends State<DocumentSearchBar> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return OpenContainer(
|
return OpenContainer(
|
||||||
|
transitionDuration: const Duration(milliseconds: 200),
|
||||||
transitionType: ContainerTransitionType.fadeThrough,
|
transitionType: ContainerTransitionType.fadeThrough,
|
||||||
closedElevation: 1,
|
closedElevation: 1,
|
||||||
middleColor: Theme.of(context).colorScheme.surfaceVariant,
|
middleColor: Theme.of(context).colorScheme.surfaceVariant,
|
||||||
|
|||||||
Reference in New Issue
Block a user